123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace app\models\routine;
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
- class RoutineQrcode extends BaseModel
- {
-
- protected $pk = 'id';
-
- protected $name = 'routine_qrcode';
- use ModelTrait;
-
- public static function routineQrCodeForever($thirdId = 0, $thirdType = 'spread', $page = '', $qrCodeLink = '')
- {
- $count = self::where('third_id', $thirdId)->where('third_type', $thirdType)->count();
- if ($count) return self::where('third_id', $thirdId)->where('third_type', $thirdType)->field('id')->find();
- return self::setRoutineQrcodeForever($thirdId, $thirdType, $page, $qrCodeLink);
- }
-
- public static function setRoutineQrcodeForever($thirdId = 0, $thirdType = 'spread', $page = '', $qrCodeLink = '')
- {
- $data['third_type'] = $thirdType;
- $data['third_id'] = $thirdId;
- $data['status'] = 1;
- $data['add_time'] = time();
- $data['page'] = $page;
- $data['url_time'] = '';
- $data['qrcode_url'] = $qrCodeLink;
- return self::create($data);
- }
-
- public static function setRoutineQrcodeFind($id = 0, $data = array())
- {
- if (!$id) return false;
- $count = self::getRoutineQrcodeFind($id);
- if (!$count) return false;
- return self::edit($data, $id, 'id');
- }
-
- public static function getRoutineQrcodeFind($id = 0)
- {
- if (!$id) return 0;
- return self::where('id', $id)->count();
- }
-
- public static function getRoutineQrcodeFindType($id = 0, $field = 'third_type,third_id,page')
- {
- if (!$id) return false;
- $count = self::getRoutineQrcodeFind($id);
- if (!$count) return false;
- return self::where('id', $id)->where('status', 1)->field($field)->find();
- }
- }
|