123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- declare (strict_types = 1);
- namespace app\txx\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class Act extends Model
- {
- protected $createTime='addtime';
- protected $updateTime="updatetime";
- public static $statusCn=['待选择商品','待同步创建优惠券码','待同步优惠券码','待确认上传至活动主办方','已确认上传至活动主办方','券码创建失败','券码同步失败'];
- public function goodInfo(){
- return $this->hasMany(ActGood::class,'actCode','actCode')
- ->where(['is_del'=>0])
- ->with(['platformYz'=>["good"=>['unit','brand','category'],"platform"]]);
- }
- public static function onAfterUpdate(Model $model) : void{
- if($model->version=='2.0' && $model->is_del==0 && $model->status==4){
- self::sysncAct($model->actCode,$model->status,$model->version);
- }
- }
- public static function sysncAct($actCode,$actStatus,$version){
- $list=ActGood::where(['version'=>$version,'actCode'=>$actCode,'is_del'=>0,'status'=>6])->select();
- if(!$list->isEmpty()){
- ActGood::where(['version'=>$version,'actCode'=>$actCode,'is_del'=>0,'status'=>6])->update(['status'=>3]);
- }
- }
- }
|