request->post(); $id = $post['id'] ?? 0; $product = $post['product'] ?? '[]'; $product = json_decode($product, true); //检查花材是否都是同家门店的 ProductClass::valid($product, $this->mainId); $info = OrderService::getOrderInfo($id); OrderClass::valid($info, $this->shopId); //添加修改花材 $orderSn = $info['orderSn'] ?? ''; OrderItemClass::replaceItem($orderSn, $product); util::complete(); } //修改花材时获取订单花材和花材基本信息的组合 ssh 20210809 public function actionGetOrderProduct() { $id = Yii::$app->request->get('id', 0); $order = OrderClass::getById($id, true); OrderClass::valid($order, $this->shopId); $orderSn = $order->orderSn ?? ''; $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', 'productId'); $ids = array_column($itemList, 'productId'); if (empty($ids)) { util::fail('没有找到花材'); } $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id'); if (empty($productList)) { util::fail('没有找到花材信息'); } foreach ($productList as $key => $product) { $productId = $product['id'] ?? 0; $currentItem = $itemList[$productId] ?? []; $bigCount = $currentItem['bigNum'] ?? 0; $smallCount = $currentItem['smallNum'] ?? 0; $userPrice = $currentItem['userPrice'] ?? 0; $productList[$key]['bigCount'] = $bigCount; $productList[$key]['smallCount'] = $smallCount; $productList[$key]['userPrice'] = $userPrice; $cover = imgUtil::groupImg($product['cover']); $productList[$key]['cover'] = $cover; $bigPrice = $product['unitPrice'] ?? 0; $smallPrice = $product['smallUnitPrice'] ?? 0; $productList[$key]['bigPrice'] = $bigPrice; $productList[$key]['smallPrice'] = $smallPrice; $productList[$key]['cover'] = $cover; } util::success(['productList' => array_values($productList)]); } //根据花材id取订单列表 ssh 20211011 public function actionGetOrderInfoList() { $get = Yii::$app->request->get(); $productId = $get['productId'] ?? 0; $product = ProductClass::getById($productId, true); ProductClass::check($product, $this->mainId); $where = ['shopId' => $this->shopId, 'productId' => $productId]; $respond = OrderItemClass::getOrderInfoList($where); util::success($respond); } }