Browse Source

有赞对接平台,商品上线管理优化

wufeng 2 years ago
parent
commit
6407adefc5

+ 89 - 85
app/admin/controller/Good.php

@@ -115,7 +115,13 @@ class Good extends Base
 //        if(!empty($role['platform']) ){
 //            $where[]=["b.platform_code","in",$role['platform']];
 //        }
-        $count = Db::name('good')->alias("a")->leftJoin("good_platform b","a.spuCode=b.spuCode")->where($where)
+        $count = Db::name('good')
+            ->alias("a")
+            ->leftJoin("good_platform b","a.spuCode=b.spuCode")
+            ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
+            ->leftJoin("platform p","p.id=b.platform_code")
+            ->where('p.platform_type',0)//只筛选非对接平台的商品
+            ->where($where)
             ->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
@@ -128,6 +134,8 @@ class Good extends Base
             ->leftJoin("good_platform b","a.spuCode=b.spuCode")
 //            ->leftJoin("good_basic gb","gb.spuCode=a.spuCode")
             ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
+            ->leftJoin("platform p","p.id=b.platform_code")
+            ->where('p.platform_type',0)//只筛选非对接平台的商品
             ->where($where)
             ->page($page,$size)
             ->order("b.addtime desc")
@@ -174,113 +182,109 @@ class Good extends Base
     }
 
     //获取跟有赞对接的平台所属的商品上线信息
-    public function listByYz(){
-
+    public function listByYz()
+    {
         $param = $this->request->only([
-            'page'=>1,
-            'size'=>10,
-            'cat_id'=>'',
-            'good_name'=>'',
-            'skucode'=>'',
-            'spucode'=>'',
-            'start'=>'',
-            'end'=>'',
-            'is_stock'=>'',
-            'good_type'=>'',
-            'supplierNo'=>'',
-            'companyNo'=>'',
-            'creater'=>'',
-            'createrid'=>'',
-            'status'=>'',
-            'platform_code'=>'',
-            'plat_code'=>'',
-            'exam_status'=>'',
-            'brand_id'=>'',
-            'company_name'=>'',
-        ],'post','trim');
-        $where =[["a.is_del","=",0]];
-        if($param['cat_id']!=="") $where[]=['a.cat_id',"=",$param['cat_id']];
-        if($param['good_name']!=="") $where[]=['a.good_name','like','%'.$param['good_name'].'%'];
-        if($param['skucode']!=='') $where [] = ['b.skucode','like','%'.$param['skucode'].'%'];
-        if($param['spucode']!=='') $where [] = ['b.spucode','like','%'.$param['spucode'].'%'];
-        if($param['start']!=='') $where[]=['b.addtime','>=',date('Y-m-d H:i:s',strtotime($param['start']))];
-        if($param['end']!=="") $where[]=['b.addtime',"<",date('Y-m-d H:i:s',strtotime($param['end'])+24*3600)];
-        if($param['is_stock']!=="") $where[]=['a.is_stock',"=",$param['is_stock']];
-        if($param['good_type']!=="")  $where[]=['a.good_type',"=",$param['good_type']];
-        if($param['supplierNo']!=="") $where[]=['a.supplierNo',"=",$param['supplierNo']];
-        if($param['companyNo']!=="")  $where[]=['a.companyNo',"like",'%'.$param['companyNo'].'%'];
-        if($param['creater']!=='')  $where[]=['a.creater',"like",'%'.$param['creater'].'%'];
-        if($param['createrid']!=='') $where[]=['a.createrid',"=",$param['createrid']];
-        if($param['status']!=='') $where[]=['a.status','=',$param['status']];
-        if($param['platform_code']!=="") $where[]=["platform_code",'=',$param['platform_code']];
-        if($param['plat_code']!=='') $where[]=["b.plat_code","like",'%'.$param['plat_code'].'%'];
-        if($param['exam_status']!=='') $where[]=['b.exam_status',"=",$param['exam_status']];
-        if($param['brand_id']!=="") $where[]=['a.brand_id',"=",$param['brand_id']];
-        $role=$this->checkRole();
-        if(!empty($role['write']) ) $where[]=["a.createrid","in",$role['write']];
+            'page' => 1,
+            'size' => 10,
+            'cat_id' => '',
+            'good_name' => '',
+            'skucode' => '',
+            'spucode' => '',
+            'start' => '',
+            'end' => '',
+            'is_stock' => '',
+            'good_type' => '',
+            'supplierNo' => '',
+            'companyNo' => '',
+            'creater' => '',
+            'createrid' => '',
+            'status' => '',
+            'platform_code' => '',
+            'plat_code' => '',
+            'exam_status' => '',
+            'brand_id' => '',
+            'company_name' => '',
+        ], 'post', 'trim');
+        $where = [["a.is_del", "=", 0]];
+        if ($param['cat_id'] !== "") $where[] = ['a.cat_id', "=", $param['cat_id']];
+        if ($param['good_name'] !== "") $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
+        if ($param['skucode'] !== '') $where [] = ['b.skucode', 'like', '%' . $param['skucode'] . '%'];
+        if ($param['spucode'] !== '') $where [] = ['b.spucode', 'like', '%' . $param['spucode'] . '%'];
+        if ($param['start'] !== '') $where[] = ['b.addtime', '>=', date('Y-m-d H:i:s', strtotime($param['start']))];
+        if ($param['end'] !== "") $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($param['end']) + 24 * 3600)];
+        if ($param['is_stock'] !== "") $where[] = ['a.is_stock', "=", $param['is_stock']];
+        if ($param['good_type'] !== "") $where[] = ['a.good_type', "=", $param['good_type']];
+        if ($param['supplierNo'] !== "") $where[] = ['a.supplierNo', "=", $param['supplierNo']];
+        if ($param['companyNo'] !== "") $where[] = ['a.companyNo', "like", '%' . $param['companyNo'] . '%'];
+        if ($param['creater'] !== '') $where[] = ['a.creater', "like", '%' . $param['creater'] . '%'];
+        if ($param['createrid'] !== '') $where[] = ['a.createrid', "=", $param['createrid']];
+        if ($param['status'] !== '') $where[] = ['a.status', '=', $param['status']];
+        if ($param['platform_code'] !== "") $where[] = ["platform_code", '=', $param['platform_code']];
+        if ($param['plat_code'] !== '') $where[] = ["b.plat_code", "like", '%' . $param['plat_code'] . '%'];
+        if ($param['exam_status'] !== '') $where[] = ['b.exam_status', "=", $param['exam_status']];
+        if ($param['brand_id'] !== "") $where[] = ['a.brand_id', "=", $param['brand_id']];
+        $role = $this->checkRole();
+        if (!empty($role['write'])) $where[] = ["a.createrid", "in", $role['write']];
         if ($param['company_name'] !== '') $where[] = ["a.createrid", 'in', get_company_item_user_by_name($param['company_name'])];
 
         $count = Db::name('good')
             ->alias("a")
-            ->leftJoin("good_platform b","a.spuCode=b.spuCode")
+            ->leftJoin("platform_youzan b", "a.spuCode=b.spuCode")
             ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
-            ->leftJoin("platform p","p.id=b.platform_code")
             ->where($where)
-            ->where('p.platform_type',1)//只筛选有赞对接平台的商品
             ->count();
 
         $total = ceil($count / $param['size']);
         $param['size'] = $param['page'] >= $total ? $total : $param['page'];
         $list = Db::name('good')
             ->alias("a")
-            ->field("b.skuCode,b.platform_code,b.plat_code,b.id as good_id,a.cat_id,a.good_name,a.good_img,a.good_info_img,a.good_thumb_img,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.good_unit,a.noble_metal,a.companyNo,a.spuCode,a.good_type,b.creater,b.addtime,b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,u.itemid")//成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
-            ->leftJoin("good_platform b","a.spuCode=b.spuCode")
+            ->field("b.skuCode,b.platform_id platform_code,b.plat_code,b.id as platform_youzan_id,a.cat_id,a.good_name,a.good_img,a.good_info_img,a.good_thumb_img,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.good_unit,a.noble_metal,a.companyNo,a.spuCode,a.good_type,b.creater,b.addtime,b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,u.itemid")//成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
+            ->leftJoin("platform_youzan b", "a.spuCode=b.spuCode")
             ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
-            ->leftJoin("platform p","p.id=b.platform_code")
             ->where($where)
-            ->where('p.platform_type',1)//只筛选有赞对接平台的商品
-            ->page($param['page'],$param['size'])
+            ->page($param['page'], $param['size'])
             ->order("b.addtime desc")
             ->cursor();
-        $data=[];
-        foreach ($list as $value){
-            $value['cat_info']= made($value['cat_id'],[]);
-            $platform = Db::name("platform")->field('id,platform_name')->where(["id"=>$value['platform_code']])->find();
-            $value['platform_name'] = isset($platform['platform_name']) ? $platform['platform_name']:"";
-            $value['platform_code_en'] = isset($platform['platform_code_en']) ? $platform['platform_code_en']:"";
-            $supplier = Db::name("supplier")->field('id,name')->where(["code"=>$value['supplierNo']])->find();
-            $value['supplier_name'] = isset($supplier['name']) ? $supplier['name']:"";
-            $brand=Db::name("brand")->field('id,brand_name')->where(["id"=>$value['brand_id']])->find();
-            $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
-            $unit = Db::name("unit")->field('id,unit')->where(["id"=>$value['good_unit']])->find();
-            $value['unit'] =isset($unit['unit'])?$unit['unit']:"";
-            $company = Db::name("business")->field('id,company')->where(["companyNo"=>$value['companyNo']])->find();
-            $value['company'] = isset($company['company'])?$company['company']:"";
-            $value['stock_total'] = Db::name("good_stock")->where(['spuCode'=>$value['spuCode'],"is_del"=>0])->sum("usable_stock");
-            $value['status']=$value['exam_status'];
-            $value['exclusive']=makeExcluse($value['is_exclusive']);
+        $data = [];
+        foreach ($list as $value) {
+            $value['cat_info'] = made($value['cat_id'], []);
+            $platform = Db::name("platform")->field('id,platform_name')->where(["id" => $value['platform_code']])->find();
+            $value['platform_name'] = isset($platform['platform_name']) ? $platform['platform_name'] : "";
+            $value['platform_code_en'] = isset($platform['platform_code_en']) ? $platform['platform_code_en'] : "";
+            $supplier = Db::name("supplier")->field('id,name')->where(["code" => $value['supplierNo']])->find();
+            $value['supplier_name'] = isset($supplier['name']) ? $supplier['name'] : "";
+            $brand = Db::name("brand")->field('id,brand_name')->where(["id" => $value['brand_id']])->find();
+            $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
+            $unit = Db::name("unit")->field('id,unit')->where(["id" => $value['good_unit']])->find();
+            $value['unit'] = isset($unit['unit']) ? $unit['unit'] : "";
+            $company = Db::name("business")->field('id,company')->where(["companyNo" => $value['companyNo']])->find();
+            $value['company'] = isset($company['company']) ? $company['company'] : "";
+            $value['stock_total'] = Db::name("good_stock")->where(['spuCode' => $value['spuCode'], "is_del" => 0])->sum("usable_stock");
+            $value['status'] = $value['exam_status'];
+            $value['exclusive'] = makeExcluse($value['is_exclusive']);
 //            $value['good_info_img']=$value['good_info_img'];
 //            $value['good_img']=$value['good_img'];
-            $spec = Db::name("good_spec")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->select()->toArray();
-            $speclist=[];
-            if(!empty($spec)){
-                foreach ($spec as $val){
-                    $temp=[];
-                    $temp['spec_id']=$val['spec_id'];
-                    $temp['spec_value_id']=$val['spec_value_id'];
-                    $sp = Db::name("specs")->where(["id"=>$val['spec_id']])->find();
-                    $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
-                    $spv = Db::name("spec_value")->where(["id"=>$val['spec_value_id']])->find();
-                    $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
-                    $speclist[]=$temp;
+            $spec = Db::name("good_spec")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->select()->toArray();
+            $speclist = [];
+            if (!empty($spec)) {
+                foreach ($spec as $val) {
+                    $temp = [];
+                    $temp['spec_id'] = $val['spec_id'];
+                    $temp['spec_value_id'] = $val['spec_value_id'];
+                    $sp = Db::name("specs")->where(["id" => $val['spec_id']])->find();
+                    $temp['spec_name'] = isset($sp["spec_name"]) ? $sp["spec_name"] : "";
+                    $spv = Db::name("spec_value")->where(["id" => $val['spec_value_id']])->find();
+                    $temp['spec_value'] = isset($spv["spec_value"]) ? $spv["spec_value"] : "";
+                    $speclist[] = $temp;
                 }
             }
-            $value['specinfo']=$speclist;
-            $value['noble_name']=isset($value['noble_metal'])&&$value['noble_metal']!=0?$this->noble[$value['noble_metal']] :"";
+            $value['specinfo'] = $speclist;
+            $value['noble_name'] = isset($value['noble_metal']) && $value['noble_metal'] != 0 ? $this->noble[$value['noble_metal']] : "";
             $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
-            $data[]=$value;
+            $data[] = $value;
         }
-        return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
+        return app_show(0, "获取成功", ['list' => $data, 'count' => $count]);
     }
 
     public function info(){

+ 20 - 1
app/admin/controller/Goodup.php

@@ -1199,7 +1199,7 @@ class Goodup extends Base
     public function  online(){
         $platform =isset($this->post['platform'])&&!empty($this->post['platform'])? $this->post['platform']:"";
         if($platform==""){
-            return error_show(1004,"参数codes不能为空");
+            return error_show(1004,"参数platform不能为空");
         }
         $spuCode =isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
         if($spuCode===''){
@@ -1227,6 +1227,25 @@ class Goodup extends Base
         }
         $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
         $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+
+
+        //区分是否是对接平台
+        $platform_info=Db::name('platform')
+            ->field('id,platform_type')
+            ->where(['is_del'=>0,'id'=>$platform])
+            ->find();
+
+        if(empty($platform_info)) return error_show(1005,'所选的平台不存在');
+        if($platform_info['platform_type']==1) return \app\youzan\logic\Goodup::create([
+            'platform_id'=>$platform,
+            'online_reason'=>$online_reason,
+            'online_remark'=>$online_remark,
+            'good_data'=>$datas,
+            'createrid'=>$createrid,
+            'creater'=>$creater,
+        ]);
+
+
         $data=[];
         $isonline=[];
         $i=0;

+ 14 - 10
app/youzan/controller/Index.php

@@ -24,22 +24,26 @@ class Index extends Base
 
     }
 
-    //商品上线—有赞平台对接
-    public function youzanUpOnline()
+    //审核并将商品推送到有赞平台
+    public function checkExamstatus()
     {
-        $param = $this->request->only(['good_platform_id', 'yz_cat_id', 'cat_id', 'support_refund', 'origin', 'price', 'token']);
+        $param = $this->request->only(['platform_youzan_id', 'exam_status', 'reject_reason', 'yz_cat_id', 'yz_cat_name'=>'','is_support_barter', 'good_price', 'cost_fee', 'final_price', 'token', 'start_sale_num']);
 
         $val = Validate::rule([
-            'good_platform_id|商品上线记录ID' => 'require|number|gt:0',
-            'yz_cat_id|有赞分类' => 'require|number|gt:0',
-            'cat_id|自有分类' => 'require|number|gt:0',
-            'support_refund|是否可退货' => 'require|number|in:0,1',
-            'origin|系统售价' => 'require|float',
-            'price|最后售价' => 'require|float',
+            'platform_youzan_id|商品上线记录ID' => 'require|number|gt:0',
+            'exam_status|审核状态' => 'require|number|in:1,2',
+            'reject_reason|驳回原因' => 'requireIf:exam_status,2',
+            'yz_cat_id|有赞分类' => 'requireIf:exam_status,1|number|gt:0',
+            'yz_cat_name|有赞分类名称' => 'requireIf:exam_status,1',
+            'is_support_barter|是否可退货' => 'requireIf:exam_status,1|number|in:0,1',
+            'good_price|系统售价' => 'requireIf:exam_status,1|float',
+            'cost_fee|工艺费' => 'requireIf:exam_status,1|float',
+            'final_price|最终售价' => 'requireIf:exam_status,1|float',
+            'start_sale_num|有赞起售数' => 'requireIf:exam_status,1|number',
             'token' => 'require',
         ]);
 
-        if ($val->check($param)) return Goodup::youzanGoodUpOnline($param['good_platform_id'], $param);
+        if ($val->check($param)) return Goodup::youzanGoodUpOnline($param['platform_youzan_id'], $param);
         else return error_show(1005, $val->getError());
     }
 

+ 172 - 41
app/youzan/logic/Goodup.php

@@ -2,7 +2,9 @@
 
 namespace app\youzan\logic;
 
-use app\youzan\model\GoodPlatform;
+use app\admin\model\ActionLog;
+use app\admin\model\ProcessOrder;
+use app\youzan\model\PlatformYouzan;
 use think\Exception;
 use think\facade\Cache;
 use think\facade\Db;
@@ -16,62 +18,191 @@ class Goodup
     private static $redis_good_up_online_key = 'yz_good_up_online';
     private static $redis_good_offline_key = 'yz_good_offline';
 
-    //添加商品上线到处理队列中
-    public static function youzanGoodUpOnline(int $good_platform_id = 0, array $data = [])
+
+    //提交商品上线
+    public static function create(array $data = [])
+    {
+
+        $isonline = [];
+        $i = 0;
+        Db::startTrans();
+        try {
+            foreach ($data['good_data'] as $value) {
+                $count = Db::name("good_nake")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->count();
+                $ist = Db::name("good_platform")->where(["spuCode" => $value['spuCode'], "platform_code" => $data['platform_id'], "is_del" => 0])->find();
+                if ($ist) {
+                    $god = Db::name("good_basic")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->find();
+                    if ($god) {
+                        $tp = [];
+                        $tp['spuCode'] = $value['spuCode'];
+                        $tp['good_name'] = $god['good_name'];
+                        $tp['good_img'] = $god['good_thumb_img'];
+                        $tp['exam_status'] = $ist['exam_status'];
+                        $spec = Db::name("good_spec")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->select()->toArray();
+                        $speclist = [];
+                        if (!empty($spec)) {
+                            foreach ($spec as $val) {
+                                $temp = [];
+                                $temp['id'] = $val['id'];
+                                $temp['spuCode'] = $val['spuCode'];
+                                $temp['spec_id'] = $val['spec_id'];
+                                $temp['spec_value_id'] = $val['spec_value_id'];
+                                $temp['is_del'] = $val['is_del'];
+                                $sp = Db::name("specs")->where(["id" => $val['spec_id']])->find();
+                                $temp['spec_name'] = isset($sp["spec_name"]) ? $sp["spec_name"] : "";
+                                $spv = Db::name("spec_value")->where(["id" => $val['spec_value_id']])->find();
+                                $temp['spec_value'] = isset($spv["spec_value"]) ? $spv["spec_value"] : "";
+                                $speclist[] = $temp;
+                            }
+                        }
+                        $tp["speclist"] = empty($speclist) ? [] : $speclist;
+                        $isonline[] = $tp;
+                    }
+
+                }
+                if (!empty($isonline)) {
+                    return app_show(1009, "存在已上线产品", $isonline);
+                }
+                //改变编码规则,将原来的skuCode后两位换成序列号
+                //str_pad字符串填充
+                $skuCode = makeNo("SN");
+                $skuCode = substr($skuCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
+                $tmp = [
+                    "platform_id" => $data['platform_id'],
+                    "online_reason" => $data['online_reason'],
+                    "online_remark" => $data['online_remark'],
+                    "spuCode" => $value['spuCode'],
+                    "skuCode" => $skuCode,
+                    "exam_status" => PlatformYouzan::$exam_status_0,
+                    "is_del" => PlatformYouzan::$del_normal,
+                    "createrid" => $data['createrid'],
+                    "creater" => $data['creater'],
+                    "updaterid" => $data['createrid'],
+                    "updater" => $data['creater'],
+                    "addtime" => date("Y-m-d H:i:s"),
+                    "updatetime" => date("Y-m-d H:i:s")
+                ];
+                $i++;
+                //修改状态,添加待办
+                $create = Db::name("platform_youzan")->insert($tmp, true);
+                if ($create > 0) {
+                    ActionLog::logAdd(['id' => $data['createrid'], 'nickname' => $data['creater']], [
+                        "order_code" => $skuCode,
+                        "status" => $tmp['exam_status'],//这里的status是之前的值
+                        "action_remark" => '',//备注
+                        "action_type" => "create"//新建create,编辑edit,更改状态status
+                    ], "SPSX", $tmp['exam_status'], $tmp);
+
+                    ProcessOrder::AddProcess(['id' => $data['createrid'], 'nickname' => $data['creater']], [
+                        "order_type" => 'SPSX',
+                        "order_code" => $skuCode,
+                        "order_id" => $create,
+                        "order_status" => $tmp['exam_status'], "before_status" => $tmp['exam_status']
+                    ]);
+                    $iso = Db::name("good")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->find();
+                    if ($iso == false) {
+                        unset($value['id']);
+                        $value['addtime'] = date("Y-m-d H:i:s");
+                        $value['updatetime'] = date("Y-m-d H:i:s");
+                    } else {
+                        $value['id'] = $iso['id'];
+                        $value['updatetime'] = date("Y-m-d H:i:s");
+                    }
+                    $up = Db::name("good")->save($value);
+                    if (!$up) {
+                        Db::rollback();
+                        return error_show(1004, "提交失败");
+                    }
+                } else {
+                    Db::rollback();
+                    return error_show(1004, "提交失败");
+                }
+            }
+            Db::commit();
+            return app_show(0, "提交成功");
+        } catch (\Exception $e) {
+            Db::rollback();
+            return error_show(1004, $e->getMessage());
+        }
+
+    }
+
+    //审核并将商品推送到有赞平台
+    public static function youzanGoodUpOnline(int $platform_youzan_id = 0, array $data = [])
     {
 
         Db::startTrans();
 
         try {
 
-            $db = new GoodPlatform();
+            $db = new PlatformYouzan();
 
             $rs = $db
-                ->field('gp.id,gp.spuCode,gp.skuCode,gp.exam_status,gp.status,gb.good_name,gb.weight,gb.good_img')
-                ->alias('gp')
-                ->where(['gp.id' => $good_platform_id, 'gp.is_del' => $db::$del_normal])
-                ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode')
+                ->field('a.id,a.spuCode,a.skuCode,a.exam_status,gb.good_name,gb.weight,gb.good_img,gb.cat_id')
+                ->alias('a')
+                ->where(['a.id' => $platform_youzan_id, 'a.is_del' => $db::$del_normal])
+                ->leftJoin('good_basic gb', 'gb.spuCode=a.spuCode')
                 ->findOrEmpty();
 
             if ($rs->isEmpty()) throw new Exception('该商品上线记录不存在');
-            if ($rs->exam_status != $db::$exam_status_6) throw new Exception('该商品尚未上线成功');
-            if ($rs->status == $db::$status_online_success) throw new Exception('该商品已经在有赞平台上线了');
+            if ($rs->exam_status != $db::$exam_status_0) throw new Exception('该商品并不是待审核状态');
 
             $userinfo = GetUserInfo($data['token']);
 
-            //入队列
-            Cache::store("redis")->handler()->lPush(self::$redis_good_up_online_key, json_encode([
-                'item_no' => $rs->skuCode,//商品自定义编码 skuCode
-                'item_type' => 0,//0实物商品
-                'title' => $rs->good_name,//商品标题
-                'is_support_barter' => $data['support_refund'],//是否支持换货。1:支持;0:不支持
-                'desc' => '我是商品描述',//商品描述
-                'item_weight' => $rs->weight,
-                'category_id' => $data['cat_id'],
-                'auto_listing_time' => '0',//0立即售出,传值表示定时(要大于当前时间戳)
-                'stock_deduct_mode' => 0,//0拍下减库存
-                'is_display' => 1,//1上架商品
-                'quantity' => '1111111111',//库存数,先随便写个数,待 @戴 确定
-                'hide_stock' => 0,//0显示库存,1不显示库存
-                'origin' => $data['origin'],//系统售价
-                'price' => $data['price'],//最后售价
-                'uid' => isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0,
-                'nickname' => isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '',
-                'good_platform_id' => $good_platform_id,
-                'good_img' => $rs->good_img,//图片集合
-                'post_fee' => 0,//运费,单位分,整数
-                'sell_point' => '',//商品卖点信息
-                'yz_cat_id' => $data['yz_cat_id'],//有赞类目id
-            ]));
+            $update_data = [
+                'exam_status' => $data['exam_status'],
+                'updaterid' => isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0,
+                'updater' => isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '',
+                'updatetime' => date('Y-m-d H:i:s'),
+            ];
 
-            //更新状态值
-            $db->where('id', $good_platform_id)
-                ->where('status', '<>', $db::$status_online_success)
-                ->save([
-                    'status' => $db::$status_online_ing,
-                    'updatetime' => date('Y-m-d H:i:s'),
+            if ($data['exam_status'] == $db::$exam_status_1) {
+                //审核通过
+                $update_data = array_merge($update_data, [
+                    'yz_cat_id' => $data['yz_cat_id'],
+                    'yz_cat_name' => $data['yz_cat_name'],
+                    'is_support_barter' => $data['is_support_barter'],
+                    'good_price' => $data['good_price'],
+                    'cost_fee' => $data['cost_fee'],
+                    'final_price' => $data['final_price'],
+                    'start_sale_num' => $data['start_sale_num'],
+                    'reject_reason'=>'',
                 ]);
 
+                //入队列
+                Cache::store("redis")->handler()->lPush(self::$redis_good_up_online_key, json_encode([
+                    'item_no' => $rs->skuCode,//商品自定义编码 skuCode
+                    'item_type' => 0,//0实物商品
+                    'title' => $rs->good_name,//商品标题
+                    'is_support_barter' => $data['is_support_barter'],//是否支持换货。1:支持;0:不支持
+                    'desc' => '我是商品描述',//商品描述
+                    'item_weight' => $rs->weight,
+                    'category_id' => $rs->cat_id,
+                    'auto_listing_time' => '0',//0立即售出,传值表示定时(要大于当前时间戳)
+                    'stock_deduct_mode' => 0,//0拍下减库存
+                    'is_display' => 1,//1上架商品
+                    'quantity' => '1111111111',//库存数,先随便写个数,待 @戴 确定
+                    'hide_stock' => 0,//0显示库存,1不显示库存
+                    'origin' => $data['good_price'],//系统售价
+                    'price' => $data['final_price'],//最后售价
+                    'uid' => isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0,
+                    'nickname' => isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '',
+                    'platform_youzan_id' => $platform_youzan_id,
+                    'good_img' => $rs->good_img,//图片集合
+                    'post_fee' => 0,//运费,单位分,整数
+                    'sell_point' => '',//商品卖点信息
+                    'yz_cat_id' => $data['yz_cat_id'],//有赞类目id
+                    'start_sale_num' => $data['start_sale_num'],//商品起售数,默认为1
+                ]));
+            }else{
+                $update_data = array_merge($update_data, ['reject_reason'=>$data['reject_reason']]);
+            }
+
+            //更新
+            $db->where('id', $platform_youzan_id)
+                ->where('exam_status', '=', $db::$exam_status_0)
+                ->save($update_data);
+
             Db::commit();
 
             return app_show(0, '操作成功');
@@ -91,7 +222,7 @@ class Goodup
 
         try {
 
-            $db = new GoodPlatform();
+            $db = new PlatformYouzan();
 
             $rs = $db
                 ->field('gp.id,gp.skuCode,gp.exam_status,gp.status')

+ 0 - 33
app/youzan/model/GoodPlatform.php

@@ -1,33 +0,0 @@
-<?php
-
-namespace app\youzan\model;
-
-use think\Model;
-
-//商品上线平台表
-class GoodPlatform extends Model
-{
-    protected $table = 'wsm_good_platform';
-    protected $pk = 'id';
-    protected $autoWriteTimestamp = false;
-
-    public static $del_normal = 0;//未删除
-    public static $deleted = 1;//已删除
-
-    public static $exam_status_0 = 0;//待提交
-    public static $exam_status_1 = 1;//待完善成本
-    public static $exam_status_2 = 2;//待产品审核
-    public static $exam_status_3 = 3;//待财务定价
-    public static $exam_status_4 = 4;//待财务审核定价
-    public static $exam_status_5 = 5;//待上线
-    public static $exam_status_6 = 6;//上线成功
-    public static $exam_status_7 = 7;//审核失败
-    public static $exam_status_8 = 8;//已下线
-
-    public static $status_online_ing = 1;//有赞待上线(处理中)
-    public static $status_online_success = 2;//有赞上线成功
-    public static $status_online_fail = 3;//有赞上线失败
-    public static $status_offline = 4;//有赞已下线
-
-
-}

+ 26 - 0
app/youzan/model/PlatformYouzan.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace app\youzan\model;
+
+use think\Model;
+
+//平台对接-有赞
+class PlatformYouzan extends Model
+{
+    protected $table = 'wsm_platform_youzan';
+    protected $pk = 'id';
+    protected $autoWriteTimestamp = false;
+
+    public static $del_normal = 0;//未删除
+    public static $deleted = 1;//已删除
+
+    public static $exam_status_0 = 0;//待审核
+    public static $exam_status_1 = 1;//审核通过待处理
+    public static $exam_status_2 = 2;//审核驳回
+    public static $exam_status_6 = 6;//上线成功
+    public static $exam_status_7 = 7;//上线失败
+    public static $exam_status_8 = 8;//已下线
+
+
+
+}

+ 1 - 1
app/youzan/route/app.php

@@ -4,5 +4,5 @@ use think\facade\Route;
 
 route::rule('push', 'youzan/Push/GetPush');
 route::rule('yz_cat_list', 'youzan/Index/getYzCatList');//有赞类目列表
-route::rule('yz_goodup', 'youzan/Index/youzanUpOnline');//将商品推送到有赞平台
+route::rule('yz_check_exam_status', 'youzan/Index/checkExamstatus');//审核并将商品推送到有赞平台
 route::rule('yz_goodoff', 'youzan/Index/youzanOffline');//将商品从有赞平台下线