RoutineQrcodeRepository.php 1.7 KB

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