| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace ghs\controllers;
- use bizGhs\order\classes\StockOutOrderClass;
- use bizGhs\product\classes\ProductClass;
- use common\components\util;
- use Yii;
- //出库 linqh 2021.1.23
- class StockOutController extends BaseController
- {
- //出库列表 linqh 2021.1.23
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $orderStatus = isset($get['status']) ? $get['status'] : '';
- $where = [];
- if (!empty($orderStatus)) {
- $where['status'] = $orderStatus;
- }
- $list = StockOutOrderClass::getOrderList($where);
- util::success($list);
- }
- //新增出库 linqh 2021.1.23
- public function actionCreateOrder()
- {
- $post = Yii::$app->request->post();
- $post['merchantId'] = $this->merchantId;
- $post['outShopId'] = $this->shopId;
- $post['adminId'] = $this->adminId;
- $inShopId = $post['inShopId']??0;
- $now = date('Y-m-d H:i:s');
- $date = $post['date']??$now;
- $post['outTime'] = $date;
- $action = $post['action']??'wait'; //confirm(直接出库) wait(待出库中)
- $post['action'] = $action;
- //判断 入库的门店ID是否有效
- //todo
- $post['inShopId'] = $inShopId;
- //是否判断 inShopId 下还有未完成出库的订单?
- //todo
- $ghsItemInfo = $post['itemInfo']??'';
- if(empty($ghsItemInfo)){
- util::fail('请选择花材');
- }
- $ghsItemInfo = json_decode($ghsItemInfo,true); // [{productId:0,bigNum:1,smallNum:0}]
- if(!is_array($ghsItemInfo)){
- util::fail('花材格式不正确');
- }
- $productIds = array_column($ghsItemInfo,'productId');
- ProductClass::valid($productIds,$this->shopId);
- //判断花材里的信息
- foreach ($ghsItemInfo as $v){
- $bigNum = $v['bigNum']??0;
- $smallNum = $v['smallNum']??0;
- if($bigNum <=0 && $smallNum <=0){
- util::fail('花材数量不能为0');
- }
- }
- $post['itemInfo'] = $ghsItemInfo;
- $order = StockOutOrderClass::addOrder($post);
- if($order){
- util::success($order);
- }else{
- util::fail();
- }
- }
- //
- //出库详情 linqh 2021.1.23
- public function actionDetail()
- {
- $orderSn = Yii::$app->request->get('orderSn','');
- $orderData = StockOutOrderClass::getOrderDetail($orderSn,$this->shopId);
- util::success($orderData);
- }
- //确认出库 linqh 2021.1.23
- //取消出库 linqh 2021.1.23
- }
|