WechatQrcodeDao.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\wechat;
  12. use app\dao\BaseDao;
  13. use app\model\wechat\WechatQrcode;
  14. class WechatQrcodeDao extends BaseDao
  15. {
  16. /**
  17. * @return string
  18. */
  19. protected function setModel(): string
  20. {
  21. return WechatQrcode::class;
  22. }
  23. /**
  24. * 获取列表
  25. * @param $where
  26. * @param $page
  27. * @param $limit
  28. * @return array
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. */
  33. public function getList($where, $page = 0, $limit = 0)
  34. {
  35. return $this->search($where)->with(['user', 'record' => function ($query) {
  36. $query->where('is_follow', 1)->whereDay('add_time', 'yesterday')->field('qid,count(distinct uid) as number')->bind(['y_follow' => 'number']);
  37. }])->when($page && $limit, function ($query) use ($page, $limit) {
  38. $query->page($page, $limit);
  39. })->order('id desc')->select()->toArray();
  40. }
  41. /**
  42. * 更新次数
  43. * @param $id
  44. * @param $isFollow
  45. */
  46. public function upFollowAndScan($id, $isFollow)
  47. {
  48. $this->getModel()->where('id', $id)->inc('scan')->when($isFollow, function ($query) {
  49. $query->inc('follow');
  50. })->update();
  51. }
  52. }