WechatQrcodeDao.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\dao\wechat;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\BaseModel;
  14. use app\common\model\wechat\WechatQrcode;
  15. use think\db\exception\DataNotFoundException;
  16. use think\db\exception\DbException;
  17. use think\db\exception\ModelNotFoundException;
  18. use think\Model;
  19. /**
  20. * Class WechatQrcodeDao
  21. * @package app\common\dao\wechat
  22. * @author xaboy
  23. * @day 2020-04-28
  24. */
  25. class WechatQrcodeDao extends BaseDao
  26. {
  27. /**
  28. * @return BaseModel
  29. * @author xaboy
  30. * @day 2020-03-30
  31. */
  32. protected function getModel(): string
  33. {
  34. return WechatQrcode::class;
  35. }
  36. /**
  37. * @param $ticket
  38. * @return array|Model|null
  39. * @throws DataNotFoundException
  40. * @throws DbException
  41. * @throws ModelNotFoundException
  42. * @author xaboy
  43. * @day 2020-04-28
  44. */
  45. public function ticketByQrcode($ticket)
  46. {
  47. return WechatQrcode::getDB()->where('ticket', $ticket)->find();
  48. }
  49. /**
  50. * @param $type
  51. * @param $id
  52. * @return array|Model|null
  53. * @throws DataNotFoundException
  54. * @throws DbException
  55. * @throws ModelNotFoundException
  56. * @author xaboy
  57. * @day 2020-04-28
  58. */
  59. public function getForeverQrcode($type, $id)
  60. {
  61. return WechatQrcode::getDB()->where('third_id', $id)->where('third_type', $type)->where('expire_seconds', 0)->find();
  62. }
  63. /**
  64. * @param $type
  65. * @param $id
  66. * @return array|Model|null
  67. * @throws DataNotFoundException
  68. * @throws DbException
  69. * @throws ModelNotFoundException
  70. * @author xaboy
  71. * @day 2020-04-28
  72. */
  73. public function getTemporaryQrcode($type, $id)
  74. {
  75. return WechatQrcode::getDB()->where('third_id', $id)->where('third_type', $type)->where('expire_seconds', '>', 0)->find();
  76. }
  77. }