Act.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\txx\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class Act extends Model
  9. {
  10. public static $statusCn=["待选择商品","待同步创建优惠券码","待同步优惠券码","待确认上传至活动主办方","已确认上传至活动主办方","券码创建失败","券码同步失败"];
  11. public function goodInfo(){
  12. return $this->hasMany(ActGood::class,"actCode","actCode")->where(["is_del"=>0])->with(["Promocode"]);
  13. }
  14. public static function onAfterUpdate(Model $model) : void{
  15. if($model->version=='2.0' && $model->is_del==0 && $model->status==4){
  16. self::sysncAct($model->actCode,$model->status,$model->version);
  17. }
  18. }
  19. public static function sysncAct($actCode,$actStatus,$version){
  20. $list=ActGood::where(['version'=>$version,'actCode'=>$actCode,'is_del'=>0,"status"=>6])->select();
  21. if(!$list->isEmpty()){
  22. ActGood::where(['version'=>$version,'actCode'=>$actCode,'is_del'=>0,'status'=>6])->update(['status'=>3]);
  23. }
  24. }
  25. }