WechatQrcodeDao.php 1.8 KB

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