wugg 2 years ago
parent
commit
68ba772b44
1 changed files with 13 additions and 8 deletions
  1. 13 8
      app/admin/controller/CatPlat.php

+ 13 - 8
app/admin/controller/CatPlat.php

@@ -233,6 +233,10 @@ use think\App;class CatPlat extends Base{
         if($platform==false){
             return error_show(1004,"平台信息不存在");
         }
+        $num=isset($this->post['min_num'])&&$this->post['min_num']!=="" ? intval($this->post['min_num']):"";
+        if($num==""){
+            return error_show(1005,"参数min_num不能为空");
+        }
         if ($platform['type']!=1)  return error_show(1004,"平台为非对接平台");
         $good =Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->find();
         if($good==false){
@@ -240,15 +244,16 @@ use think\App;class CatPlat extends Base{
         }
         $nakelist = Db::name("good_nake")
             ->where(['spuCode'=>$spuCode,"is_del"=>0])
-            ->order("min_num asc")
+            ->where("min_num","<=",$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();
-//
-//            //非库存品的话,继续校验最小起订量
-//            //库存品的话,不足采购起订量的时候,取采购最小起订量
-//            if ($good['is_stock'] == 0) return error_show(1010, "起订量不足{$nakelist['min_num']}");
-//        }
+        if($nakelist==false){
+            $nakelist = Db::name("good_nake")->where(['spuCode'=>$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_plat")->where(["cat_id"=>$good['cat_id'],"is_del"=>0,"platform_id"=>$platid])->find();
         if ($catinfo==false)  return error_show(1005,"分类未设置平台毛利率");
         $budget = isset($catinfo['sale_rate']) ? $catinfo['sale_rate']/100:0;