瀏覽代碼

Merge branch 'version1.5' of wugg/phpstock into master-online

wugg 3 年之前
父節點
當前提交
b8aedef50c

+ 43 - 0
app/admin/controller/After.php

@@ -5,7 +5,9 @@ namespace app\admin\controller;
 use app\admin\model\ActionLog;
 use app\admin\model\ProcessOrder;
 use think\App;
+use think\Exception;
 use think\facade\Db;
+use think\facade\Validate;
 
 
 class After extends \app\BaseController
@@ -858,4 +860,45 @@ class After extends \app\BaseController
             return error_show(1004,$e->getMessage());
         }
     }
+
+    //取消售后
+    public function Cancel()
+    {
+        //接收参数
+        $data = $this->request->only(['token', 'returnCode'], 'post', 'trim');
+
+        $val = Validate::rule(['returnCode|售后单编号' => 'require']);
+
+        if (!$val->check($data)) return error_show(1005, $val->getError());
+
+        Db::startTrans();
+        try {
+
+            $rs = Db::name('order_return')->field('id,status')->where([['returnCode', '=', $data['returnCode']], ['is_del', '=', 0], ['status', '<>', 8]])->find();
+
+            if (!$rs) throw new Exception('该售后单记录不存在');
+
+            //修改记录
+            $res = Db::name('order_return')->where(['id' => $rs['id']])->update(['status' => 8, 'updatetime' => date('Y-m-d H:i:s')]);
+
+            if (!$res) throw new Exception('该售后单记录修改失败');
+
+            //记录日志
+            ActionLog::logAdd($data['token'], ["order_code" => $data['returnCode'], "status" => 8, "action_remark" => '', "action_type" => "cancel"], 'SHD', 8, $this->post);
+            ProcessOrder::AddProcess($this->post['token'], ["order_code" => $data['returnCode'], "order_id" => $rs['id'], "order_status" => 8, "order_type" => 'SHD']);
+
+            //提交
+            Db::commit();
+
+            return app_show(0, "取消成功");
+
+        } catch (\Exception $e) {
+
+            Db::rollback();
+
+            return error_show(1004, $e->getMessage());
+        }
+
+    }
+
 }

+ 109 - 233
app/admin/controller/Consult.php

@@ -2,6 +2,8 @@
 
 namespace app\admin\controller;
 
+use app\admin\model\ActionLog;
+use app\admin\model\ProcessOrder;
 use think\App;
 use think\facade\Db;
 use think\facade\Validate;
@@ -131,14 +133,7 @@ class Consult extends Base
         if($endtime===""){
             return error_show(1002,"参数endtime不能为空");
         }
-//        $saleid =  isset($this->post['saleid']) && $this->post['saleid'] !=="" ? intval($this->post['saleid']) : "";
-//        if($saleid===""){
-//            return error_show(1002,"参数saleid不能为空");
-//        }
-//        $depart =  isset($this->post['depart']) && $this->post['depart'] !=="" ? intval($this->post['depart']) : "";
-//        if($depart===""){
-//            return error_show(1002,"参数depart不能为空");
-//        }
+
         $platform_code =  isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']) :
             "";
         if($platform_code===""){
@@ -160,226 +155,94 @@ class Consult extends Base
         $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
         $depart= Db::name("depart_user")->where(["uid"=>$createrid,"status"=>1,"is_del"=>0])->find();
         $zxNo=makeNo("ZX");
-        $data=[
-            "zxNo"=>$zxNo,
-            "createrid"=>$createrid,
-            "creater"=>$creater,
-            "is_project"=>$is_project,
-            "projectNo"=>isset($projectNo) ? $projectNo:"",
-            "khNo"=>$khNo,
-            "companyNo"=>$companyNo,
-            "endtime"=>$endtime,
-            "salesman"=>$creater,
-            "platform_code"=>$platform_code,
-            "saleid"=>$createrid,
-            "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
-            "status"=>0,
-            "is_del"=>0,
-            "addtime"=>date("Y-m-d H:i:s"),
-            "updatetime"=>date("Y-m-d H:i:s"),
-        ];
-        $zx = Db::name("consult_order")->insert($data);
-        if($zx){
-            foreach ($ladder as $value){
-                $infoNo=makeNo("INF");
-                $specinfo=[];
-                if(isset($value['specinfo']) &&!empty($value['specinfo'])){
-                    foreach ($value["specinfo"] as $v){
-                        $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
-                        $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
-                        $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
-                        $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
-                        $specinfo[]=$v;
+        Db::startTrans();
+        try{
+            $data=[
+                "zxNo"=>$zxNo,
+                "createrid"=>$createrid,
+                "creater"=>$creater,
+                "is_project"=>$is_project,
+                "projectNo"=>isset($projectNo) ? $projectNo:"",
+                "khNo"=>$khNo,
+                "companyNo"=>$companyNo,
+                "endtime"=>$endtime,
+                "salesman"=>$creater,
+                "platform_code"=>$platform_code,
+                "saleid"=>$createrid,
+                "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
+                "status"=>0,
+                "is_del"=>0,
+                "addtime"=>date("Y-m-d H:i:s"),
+                "updatetime"=>date("Y-m-d H:i:s"),
+            ];
+            $zx = Db::name("consult_order")->insert($data);
+            if($zx){
+                foreach ($ladder as $value){
+                    $infoNo=makeNo("INF");
+                    $specinfo=[];
+                    if(isset($value['specinfo']) &&!empty($value['specinfo'])){
+                        foreach ($value["specinfo"] as $v){
+                            $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
+                            $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
+                            $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
+                            $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
+                            $specinfo[]=$v;
+                        }
+                    }
+                    $info=[
+                        "infoNo"=>$infoNo,
+                        "zxNo"=>$zxNo,
+                        "spuCode"=>"",
+                        "good_name"=>$value['good_name'],
+                        "good_img"=>$value['good_img'],
+                        "cat_id"=>$value['cat_id'],
+                        "unit"=>$value['unit'],
+                        "brand_id"=>$value['brand_id'],
+                        "arrival_time"=>$value['arrival_time'],
+                        "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
+                        "cost_desc"=>$value['cost_desc'],
+                        "is_addrs"=>$value['is_addrs'],
+                        "is_custom"=>$value['is_custom'],
+                        "metal_id"=>$value['metal_id'],
+                        "config"=>isset($value['config'])?$value['config']:"",
+                        "other_config"=>isset($value['other_config'])?$value['other_config']:"",
+                        "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0",
+                        "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0",
+                        "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0",
+                        "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0",
+                        "budget_price"=>$value['budget_price'],
+                        "num"=>$value['num'],
+                        "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
+                        "use_desc"=>$value['use_desc'],
+                        "remark"=>$value['remark'],
+                        "status"=>1,
+                        "is_del"=>0,
+                        "addtime"=>date("Y-m-d H:i:s"),
+                        "updatetime"=>date("Y-m-d H:i:s")
+                    ];
+                    $up = Db::name("consult_info")->insert($info);
+                    if(!$up){
+                        Db::rollback();
+                        return error_show(1004,'添加失败');
                     }
                 }
-                $info=[
-                    "infoNo"=>$infoNo,
-                    "zxNo"=>$zxNo,
-                    "spuCode"=>"",
-                    "good_name"=>$value['good_name'],
-                    "good_img"=>$value['good_img'],
-                    "cat_id"=>$value['cat_id'],
-                    "unit"=>$value['unit'],
-                    "brand_id"=>$value['brand_id'],
-                    "arrival_time"=>$value['arrival_time'],
-                    "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
-                    "cost_desc"=>$value['cost_desc'],
-                    "is_addrs"=>$value['is_addrs'],
-                    "is_custom"=>$value['is_custom'],
-                    "metal_id"=>$value['metal_id'],
-                    "config"=>isset($value['config'])?$value['config']:"",
-                    "other_config"=>isset($value['other_config'])?$value['other_config']:"",
-                    "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0",
-                    "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0",
-                    "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0",
-                    "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0",
-                    "budget_price"=>$value['budget_price'],
-                    "num"=>$value['num'],
-                    "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
-                    "use_desc"=>$value['use_desc'],
-                    "remark"=>$value['remark'],
-                    "status"=>1,
-                    "is_del"=>0,
-                    "addtime"=>date("Y-m-d H:i:s"),
-                    "updatetime"=>date("Y-m-d H:i:s")
-                ];
-                $up = Db::name("consult_info")->insert($info);
-                if(!$up){
-                    Db::rollback();
-                    return error_show(1004,'添加失败');
-                }
+                $stn = ["order_code"=>$zxNo,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
+                ActionLog::logAdd($this->post['token'],$stn,"ZXD",2,$info);
+                $process=["order_code"=>$zxNo,"order_id"=>Db::name("consult_order")->getLastInsID(),"order_status"=>1,"order_type"=>'ZXD'];
+                ProcessOrder::AddProcess($this->post['token'],$process);
+                Db::commit();
+                return  app_show(0,"新建成功",["zxNo"=>$zxNo]);
+            }else{
+                Db::rollback();
+                return error_show(1004,"新建失败");
             }
-
-            return  app_show(0,"新建成功",["zxNo"=>$zxNo]);
-        }else{
-            return error_show(1004,"新建失败");
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1003,$e->getMessage());
         }
+
     }
 
-//    public function zxadd(){
-//        $good_name = isset($this->post['good_name'])&&$this->post['good_name']!==""?trim($this->post['good_name']):"";
-//        if($good_name===""){
-//            return error_show(1004,"参数good_name不能为空");
-//        }
-//        $zxNo = isset($this->post['zxNo'])&&$this->post['zxNo']!==""?trim($this->post['zxNo']):"";
-//        if($zxNo===""){
-//            return error_show(1004,"参数zxNo不能为空");
-//        }
-//
-//        $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):"";
-//        if($cat_id===""){
-//            return error_show(1004,"参数cat_id不能为空");
-//        }
-//        $arrival_time = isset($this->post['arrival_time'])&&$this->post['arrival_time']!==""?$this->post['arrival_time']
-//            :"";
-//        if($arrival_time===""){
-//            return error_show(1004,"参数arrival_time不能为空");
-//        }
-//        $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""?trim($this->post['good_img']):"";
-//        if($good_img===""){
-//            return error_show(1004,"参数good_img不能为空");
-//        }
-//        $is_custom = isset($this->post['is_custom'])&&$this->post['is_custom']!==""?intval($this->post['is_custom']):"";
-//        if($is_custom===""){
-//            return error_show(1004,"参数is_custom不能为空");
-//        }
-//        $unit = isset($this->post['unit'])&&$this->post['unit']!==""?trim($this->post['unit']):"";
-//        if($unit===""){
-//            return error_show(1004,"参数unit不能为空");
-//        }
-//        $brand_id = isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"";
-//        if($brand_id===""){
-//            return error_show(1004,"参数brand_id不能为空");
-//        }
-//        $material = isset($this->post['material'])&&$this->post['material']!==""?trim($this->post['material']):"";
-//        if($material===""){
-//            return error_show(1004,"参数material不能为空");
-//        }
-//        $color = isset($this->post['color'])&&$this->post['color']!==""?trim($this->post['color']):"";
-//        if($color===""){
-//            return error_show(1004,"参数color不能为空");
-//        }
-//        $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!==""?trim($this->post['cost_desc']):"";
-//        if($cost_desc===""){
-//            return error_show(1004,"参数cost_desc不能为空");
-//        }
-//        $model = isset($this->post['model'])&&$this->post['model']!==""?trim($this->post['model']):"";
-//        if($model===""){
-//            return error_show(1004,"参数model不能为空");
-//        }
-//
-//        $is_addrs = isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
-//        if($is_addrs===""){
-//            return error_show(1004,"参数is_addrs不能为空");
-//        }
-//
-//        $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!==""?trim($this->post['metal_id']):"";
-//        if($metal_id===""){
-//            return error_show(1004,"参数metal_id不能为空");
-//        }
-//        if($metal_id==0){
-//            $config = isset($this->post['config'])&&!empty($this->post['config'])?$this->post['config']:"";
-//            if($config===""){
-//                return error_show(1004,"参数config不能为空");
-//            }
-//            $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""?trim($this->post['other_config'])
-//                :"";
-//            if($other_config===""){
-//                return error_show(1004,"参数other_config不能为空");
-//            }
-//            $specs_weight = isset($this->post['specs_weight'])&&$this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
-//            if($specs_weight===""){
-//                return error_show(1004,"参数specs_weight不能为空");
-//            }
-//            $gold_price = isset($this->post['gold_price'])&&$this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
-//            if($gold_price===""){
-//                return error_show(1004,"参数gold_price不能为空");
-//            }
-//
-//        }
-//        $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
-//        if($budget_price===""){
-//            return error_show(1004,"参数budget_price不能为空");
-//        }
-//        $num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):"";
-//        if($num===""){
-//            return error_show(1004,"参数num不能为空");
-//        }
-//        $use_desc = isset($this->post['use_desc'])&&$this->post['use_desc']!==""?trim($this->post['use_desc']):"";
-//        if($use_desc===""){
-//            return error_show(1004,"参数use_desc不能为空");
-//        }
-//        $remark = isset($this->post['remark'])&&$this->post['remark']!==""?trim($this->post['remark']):"";
-//        if($remark===""){
-//            return error_show(1004,"参数remark不能为空");
-//        }
-//
-//        Db::startTrans();
-//        try{
-//                $infoNo=makeNo("INF");
-//                $info=[
-//                    "infoNo"=>$infoNo,
-//                    "zxNo"=>$zxNo,
-//                    "spuCode"=>"",
-//                    "good_name"=>$good_name,
-//                    "good_img"=>$good_img,
-//                    "cat_id"=>$cat_id,
-//                    "unit"=>$unit,
-//                    "brand_id"=>$brand_id,
-//                    "arrival_time"=>$arrival_time,
-//                    "model"=>$model,
-//                    "color"=>$color,
-//                    "material"=>$material,
-//                    "cost_desc"=>$cost_desc,
-//                    "is_addrs"=>$is_addrs,
-//                    "is_custom"=>$is_custom,
-//                    "metal_id"=>$metal_id,
-//                    "config"=>isset($config)?$config:"",
-//                    "other_config"=>isset($other_config)?$other_config:"",
-//                    "specs_weight"=>isset($specs_weight)?$specs_weight:0,
-//                    "gold_price"=>isset($gold_price)?$gold_price:0,
-//                    "budget_price"=>$budget_price,
-//                    "num"=>$num,
-//                    "use_desc"=>$use_desc,
-//                    "remark"=>$remark,
-//                    "status"=>0,
-//                    "is_del"=>0,
-//                    "addtime"=>date("Y-m-d H:i:s"),
-//                    "updatetime"=>date("Y-m-d H:i:s")
-//                ];
-//                $up = Db::name("consult_info")->insert($info);
-//                if($up){
-//                    Db::commit();
-//                    return app_show(0,"添加成功",["infoNo"=>$infoNo]);
-//                }else{
-//                    Db::rollback();
-//                    return error_show(1004,'添加失败');
-//                }
-//        }catch (\Exception $e){
-//            Db::rollback();
-//            return error_show(1004,$e->getMessage());
-//        }
-//    }
 
     public function zxinfo(){
         $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
@@ -492,14 +355,6 @@ class Consult extends Base
         if($specin==""){
             return error_show(1003,"参数specinfo不能为空");
         }
-//        $color= isset($this->post['color'])&&$this->post['color']!=""?trim($this->post['color']):"";
-//        if($color==""){
-//            return error_show(1003,"参数color不能为空");
-//        }
-//        $material= isset($this->post['material'])&&$this->post['material']!=""?trim($this->post['material']):"";
-//        if($material==""){
-//            return error_show(1003,"参数material不能为空");
-//        }
         $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
         if($cost_desc==""){
             return error_show(1003,"参数cost_desc不能为空");
@@ -605,7 +460,8 @@ class Consult extends Base
                 "status"=>1,
                 "is_del"=>0,
                 "addtime"=>date("Y-m-d H:i:s"),
-                "updatetime"=>date("Y-m-d H:i:s")
+                "updatetime"=>date("Y-m-d H:i:s"),
+                'bargain_status'=>1
             ];
             $up = Db::name("consult_info")->insert($info);
             if($up){
@@ -615,7 +471,7 @@ class Consult extends Base
                         $value['infoNo']=$innew;
                         $value['bidNo']=makeNo("BD");
                         $value['spuCode']=makeNo("SPU");
-                        $value['status'] =1;
+                        $value['status'] =0;
                         $value['updatetime'] =date("Y-m-d H:i:s");
                         $in = Db::name("consult_bids")->insert($value);
                         if($in==false){
@@ -662,6 +518,7 @@ class Consult extends Base
         $zxinfo['updatetime']=date("Y-m-d H:i:s");
         $up = Db::name("consult_info")->save($zxinfo);
         if($up){
+
             return app_show(0,"状态更新成功");
         }else{
             return error_show(1003,"状态更新失败");
@@ -1187,6 +1044,16 @@ class Consult extends Base
         if(empty($user)||$user['code']!=0){
             return error_show(1002,"用户数据不存在");
         }
+        //新增两个字段
+        //议价备注
+        $bargain_remark = isset($this->post['bargain_remark']) && $this->post['bargain_remark'] != "" ? trim($this->post['bargain_remark']) : "";
+        //议价原因id
+        $result_info_id = isset($this->post['result_info_id']) && $this->post['result_info_id'] != "" ? $this->post['result_info_id'] : "";
+        if ($result_info_id != '') {
+            $temp = Db::name('result_info')->field('id')->where(['result_code' => $result_info_id, 'type' => 7, 'status' => 1, 'is_del' => 0])->find();//type 7议价原因
+            if (empty($temp)) return error_show(1004, "议价原因选择不正确");
+        }
+
         $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
         $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
         $bargainNo =makeNo("BA");
@@ -1211,7 +1078,9 @@ class Consult extends Base
                 "creater"=>$creater,
                 "createrid"=>$createrid,
                 "addtime"=>date("Y-m-d H:i:s"),
-                "updatetime"=>date("Y-m-d H:i:s")
+                "updatetime"=>date("Y-m-d H:i:s"),
+                'bargain_remark'=>$bargain_remark,
+                'result_info_id'=>$result_info_id,
             ];
             $int = Db::name("bargain_order")->insert($data);
             if($int){
@@ -1441,6 +1310,13 @@ class Consult extends Base
         $info['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
         $info['sale_price'] =round($bidinfos['sale_price'],2);
         $info['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
+
+        //获取议价原因
+        if ($info['result_info_id'] != 0) {
+            $info['result_info'] = Db::name('result_info')->where(['result_code' => $info['result_info_id'], 'type' => 7, 'status' => 1, 'is_del' => 0])->value('result');
+        } else {
+            $info['result_info'] = '';
+        }
         return app_show(0,"获取成功",$info);
     }
 

+ 21 - 22
app/admin/controller/Good.php

@@ -309,7 +309,7 @@ class Good extends Base
         $condition = [["a.is_del","=",0]];
         $type_code = isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
         if($type_code!==""){
-          $condition[]=["a.good_type_code","=",$type_code];
+          $condition[]=["a.spuCode","=",$type_code];
         }
         $wsm_code = isset($this->post['wsm_code']) &&$this->post['wsm_code'] !=="" ? trim($this->post['wsm_code'])
             :"";
@@ -343,7 +343,7 @@ class Good extends Base
       $condition = [["is_del","=",0]];
       $type_code = isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
       if($type_code!==""){
-          $condition[]=["good_type_code","like","%{$type_code}%"];
+          $condition[]=["spuCode","like","%{$type_code}%"];
       }
       $wsm_code = isset($this->post['wsm_code']) &&$this->post['wsm_code'] !=="" ? trim($this->post['wsm_code'])
           :"";
@@ -450,8 +450,7 @@ class Good extends Base
               (['a.wsm_code'=>$value['wsm_code'],"a.is_del"=>0])->field("a.name as wsm_name,wsm_code,b.code,b.name")
                   ->find();
               $good = Db::name("good_stock")->alias("a")
-                  ->join("good c","c.spuCode=a.spuCode","left")->where(["a.wsm_code"=>$value['wsm_code'],"a
-                  .is_del"=>0,"c.is_del"=>0])->select();
+                  ->join("good c","c.spuCode=a.spuCode","left")->where(["a.wsm_code"=>$value['wsm_code'],"a.is_del"=>0,"c.is_del"=>0])->select();
           }
           $temp['wsm_name'] = isset($wsm['wsm_name'])?$wsm['wsm_name']:"";
           $temp['wsm_code']=$value['wsm_code'];
@@ -472,37 +471,37 @@ class Good extends Base
     public function GetStockGod(){
         $page = isset($this->post['page']) &&$this->post['page'] !=="" ? intval($this->post['page']):1;
         $size = isset($this->post['size']) &&$this->post['size'] !=="" ? intval($this->post['size']):10;
-        $condition = [["a.is_del","=",0],["b.is_del","=",0],["c.usable_stock",">",0]];
+        $condition = [["b.is_del","=",0],["c.usable_stock",">",0]];
         $type_code = isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code'])
             :"";
         if($type_code!==""){
-            $condition[]=["b.type_code","like","%{$type_code}%"];
+            $condition[]=["b.spuCode","like","%{$type_code}%"];
         }
-        $count = Db::name("good_type")->alias("b")
-            ->join("good a","a.good_code = b.good_code","left")
-            ->join("good_stock c","c.good_type_code = b.type_code","left")
-            ->where($condition)->group("a.good_code,a.good_name,a.unit,a.sort_f,b.type_code,b.attribute,a.addtime")->count();
+        $count = Db::name("good")->alias("b")
+            ->join("good_stock c","c.spuCode = b.spuCode","left")
+            ->where($condition)->group("b.spuCode,b.good_name,b.good_unit,b.cat_id,b.craft_desc,b.addtime")
+            ->count();
         $page>=ceil($count/$size) ? $page=ceil($count/$size) :"";
-        $list = Db::name("good_type")->alias("b")
-            ->join("good a","a.good_code = b.good_code","left")
-            ->join("good_stock c","c.good_type_code = b.type_code","left")
-            ->where($condition)->field("a.good_code,a.good_name,a.unit,a.sort_f,b.type_code,b.attribute,a.addtime,sum(c.wait_in_stock) wait_in_stock,
+        $list = Db::name("good")->alias("b")
+            ->join("good_stock c","c.spuCode = b.spuCode","left")
+            ->where($condition)->field("b.spuCode,b.good_name,b.good_unit,b.cat_id,b.craft_desc,b.addtime,sum(c.wait_in_stock) wait_in_stock,
                 sum(c.wait_out_stock) wait_out_stock,sum(c.usable_stock) usable_stock,sum(c.intra_stock) intra_stock,sum(c.warn_stock) warn_stock,sum(c.total_stock) total_stock")
-            ->page($page,$size)->order("a.addtime desc")->group("a.good_code,a.good_name,a.unit,a.sort_f,b.type_code,b.attribute,a.addtime")->select();
+            ->page($page,$size)->order("b.addtime desc")->group("b.spuCode,b.good_name,b.good_unit,b.cat_id,b.craft_desc,b.addtime")->select();
        // echo Db::name("good_type")->getLastSql();
         $data=[];
         foreach ($list as $key=>$value){
             $temp=[];
-            if($value['type_code']!=""){
+            if($value['spuCode']!=""){
                 $child = Db::name("good_stock")->alias("a")->join("warehouse_info b","a.wsm_code=b.wsm_code","left")
-                    ->where(['a.good_type_code'=>$value['type_code'],"b.wsm_type"=>1,"a.is_del"=>0])->field("a.wsm_code,b.name wsm_name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,a.total_stock,a.warn_stock")->select();
+                    ->where(['a.spuCode'=>$value['spuCode'],"b.wsm_type"=>1,"a.is_del"=>0])->field("a.wsm_code,b.name wsm_name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,a.total_stock,a.warn_stock")->select();
             }
             $temp['good_name'] = $value['good_name'];
-            $temp['good_code'] = $value['good_code'];
-            $temp['type_code'] = $value['type_code'];
-            $temp['unit'] = $value['unit'];
-            $temp['sort_f']=$value['sort_f'];
-            $temp['attribute']=$value['attribute'];
+            $temp['good_code'] = $value['spuCode'];
+            $temp['type_code'] ='';
+            $unit = Db::name("unit")->where(['id'=>$value['good_unit']])->find();
+            $temp['unit'] = isset($unit['unit'])?$unit['unit']:"";
+            $temp['sort_f']=isset($value['cat_id'])?made($value['cat_id']):[];
+            $temp['attribute']=$value['craft_desc'];
             $temp['addtime']=$value['addtime'];
             $temp['usable_stock'] = isset($value['usable_stock'])? $value['usable_stock']:"";
             $temp['wait_in_stock'] = isset($value['wait_in_stock'])? $value['wait_in_stock']:"";

+ 1 - 1
app/admin/controller/Log.php

@@ -115,7 +115,7 @@ class Log extends BaseController
         $count = Db::name("order_msg")->where($condition)->count();
         $total = ceil($count/$size);
         $page = $page >= $total ? $total : $page;
-        $list =Db::name("order_msg")->where($condition)->page($page,$size)->select();
+        $list =Db::name("order_msg")->where($condition)->page(intval($page),$size)->select();
         $data=[];
         $type = \think\facade\Config::get("order");
         foreach ($list as $value){

+ 46 - 44
app/admin/controller/Purch.php

@@ -424,12 +424,12 @@ class Purch extends Base
         if($cg==""){
             return error_show(1002,"未找到采购单数据");
         }
-        $gd= Db::name('good')->where(['good_code'=>$cg['good_code']])->find();
+        $gd= Db::name('good')->where(['spuCode'=>$cg['spuCode']])->find();
         if($gd==""){
             return error_show(1002,"未找到商品数据");
         }
-        $diff_weight = isset($this->post['diff_weight']) && $this->post['diff_weight'] !=="" ? trim($this->post['diff_weight']) :"";
-        if($diff_weight==""){
+        $diff_weight = isset($this->post['diff_weight']) && $this->post['diff_weight'] !=="" ? floatval($this->post['diff_weight']) :"";
+        if($diff_weight===""){
             return error_show(1002,"参数diff_weight不能为空");
         }
         $apply_id =GetUserInfo($token);
@@ -439,11 +439,9 @@ class Purch extends Base
         $rid= isset($apply_id["data"]['id']) ?  $apply_id["data"]['id'] : "";
         $rname= isset($apply_id["data"]['nickname']) ?  $apply_id["data"]['nickname'] : "";
         $diff_price = $diff_weight*$cg['gold_price'];
-       // $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
         $data=[
             "cgdNo"=>$cgdNo,
-            "good_code"=>$cg['good_type_code'],
-            "good_kode"=>$cg['good_code'],
+            "good_code"=>$cg['spuCode'],
             "good_name"=>$cg['good_name'],
             "sale_price"=>$cg['good_price'],
             "good_weight"=>$cg['weight'],
@@ -452,7 +450,7 @@ class Purch extends Base
             "apply_name"=>$rname,
             "diff_weight"=>$diff_weight,
             "diff_price"=>$diff_price,
-            "gold_price"=>$cg['gold_price'],
+            "gold_price"=>$cg['good_price'],
             "status"=>1,
             "is_del"=>0,
             "addtime"=>date("Y-m-d H:i:s"),
@@ -462,40 +460,44 @@ class Purch extends Base
         try{
             $item = Db::name("purchease_diff")->insert($data,true);
             if($item>0){
-                $stm = ["order_code"=>$cgdNo,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
-                ActionLog::logAdd($this->post['token'],$stm,"CGGCD",1,$stm);
-                $process=["order_code"=>$cgdNo,"order_id"=>$item,"order_status"=>1,"order_type"=>'CGGCD'];
-                ProcessOrder::AddProcess($this->post['token'],$process);
-                if($cg['order_type']==2){
-                    $order = Db::name("sale")->where(["orderCode"=>$cg['bkcode']])->find();
+//                $stm = ["order_code"=>$cgdNo,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
+//                ActionLog::logAdd($this->post['token'],$stm,"CGGCD",1,$stm);
+//                $process=["order_code"=>$cgdNo,"order_id"=>$item,"order_status"=>1,"order_type"=>'CGGCD'];
+//                ProcessOrder::AddProcess($this->post['token'],$process);
+                $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->column("orderCode");
+
+                if(!empty($orderCode)){
+                    $order = Db::name("sale")->where(["orderCode"=>$orderCode])->select()->toArray();
                     if(empty($order)){
                         Db::rollback();
                         return error_show(1002,"未找到确认单信息");
                     }
-                    $data=[
-                        "orderCode"=>$cg['bkcode'],
-                        "good_code"=>$cg['good_type_code'],
-                        "good_kode"=>$cg['good_code'],
-                        "good_name"=>$cg['good_name'],
-                        "diff_weight"=>$diff_weight,
-                        "diff_price"=>$diff_weight*$cg['gold_price'],
-                        "gold_price"=>$cg['gold_price'],
-                        "status"=>1,
-                        "addtime"=>date("Y-m-d H:i:s"),
-                        "updatetime"=>date("Y-m-d H:i:s")
-                    ];
-                    $cgd = Db::name('sale_diff')->insert($data,true);
-                    if($cgd>0){
-                        $sto = ["order_code"=>$cg['bkcode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
-                        ActionLog::logAdd($this->post['token'],$sto,"ZXGCD",1,$sto);
-                        $process=["order_code"=>$cg['bkcode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'ZXGCD'];
-                        ProcessOrder::AddProcess($this->post['token'],$process);
-                        Db::commit();
-                        return error_show(0,"新建成功");
-                    }else{
-                        Db::rollback();
-                        return error_show(1002,"新建失败");
+                    foreach ($orderCode as $value){
+                        $data=[
+                            "orderCode"=>$value['orderCode'],
+                            "good_code"=>$value['spuCode'],
+                            "good_name"=>$value['good_name'],
+                            "diff_weight"=>$diff_weight,
+                            "diff_price"=>$diff_weight*$value['good_price'],
+                            "gold_price"=>$value['good_price'],
+                            "status"=>1,
+                            "addtime"=>date("Y-m-d H:i:s"),
+                            "updatetime"=>date("Y-m-d H:i:s")
+                        ];
+                        $cgd = Db::name('sale_diff')->insert($data,true);
+                        if($cgd==0){
+//                            $sto = ["order_code"=>$cg['bkcode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
+//                            ActionLog::logAdd($this->post['token'],$sto,"ZXGCD",1,$sto);
+//                            $process=["order_code"=>$cg['bkcode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'ZXGCD'];
+//                            ProcessOrder::AddProcess($this->post['token'],$process);
+//                            Db::commit();
+//                            return error_show(0,"新建成功");
+//                        }else{
+                            Db::rollback();
+                            return error_show(1002,"新建失败");
+                        }
                     }
+
                 }
                 Db::commit();
                 return error_show(0,"新建成功");
@@ -532,11 +534,11 @@ class Purch extends Base
         if($apply_name!==""){
             $where[]=['a.apply_name',"like","%$apply_name%"];
         }
-        $count = Db::name('purchease_diff')->alias('a')->join("good b","b.good_code=a.good_kode","left")
+        $count = Db::name('purchease_diff')->alias('a')->join("good b","b.spuCode=a.good_code","left")
             ->where($where)->count();
         $total = ceil($count/$size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('purchease_diff')->alias('a')->join("good b","b.good_code=a.good_kode","left")
+        $list = Db::name('purchease_diff')->alias('a')->join("good b","b.spuCode=a.good_code","left")
             ->where($where)->page($page,$size)->order("a.addtime desc")->field("a.*,b.cat_id")->select();
         $data=[];
         foreach ($list as $value){
@@ -554,8 +556,8 @@ class Purch extends Base
         if($idinf==false){
             return error_show(1002,"未找到采购工差单数据");
         }
-        $dn = Db::name('purchease_order')->where(['cgdNo'=>$idinf['cgdNo'],'is_del'=>0])->field('order_type')->find();
-        $goon = Db::name('good')->where(['good_code'=>$idinf['good_kode']])->find();
+        $dn = Db::name('purchease_order')->where(['cgdNo'=>$idinf['cgdNo'],'is_del'=>0])->find();
+        $goon = Db::name('good')->where(['spuCode'=>$idinf['good_code']])->find();
         if(empty($goon)){
             return error_show(1002,"未找到商品数据");
         }
@@ -609,10 +611,10 @@ class Purch extends Base
             $dio['updatetime']=date("Y-m-d H:i:s");
             $item = Db::name("purchease_diff")->update($dio);
          if ($item){
-             $sto = ["order_code"=>$dio['cgdNo'],"status"=>$temp,"action_remark"=>'',"action_type"=>"status"];
-             ActionLog::logAdd($this->post['token'],$sto,"CGGCD",$dio['status'],$sto);
-             $process=["order_code"=>$dio['cgdNo'],"order_id"=>$dio['id'],"order_status"=>$status,"order_type"=>'CGGCD'];
-             ProcessOrder::AddProcess($this->post['token'],$process);
+//             $sto = ["order_code"=>$dio['cgdNo'],"status"=>$temp,"action_remark"=>'',"action_type"=>"status"];
+//             ActionLog::logAdd($this->post['token'],$sto,"CGGCD",$dio['status'],$sto);
+//             $process=["order_code"=>$dio['cgdNo'],"order_id"=>$dio['id'],"order_status"=>$status,"order_type"=>'CGGCD'];
+//             ProcessOrder::AddProcess($this->post['token'],$process);
                 return error_show(0,"更新成功");
             }else{
                 return error_show(1002,"更新失败");

+ 9 - 6
app/admin/controller/Purchin.php

@@ -188,13 +188,16 @@ class Purchin extends BaseController
             return error_show(1009,"采购单剩余未发货数量不足");
         }
         if($cgdinfo['order_type']==1||$cgdinfo['order_type']==2 ){
-            $goodinfo = Db::name("good")->where(["spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
+            $goodinfo = Db::name("good_basic")->where(["spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
             if($goodinfo==false){
                 return error_show(1004,"商品数据未找到");
             }
             if($goodinfo['is_stock']==0){
                 $status=4;
             }
+        } else {
+            $send_way = Db::name("good_zixun")->where(["spuCode" => $cgdinfo['spuCode'], "is_del" => 0])->value('send_way');
+            if ($send_way) $status = 4;
         }
         $orin = [
             "wsm_in_code"=>$wsm_in_code,
@@ -285,8 +288,8 @@ class Purchin extends BaseController
                     $good_data[]=["stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,
                         'stock'=>$send_num,"stock_name"=>"usable_stock"];
                     if($upd){
-                        GoodLog::LogAdd($this->post['token'],$good_data,'入库单');
-                        ActionLog::logAdd($this->post['token'],$order,"仓库库存", 1,$good  );
+                        GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
+                        ActionLog::logAdd($this->post['token'],$order,"RKD", 1,$good  );
                         Db::commit();
                         return app_show(0,'商品入库成功',["wsm_in_code"=>$wsm_in_code]);
                     }else{
@@ -460,7 +463,7 @@ class Purchin extends BaseController
             $info['updatetime'] = date("Y-m-d H:i:s");
             $update = Db::name("purchease_in")->save($info);
             if($update){
-                ActionLog::logAdd($this->post['token'],$order,"入库单",$status,$this->post);
+                ActionLog::logAdd($this->post['token'],$order,"RKD",$status,$this->post);
                 $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>$status,"order_type"=>'RKD'];
                 ProcessOrder::AddProcess($this->post['token'],$process);
                 if($status==0){
@@ -544,8 +547,8 @@ class Purchin extends BaseController
                     $good_data[]=["stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,
                     'stock'=>$info['wsm_num'],"stock_name"=>"usable_stock"];
                     if($upd){
-                        GoodLog::LogAdd($this->post['token'],$good_data,'入库单');
-                        ActionLog::logAdd($this->post['token'],$order,"仓库库存", 1,$good  );
+                        GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
+                        ActionLog::logAdd($this->post['token'],$order,"RKD", 1,$good  );
                         Db::commit();
                         return app_show(0,'商品入库成功');
                     }else{

+ 3 - 3
app/admin/controller/Resign.php

@@ -766,7 +766,7 @@ class Resign extends BaseController
             "send_num"=>"0",
             "wsend_num"=>$info['good_num'],
             "remark"=>"",
-            "status"=>1,
+            "status"=>0,//0表示初始化
             "lasttime"=>date("Y-m-d H:i:s"),
             "is_del"=>0,
             "order_type"=>1,
@@ -811,8 +811,8 @@ class Resign extends BaseController
                         $good_data[]=["stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,
                             'stock'=>$info['good_num'],"stock_name"=>"wait_in_stock"];
                         if($upd) {
-                            GoodLog::LogAdd($this->post['token'], $good_data, '入库单');
-                            ActionLog::logAdd($this->post['token'], $order, "仓库库存", 1, $good);
+                            GoodLog::LogAdd($this->post['token'], $good_data, 'RKD');
+                            ActionLog::logAdd($this->post['token'], $order, "RKD", 1, $good);
                             $process=["order_code"=>$cgdCode,"order_id"=>Db::name("purchease_order")->getLastInsID(),"order_status"=>$cg['status'],"order_type"=>'CGD'];
                             ProcessOrder::AddProcess($this->post['token'],$process);
                             $info['wsm_code']=$wsm_code;

+ 69 - 63
app/admin/controller/Sale.php

@@ -152,6 +152,8 @@ class Sale extends Base
             "good_num"=>$good_num,
             "good_type"=>$goodtype,
             "order_type"=>$order_type,
+            'send_way'=>2
+
         ];
         $addrlist = isset($this->post['addrlist']) && $this->post['addrlist'] !=="" ?$this->post['addrlist']:"";
         if($sendtype==1){
@@ -342,6 +344,8 @@ class Sale extends Base
             return error_show(1005,$e->getMessage());
         }
     }
+
+    //采购单
     public function createCgd($data){
         $cgdCode = makeNo("CG");
         $supplier=Db::name("supplier")->where(["code"=>$data['supplierNo'],"is_del"=>0])->find();
@@ -401,10 +405,10 @@ class Sale extends Base
             "supplier_name"=>$supplier['name'],
             "companyNo"=>$data['companyNo'],
             "send_status"=>1,
-            "send_num"=>"0",
+            "send_num"=>0,
             "wsend_num"=>$data['good_num'],
             "remark"=>"",
-            "status"=>1,
+            "status"=>0,//0初始化
             "lasttime"=>date("Y-m-d H:i:s"),
             "is_del"=>0,
             "order_type"=>$data['order_type'],
@@ -470,11 +474,6 @@ class Sale extends Base
         if($arrtime==""){
             return error_show(1004,"参数arrtime不能为空");
         }
-        $order =Db::name("order_num")->where(["orderCode"=>$orderCode,"status"=>1])->where([["wsend_num",">=",0]])
-            ->select()->toArray();
-        if(empty($order)){
-            return error_show(1004,"未找到可以发货得采购单数据");
-        }
         $token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
         $apply_id =GetUserInfo($token);
         if(empty($apply_id)||$apply_id['code']!=0){
@@ -538,6 +537,11 @@ class Sale extends Base
                         Db::rollback();
                         return error_show(1002,"发货地址添加创建失败");
                     }
+                    $order =Db::name("order_num")->where(["orderCode"=>$orderCode,"status"=>1])->where([["wsend_num",">=",0]])
+                        ->select()->toArray();
+                    if(empty($order)){
+                        return error_show(1004,"未找到可以发货得采购单数据");
+                    }
                     $num = $value['receipt_quantity'];
                     $orsend=[];
                     foreach ($order as $val){
@@ -643,6 +647,7 @@ class Sale extends Base
             "good_type"=>1,
             "is_diff"=>$zxinfo['is_diff'],
             "order_type"=>3,
+            'send_way'=>$zxinfo['send_way']
         ];
         $token=isset($this->post['token'])&&$this->post['token']!=""? trim($this->post['token']):"";
         if($token==""){
@@ -1000,6 +1005,8 @@ class Sale extends Base
             "good_num"=>$data['good_num'],
             "good_type"=>1,
             "order_type"=>4,
+            "send_way"=>$goodinfo['send_way'],
+
         ];
         $datas=[
             "orderCode"=>$orderCode,
@@ -1253,6 +1260,7 @@ class Sale extends Base
                 "good_num"=>$data['good_num'],
                 "good_type"=>1,
                 "order_type"=>2,
+                'send_way'=>2
             ];
             if($good['is_stock']==0) {
                 $bol = $this->createCgd($cgd);
@@ -2917,76 +2925,74 @@ class Sale extends Base
 
     }
 
-    public function  getPrice(){
-        $skuCode=isset($this->post['skuCode'])&&$this->post['skuCode']!=""?trim($this->post['skuCode']):"";
-        if($skuCode===""){
-            return error_show(1003,"参数skuCode不能为空");
+    public function getPrice()
+    {
+        $skuCode = isset($this->post['skuCode']) && $this->post['skuCode'] != "" ? trim($this->post['skuCode']) : "";
+        if ($skuCode === "") {
+            return error_show(1003, "参数skuCode不能为空");
         }
-        $is_activity=isset($this->post['is_activity'])&&$this->post['is_activity']!==""?intval($this->post['is_activity'])
-            :"";
-        if($is_activity===""){
-            return error_show(1003,"参数is_activity不能为空");
+        $is_activity = isset($this->post['is_activity']) && $this->post['is_activity'] !== "" ? intval($this->post['is_activity'])
+            : "";
+        if ($is_activity === "") {
+            return error_show(1003, "参数is_activity不能为空");
         }
-        $sale_num=isset($this->post['sale_num'])&&$this->post['sale_num']!==""?intval($this->post['sale_num']):"";
-        if($sale_num===""){
-            return error_show(1003,"参数sale_num不能为空");
+        $sale_num = isset($this->post['sale_num']) && $this->post['sale_num'] !== "" ? intval($this->post['sale_num']) : "";
+        if ($sale_num === "") {
+            return error_show(1003, "参数sale_num不能为空");
         }
         $ct = Db::name('good_platform')->alias('a')->join('good b', 'b.spuCode=a.spuCode', 'left')
-            ->where(['a.skuCode' =>$skuCode])->find();
+            ->where(['a.skuCode' => $skuCode])->find();
         if ($ct == false) {
             return error_show(1002, "未找到商品数据");
         }
-        $origin = Db::name("good_nake")->where([["spuCode","=",$ct['spuCode']],["min_num","<=", $sale_num],["is_del","=",
-            0]])->order("min_num desc")->find();
-        if($origin==false){
-            $origin = Db::name("good_nake")->where([["spuCode","=",$ct['spuCode']],["is_del","=",
-                0]])->order("min_num asc")->find();
-            return error_show(1003,"不满足成本最低阶梯数量{$origin['min_num']}");
-        }
-        $stock=0;
-        if($ct['is_stock']==1){
-            $good_stock =Db::name("good_stock")->where(["spuCode"=>$ct['spuCode'],"is_del"=>0])->find();
-            $stock= isset($good_stock['usable_stock'])?$good_stock['usable_stock']:"0";
-        }
-        if($is_activity==1){
-            $act = Db::name("activity_info")->alias("a")->leftJoin("good_activity b","a.activity_code=b.activity_code")
-                ->where(["a.skuCode"=>$skuCode,"a.is_del"=>0,"a.status"=>1,"b.status"=>6,"b.is_del"=>0])->find();
-            if($act==false){
-                return error_show(1003,"未找到相关活动价");
-            }
-            if($act['moq_num']>$sale_num){
-                return error_show(1003,"商品不满足活动价起订量{$act['moq_num']}");
+
+        $stock = 0;
+        if ($ct['is_stock'] == 1) {
+            $good_stock = Db::name("good_stock")->where(["spuCode" => $ct['spuCode'], "is_del" => 0])->find();
+            $stock = isset($good_stock['usable_stock']) ? $good_stock['usable_stock'] : "0";
+        }
+        if ($is_activity == 1) {
+            $act = Db::name("activity_info")->alias("a")->leftJoin("good_activity b", "a.activity_code=b.activity_code")
+                ->where(["a.skuCode" => $skuCode, "a.is_del" => 0, "a.status" => 1, "b.status" => 6, "b.is_del" => 0])->find();
+            if ($act == false) {
+                return error_show(1003, "未找到相关活动价");
             }
-            if($act['activity_stock']<$sale_num){
-                return error_show(1003,"商品活动库存剩余{$act['activity_stock']}");
+            if ($act['moq_num'] > $sale_num) {
+                return error_show(1003, "商品不满足活动价起订量{$act['moq_num']}");
             }
-            return app_show(0,"获取成功",['sale_price'=>$act['activity_price'],"stock"=>$act['activity_stock']]);
-        }else{
-          $good = Db::name("good_ladder")->where(["skuCode"=>$skuCode,"is_del"=>0,"status"=>1])->order("min_num desc")
-              ->select()->toArray();
-            if(empty($good)){
-                return error_show(1003,"未找到相关阶梯价格");
+            if ($act['activity_stock'] < $sale_num) {
+                return error_show(1003, "商品活动库存剩余{$act['activity_stock']}");
             }
-            $lastnum=0;
-            $lastprice=0;
-            foreach ($good as $value){
-
-                if($value['min_num']>$sale_num){
-                    $lastnum=$value['min_num'];
-                    $lastprice=0;
-                    continue;
-                }else{
-                    $lastnum=0;
-                    $lastprice=$value['sale_price'];
-                    break;
+            return app_show(0, "获取成功", ['sale_price' => $act['activity_price'], "stock" => $act['activity_stock']]);
+        } else {
+
+            if ($ct['is_stock'] == 0) {
+                //good_nake 成本阶梯 good_ladder销售阶梯
+                $origin = Db::name("good_nake")->where([["spuCode", "=", $ct['spuCode']], ["is_del", "=", 0]])->order("min_num asc")->find();
+                if (!$origin) {
+                    return error_show(1003, "没有找到成本数据");
                 }
+            }
 
+            $good = Db::name("good_ladder")->where(["skuCode" => $skuCode, "is_del" => 0, "status" => 1])->order("min_num asc")->find();
+            if (!$good) {
+                return error_show(1003, "未找到相关阶梯价格");
             }
-            if($lastnum==0){
-                return app_show(0,"获取成功",['sale_price'=>$lastprice,"stock"=>$stock]);
-            }else{
-                return error_show(1003,"商品不满足起订量{$lastnum}");
+
+            if(!isset($origin['min_num'])) $origin['min_num']=0;
+
+            $lastnum = max($origin['min_num']??0, $good['min_num']);
+            if ($sale_num < $lastnum) {
+                return error_show(1003, "商品不满足起订量{$lastnum}");
             }
+
+            $good_temp = Db::name("good_ladder")->where(["skuCode" => $skuCode, "is_del" => 0, "status" => 1])->where('min_num', '<=', $sale_num)->order("min_num desc")->find();
+            if (!$good_temp) {
+                return error_show(1003, "未找到相关阶梯价格");
+            }
+
+            return app_show(0, "获取成功", ['sale_price' => $good_temp['sale_price'], "stock" => $stock]);
+
         }
     }
 

+ 0 - 12
app/admin/controller/Specs.php

@@ -143,23 +143,11 @@ class Specs extends BaseController
         if($spec_name==""){
             return error_show(1002,"参数spec_name不能为空");
         }
-//        $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
-//        if($token==''){
-//            return error_show(105,"参数token不能为空");
-//        }
-//        $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'] : "";
         $exam_status = isset($this->post['exam_status']) &&$this->post['exam_status'] !==""? intval($this->post['exam_status']):"0";
         $status = isset($this->post['status']) &&$this->post['status'] !==""? intval($this->post['status']):"0";
         $data = [
             "id"=>$id,
             "spec_name"=>$spec_name,
-//            "creater"=>$creater,
-//            "createrid"=>$createrid,
             "exam_status"=>$exam_status,
             "status"=>$status,
             "is_del"=>0,

+ 2 - 0
app/admin/route/app.php

@@ -240,6 +240,8 @@ Route::rule('afterfeed','admin/After/postfeed');
 Route::rule('afterpost','admin/After/addpost');
 Route::rule('aftergys','admin/After/GysFeed');
 Route::rule('afterwsm','admin/After/GetWsm');
+Route::rule('aftercancel','admin/After/Cancel');
+//Route::rule('aftersetwsm','admin/After/setWsm');
 
 Route::rule('processolist','admin/Proorder/list');
 Route::rule('processowaitlist','admin/Proorder/waitlist');