123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\common\model\user;
- use app\common\model\BaseModel;
- use app\common\model\store\product\Spu;
- class UserHistory extends BaseModel
- {
- public static function tablePk(): ?string
- {
- return 'user_history_id';
- }
- public static function tableName(): string
- {
- return 'user_history';
- }
- public function getUpdateTimeAttr($value)
- {
- return date('Y-m-d H:i:s',$value);
- }
- public function getStopTimeAttr()
- {
- if(!$this->spu) return '';
- if($this->spu->product_type == 1){
- $day = date('Y-m-d',time());
- $_day = strtotime($day);
- $end_day = strtotime($this->spu->seckillActive['end_day']);
- if($end_day >= $_day)
- return strtotime($day.$this->spu->seckillActive['end_time'].':00:00');
- if($end_day < strtotime($day))
- return strtotime(date('Y-m-d',$end_day).$this->spu->seckillActive['end_time'].':00:00');
- }
- }
- public function spu()
- {
- return $this->hasOne(Spu::class,'spu_id','res_id');
- }
- public function searchUidAttr($query,$value)
- {
- $query->where('uid',$value);
- }
- public function searchHistoryIdAttr($query,$value)
- {
- $query->where('history_id',$value);
- }
- public function searchHistoryIdsAttr($query,$value)
- {
- $query->where('history_id','in',$value);
- }
- }
|