|
|
@@ -0,0 +1,107 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace hd\controllers;
|
|
|
+
|
|
|
+use bizHd\pd\classes\PdGoodsClass;
|
|
|
+use Yii;
|
|
|
+use common\components\util;
|
|
|
+
|
|
|
+class PdGoodsController extends BaseController
|
|
|
+{
|
|
|
+
|
|
|
+ //订单列表 ssh 20230302
|
|
|
+ public function actionList()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->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 actionDetail()
|
|
|
+ {
|
|
|
+ $orderSn = Yii::$app->request->get('orderSn', '');
|
|
|
+ $orderData = PdGoodsClass::getOrderDetail($orderSn, $this->shopId);
|
|
|
+ util::success($orderData);
|
|
|
+ }
|
|
|
+
|
|
|
+ //盘点确认
|
|
|
+ public function actionCreateOrder()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $post['sjId'] = $this->sjId;
|
|
|
+ $post['shopId'] = $this->shopId;
|
|
|
+ $post['adminId'] = $this->adminId;
|
|
|
+ $this->saveOrder($post, false, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //盘点存草稿
|
|
|
+ public function actionCreateDraft()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $post['sjId'] = $this->sjId;
|
|
|
+ $post['shopId'] = $this->shopId;
|
|
|
+ $post['adminId'] = $this->adminId;
|
|
|
+
|
|
|
+ $this->saveOrder($post, true, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //编辑草稿 ,继续保存草稿
|
|
|
+ public function actionUpdateDraft()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $post['sjId'] = $this->sjId;
|
|
|
+ $post['shopId'] = $this->shopId;
|
|
|
+ $post['adminId'] = $this->adminId;
|
|
|
+ $orderSn = $post['orderSn'] ?? '';
|
|
|
+ $orderData = PdGoodsClass::orderExist($orderSn, $this->shopId);
|
|
|
+ if ($orderData['status'] != PdGoodsClass::STATUS_DRAFT) {
|
|
|
+ util::fail("订单不存在");
|
|
|
+ }
|
|
|
+ $this->saveOrder($post, true, true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //编辑草稿, 确认
|
|
|
+ public function actionUpdateOrder()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $post['sjId'] = $this->sjId;
|
|
|
+ $post['shopId'] = $this->shopId;
|
|
|
+ $post['adminId'] = $this->adminId;
|
|
|
+ $orderSn = $post['orderSn'] ?? '';
|
|
|
+ $orderData = PdGoodsClass::orderExist($orderSn, $this->shopId);
|
|
|
+ if ($orderData['status'] != PdGoodsClass::STATUS_DRAFT) {
|
|
|
+ util::fail("订单不存在");
|
|
|
+ }
|
|
|
+ $this->saveOrder($post, false, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function saveOrder($post, $draft = false, $update = false)
|
|
|
+ {
|
|
|
+ $ghsItemInfo = $post['itemInfo'] ?? '';
|
|
|
+ if (empty($ghsItemInfo)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+ $ghsItemInfo = json_decode($ghsItemInfo, true);
|
|
|
+ if (!is_array($ghsItemInfo)) {
|
|
|
+ util::fail('花材格式不正确');
|
|
|
+ }
|
|
|
+ foreach ($ghsItemInfo as $key => $item) {
|
|
|
+ //如果盘点数是99999则转为0
|
|
|
+ if (isset($item['bigNum']) && $item['bigNum'] == 99999) {
|
|
|
+ $ghsItemInfo[$key]['bigNum'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $post['itemInfo'] = $ghsItemInfo;
|
|
|
+ PdGoodsClass::opOrder($post, $draft, $update);
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|