Browse Source

全部发货

shish 2 years ago
parent
commit
9755896bd5
2 changed files with 44 additions and 2 deletions
  1. 38 0
      app-ghs/controllers/OrderController.php
  2. 6 2
      biz-ghs/order/classes/OrderClass.php

+ 38 - 0
app-ghs/controllers/OrderController.php

@@ -33,6 +33,44 @@ class OrderController extends BaseController
 
 
     public $guestAccess = ['create-order', 'order-relate', 'fast-pay', 'info'];
     public $guestAccess = ['create-order', 'order-relate', 'fast-pay', 'info'];
 
 
+    public function actionAllFh()
+    {
+        $post = Yii::$app->request->post();
+        $ids = $post['ids'] ?? '';
+        if (empty($ids)) {
+            util::fail('请选择要合并发货的订单');
+        }
+        $arr = explode(',', $ids);
+        if (empty($arr)) {
+            util::fail('请选择要合并发货的订单哦');
+        }
+        $fhWl = $post['fhWl'] ?? '';
+        $fhWlNo = $post['fhWlNo'] ?? '';
+        $fhType = 0;
+        $params = [
+            'fhType' => $fhType,
+            'fhWl' => $fhWl,
+            'fhWlNo' => $fhWlNo,
+        ];
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $all = OrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
+            foreach ($all as $order) {
+                if ($order->mainId != $this->mainId) {
+                    util::fail('不是你的订单哦');
+                }
+                OrderClass::orderFh($order, $params, true);
+            }
+            $transaction->commit();
+            util::complete();
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::error("操作失败原因:" . $e->getMessage());
+            util::fail('操作失败');
+        }
+    }
+
     //合并打印 ssh 20230929
     //合并打印 ssh 20230929
     public function actionMergePrint()
     public function actionMergePrint()
     {
     {

+ 6 - 2
biz-ghs/order/classes/OrderClass.php

@@ -120,10 +120,14 @@ class OrderClass extends BaseClass
     ];
     ];
 
 
     //订单发货 ssh 20230613
     //订单发货 ssh 20230613
-    public static function orderFh($order, $params)
+    public static function orderFh($order, $params, $allowRepeat = false)
     {
     {
         if ($order->fhStatus == 1) {
         if ($order->fhStatus == 1) {
-            util::fail('订单已发货');
+            if ($allowRepeat == false) {
+                util::fail('订单已发货');
+            } else {
+                return true;
+            }
         }
         }
         $cgId = $order->purchaseId ?? 0;
         $cgId = $order->purchaseId ?? 0;
         $cg = PurchaseClass::getById($cgId, true);
         $cg = PurchaseClass::getById($cgId, true);