Browse Source

供应商升级优化

wufeng 2 years ago
parent
commit
f3aa67c15d
2 changed files with 54 additions and 28 deletions
  1. 47 28
      app/admin/controller/Goodup.php
  2. 7 0
      app/admin/controller/Suppler.php

+ 47 - 28
app/admin/controller/Goodup.php

@@ -1674,18 +1674,18 @@ class Goodup extends Base
         if($proof_url===""){
             return error_show(1004,"参数proof_url不能为空");
         }
-        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
-        if($token==''){
-            return error_show(105,"参数token不能为空");
-        }
+//        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
+//        if($token==''){
+//            return error_show(105,"参数token不能为空");
+//        }
         $exam_remark = isset($this->post['exam_remark'])&& $this->post['exam_remark']!='' ? trim($this->post['exam_remark']):"";
 
-        $user =GetUserInfo($token);
-        if(empty($user)||$user['code']!=0){
-            return error_show(1002,"用户数据不存在");
-        }
-        $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
-        $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+//        $user =GetUserInfo($token);
+//        if(empty($user)||$user['code']!=0){
+//            return error_show(1002,"用户数据不存在");
+//        }
+        $createrid= $this->uid;//isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+        $creater= $this->uname;//isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
         $bifore=$platform['exam_status'];
         $platform['exam_status']=4;
         $platform['updatetime']=date("Y-m-d H:i:s");
@@ -1713,14 +1713,14 @@ class Goodup extends Base
             }
             $up = Db::name("good_platform")->save($platform);
             if($up){
-                ActionLog::logAdd($this->post['token'], [
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
                     "order_code" =>$platform['skuCode'],//咨询单详情编号
                     "status" =>$bifore,//这里的status是之前的值
                     "action_remark" => '',//备注
                     "action_type" => "edit"//新建create,编辑edit,更改状态status
                 ], "SPSX", $platform['exam_status'],$platform);
 
-                ProcessOrder::AddProcess($this->post['token'], [
+                ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
                     "order_type" => 'SPSX',
                     "order_code" =>$platform['skuCode'],//咨询单详情编号
                     "order_id" => $platform['id'],
@@ -2348,32 +2348,51 @@ class Goodup extends Base
     }
 
     public function checkPrice(){
-        $spuCode=isset($this->post['spuCode'])&&$this->post['spuCode']!=""? trim($this->post['spuCode']):"";
-        if($spuCode==""){
-            return error_show(1005,"参数spuCode不能为空");
-        }
-        $good =Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->find();
-        if($good==false){
-            return error_show(1005,"商品数据未找到");
-        }
-        $num=isset($this->post['min_num'])&&$this->post['min_num']!=="" ? intval($this->post['min_num']):"";
-        if($num==""){
-            return error_show(1005,"参数min_num不能为空");
-        }
+
+        $param = $this->request->only(['spuCode','min_num'],'post','trim');
+
+        $val = Validate::rule([
+            'spuCode'=>'require',
+            'min_num'=>'require',
+        ]);
+        if($val->check($param) == false) return json_show(1005,$val->getError());
+
+//        $spuCode=isset($this->post['spuCode'])&&$this->post['spuCode']!=""? trim($this->post['spuCode']):"";
+//        if($spuCode==""){
+//            return error_show(1005,"参数spuCode不能为空");
+//        }
+        $good =Db::name("good_basic")
+            ->field('id,is_stock,cat_id,is_gold_price,noble_weight,cgd_gold_price')
+            ->where(["spuCode"=>$param['spuCode'],"is_del"=>0])
+            ->findOrEmpty();
+        if(empty($good)) return json_show(1005,"商品数据未找到");
+
+//        $num=isset($this->post['min_num'])&&$this->post['min_num']!=="" ? intval($this->post['min_num']):"";
+//        if($num==""){
+//            return error_show(1005,"参数min_num不能为空");
+//        }
 
         $nakelist = Db::name("good_nake")
-            ->where(['spuCode'=>$spuCode,"is_del"=>0])
-            ->where([["min_num","<=",$num]])
+            ->where(['spuCode'=>$param['spuCode'],"is_del"=>0])
+            ->where([["min_num","<=",$param['min_num']]])
             ->order("min_num desc")
             ->find();
         if($nakelist==false){
-            $nakelist = Db::name("good_nake")->where(['spuCode'=>$spuCode,"is_del"=>0])->order("min_num asc")->find();
+            $nakelist = Db::name("good_nake")
+                ->where(['spuCode'=>$param['spuCode'],"is_del"=>0])
+                ->order("min_num asc")
+                ->find();
 
             //非库存品的话,继续校验最小起订量
             //库存品的话,不足采购起订量的时候,取采购最小起订量
             if ($good['is_stock'] == 0) return error_show(1010, "起订量不足{$nakelist['min_num']}");
         }
-        $catinfo = Db::name("cat")->where(["id"=>$good['cat_id']])->find();
+
+        $catinfo = Db::name("cat")
+            ->field('id,sale_rate')
+            ->where(["id"=>$good['cat_id']])
+            ->find();
+
         $budget = isset($catinfo['sale_rate']) ? $catinfo['sale_rate']/100:0;
         $top_cat_id = made($catinfo['id']);//获取所有分类
         $top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id

+ 7 - 0
app/admin/controller/Suppler.php

@@ -710,6 +710,13 @@ class Suppler extends Base
 
         $rs = $userCommon->handle('upgrade', $param);
 
+        if (isset($rs['code']) && $rs['code'] == 0) {
+            //更新用户和角色关联表的数据
+            Db::name('user_role')
+                ->where(['companyNo' => $param['code'], 'company_type' => 1])
+                ->update(['company_type' => 2]);
+        }
+
         return json_show($rs['code'], $rs['message'], $rs['data']);
 
     }