StockOutController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\order\classes\StockOutOrderClass;
  4. use bizGhs\product\classes\ProductClass;
  5. use common\components\util;
  6. use Yii;
  7. //出库 linqh 2021.1.23
  8. class StockOutController extends BaseController
  9. {
  10. //出库列表 linqh 2021.1.23
  11. public function actionList()
  12. {
  13. $get = Yii::$app->request->get();
  14. $orderStatus = isset($get['status']) ? $get['status'] : '';
  15. $where = [];
  16. if (!empty($orderStatus)) {
  17. $where['status'] = $orderStatus;
  18. }
  19. $list = StockOutOrderClass::getOrderList($where);
  20. util::success($list);
  21. }
  22. //新增出库 linqh 2021.1.23
  23. public function actionCreateOrder()
  24. {
  25. $post = Yii::$app->request->post();
  26. $post['merchantId'] = $this->merchantId;
  27. $post['outShopId'] = $this->shopId;
  28. $post['adminId'] = $this->adminId;
  29. $inShopId = $post['inShopId']??0;
  30. $now = date('Y-m-d H:i:s');
  31. $date = $post['date']??$now;
  32. $post['outTime'] = $date;
  33. $action = $post['action']??'wait'; //confirm(直接出库) wait(待出库中)
  34. $post['action'] = $action;
  35. //判断 入库的门店ID是否有效
  36. //todo
  37. $post['inShopId'] = $inShopId;
  38. //是否判断 inShopId 下还有未完成出库的订单?
  39. //todo
  40. $ghsItemInfo = $post['itemInfo']??'';
  41. if(empty($ghsItemInfo)){
  42. util::fail('请选择花材');
  43. }
  44. $ghsItemInfo = json_decode($ghsItemInfo,true); // [{productId:0,bigNum:1,smallNum:0}]
  45. if(!is_array($ghsItemInfo)){
  46. util::fail('花材格式不正确');
  47. }
  48. $productIds = array_column($ghsItemInfo,'productId');
  49. ProductClass::valid($productIds,$this->shopId);
  50. //判断花材里的信息
  51. foreach ($ghsItemInfo as $v){
  52. $bigNum = $v['bigNum']??0;
  53. $smallNum = $v['smallNum']??0;
  54. if($bigNum <=0 && $smallNum <=0){
  55. util::fail('花材数量不能为0');
  56. }
  57. }
  58. $post['itemInfo'] = $ghsItemInfo;
  59. $order = StockOutOrderClass::addOrder($post);
  60. if($order){
  61. util::success($order);
  62. }else{
  63. util::fail();
  64. }
  65. }
  66. //
  67. //出库详情 linqh 2021.1.23
  68. public function actionDetail()
  69. {
  70. $orderSn = Yii::$app->request->get('orderSn','');
  71. $orderData = StockOutOrderClass::getOrderDetail($orderSn,$this->shopId);
  72. util::success($orderData);
  73. }
  74. //确认出库 linqh 2021.1.23
  75. //取消出库 linqh 2021.1.23
  76. }