request->get(); $orderId = $get['orderId'] ?? 0; $productId = $get['productId'] ?? 0; $shop = $this->shop; $order = OrderClass::getById($orderId, true); if (empty($order)) { util::fail('没有找到订单'); } $bookSn = $shop->bookSn ?? 0; if (empty($bookSn)) { util::fail('当前不是在预订活动中'); } $customId = $order->customId ?? 0; $res = BookItemCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId, 'itemId' => $productId], true); if (empty($res)) { util::fail('数据有问题'); } util::success(['res' => $res]); } //下架 ssh 20240721 public function actionGoOff() { $staff = $this->shopAdmin; if (isset($staff->identity) && $staff->identity == 2) { util::fail('不能操作'); } $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $num = $get['num'] ?? 0; if (empty($num)) { util::fail('请填写下架数量'); } $shop = $this->shop; $bookSn = $shop->bookSn ?? 0; if (empty($bookSn)) { util::fail('预订没有开户'); } $book = BookItemCustomClass::getById($id, true); if (empty($book) || $book->bookSn != $bookSn) { util::fail('当前无法操作'); } $staff = $this->shopAdmin; $staffId = $staff->id ?? 0; $staffName = $staff->name ?? ''; $params = ['staffId' => $staffId, 'staffName' => $staffName, 'staff' => $staff]; BookItemCustomClass::goOff($book, $shop, $params, $num); util::complete('操作成功'); } //标记装箱 ssh 20240721 public function actionToBox() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $shop = $this->shop; $bookSn = $shop->bookSn ?? 0; if (empty($bookSn)) { util::fail('预订没有开户'); } $book = BookItemCustomClass::getById($id, true); if (empty($book) || $book->bookSn != $bookSn) { util::fail('当前无法操作'); } BookItemCustomClass::toBox($book); util::complete('操作成功'); } //取消装箱 ssh 20240721 public function actionCancelBox() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $shop = $this->shop; $bookSn = $shop->bookSn ?? 0; if (empty($bookSn)) { util::fail('预订没有开户'); } $book = BookItemCustomClass::getById($id, true); if (empty($book) || $book->bookSn != $bookSn) { util::fail('当前无法操作'); } BookItemCustomClass::cancelBox($book); util::complete('操作成功'); } //仓库有货上架和上齐 ssh 20240721 public function actionGoOn() { $staff = $this->shopAdmin; if (isset($staff->identity) && $staff->identity == 2) { util::fail('不能操作'); } $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $num = $get['num'] ?? 0; $shop = $this->shop; $bookSn = $shop->bookSn ?? 0; if (empty($bookSn)) { util::fail('预订没有开启'); } $book = BookItemCustomClass::getById($id, true); if (empty($book) || $book->bookSn != $bookSn) { util::fail('当前无法操作'); } $staff = $this->shopAdmin; $staffId = $staff->id ?? 0; $staffName = $staff->name ?? ''; $params = ['staffId' => $staffId, 'staffName' => $staffName, 'staff' => $staff]; BookItemCustomClass::goOn($book, $shop, $params, $num); util::complete('操作成功'); } //批量上齐 ssh 20240812 public function actionBatchGoOn() { $post = Yii::$app->request->post(); $ids = $post['ids'] ?? ''; $staff = $this->shopAdmin; if (isset($staff->identity) && $staff->identity == 2) { util::fail('不能操作'); } $shop = $this->shop; $bookSn = $shop->bookSn ?? 0; if (empty($bookSn)) { util::fail('预订没有开启'); } if (empty($ids)) { util::fail('请选择要上齐的项'); } $arr = json_decode($ids, true); if (empty($arr)) { util::fail('请选择项'); } $staff = $this->shopAdmin; $staffId = $staff->id ?? 0; $staffName = $staff->name ?? ''; $params = ['staffId' => $staffId, 'staffName' => $staffName, 'staff' => $staff]; $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { foreach ($arr as $id) { $num = 0; $book = BookItemCustomClass::getById($id, true); if (empty($book)) { util::fail('有选择项没有找到'); } if ($book->bookSn != $bookSn) { util::fail('有选择的项不是当前预订活动'); } BookItemCustomClass::goOn($book, $shop, $params, $num); } $transaction->commit(); util::complete(); } catch (\Exception $e) { Yii::info("操作失败原因:" . $e->getMessage()); $transaction->rollBack(); util::fail('操作失败'); } } //预订客户列表 ssh 20240616 public function actionList() { $get = Yii::$app->request->get(); $where = []; $where['mainId'] = $this->mainId; $bookSn = $get['bookSn'] ?? ''; if (empty($bookSn)) { $shop = $this->shop; $bookSn = $shop->bookSn ?? 0; if (empty($bookSn)) { util::success(['list' => [], 'hint' => 'no bookSn']); } } $where['bookSn'] = $bookSn; $customId = $get['customId'] ?? 0; if (!empty($customId)) { $where['customId'] = $customId; } $itemId = $get['itemId'] ?? 0; $remainNum = 0; $remainName = ''; if (!empty($itemId)) { $where['itemId'] = $itemId; //显示剩余数量 $product = ProductClass::getById($itemId, true); $booItem = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId], true); if (!empty($booItem)) { $stock = $product->stock ?? 0; $onNum = $booItem->onNum ?? 0; $remainNum = bcsub($stock, $onNum); $remainName = $product->name ?? ''; } } $list = BookItemCustomClass::getAllByCondition($where, '(bookNum-onNum) DESC', '*'); util::success(['list' => $list, 'remainNum' => $remainNum, 'remainName' => $remainName]); } }