shish 2 лет назад
Родитель
Сommit
9355c2e56d
1 измененных файлов с 18 добавлено и 1 удалено
  1. 18 1
      app-ghs/controllers/OrderItemController.php

+ 18 - 1
app-ghs/controllers/OrderItemController.php

@@ -22,6 +22,9 @@ class OrderItemController extends BaseController
         $post = Yii::$app->request->post();
         $id = $post['id'] ?? 0;
         $data = $post['data'] ?? [];
+        if (empty($data)) {
+            util::fail('没有花材数据');
+        }
         $order = OrderClass::getById($id, true);
         if (empty($order)) {
             util::fail('没有订单');
@@ -35,7 +38,21 @@ class OrderItemController extends BaseController
         if ($order->status != 2) {
             util::fail('待发货订单才能修改');
         }
-        print_r($data);die;
+        foreach ($data as $item) {
+            $id = $item['id'] ?? 0;
+            $xhNum = $item['xhNum'] ?? 0;
+            $xhUnitPrice = $item['xhUnitPrice'] ?? 0;
+            $info = OrderItemClass::getById($id, true);
+            if (empty($info)) {
+                continue;
+            }
+            if ($info->orderSn != $order->orderSn) {
+                continue;
+            }
+            $info->xhNum = $xhNum;
+            $info->xhUnitPrice = $xhUnitPrice;
+            $info->save();
+        }
         util::complete();
     }