RoutineQrcodeRepository.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\common\repositories\wechat;
  3. use app\common\dao\wechat\RoutineQrcodeDao;
  4. use app\common\repositories\BaseRepository;
  5. use ln\services\MiniProgramService;
  6. /**
  7. * Class RoutineQrcodeRepository
  8. * @package app\common\repositories\wechat
  9. * @author zfy
  10. * @day 2020/6/18
  11. * @mixin RoutineQrcodeDao
  12. */
  13. class RoutineQrcodeRepository extends BaseRepository
  14. {
  15. /**
  16. * RoutineQrcodeRepository constructor.
  17. * @param RoutineQrcodeDao $dao
  18. */
  19. public function __construct(RoutineQrcodeDao $dao)
  20. {
  21. $this->dao = $dao;
  22. }
  23. /**
  24. * TODO 获取小程序二维码
  25. * @param $thirdId
  26. * @param $thirdType
  27. * @param $page
  28. * @param $imgUrl
  29. * @return array|bool
  30. * @throws \think\db\exception\DataNotFoundException
  31. * @throws \think\db\exception\DbException
  32. * @throws \think\db\exception\ModelNotFoundException
  33. */
  34. public function getShareCode($thirdId, $thirdType, $page, $imgUrl)
  35. {
  36. $res = $this->dao->routineQrCodeForever($thirdId, $thirdType, $page, $imgUrl);
  37. $resCode = MiniProgramService::create()->qrcodeService()->appCodeUnlimit($res->routine_qrcode_id, '', 280);
  38. if ($resCode)
  39. return ['res' => $resCode, 'id' => $res->routine_qrcode_id];
  40. else return false;
  41. }
  42. /**
  43. * TODO 获取小程序页面带参数二维码不保存数据库
  44. * @param string $page
  45. * @param string $pramam
  46. * @param int $width
  47. * @return mixed
  48. */
  49. public function getPageCode($page = '', $pramam = "", $width = 280)
  50. {
  51. return MiniProgramService::create()->qrcodeService()->appCodeUnlimit($pramam, $page, $width);
  52. }
  53. }