wugg 8 months ago
parent
commit
396c72d787
2 changed files with 21 additions and 1 deletions
  1. 1 1
      app/txx/controller/Act.php
  2. 20 0
      app/txx/model/ActGood.php

+ 1 - 1
app/txx/controller/Act.php

@@ -201,7 +201,7 @@ class Act extends Base
       $info['statusCn'] = \app\txx\model\Act::$statusCn[$info['status']]??'';
       $info['act_status_cn']=self::$ActStatusCn[$info['act_status']];
       $info['goodInfo']->visible(['id','actCode','yz_good_code','stock_num','status','addtime','updatetime',
-        'final_price','good_name','unit_name','cat_name','brand_name','fetch_url','roundId','status_cn']);;
+        'sale_price','good_name','unit_name','cat_name','brand_name','fetch_url','roundId','status_cn']);;
       $this->success("获取成功",$info);
     }
 

+ 20 - 0
app/txx/model/ActGood.php

@@ -28,4 +28,24 @@ class ActGood extends Model
     public function platformYz(){
         return $this->belongsTo(PlatformYouzan::class,'yz_good_code','skuCode')->bind(['plat_code','spuCode','sale_price','final_price','platform_name','good_name',"unit_name","brand_name","cat_name","cat_search"]);
     }
+
+    public static function onAfterUpdate(Model $model) : void{
+        if($model->version=='2.0' && $model->is_del==0){
+            self::sysncAct($model->actCode,$model->status,$model->version);
+         }
+     }
+
+    // 0 '待审核',1 '待生成券码信息',2 '待同步券码信息',3 '已同步券码信息',4 '券码生成失败',5'券码同步失败'
+    //'待选择商品','待同步创建优惠券码','待同步优惠券码','待确认上传至活动主办方','已确认上传至活动主办方','券码创建失败','券码同步失败'
+    public static function sysncAct($actCode,$goodStatus,$version){
+                $actStatus=['1'=>'1','2'=>'2','3'=>'3','4'=>'5','5'=>'6'];//0 '待审核',1 '待生成券码信息',2 '待同步券码信息',3 '已同步券码信息',4 '券码生成失败',5'券码同步失败'
+                $num = self::where(['version'=>$version,'actCode'=>$actCode,'is_del'=>0])->where('status','<>',$goodStatus)->count();
+               if($num==0){
+                    $act = \app\txx\model\Act::where(['actCode'=>$actCode])->findOrEmpty();
+                    if(!$act->isEmpty()){
+                        $act->status=$actStatus[$goodStatus];
+                        $act->save();
+                    }
+               }
+     }
 }