RoutineQrcode.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace app\routine\model\routine;
  3. use basic\ModelBasic;
  4. use traits\ModelTrait;
  5. /**
  6. * 小程序二维码Model
  7. * Class RoutineQrcode
  8. * @package app\routine\model\routine
  9. */
  10. class RoutineQrcode extends ModelBasic {
  11. use ModelTrait;
  12. /**
  13. * 添加二维码记录
  14. * @param string $thirdType
  15. * @param int $thirdId
  16. * @return object
  17. */
  18. public static function setRoutineQrcodeForever($thirdId = 0,$thirdType = 'spread',$page = '',$imgUrl = ''){
  19. $data['third_type'] = $thirdType;
  20. $data['third_id'] = $thirdId;
  21. $data['status'] = 0;
  22. $data['add_time'] = time();
  23. $data['page'] = $page;
  24. $data['url_time'] = '';
  25. $data['qrcode_url'] = $imgUrl;
  26. return self::set($data);
  27. }
  28. /**
  29. * 修改二维码地址
  30. * @param int $id
  31. * @param array $data
  32. * @return bool
  33. */
  34. public static function setRoutineQrcodeFind($id = 0,$data = array()){
  35. if(!$id) return false;
  36. $count = self::getRoutineQrcodeFind($id);
  37. if(!$count) return false;
  38. return self::edit($data,$id,'id');
  39. }
  40. /**
  41. * 获取二维码是否存在
  42. * @param int $id
  43. * @return int|string
  44. */
  45. public static function getRoutineQrcodeFind($id = 0){
  46. if(!$id) return 0;
  47. return self::where('id',$id)->count();
  48. }
  49. /**
  50. * 获取小程序二维码信息
  51. * @param int $id
  52. * @param string $field
  53. * @return array|bool|false|\PDOStatement|string|\think\Model
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @throws \think\exception\DbException
  57. */
  58. public static function getRoutineQrcodeFindType($id = 0,$field = 'third_type,third_id,page'){
  59. if(!$id) return false;
  60. $count = self::getRoutineQrcodeFind($id);
  61. if(!$count) return false;
  62. return self::where('id',$id)->where('status',1)->field($field)->find();
  63. }
  64. }