소스 검색

台账暂存

wufeng 2 년 전
부모
커밋
fcaebf0efc

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

@@ -114,6 +114,15 @@ class After extends Base
             $orde = ["order_code"=>$returnCode,"status"=>$in['status'],"action_remark"=>'',"action_type"=>"create"];
             ActionLog::logAdd($this->post['token'],$orde,'SHD',1,$orde);
             if($create>0){
+
+                //维护台账
+                Db::name('standing_book')
+                    ->where('outCode', $outCode)
+                    ->update([
+                        'returnCode' => $returnCode,
+                        'updatetime' => date("Y-m-d H:i:s")
+                    ]);
+
                     $process=["order_code"=>$returnCode,"order_id"=>$create,"order_status"=>$in['status'],"order_type"=>'SHD',"before_status"=>1];
                     ProcessOrder::AddProcess($token,$process);
                     Db::commit();
@@ -715,6 +724,15 @@ class After extends Base
                     ];
                     $back =Db::name("order_back")->insert($data,true);
                     if($back>0){
+
+                        //维护台账
+                        Db::name('standing_book')
+                            ->where('returnCode', $bkcode)
+                            ->update([
+                                'thNo' => $data['thNo'],
+                                'updatetime' => date("Y-m-d H:i:s")
+                            ]);
+
                         $order = ["order_code"=>$data['thNo'],"status"=>0,"action_remark"=>'',"action_type"=>"create"];
                         ActionLog::logAdd($this->post['token'],$order,"CKTHD", 0,$data);
                         $process=["order_code"=>$data['thNo'],"order_id"=>$back,"order_status"=>0,"order_type"=>"CKTHD","before_status"=>0];
@@ -1031,6 +1049,15 @@ class After extends Base
                             "order_id" => $sav,
                             "order_status" => $thdata['status'],"before_status"=>1
                         ]);
+
+                        //维护台账记录
+                        Db::name('standing_book')
+                            ->where(['returnCode' => $bkcode])
+                            ->update([
+                                'thNo' => $thNo,
+                                'updatetime' => date("Y-m-d H:i:s")
+                            ]);
+
                         if($info['return_tag']==1){
                             $sale['th_num']+= $info['error_num'];
                             if($sale['th_num']==$sale['send_num']&& $sale['wsend_num']==0){

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

@@ -1065,6 +1065,18 @@ class Project extends Base
                         return error_show(1004, "销售订单创建失败");
                     }
                 }
+
+                Db::name('standing_book')
+                    ->where('projectNo', $backinfo['projectNo'])
+                    ->update([
+                        'orderCode' => $orderCode,
+                        'customer_code' => $prject['khNo'],
+                        'spuCode' => $backinfo['spuCode'],
+                        'order_type' => $data['order_type'],
+                        'supplierNo' => $prject['companyNo'],
+                        'updatetime' => date("Y-m-d H:i:s")
+                    ]);
+
                 Db::commit();
                 return error_show(0, "销售订单创建成功");
             }

+ 14 - 0
app/admin/controller/Purch.php

@@ -710,6 +710,11 @@ class Purch extends Base
                 $process=["order_code"=>$cgdNo,"order_id"=>$item,"order_status"=>1,"order_type"=>'CGGCD',"before_status"=>1];
                 ProcessOrder::AddProcess($this->post['token'],$process);
 
+                $update_standing_book_data = [
+                    'cgd_diff_id' => $item,//采购工差单id
+                    'updatetime' => date("Y-m-d H:i:s")
+                ];
+
                 $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->find();
                 if($orderCode!=false){
                     $order = Db::name("sale")->where("orderCode", '=', $orderCode['orderCode'])->find();
@@ -747,7 +752,16 @@ class Purch extends Base
                     ActionLog::logAdd($this->post['token'],$sto,"XSGCD",1,$data);
                     $process=["order_code"=>$orderCode['orderCode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'XSGCD',"before_status"=>1];
                     ProcessOrder::AddProcess($this->post['token'],$process);
+
+                    $update_standing_book_data['sale_diff_id']=$cgd;//工差单id
+
                 }
+
+                //维护台账记录
+                Db::name('standing_book')
+                    ->where('cgdNo', $cgdNo)
+                    ->update($update_standing_book_data);
+
                 Db::commit();
                 return error_show(0,"新建成功");
             }else{

+ 4 - 0
app/admin/controller/Purchin.php

@@ -253,6 +253,10 @@ class Purchin extends Base
                 $process=["order_code"=>$wsm_in_code,"order_id"=>$win,"order_status"=>$status,"order_type"=>'RKD',"before_status"=>$status];
                 ProcessOrder::AddProcess($this->post['token'],$process);
                 $order = ["order_code"=>$cgdNo,"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
+
+                //维护台账信息
+                Db::name('standing_book')->where('cgdNo', $cgdNo)->update(['wsm_in_code' => $wsm_in_code, 'update' => date('Y-m-d H:i:s')]);
+
                 if($status==1){
                             Db::commit();
                             return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);

+ 17 - 0
app/admin/controller/Reorder.php

@@ -104,6 +104,14 @@ class Reorder extends Base
                 ActionLog::logAdd($this->post['token'],$stn,"XSTHD",$in['status'],$in);
                 $process=["order_code"=>$returnCode,"order_id"=>$create,"order_status"=>$in['status'],"order_type"=>'XSTHD',"before_status"=>0];
                 ProcessOrder::AddProcess($this->post['token'],$process);
+
+                //维护台账信息
+                Db::name('standing_book')
+                    ->where('orderCode', $ordeCode)
+                    ->update([
+                        "returnGoodCode" => $returnCode,
+                        "updatetime" => date("Y-m-d H:i:s")
+                    ]);
                 if($returnadr!=""){
                     $inf=[];
                     foreach ($returnadr as $val){
@@ -1051,6 +1059,15 @@ class Reorder extends Base
                 $ste = ["order_code"=>$returnCode,"status"=>0,"action_remark"=>'',
                     "action_type"=>"create"];
                 ActionLog::logAdd($this->post['token'],$ste,"XSTHD",3,$in);
+
+                //维护台账记录
+                Db::name('standing_book')
+                    ->where('ordeCode', $ordeCode)
+                    ->update([
+                        'returnGoodCode' => $returnCode,
+                        'updatetime' => date("Y-m-d H:i:s")
+                    ]);
+
                 if ($order['send_type'] == 1) {
                     $wsend = Db::name("order_out")->where(['orderCode' => $ordeCode, "status" => 1, "order_type"
                     =>2])->select();

+ 27 - 2
app/admin/controller/Sale.php

@@ -1142,8 +1142,7 @@ class Sale extends Base
                     }
 
                     //处理台账
-                $standing_book_id = Db::name('standing_book')->where('infoNo', $standing_book_data['infoNo'])->value('id');
-                if (!empty($standing_book_id)) Db::name('standing_book')->where('id', $standing_book_id)->update($standing_book_data);
+                Db::name('standing_book')->where('infoNo', $standing_book_data['infoNo'])->update($standing_book_data);
 
                 Db::commit();
                 return error_show(0,"咨询订单创建成功",["order_code"=>$orderCode]);
@@ -2083,6 +2082,16 @@ class Sale extends Base
                 ActionLog::logAdd($this->post['token'],$stn,"XSQRD",$etid['status'],$datn);
 //                $order=["order_type"=>'XSQRD',"order_code"=>$etid['orderCode'],"order_id"=>$id,"order_status"=>$etid['status'],"before_status"=> 0];
 //                ProcessOrder::AddProcess($this->post['token'],$order);
+
+                //更新台账
+                Db::name('standing_book')
+                    ->where('orderCode', $etid['orderCode'])
+                    ->update([
+                        'customer_code' => $customer_code,
+                        'supplierNo' => $supplierNo,
+                        'updatetime' => date("Y-m-d H:i:s")
+                    ]);
+
                 foreach ($vi as $ion) {
                     $iten = [];
                     isset($ion['id']) && $ion['id'] !== "" ? $iten['id'] = $ion['id'] : '';
@@ -2501,6 +2510,10 @@ class Sale extends Base
                             Db::rollback();
                             return error_show(1003, "创建失败");
                         }
+
+                        //维护台账
+                        Db::name('standing_book')->where('cgdNo', $cgd)->update(['wsm_in_code' => $wsm_in_code, 'update' => date('Y-m-d H:i:s')]);
+
                         $good = Db::name("good_stock")->where(["wsm_code" => $wsm['wsm_code'], "good_type_code" => $zxinfo['cpNo'], "is_del" => 0])->find();
                         if (empty($good)) {
                             $good = [
@@ -3420,6 +3433,18 @@ class Sale extends Base
                                 "order_id" => $datainfo,
                                 "order_status" => $data['status'],"before_status"=> 0
                             ]);
+
+                        //维护台账记录
+                        Db::name('standing_book')
+                            ->where('orderCode', $orderCode)
+                            ->update([
+                                'order_type' => $der['order_type'],
+                                'cgdNo' => $order['cgdNo'],
+                                'outCode' => $outCode,
+                                'customer_code' => $der['customer_code'],
+                                'updatetime' => date('Y-m-d H:i:s'),
+                            ]);
+
                         Db::commit();
                         return app_show(0,"出库单新建成功");
                     }

+ 18 - 2
app/admin/controller/Salezx.php

@@ -128,7 +128,15 @@ class Salezx extends \app\BaseController
             $datainfo = Db::name('sale')->insert($data,true);
             $vat=[];
             if($datainfo>0){
-               $bol= $this->createCgd($data,$good,$goodinfo);
+
+                $standing_bood_data=[
+                    "orderCode"=>$orderCode,
+                    "customer_code"=>$customer_code,
+                    "supplierNo"=>$supplierNo,
+                    'updatetime'=>date("Y-m-d H:i:s"),
+                ];
+
+               $bol= $this->createCgd($data,$good,$goodinfo,$standing_bood_data);
                if($bol==false){
                    Db::rollback();
                    return error_show(1002,"咨询订单创建失败");
@@ -223,6 +231,12 @@ class Salezx extends \app\BaseController
                     "order_status" => 0
                 ]);
 
+
+                //根据zxinfoNo查找infoNo,找到则更新台账,否则就新增台账
+                $infoNo = Db::name('consult_bids')->where('bidNo', $zxinfoNo)->value('infoNo');
+                if (empty($infoNo)) Db::name('standing_book')->insert(array_merge($standing_bood_data, ['addtime' => date('Y-m-d H:i:s')]));
+                else Db::name('standing_book')->where('infoNo', $infoNo)->update($standing_bood_data);
+
                     Db::commit();
                     return error_show(0,"咨询订单创建成功");
             }
@@ -234,7 +248,7 @@ class Salezx extends \app\BaseController
         }
     }
 
-    public function createCgd($data,$good,$good_info){
+    public function createCgd($data,$good,$good_info,array &$standing_bood_data=[]){
                 $cgdCode = makeNo("CG");
                 $supplier=Db::name("supplier")->where(["code"=>$good['supplierNo'],"is_del"=>0])->find();
                 if($supplier==false){
@@ -319,6 +333,8 @@ class Salezx extends \app\BaseController
                             "order_status" => $cg['status']
                         ]);
 
+                        $standing_bood_data['cgdNo']=$cgdCode;
+
                         return true;
                     }else{
                         return false;

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

@@ -12,18 +12,53 @@ class StandingBook extends Base
     public function getList()
     {
 
-        $param = $this->request->only(['start_date' => '', 'end_date' => '', 'projectNo' => '', 'planNo' => '', 'spuCode' => '', 'infoNo' => '', 'bidNo' => '', 'orderCode' => '', 'bk_code' => '', 'cgdNo' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
+        $param = $this->request->only([
+            'start_date' => '',
+            'end_date' => '',
+            'standBookNo' => '',
+            'projectNo' => '',
+            'infoNo' => '',
+            'bargainNo' => '',
+            'bk_code' => '',
+            'orderCode' => '',
+            'outCode' => '',
+            'returnCode' => '',
+            'thNo' => '',
+            'returnGoodCode' => '',
+            'cgdNo' => '',
+            'wsm_in_code' => '',
+            'cgdReturnCode' => '',
+            'spuCode' => '',
+            'skuCode' => '',
+            'order_type' => '',
+            'supplierNo' => '',
+            'companyNo' => '',
+            'customer_code' => '',
+            'page' => 1,
+            'size' => 15
+        ], 'post', 'trim');
 
         $where = [];
         if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
+        if ($param['standBookNo'] != '') $where[] = ['standBookNo', 'like', '%' . $param['standBookNo'] . '%'];
         if ($param['projectNo'] != '') $where[] = ['projectNo', 'like', '%' . $param['projectNo'] . '%'];
-        if ($param['planNo'] != '') $where[] = ['planNo', 'like', '%' . $param['planNo'] . '%'];
-        if ($param['spuCode'] != '') $where[] = ['spuCode', 'like', '%' . $param['spuCode'] . '%'];
         if ($param['infoNo'] != '') $where[] = ['infoNo', 'like', '%' . $param['infoNo'] . '%'];
-        if ($param['bidNo'] != '') $where[] = ['bidNo', 'like', '%' . $param['bidNo'] . '%'];
-        if ($param['orderCode'] != '') $where[] = ['orderCode', 'like', '%' . $param['orderCode'] . '%'];
+        if ($param['bargainNo'] != '') $where[] = ['bargainNo', 'like', '%' . $param['bargainNo'] . '%'];
         if ($param['bk_code'] != '') $where[] = ['bk_code', 'like', '%' . $param['bk_code'] . '%'];
+        if ($param['orderCode'] != '') $where[] = ['orderCode', 'like', '%' . $param['orderCode'] . '%'];
+        if ($param['outCode'] != '') $where[] = ['outCode', 'like', '%' . $param['outCode'] . '%'];
+        if ($param['returnCode'] != '') $where[] = ['returnCode', 'like', '%' . $param['returnCode'] . '%'];
+        if ($param['thNo'] != '') $where[] = ['thNo', 'like', '%' . $param['thNo'] . '%'];
+        if ($param['returnGoodCode'] != '') $where[] = ['returnGoodCode', 'like', '%' . $param['returnGoodCode'] . '%'];
         if ($param['cgdNo'] != '') $where[] = ['cgdNo', 'like', '%' . $param['cgdNo'] . '%'];
+        if ($param['wsm_in_code'] != '') $where[] = ['wsm_in_code', 'like', '%' . $param['wsm_in_code'] . '%'];
+        if ($param['cgdReturnCode'] != '') $where[] = ['cgdReturnCode', 'like', '%' . $param['cgdReturnCode'] . '%'];
+        if ($param['spuCode'] != '') $where[] = ['spuCode', 'like', '%' . $param['spuCode'] . '%'];
+        if ($param['skuCode'] != '') $where[] = ['skuCode', 'like', '%' . $param['skuCode'] . '%'];
+        if ($param['order_type'] != '') $where[] = ['order_type', '=', $param['order_type']];
+        if ($param['supplierNo'] != '') $where[] = ['supplierNo', 'like', '%' . $param['supplierNo'] . '%'];
+        if ($param['companyNo'] != '') $where[] = ['companyNo', 'like', '%' . $param['companyNo'] . '%'];
+        if ($param['customer_code'] != '') $where[] = ['customer_code', 'like', '%' . $param['customer_code'] . '%'];
 
         $count = Db::name('standing_book')
             ->where($where)

+ 6 - 1
app/admin/route/app.php

@@ -566,4 +566,9 @@ Route::rule('seooa','admin/SaleReport/orderOutAddr');//有地址待发货单列
 Route::rule('seooae','admin/SaleReport/orderOutAddrExport');//有地址待发货单列表-导出
 
 
-Route::rule('statlist','admin/Stat/list');//
+Route::rule('statlist','admin/Stat/list');//
+
+
+Route::rule('standbooklist','admin/StandingBook/getList');//台账列表
+Route::rule('standbookdetail','admin/StandingBook/getDetail');//台账详情
+

+ 33 - 6
app/command/ImportOrderFromCHandleData.php

@@ -50,6 +50,8 @@ class ImportOrderFromCHandleData extends Command
                 Db::startTrans();
                 try {
 
+                    $standing_book_data = [];
+
                     //先找用户确认信息
                     $extend_data = Db::name('order_import_from_c_extend')
                         ->where(['order_import_from_c_id' => $c_data['id'], 'is_del' => 0, 'type' => 2])
@@ -254,15 +256,28 @@ class ImportOrderFromCHandleData extends Command
                             if ($actupp == false) throw new Exception('活动库存修改失败');
 
                         }
+
+                        //补充台账数据
+                        $standing_book_data = array_merge($standing_book_data, [
+                            'orderCode' => $orderCode,
+//                            'outCode'=>,
+//                            'cgdNo'=>,
+                            'spuCode' => $data['good_code'],
+                            'skuCode' => $data['skuCode'],
+                            'order_type' => $data['order_type'],
+                            'supplierNo' => $data['supplierNo'],
+                            'companyNo' => $extend_data['companyNo'],
+                            'customer_code' => $data['customer_code'],
+                        ]);
                         if ($is_stock == 0) {
 
                             //非库存品
-                            $bol = $this->createCgd($cgd, $rm, $ri);
+                            $bol = $this->createCgd($cgd, $rm, $ri, $standing_book_data);
                             if ($bol == false) throw new Exception('订单创建失败');
 
                         } else {
                             //库存品
-                            $bol = $this->RelaCgd(['orderCode' => $orderCode, "good_num" => $good_num, "spuCode" => $spuCode, "companyNo" => $supplierNo, 'order_type' => $order_type]);
+                            $bol = $this->RelaCgd(['orderCode' => $orderCode, "good_num" => $good_num, "spuCode" => $spuCode, "companyNo" => $supplierNo, 'order_type' => $order_type], $standing_book_data);
                             if ($bol == false) throw new Exception('库存商品关联采购单失败');
 
                             if (isset($stock)) {
@@ -366,6 +381,8 @@ class ImportOrderFromCHandleData extends Command
                                         "order_status" => 0,
                                         "before_status" => 0
                                     ]);
+
+                                    $standing_book_data['outCode'] = $outCode;
                                 }
                             } else throw new Exception('发货地址添加失败');
                         }
@@ -386,6 +403,10 @@ class ImportOrderFromCHandleData extends Command
                             'orderCode' => $orderCode
                         ]);
 
+                    //维护台账记录
+                    if (isset($standing_book_data['bk_code'])) Db::name('standing_book')->where('bk_code', $standing_book_data['bk_code'])->update(array_merge($standing_book_data, ['updatetime' => date('Y-m-d H:i:s')]));
+                    else Db::name('standing_book')->insert(array_merge($standing_book_data, ['addtime' => date('Y-m-d H:i:s'), 'updatetime' => date('Y-m-d H:i:s')]));
+
                     Db::commit();
 
                     $output->writeln(date('Y-m-d H:i:s') . '|处理成功');
@@ -411,11 +432,10 @@ class ImportOrderFromCHandleData extends Command
 
 
     //创建采购单
-    private function createCgd($data = [], $rm = '0', $ri = '')
+    private function createCgd($data = [], $rm = '0', $ri = '', array &$standing_book_data = [])
     {
         $cgdCode = makeNo("CG");
-        $supplier = Db::name("supplier")
-            ->where(["code" => $data['supplierNo'], "is_del" => 0])->find();
+        $supplier = Db::name("supplier")->where(["code" => $data['supplierNo'], "is_del" => 0])->find();
         if ($supplier == false) return false;
 
         $wsm = Db::name("warehouse_info")
@@ -505,6 +525,8 @@ class ImportOrderFromCHandleData extends Command
                 "before_status" => 0
             ]);
 
+            $standing_book_data['cgdNo'] = $cgdCode;
+
             $rela = [
                 "orderCode" => $data['orderCode'],
                 "cgdNo" => $cgdCode,
@@ -554,7 +576,7 @@ class ImportOrderFromCHandleData extends Command
 
 
     //创建.....
-    private function RelaCgd(array $outinfo = [])
+    private function RelaCgd(array $outinfo = [], array &$standing_book_data = [])
     {
         //备库单
         $cgd = Db::name("order_bk")
@@ -615,6 +637,11 @@ class ImportOrderFromCHandleData extends Command
         $insetrCgd = Db::name("purchease_order")->insert($QrdCgd);
         if ($insetrCgd == false) return false;
 
+        $standing_book_data = array_merge($standing_book_data, [
+            'cgdNo' => $QrdCgd['cgdNo'],
+            'bk_code' => $QrdCgd['bkcode'],
+        ]);
+
         $merge_num = Db::name("purchease_order")
             ->where(["bkcode" => $cgdinfo['bkcode'], "order_type" => $outinfo['order_type'], "is_del" => 0])
             ->field("sum(send_num)-sum(th_num) as num")