wugg 8 months ago
parent
commit
9c1a0f287a
2 changed files with 17 additions and 6 deletions
  1. 13 5
      app/txx/controller/Act.php
  2. 4 1
      app/txx/controller/Activity.php

+ 13 - 5
app/txx/controller/Act.php

@@ -3,8 +3,7 @@ declare (strict_types = 1);
 
 namespace app\txx\controller;
 
-use app\BaseController;
-use think\facade\Validate;
+use app\txx\model\ActGood;use think\facade\Validate;
 use app\txx\model\Act as Actm;
 use think\App;
 
@@ -13,6 +12,7 @@ class Act extends Base
 	protected $uid=0;
 	protected $uname='';
 	protected $model;
+	protected static $ActStatusCn=["无状态",'活动未开始','活动进行中',"活动已结束"];
     public function __construct(App $app) {
 		parent::__construct($app);
 		if($this->request->isCx==1){
@@ -65,6 +65,7 @@ class Act extends Base
       ->paginate(["list_rows"=>$param['size'],"page"=>$param['page']])
       ->each(function(&$item){
         $item['act_status']=time()< strtotime($item['startTime'])?1:(time()> strtotime($item['endTime'])?3:2);
+        $item['act_status_cn'] = self::$ActStatusCn[$item['act_status']];
       });
       $this->success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
     }
@@ -144,11 +145,11 @@ class Act extends Base
             'contactor|联系人' => 'require|max:255',
             'mobile|联系电话' => 'require',
         ]);
-        if($validate->check($param)==false)return  json_show(1004,$validate->getError());
+        if($validate->check($param)==false)$this->error($validate->getError());
          $actm=new Actm();
         $info = $actm->where(["actCode"=>$param['actCode'],"is_del"=>0])->find();
-        if($info->isEmpty()) return json_show(1005,"活动不存在");
-        if($info->status==1) return json_show(1005,"活动已发布,不能编辑");
+        if($info->isEmpty())$this->error("活动不存在");
+        if($info->status==1)$this->error("活动已发布,不能编辑");
 
         $data=[
         	"act_name"=>$param['act_name'],
@@ -180,6 +181,13 @@ class Act extends Base
       if($validate->check($param)==false)$this->error($validate->getError());
 
       $info = $this->model->with(["goodInfo"])->where(["actCode"=>$param['actCode'],"is_del"=>0])->findOrEmpty();
+      if($info->isEmpty()) $this->error("活动不存在");
+      $info['act_status']=time()< strtotime($info['startTime'])?1:(time()> strtotime($info['endTime'])?3:2);
+      $info['goodInfo']->each(function(&$item){
+          $item['status_cn']=ActGood::$statusCn[$item['status']]??'';
+      });
+      $info['statusCn'] = \app\txx\model\Act::$statusCn[$info['status']]??'';
+      $info['act_status_cn']=self::$ActStatusCn[$info['act_status']];
       $this->success("获取成功",$info);
     }
 

+ 4 - 1
app/txx/controller/Activity.php

@@ -100,7 +100,7 @@ class Activity extends Base{
     }
 
     public function list(){
-        $param=$this->request->param(["actCode"=>"","status"=>"","skuCode"=>"","roundId"=>"","page"=>1,"size"=>15],"post","trim");
+        $param=$this->request->param(["actCode"=>"","status"=>"","skuCode"=>"","version"=>"","roundId"=>"","page"=>1,"size"=>15],"post","trim");
         $where=[["is_del","=",0]];
         if($param['actCode']!==""){
             $where[]=["actCode","like","%".$param['actCode']."%"];
@@ -113,6 +113,9 @@ class Activity extends Base{
         }
         if($param['roundId']!==""){
             $where[]=["roundId","=",$param['roundId']];
+        }
+         if($param['version']!==''){
+            $where[]=['version','=',$param['version']];
         }
         $list= $this->model->with(["act","platformYz"=>["platform","good"=>['unit','brand','category']],"promocode"])->where($where)->order("id desc")->paginate(["list_rows"=>$param['size'],"page"=>$param['page']]);
         $list->each(function($item,$key){