request->get(); $orderStatus = isset($get['status']) ? $get['status'] : ''; $where = []; $where['shopId'] = $this->shopId; if (!empty($orderStatus)) { $where['status'] = $orderStatus; } $list = PdGoodsClass::getPdList($where); util::success($list); } //订单详情 public function actionGetInfo() { $get = Yii::$app->request->get(); $orderSn = $get['orderSn'] ?? ''; $info = PdGoodsClass::getByCondition(['orderSn' => $orderSn], true); if (empty($info) || $info->mainId != $this->mainId) { util::fail('没有找到盘点记录'); } $detail = PdGoodsDetailClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); $data = ['info' => $info, 'goodsList' => $detail]; util::success($data); } //创建盘点 ssh 20230302 public function actionCreateOrder() { $post = Yii::$app->request->post(); $post['sjId'] = $this->sjId; $post['shopId'] = $this->shopId; $staff = $this->shopAdmin; $post['adminId'] = $this->adminId; $post['staffName'] = $staff->name ?? ''; $post['mainId'] = $this->mainId; $goodsItemInfo = $post['goodsInfo'] ?? ''; if (empty($goodsItemInfo)) { util::fail('请选择花材'); } $goodsItemInfo = json_decode($goodsItemInfo, true); if (!is_array($goodsItemInfo)) { util::fail('商品格式错误'); } foreach ($goodsItemInfo as $key => $item) { //如果盘点数是99999则转为0 if (isset($item['num']) && $item['num'] == 99999) { $goodsItemInfo[$key]['num'] = 0; } } $post['goodsInfo'] = $goodsItemInfo; $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { PdGoodsClass::createPd($post); $transaction->commit(); util::complete(); } catch (\Exception $e) { $transaction->rollBack(); Yii::info("操作原因:" . $e->getMessage()); util::fail('操作失败'); } } }