StockInController.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\admin\classes\AdminRoleClass;
  4. use bizGhs\order\classes\StockInOrderClass;
  5. use common\components\util;
  6. use Yii;
  7. //入库 lqh 2021.1.25
  8. class StockInController extends BaseController
  9. {
  10. //入库列表 lqh 2021.1.25
  11. public function actionList()
  12. {
  13. $get = Yii::$app->request->get();
  14. $orderStatus = isset($get['status']) ? $get['status'] : '';
  15. $where = [];
  16. $where['inShopId'] = $this->shopId;
  17. if (!empty($orderStatus)) {
  18. $where['status'] = $orderStatus;
  19. }
  20. $list = StockInOrderClass::getOrderList($where);
  21. util::success($list);
  22. }
  23. //入库详情 lqh 2021.1.25
  24. public function actionDetail()
  25. {
  26. $orderSn = Yii::$app->request->get('orderSn', '');
  27. $orderData = StockInOrderClass::getOrderDetail($orderSn, $this->shopId);
  28. util::success($orderData);
  29. }
  30. //确认入库 lqh 2021.1.24
  31. public function actionConfirmOrder()
  32. {
  33. $get = Yii::$app->request->get();
  34. $orderSn = $get['orderSn'];
  35. $connection = Yii::$app->db;
  36. $transaction = $connection->beginTransaction();
  37. try {
  38. StockInOrderClass::confirmOrder($orderSn, $this->shopId, $this->adminId);
  39. $transaction->commit();
  40. util::complete("入库成功");
  41. } catch (\Exception $exception) {
  42. Yii::info("确认入库报错:" . $exception->getMessage());
  43. $transaction->rollBack();
  44. util::fail();
  45. }
  46. }
  47. //取消入库 lqh 2021.1.24
  48. public function actionCancelOrder()
  49. {
  50. $get = Yii::$app->request->get();
  51. $orderSn = $get['orderSn'] ?? '';
  52. $order = StockInOrderClass::getByCondition(['orderSn' => $orderSn], true);
  53. if (empty($order)) {
  54. util::fail('订单不存在');
  55. }
  56. if (isset($order->inShopId) == false || $order->inShopId != $this->shopId) {
  57. util::fail('没有权限');
  58. }
  59. $id = $order->id ?? 0;
  60. $info = StockInOrderClass::getLockById($id);
  61. StockInOrderClass::cancelOrder($info, $this->adminId);
  62. util::complete("取消成功");
  63. }
  64. }