WechatQrcodeDao.php 1.8 KB

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