Browse Source

Merge branch 'version1.5' into dev_wf

wufeng 2 years ago
parent
commit
6b0b3f9c17

+ 8 - 1
app/admin/controller/After.php

@@ -939,7 +939,7 @@ class After extends Base
                         "return_wsm"=>$returninfo["return_wsm"],
 //                        "defective_wsm"=>'',
                         "return_msg"=>$info["error_msg"],
-                        "return_num"=>$info["total_num"],
+                        "return_num"=>$info["error_num"],
                         "normal_num"=>0,
                         "received_num"=>0,
                         "apply_id"=>$info['apply_id'],
@@ -975,6 +975,13 @@ class After extends Base
                             "order_status" => $thdata['status']
                         ]);
 
+//                        $out['status']=$info['is_receive']==1&&$info['total_num']>$info['error_num'] ?3:4;
+//                        $out['updatetime']=date("Y-m-d H:i:s");
+//                        $outup=Db::name("order_out")->save($out);
+//                        if($outup==false){
+//                            Db::rollback();
+//                            return error_show(1005,"发货单更新失败");
+//                        }
                         Db::commit();
                         return app_show(0,"退货单新建成功",["thNo"=>$thNo]);
                     }

+ 3 - 5
app/admin/controller/Consult.php

@@ -1737,7 +1737,7 @@ class Consult extends Base
                     "mark_fee"=>$value["mark_fee"],
                     "nake_fee"=>$value["nake_fee"],
                     "cert_fee"=>$value["cert_fee"],
-                    "cost_fee"=>$value['status']==5? $value["sale_cost_fee"]: $value["cost_fee"],
+                    "cost_fee"=>$value['status']>=5? $value["sale_cost_fee"]: $value["cost_fee"],
                     "num"=>$bidinfo["num"],
                 ];
             if($value['is_gold_price']==1){
@@ -1751,15 +1751,13 @@ class Consult extends Base
 
             //reject驳回原因,status==5表示驳回
             $value['reject']=[];
-            if ($value['status'] == 5) {
+            if ($value['status'] >=5) {
                 $value['reject'] = Db::name('bargain_order')
                     ->field('id,remark,status')
                     ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
-                    ->whereIn('status', [5, 6])
+                    ->whereIn('status', [3,8,11])->order("id desc")
                     ->find();
             }
-
-
             //产地
             if($value['origin_place']!=''){
                 $code = explode(",",$value['origin_place']);

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

@@ -566,6 +566,7 @@ class Good extends Base
                     $item_good['unit'] = $good_unit_s[$item_good['good_unit']]??'';
                     $item_good['brand_name'] = $brands[$item_good['brand_id']]??'';
                     $item_good['can'] = made($item_good['cat_id'],[]);
+                    $item_good['total_stock'] =$item_good['usable_stock']+$item_good['wait_out_stock'];
 
                 }
 
@@ -582,7 +583,6 @@ class Good extends Base
             $temp['wait_out_stock'] = $value['wait_out_stock'];
             $temp['intra_stock'] = $value['intra_stock'];
             $temp['total_stock'] = $value['usable_stock']+$value['wait_out_stock'] ;
-            // $temp['warn_stock'] = $value['warn_stock'];
             $temp['child']=isset($good)&&!empty($good) ? $good:[];
             $data[]=$temp;
         }
@@ -592,13 +592,14 @@ 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 = [["b.is_del","=",0],["c.usable_stock",">",0]];
+        $condition = [["b.is_del","=",0],["c.usable_stock",">",0],["a.wsm_type","<>",2]];
         $type_code = isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
         if($type_code!==""){
             $condition[]=["b.spuCode","like","%{$type_code}%"];
         }
         $count = Db::name("good")->alias("b")
             ->join("good_stock c","c.spuCode = b.spuCode","left")
+            ->leftJoin("warehouse_info a","a.wsm_code=c.wsm_code")
             ->where($condition)
             ->group("b.spuCode,b.good_name,b.good_unit,b.cat_id,b.craft_desc,b.addtime")
             ->count();
@@ -606,14 +607,14 @@ class Good extends Base
         $list = Db::name("good")
             ->alias("b")
             ->join("good_stock c","c.spuCode = b.spuCode","left")
+            ->leftJoin("warehouse_info a","a.wsm_code=c.wsm_code")
             ->where($condition)
-            ->field("b.spuCode,b.good_name,b.good_unit,b.brand_id,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.usable_stock+c.wait_out_stock) total_stock")
+            ->field("b.spuCode,b.good_name,b.good_unit,b.brand_id,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.usable_stock)+sum(c.wait_out_stock)) total_stock")
             ->page($page,$size)
             ->order("b.addtime desc")
             ->group("b.spuCode,b.good_name,b.good_unit,b.brand_id,b.cat_id,b.craft_desc,b.addtime")
             ->select()
             ->toArray();
-        // echo Db::name("good_type")->getLastSql();
         $data=[];
 
         if($list) {
@@ -630,16 +631,18 @@ class Good extends Base
                         ->join("warehouse_info b", "a.wsm_code=b.wsm_code", "left")
                         ->join("business bus", "bus.companyNo=b.companyNo", "left")
                         ->join("supplier s", "s.code=b.supplierNo", "left")
-                        ->where(['a.spuCode' => $value['spuCode'], "b.wsm_type" => 1, "a.is_del" => 0])
+                        ->where(['a.spuCode' => $value['spuCode'], "a.is_del" => 0])
+                        ->where("b.wsm_type","<>",2)
                         ->field("a.wsm_code,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,s.name supplierName,b.companyNo,bus.company")
                         ->select()
                         ->toArray();
+                   // echo Db::name("good_stock")->getLastSql();
                 }
                 $temp['good_name'] = $value['good_name'];
                 $temp['good_code'] = $value['spuCode'];
                 $temp['type_code'] = '';
 //                $unit = Db::name("unit")->where(['id' => $value['good_unit']])->find();
-                $temp['unit'] =$good_unit_s[$value['spuCode']]??'';
+                $temp['unit'] =$good_unit_s[$value['good_unit']]??'';
                 $temp['brand_name'] =$brands[$value['brand_id']]??'';
                 $temp['sort_f'] = isset($value['cat_id']) ? made($value['cat_id']) : [];
                 $temp['sort_f'] = implode('/', array_column($temp['sort_f'], 'name'));//由于这个字段原样在页面显示,所以在这里特意拼接成字符串

+ 61 - 26
app/admin/controller/Purch.php

@@ -448,7 +448,11 @@ class Purch extends Base
         if($cg==""){
             return error_show(1002,"未找到采购单数据");
         }
-        $gd= Db::name('good')->where(['spuCode'=>$cg['spuCode']])->find();
+        if($cg['order_type']==3|| $cg['order_type']==4){
+            $gd = Db::name("good_zixun")->where(["spuCode"=>$cg['spuCode']])->find();
+        }else {
+            $gd =Db::name('good_basic')->where(['spuCode'=>$cg['spuCode']])->find();
+        }
         if($gd==""){
             return error_show(1002,"未找到商品数据");
         }
@@ -462,13 +466,13 @@ 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'];
+        $diff_price = round($diff_weight*$cg['gold_price']+$diff_weight*$cg['teach_fee'],2);
         $data=[
             "cgdNo"=>$cgdNo,
             "good_code"=>$cg['spuCode'],
             "good_name"=>$cg['good_name'],
             "sale_price"=>$cg['good_price'],
-            "good_weight"=>$cg['weight'],
+            "good_weight"=>$cg['weight']*$cg['good_num'],
             "good_num"=>$cg['good_num'],
             "apply_id"=>$rid,
             "apply_name"=>$rname,
@@ -484,27 +488,22 @@ 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);
-                $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->column("orderCode");
-
-                if(!empty($orderCode)){
-                    $order = Db::name("sale")->where("orderCode", 'in', $orderCode)->select()->toArray();
-                    if(empty($order)){
+                $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->find();
+                if($orderCode!=false){
+                    $order = Db::name("sale")->where("orderCode", '=', $orderCode['orderCode'])->find();
+                    if($order==false){
                         Db::rollback();
                         return error_show(1002,"未找到确认单信息");
                     }
-                    foreach ($orderCode as $value){
+
                         $data=[
                             "cgd_diffid"=>$item,
-                            "orderCode"=>$value,
+                            "orderCode"=>$orderCode['orderCode'],
                             "good_code"=>$cg['spuCode'],
                             "good_name"=>$cg['good_name'],
                             "diff_weight"=>$diff_weight,
-                            "diff_price"=>$diff_weight*$cg['good_price'],
-                            "gold_price"=>$cg['good_price'],
+                            "diff_price"=>round($diff_weight*$order['gold_price']+$diff_weight*$order['cost_price'],2),
+                            "gold_price"=>$order['sale_price'],
                             "status"=>1,
                             "addtime"=>date("Y-m-d H:i:s"),
                             "updatetime"=>date("Y-m-d H:i:s")
@@ -520,7 +519,7 @@ class Purch extends Base
 //                        }else{
                             Db::rollback();
                             return error_show(1002,"新建失败");
-                        }
+
                     }
 
                 }
@@ -634,29 +633,60 @@ class Purch extends Base
         }
         $dio = Db::name('purchease_diff')->where(['id'=>$id,'is_del'=>0])->find();
         if(empty($dio)){
-            return error_show(1002,"退货订单未找到");
+            return error_show(1002,"工差订单未找到");
         }
         $cgd = Db::name("purchease_order")->where(['cgdNo'=>$dio['cgdNo']])->find();
         if(empty($cgd)){
             return error_show(1002,"采购单未找到");
         }
+        $salediff=Db::name("sale_diff")->where(["cgd_diffid"=>$dio['id']])->find();
+        if($salediff==false){
+            return error_show(1002,"销售工差单未找到");
+        }
         $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
         if($status===""){
             return error_show(1002,"参数status不能为空");
         }
-        $temp = $dio['status'];
+        Db::startTrans();
+        try{
+            $temp = $dio['status'];
             $dio['status']=$status;
             $dio['updatetime']=date("Y-m-d H:i:s");
             $item = Db::name("purchease_diff")->save($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);
+            if ($item){
+                if($status==2){
+                    $cgd['diff_fee'] =$dio['diff_price'];
+                    $cgd['diff_weight'] =$dio['diff_weight'];
+                    $cgd['updatetime'] =date("Y-m-d H:i:s");
+                    $cgp=Db::name("purchease_order")->save($cgd);
+                    if($cgp==false){
+                        Db::rollback();
+                        return error_show(1002,"采购单更新失败");
+                    }
+                    if($salediff['is_act']==1){
+                        $saled=[
+                            "diff_fee"=>$salediff['diff_price'],
+                            "diff_weight"=>$salediff['diff_weight'],
+                            "updatetime"=>date("Y-m-d H:i:s")
+                        ];
+                        $up =Db::name("sale")->where(["orderCode"=>$salediff['orderCode']])->save($saled);
+                        if($up==false){
+                            Db::rollback();
+                            return error_show(1002,"销售单更新失败");
+                        }
+                    }
+                }
+                Db::commit();
                 return error_show(0,"更新成功");
             }else{
+                Db::rollback();
                 return error_show(1002,"更新失败");
             }
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1002,$e->getMessage()."|".$e->getLine());
+        }
+
 
     }
 
@@ -672,16 +702,21 @@ class Purch extends Base
 
         //采购单
         $data = Db::name("purchease_order")
-            ->field('id,status')
+            ->field('id,demo_fee,good_num,weight,open_fee,teach_fee,pakge_fee,mark_fee,cert_fee,nake_fee,delivery_fee,status')
             ->where(["cgdNo" => $param['cgdNo'], "is_del" => 0])
             ->find();
 
         if (empty($data)) return error_show(1004, "未找到该采购单数据");
         if ($data['status'] != 0) return error_show(1005, '该状态下不允许修改实时金价');
+        $sale_price =  round($data['demo_fee'] / $data['good_num'] + $data['open_fee'] / $data['good_num'] +
+            $data['weight']  * $param["gold_price"] + $data['teach_fee'] *  $data['weight']  +
+            $data['pakge_fee'] +  $data['mark_fee'] + $data['cert_fee'] +$data['nake_fee'] + $data['delivery_fee'],2);
+        $total_price = round($data['good_num']*$sale_price,2);
 
         $rs = Db::name("purchease_order")
             ->where('id', $data['id'])
-            ->update(['updatetime' => date('Y-m-d H:i:s'), 'gold_price' => $param['gold_price']]);
+            ->update(['updatetime' => date('Y-m-d H:i:s'), 'gold_price' => $param['gold_price'],
+                "good_price"=>$sale_price,"total_fee"=>$total_price]);
 
         return $rs ? app_show(0, '修改采购单实时金价成功') : error_show(1005, '修改采购单实时金价失败');
 

BIN
public/good_check.xls