wugg 2 سال پیش
والد
کامیت
7b76c2fde0

+ 2 - 0
app/admin/controller/Good.php

@@ -139,6 +139,7 @@ class Good extends Base
             $value['status']=$value['exam_status'];
             $value['exclusive']=makeExcluse($value['is_exclusive']);
             $value['good_info_img']=json_decode($value['good_info_img'],true);
+            $value['good_img']=json_decode($value['good_img'],true);
             $spec = Db::name("good_spec")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->select()->toArray();
             $speclist=[];
             if(!empty($spec)){
@@ -216,6 +217,7 @@ class Good extends Base
         $excluse = makeExcluse($data['is_exclusive']);
         $data['exclusive']=$excluse;
         $data["good_info_img"]=$data['good_info_img']!=""? json_decode($data['good_info_img'],true):[];
+        $data["good_img"]=$data['good_img']!=""? json_decode($data['good_img'],true):[];
         $speclist=[];
         if(!empty($spec)){
             foreach ($spec as $value){

+ 17 - 15
app/admin/controller/Goodup.php

@@ -95,6 +95,7 @@ class Goodup extends Base
                 $supplier = Db::name("supplier")->where(['code'=>$value['supplierNo']])->find();
                 $value['supplier_name']=isset($supplier['name'])?$supplier['name']:"";
                 $value['good_info_img']=json_decode($value['good_info_img'],true);
+                $value['good_img']=json_decode($value['good_img'],true);
                 $value['exclusive']=makeExcluse($value['is_exclusive']);
                 $value['noble_name']=isset($value['noble_metal'])&&$value['noble_metal']!=0?$this->noble[$value['noble_metal']] :"";
                 $data[]=$value;
@@ -241,12 +242,12 @@ class Goodup extends Base
         }
         $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"0";
 
-        $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""? trim($this->post['good_img']):"";
+        $good_img = isset($this->post['good_img'])&&!empty($this->post['good_img'])? $this->post['good_img']:"";
         $config = isset($this->post['config'])&&$this->post['config']!==""? trim($this->post['config']):"";
         $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""? trim($this->post['other_config']):"";
-//        if($good_img===""){
-//            return error_show(1004,"参数good_img不能为空");
-//        }
+        if($good_img===""){
+            return error_show(1004,"参数good_img不能为空");
+        }
         $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
         if($good_thumb_img===""){
             return error_show(1004,"参数good_thumb_img不能为空");
@@ -330,7 +331,7 @@ class Goodup extends Base
                 "lead_time"=>$lead_time,
                 "sample_day"=>$sample_day,
                 "sample_fee"=>$sample_fee,
-                "good_img"=>$good_img,
+                "good_img"=>json_encode($good_img),
                 "good_thumb_img"=>$good_thumb_img,
                 "good_info_img"=>json_encode($good_info_img),
                 "cert_fee"=>$cert_fee,
@@ -547,10 +548,10 @@ class Goodup extends Base
 //        }
         $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval($this->post['sample_fee']):"0";
 
-        $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不能为空");
-//        }
+        $good_img = isset($this->post['good_img'])&&!empty($this->post['good_img'])? $this->post['good_img']:"";
+        if($good_img===""){
+            return error_show(1004,"参数good_img不能为空");
+        }
         $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
         if($good_thumb_img===""){
             return error_show(1004,"参数good_thumb_img不能为空");
@@ -595,7 +596,7 @@ class Goodup extends Base
                 "lead_time"=>$lead_time,
                 "sample_day"=>$sample_day,
                 "sample_fee"=>$sample_fee,
-                "good_img"=>$good_img,
+                "good_img"=>json_encode($good_img),
                 "good_thumb_img"=>$good_thumb_img,
                 "good_info_img"=>json_encode($good_info_img),
                 "status"=>$count>0?2:1,
@@ -831,6 +832,7 @@ class Goodup extends Base
         $data['exclusive']=$excluse;
         $data['noble_name']=isset($data['noble_metal'])&&$data['noble_metal']!=0?$this->noble[$data['noble_metal']] :"";
         $data["good_info_img"]=$data['good_info_img']!=""? json_decode($data['good_info_img'],true):[];
+        $data["good_img"]=$data['good_img']!=""? json_decode($data['good_img'],true):[];
         $speclist=[];
         if(!empty($spec)){
             foreach ($spec as $value){
@@ -1480,10 +1482,10 @@ class Goodup extends Base
 //        }
         $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval($this->post['sample_fee']):"0";
 
-        $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不能为空");
-//        }
+        $good_img = isset($this->post['good_img'])&&!empty($this->post['good_img'])? $this->post['good_img']:"";
+        if($good_img===""){
+            return error_show(1004,"参数good_img不能为空");
+        }
         $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
         if($good_thumb_img===""){
             return error_show(1004,"参数good_thumb_img不能为空");
@@ -1553,7 +1555,7 @@ class Goodup extends Base
                 "lead_time"=>$lead_time,
                 "sample_day"=>$sample_day,
                 "sample_fee"=>$sample_fee,
-                "good_img"=>$good_img,
+                "good_img"=>json_encode($good_img),
                 "good_thumb_img"=>$good_thumb_img,
                 "good_info_img"=>json_encode($good_info_img),
                 "cert_fee"=>$cert_fee,

+ 40 - 5
app/admin/controller/Purchin.php

@@ -174,6 +174,7 @@ class Purchin extends BaseController
                 ActionLog::logAdd($this->post['token'],$order,"rkd",$status,$this->post);
                 if($status==1){
                     $order = ["order_code"=>$cgdNo,"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
+                    ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
                     $cgdinfo['wsend_num']-=$send_num;
                     $cgdinfo['send_num']+=$send_num;
                     $cgdinfo['send_status']=$cgdinfo['wsend_num']==0 ? 3:($cgdinfo['send_num']==0 ?1:2);
@@ -181,11 +182,43 @@ class Purchin extends BaseController
                     $cgdinfo['updatetime']=date("Y-m-d H:i:s");
                     $up=Db::name("purchease_order")->save($cgdinfo);
                     if($up){
-                        ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
-                        $process=["order_code"=>$cgdNo,"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD'];
-                        ProcessOrder::AddProcess($this->post['token'],$process);
-                        Db::commit();
-                        return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
+//                        $good = Db::name("good_stock")->where(["wsm_code"=>$cgdinfo['wsm_code'],"spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
+//                        if(empty($good)) {
+//                            $good=[
+//                                "spuCode"=>$cgdinfo['skpuCode'],
+//                                "wsm_code"=>$cgdinfo['wsm_code'],
+//                                "usable_stock"=>0,
+//                                "wait_out_stock"=>0,
+//                                "wait_in_stock"=>0,
+//                                "total_stock"=>0,
+//                                "addtime"=>date("Y-m-d H:i:s"),
+//                                "updatetime"=>date("Y-m-d H:i:s"),
+//                            ];
+//                            $order = ["order_code"=>$good['good_type_code'],"status"=>1,"action_remark"=>'',
+//                                "action_type"=>"create"];
+//
+//                        }else{
+//                            $order = ["order_code"=>$good['good_type_code'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
+//                        }
+//                        $good['wait_in_stock']+=$send_num;
+//                        $good['updatetime'] = date("Y-m-d H:i:s");
+//                        $upd=  Db::name("good_stock")->save($good);
+//                        $good_data[]=["stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,
+//                            'stock'=>$send_num,"stock_name"=>"wait_in_stock"];
+//                        if($upd){
+//                            GoodLog::LogAdd($this->post['token'],$good_data,'入库单');
+//                            ActionLog::logAdd($this->post['token'],$order,"仓库库存", 1,$good  );
+                            $process=["order_code"=>$cgdNo,"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD'];
+                            ProcessOrder::AddProcess($this->post['token'],$process);
+                            Db::commit();
+                            return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
+//                        }else{
+//                            Db::rollback();
+//                            return error_show(1002,"商品入库失败");
+//                        }
+
+//                        Db::commit();
+//                        return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
                     }else{
                         Db::rollback();
                         return error_show(1004,"新建失败");
@@ -419,6 +452,7 @@ class Purchin extends BaseController
                           "wsm_code"=>$info['wsm_code'],
                           "usable_stock"=>0,
                           "wait_out_stock"=>0,
+                          "wait_in_stock"=>0,
                           "total_stock"=>0,
                           "addtime"=>date("Y-m-d H:i:s"),
                           "updatetime"=>date("Y-m-d H:i:s"),
@@ -430,6 +464,7 @@ class Purchin extends BaseController
                         $order = ["order_code"=>$good['good_type_code'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
                     }
                     $good['usable_stock']+=$info['wsm_num'];
+                    $good['wait_in_stock']-=$info['wsm_num'];
                     $good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
                     $good['updatetime'] = date("Y-m-d H:i:s");
                     $upd=  Db::name("good_stock")->save($good);

+ 30 - 2
app/admin/controller/Resign.php

@@ -6,6 +6,7 @@
 namespace app\admin\controller;
 
 use app\admin\model\ActionLog;
+use app\admin\model\GoodLog;
 use app\admin\model\ProcessOrder;
 use app\BaseController;
 use think\facade\Db;
@@ -781,8 +782,35 @@ class Resign extends BaseController
                 ];
                 $in =Db::name("order_bk")->insert($data);
                 if($in){
-                    Db::commit();
-                    return app_show(0,"采购单新建成功",["cgdNo"=>$cgdCode]);
+                  $good = Db::name("good_stock")->where(["wsm_code"=>$info['wsm_code'],"spuCode"=>$info['spuCode'],"is_del"=>0])->find();
+                        if($good==false) {
+                            $good=[
+                                "spuCode"=>$info['spuCode'],
+                                "wsm_code"=>$info['wsm_code'],
+                                "usable_stock"=>0,
+                                "wait_out_stock"=>0,
+                                "wait_in_stock"=>0,
+                                "total_stock"=>0,
+                                "addtime"=>date("Y-m-d H:i:s"),
+                                "updatetime"=>date("Y-m-d H:i:s"),
+                            ];
+                            $order = ["order_code"=>$info['spuCode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
+                        }else{
+                            $order = ["order_code"=>$info['spuCode'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
+                        }
+                        $good['wait_in_stock']+=$info['good_num'];
+                        $good['updatetime'] = date("Y-m-d H:i:s");
+                        $upd=  Db::name("good_stock")->save($good);
+                        $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);
+                            $process=["order_code"=>$cgdCode,"order_id"=>Db::name("purchease_order")->getLastInsID(),"order_status"=>$cg['status'],"order_type"=>'CGD'];
+                            ProcessOrder::AddProcess($this->post['token'],$process);
+                            Db::commit();
+                            return app_show(0, "采购单新建成功", ["cgdNo" => $cgdCode]);
+                        }
                 }
             }
                 Db::rollback();

+ 1 - 3
app/admin/controller/Sale.php

@@ -89,10 +89,9 @@ class Sale extends Base
             if($is_activity===""){
                 return error_show(1002, "参数is_activity不能为空");
             }
-            if($is_activity==1){
+            if($is_activity==1 &&$actcode=="" ){
                 return error_show(1002, "参数act_code不能为空");
             }
-
         }
         if($goodinfo['is_stock']==1){
             $stock =Db::name("good_stock")->where(["spuCode"=>$spuCode,"is_del"=>0])->find();
@@ -435,7 +434,6 @@ class Sale extends Base
                     ];
                 }else{
                     $stokc['wait_in_stock']+=$data['good_num'];
-                    $stokc['total_stock']+=$data['good_num'];
                     $stokc['updatetime']=date("Y-m-d H:i:s");
                 }
                 $stoc= Db::name("good_stock")->save($stokc);