shish před 3 roky
rodič
revize
a6ad75d110

+ 30 - 2
app-ghs/controllers/OrderController.php

@@ -33,6 +33,34 @@ class OrderController extends BaseController
 
     public $guestAccess = ['create-order', 'order-relate', 'fast-pay', 'info'];
 
+    //发货 ssh 20230613
+    public function actionFn()
+    {
+        $post = Yii::$app->request->post();
+        $id = $post['id'] ?? '';
+        $order = OrderClass::getById($id, true);
+        OrderClass::valid($order, $this->shopId);
+        $fhWl = $post['fhWl'] ?? '';
+        $fhWlNo = $post['fhWlNo'] ?? '';
+        $fhType = $post['fhType'] ?? '';
+        $params = [
+            'fhType' => $fhType,
+            'fhWl' => $fhWl,
+            'fhWlNo' => $fhWlNo,
+        ];
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            OrderClass::orderFh($order, $params);
+            $transaction->commit();
+            util::complete();
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::error("操作失败原因:" . $e->getMessage());
+            util::fail('操作失败');
+        }
+    }
+
     //修改分工 ssh 20221129
     public function actionChangeWorker()
     {
@@ -912,8 +940,8 @@ class OrderController extends BaseController
             $colorData = json_decode($colorItem, true);
             if (!empty($colorData) && is_array($colorData)) {
                 foreach ($colorData as $colorInfo) {
-                    $ptItemId = $colorInfo['ptItemId']??0;
-                    $colorList = $colorInfo['list']??[];
+                    $ptItemId = $colorInfo['ptItemId'] ?? 0;
+                    $colorList = $colorInfo['list'] ?? [];
                     if (!empty($colorList)) {
                         foreach ($colorList as $colorItemKey => $colorItem) {
                             $newXj[$ptItemId][] = $colorItem;

+ 37 - 0
biz-ghs/order/classes/OrderClass.php

@@ -118,6 +118,43 @@ class OrderClass extends BaseClass
         self::REFUND_YES => '有退款',
     ];
 
+    //订单发货 ssh 20230613
+    public static function orderFh($order, $params)
+    {
+        if ($order->fhStatus == 1) {
+            util::fail('订单已发货');
+        }
+        $cgId = $order->purchaseId ?? 0;
+        $cg = PurchaseClass::getById($cgId, true);
+        if (empty($cg)) {
+            util::fail('没有找到采购单');
+        }
+        $fhType = $params['fhType'] ?? '';
+        if (is_numeric($fhType) == false) {
+            util::fail('请选择发货类型');
+        }
+        if ($fhType == 1) {
+            $fhWl = $params['fhWl'] ?? '';
+            $fhWlNo = $params['fhWlNo'] ?? '';
+            if (empty($fhWl)) {
+                util::fail('请填写物流名称');
+            }
+            if (empty($fhWlNo)) {
+                util::fail('请填写物流编号');
+            }
+            $cg->fhWl = $fhWl;
+            $cg->fhWlNo = $fhWlNo;
+            $order->fhWl = $fhWl;
+            $order->fhWlNo = $fhWlNo;
+        }
+        $cg->fhType = $fhType;
+        $cg->fhStatus = 1;
+        $cg->save();
+        $order->fhType = $fhType;
+        $order->fhStatus = 1;
+        $order->save();
+    }
+
     public static function arrival($order, $data)
     {
         if ($order->stockChange == 1) {