RoutineQrcodeRepository.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\repositories\wechat;
  12. use app\common\dao\wechat\RoutineQrcodeDao;
  13. use app\common\repositories\BaseRepository;
  14. use crmeb\services\MiniProgramService;
  15. /**
  16. * Class RoutineQrcodeRepository
  17. * @package app\common\repositories\wechat
  18. * @author xaboy
  19. * @day 2020/6/18
  20. * @mixin RoutineQrcodeDao
  21. */
  22. class RoutineQrcodeRepository extends BaseRepository
  23. {
  24. /**
  25. * RoutineQrcodeRepository constructor.
  26. * @param RoutineQrcodeDao $dao
  27. */
  28. public function __construct(RoutineQrcodeDao $dao)
  29. {
  30. $this->dao = $dao;
  31. }
  32. /**
  33. * TODO 获取小程序二维码
  34. * @param $thirdId
  35. * @param $thirdType
  36. * @param $page
  37. * @param $imgUrl
  38. * @return array|bool
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\DbException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. */
  43. public function getShareCode($thirdId, $thirdType, $page, $imgUrl)
  44. {
  45. $res = $this->dao->routineQrCodeForever($thirdId, $thirdType, $page, $imgUrl);
  46. $resCode = MiniProgramService::create()->qrcodeService()->appCodeUnlimit($res->routine_qrcode_id, '', 280);
  47. if ($resCode)
  48. return ['res' => $resCode, 'id' => $res->routine_qrcode_id];
  49. else return false;
  50. }
  51. /**
  52. * TODO 获取小程序页面带参数二维码不保存数据库
  53. * @param string $page
  54. * @param string $pramam
  55. * @param int $width
  56. * @return mixed
  57. */
  58. public function getPageCode($page = '', $pramam = "", $width = 280)
  59. {
  60. return MiniProgramService::create()->qrcodeService()->appCodeUnlimit($pramam, $page, $width);
  61. }
  62. }