wugg 9 months ago
parent
commit
5a9c203bfd

+ 3 - 31
app/admin/controller/Cat.php

@@ -92,6 +92,7 @@ class Cat extends Base
         $data = [];
         foreach ($list as $value) {
             $value['item'] = array_column(made($value['id'] ?? 0), 'id');
+//            $value['is_gold'] = cat_is_gold($value['id']);;
             $data[] = $value;
         }
         return app_show(0, '获取成功', ['list' => $data, 'count' => $count]);
@@ -166,7 +167,6 @@ class Cat extends Base
     public function create()
     {
         $param = $this->request->only(['cat_name', 'pid', 'cat_desc' => '', 'fund_code' => '', 'specs_id', 'weight' => 0, 'status' => 0], 'post', 'trim');
-//        $cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== '' ? trim($this->post['cat_name']) : '';
         $val = Validate::rule([
             'cat_name|分类名称' => 'require|max:255',
             'pid|父级id' => 'require|number|egt:0',
@@ -176,18 +176,6 @@ class Cat extends Base
         ]);
 
         if (!$val->check($param)) return json_show(1004, $val->getError());
-
-//        if ($cat_name == '') {
-//            return error_show(1002, '参数cat_name不能为空');
-//        }
-//        $pid = isset($this->post['pid']) && $this->post['pid'] !== '' ? intval($this->post['pid']) : '0';
-//        if ($pid === '') {
-//            return error_show(1002, '参数pid不能为空');
-//        }
-
-//        $cat_desc = isset($this->post['cat_desc']) && $this->post['cat_desc'] !== '' ? trim($this->post['cat_desc']) : '';
-//        $fund_code = isset($this->post['fund_code']) && $this->post['fund_code'] !== '' ? trim($this->post['fund_code']) : '';
-
         $level = 1;
 
         if ($param['pid'] != 0) {
@@ -496,16 +484,8 @@ class Cat extends Base
     //详情
     public function info()
     {
-//        $id = isset($this->post['id']) && $this->post['id'] !== '' ? intval($this->post['id']) : '';
-        $id = $this->request->post('id/d', 0, 'trim');
-//        if ($id == '') {
-//            return error_show(1002, '参数id不能为空');
-//        }
-//        $idinfo = Db::name('cat')->where(['id' => $id])->find();
-//        if ($idinfo == '') {
-//            return error_show(1002, '未找到数据');
-//        }
 
+        $id = $this->request->post('id/d', 0, 'trim');
         $idinfo = Db::name('cat')
             ->where(['id' => $id])
             ->append(['spec'])
@@ -519,12 +499,7 @@ class Cat extends Base
                     ->toArray();
             })
             ->findOrEmpty();
-
-//        $info = Db::name('cat_specs')->where(['cat_id' => $idinfo['id'], 'is_del' => 0])->column('specs_id');
-//        $temp = Db::name('specs')->where(['id' => $info, 'is_del' => 0])->field('id,spec_name')->select();
-        //$idinfo['cat_id']=$info['cat_id'];
-//        $idinfo['spec'] = $temp;
-        // $idinfo['specs_id']=$info;
+        
         return $idinfo ? json_show(0, '获取成功', $idinfo) : json_show(1002, '未找到数据');
     }
 
@@ -642,9 +617,6 @@ class Cat extends Base
             $cat['platform_id'] = $value['id'];
             $cat['addtime'] = $date;
             $cat['updatetime'] = $date;
-//            $isT = Db::name('cat_plat')
-//                ->where(['cat_id' => $cat['cat_id'], 'platform_id' => $cat['platform_id'], 'is_del' => 0])
-//                ->column('cat_id');
             if (isset($isT[$cat['platform_id']])) {
                 $data = $cat;
                 unset($data['cat_id']);

+ 1 - 41
app/admin/controller/CompanyCatProfit.php

@@ -196,53 +196,13 @@ class CompanyCatProfit extends Base
         if ($val->check($param) == false) return json_show(1004, $val->getError());
 
         $where = [
-            ['a.companyNo', '=', $param['companyNo']],
-            ['a.is_del', '=', 0],
-            ['b.level', '=', 3],
+            ['a.companyNo', '=', $param['companyNo']],['a.is_del', '=', 0],['b.level', '=', 3],
         ];
         if ($param['cat_name'] !== '') $where[] = ['b.search', 'like', '%' . $param['cat_name'] . '%'];
 
-        //如果搜索名字,要把所有符合要求的三级分类id展现出来
-//        if ($param['cat_name'] != '') {
-//
-//            $cat_id = Db::name('cat')
-//                ->where(['is_del' => 0])
-//                ->whereLike('cat_name', '%' . $param['cat_name'] . '%')
-//                ->column('id');
-//            if (!empty($cat_id)) {
-//                $catid = [];
-////                $tmp_1 = Db::name('cat')
-////                    ->where(['is_del'=>0,'pid'=>$cat_id,'level'=>3])
-////                    ->column('id');
-////                if(!empty($tmp_1)) $catid = array_merge($catid,$tmp_1);
-//
-//                $tmp_1 = Db::name('cat')
-//                    ->where(['is_del' => 0, 'pid' => $cat_id])
-//                    ->column('id');
-//                if (!empty($tmp_1)) {
-//                    $catid = array_merge($catid, $tmp_1);
-//                    $tmp_2 = Db::name('cat')
-//                        ->where(['is_del' => 0, 'pid' => $tmp_1])
-//                        ->column('id');
-//                    if (!empty($tmp_2)) {
-//                        $catid = array_merge($catid, $tmp_2);
-//                        $tmp_3 = Db::name('cat')
-//                            ->where(['is_del' => 0, 'pid' => $tmp_2])
-//                            ->column('id');
-//                        if (!empty($tmp_3)) $catid = array_merge($catid, $tmp_3);
-//                    }
-//                }
-//
-//                if ($catid) $where[] = ['a.cat_id', 'in', $catid];
-//            }
-//
-//        }
-
         $count = Db::name('company_cat_profit')
             ->alias('a')
             ->leftJoin('cat b', 'b.id=a.cat_id')
-//            ->leftJoin('cat c', 'b.id=b.pid')
-//            ->leftJoin('cat d', 'd.id=c.pid')
             ->where($where)
             ->count('a.id');
 

+ 1 - 6
app/admin/controller/Good.php

@@ -725,11 +725,6 @@ class Good extends Base
         if($wsm_code!==""){
             $condition[]=["gs.wsm_code","=",$wsm_code];
         }
-//        $suplierNo = isset($this->post['supplierNo']) &&$this->post['supplierNo'] !=="" ? trim($this->post['supplierNo']):"";
-//        if($suplierNo!==""){
-//            $wsmcode = Db::name("warehouse_info")->where(['supplierNo'=>$suplierNo,"is_del"=>0])->column("wsm_code");
-//            $condition[]=["gs.wsm_code","in",$wsmcode];
-//        }
         $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
         if ($companyNo !== "") {
             $wsmcode = Db::name("warehouse_info")->where(['companyNo'=>$companyNo,"is_del"=>0])->column("wsm_code");
@@ -910,7 +905,7 @@ class Good extends Base
                         ->join("warehouse_info b", "a.wsm_code=b.wsm_code", "left")
                         ->where(['a.spuCode' => $value['spuCode'], "a.is_del" => 0])
                         ->where("b.wsm_type","<>",2)
-                        ->field("a.wsm_code,,b.wsm_type,b.name wsm_name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,(a.wait_out_stock+a.usable_stock) total_stock,a.warn_stock,b.supplierNo,b.companyNo,b.contactor_name")
+                        ->field("a.wsm_code,b.wsm_type,b.name wsm_name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,(a.wait_out_stock+a.usable_stock) total_stock,a.warn_stock,b.supplierNo,b.companyNo,b.contactor_name")
                         ->select()
                         ->toArray();
 

+ 11 - 9
app/admin/controller/Sale.php

@@ -105,18 +105,20 @@ class Sale extends Base
                 return error_show(1002, "参数act_code不能为空");
             }
         }
-           $origin = Db::name('good_nake')->where([['spuCode', '=', $spuCode], ['min_num', '<=', $good_num], ['is_del', '=', 0]])->order('min_num desc')->find();
-           if ($origin == false) {
-              return error_show(1003, '未找到相关阶梯成本价格');
-           }
-           $origin_price = $origin['nake_total'];
-           $cgd_origin_price = $origin['supplier_origin_price'];
+         $origin = Db::name('good_nake')->where([['spuCode', '=', $spuCode], ['min_num', '<=', $good_num], ['is_del', '=', 0]])->order('min_num desc')->find();
+         $origin_price = $origin['nake_total']??0;
+          $cgd_origin_price = $origin['supplier_origin_price']??0;
         if ($goodinfo['is_stock'] == 1) {
            $stock_num = Db::name("good")->where(["spuCode"=> $spuCode])->value("usable_stock",0);
             if($stock_num < $good_num){
                 return error_show(1003, "商品可用库存数量不足");
             }
             $origin_price = 0;
+        }else{
+        	
+           if ($origin == false) {
+              return error_show(1003, '未找到相关阶梯成本价格');
+           }
         }
 
         $sale_price = isset($this->post['good_price']) && $this->post['good_price'] !== "" ? floatval($this->post['good_price']) : '';
@@ -1886,11 +1888,11 @@ class Sale extends Base
         $sale_price = $goodlass['sale_price'];
         $origin = Db::name('good_nake')->where([['spuCode', '=', $data['spuCode']], ['min_num', '<=', $data['good_num']],
                 ['is_del', '=', 0]])->order('min_num desc')->find();
-        if ($origin == false) {
+        if ($origin == false &&  $good['is_stock'] ==0) {
                 throw new Exception('商品成本售价信息未找到');
         }
-         $origin_price = $good['is_stock'] == 0?$origin['nake_total']:0;
-         $cgd_origin_price = $origin['supplier_origin_price'];
+         $origin_price = $good['is_stock'] == 0?($origin['nake_total']??0):0;
+         $cgd_origin_price = $origin['supplier_origin_price']??0;
         
         if ($good['is_gold_price'] == 1 && $good['is_stock'] == 0) {
             $gold = Db::name("gold_price1")

+ 5 - 3
app/command/ImportOrderFromCHandleData.php

@@ -122,14 +122,16 @@ class ImportOrderFromCHandleData extends Command
                         ->where([['spuCode', '=', $spuCode], ['min_num', '<=', $good_num], ['is_del', '=', 0]])
                         ->order('min_num desc')
                         ->find();
-                if ($origin == false) throw new \Exception('未找到相关成本价格');
-                $origin_price = $goodinfo['is_stock'] == 1?0:$origin['nake_total'];
-                $cgd_origin_price = $origin['supplier_origin_price'];
+                
+                $origin_price = $goodinfo['is_stock'] == 1?0:($origin['nake_total']??0);
+                $cgd_origin_price = $origin['supplier_origin_price']??0;
                 if ($goodinfo['is_stock'] == 1) {
                     if ($ct['usable_stock'] < $good_num) {
                         throw new \Exception('商品库存数量不足');
                     }
                     
+                }else{
+                	if ($origin == false) throw new \Exception('未找到相关成本价格');
                 }
 
                 $sale_price = $extend_data['price'];

+ 4 - 3
app/command/handleYzOrderData.php

@@ -94,15 +94,16 @@ class handleYzOrderData extends Command
 				                        ->where([['spuCode', '=', $spuCode], ['min_num', '<=', $good_num], ['is_del', '=', 0]])
 				                        ->order('min_num desc')
 				                        ->find();
-				if ($origin == false) throw new \Exception('未找到相关成本价格');
-			        $origin_price = $goodinfo['is_stock'] == 1?0:$origin['nake_total'];
-			     $cgd_origin_price = $origin['supplier_origin_price'];
+				$origin_price = $goodinfo['is_stock'] == 1?0:($origin['nake_total']??0);
+			    $cgd_origin_price = $origin['supplier_origin_price']??0;
                 if ($is_stock == 1) {
                     if($ct['usable_stock'] < $good_num){
 			               throw new Exception('商品库存数量不足');
 			            }
                     $origin_price = 0;
 
+                }else{
+                	if ($origin == false) throw new \Exception('未找到相关成本价格');
                 }
 
 				$is_activity = 0;