Browse Source

批量发货时,针对库存品和非库存品进行校验

wufeng 2 years ago
parent
commit
0b8364e32d
2 changed files with 18 additions and 7 deletions
  1. 1 1
      app/abutment/controller/Order.php
  2. 17 6
      app/admin/controller/Sale.php

+ 1 - 1
app/abutment/controller/Order.php

@@ -607,7 +607,7 @@ class Order extends HomeBaseController
 
                             if ($upcgd == false) throw new Exception('采购单数量更新失败');
                         }
-                        if ($cgdinfo[$cgdNo]['send_status'] == 1 && $cgdinfo[$cgdNo]['order_type'] != 1) {
+                        if ($cgdinfo[$cgdNo]['send_status'] == 3 && $cgdinfo[$cgdNo]['order_type'] != 1) {
                             $send = Db::name("order_send")->where(["cgdNo" => $cgdNo, "status" => 1])->column("outCode");
                             if (!empty($send)) {
                                 $out = Db::name("order_out")->where(["outCode" => $send, "status" => 0])->select()->toArray();

+ 17 - 6
app/admin/controller/Sale.php

@@ -3851,7 +3851,7 @@ class Sale extends Base
                     "action_remark" => '',//备注
                     "action_type" => "edit"//新建create,编辑edit,更改状态status
                 ], "CKD", $outinfo['status'], $outinfo);
-                
+
                 ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $uname], [
                     "order_type" => 'CKD',
                     "order_code" => $outinfo['outCode'],//出库单号
@@ -4531,9 +4531,9 @@ class Sale extends Base
 
 
 
-//        $user = GetUserInfo($param['token']);
-        $createrid = $this->uid;
-        $creater = $this->uname;
+        $user = GetUserInfo($param['token']);
+        $createrid = $user['data']['id']??0;//$this->uid;
+        $creater = $user['data']['nickname']??0;//$this->uname;
 
         //所有发货单信息
         $order_out_infos = Db::name("order_out")
@@ -4555,8 +4555,7 @@ class Sale extends Base
                 $sale_infos = Db::name("sale")
                     ->where('orderCode', $order_out_infos[$value['outCode']]['orderCode'])
                     ->where('is_del', 0)
-                    ->column('id,send_num,wsend_num,status,good_code,order_source,order_type,apply_id,apply_name', 'orderCode');
-
+                    ->column('id,send_num,wsend_num,status,good_code,order_source,order_type,apply_id,apply_name,is_stock,cgderid,orderCode', 'orderCode');
 
                 if (!isset($sale_infos[$order_out_infos[$value['outCode']]['orderCode']])) throw new Exception($value['outCode'] . '该发货单对应的销售单未找到');
 
@@ -4566,6 +4565,18 @@ class Sale extends Base
                     return app_show(1005, '下列发货申请单号重复', [$value]);
                 } else $temp_out_codes[$value['outCode']] = $value['outCode'];
 
+                if ($sale_infos[$order_out_infos[$value['outCode']]]['is_stock'] == 1) {
+                    if (!in_array($user['data']['roleid'], config('app.wsm_cgder_role'))) {
+                        Db::rollback();
+                        return app_show(1003, $value['outCode'] . '发货单只能由库管操作');
+                    }
+                } else {
+                    if ($createrid! = $sale_infos[$order_out_infos[$value['outCode']]]['cgderid']) {
+                        Db::rollback();
+                        return app_show(1003, $value['outCode'] . '发货单只能由供应商负责人操作');
+                    }
+                }
+
                 //【发货单】
                 //查询已有发货单信息及状态