ReserveBoardController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. namespace addons\Store\client\controllers;
  3. use addons\ReservationService\common\enums\ReservationServiceEnum;
  4. use addons\Store\common\enums\ReserveServiceEnum;
  5. use addons\Store\common\services\ReserveBoardService;
  6. use addons\Store\common\services\ReserveOrderService;
  7. class ReserveBoardController extends BaseController
  8. {
  9. /**
  10. * 预约看板
  11. *
  12. * @return string
  13. */
  14. public function actionIndex()
  15. {
  16. if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
  17. $params = \Yii::$app->request->get();
  18. $params['store'] = $this->store;
  19. $data = (new ReserveBoardService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->index($params);
  20. $this->success('获取成功', $data);
  21. return $this->success('获取成功', []);
  22. }
  23. return $this->render($this->action->id);
  24. }
  25. public function actionGetTimeRange()
  26. {
  27. if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
  28. $params = \Yii::$app->request->get();
  29. $params['store'] = $this->store;
  30. $data = (new ReserveBoardService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->getTimeRange($params);
  31. $this->success('获取成功', $data);
  32. return $this->success('获取成功', []);
  33. }
  34. return $this->render($this->action->id);
  35. }
  36. public function actionSetOccupy()
  37. {
  38. try {
  39. if (\Yii::$app->request->isAjax) {
  40. if(\Yii::$app->request->isPost){
  41. $params = \Yii::$app->request->post();
  42. $ret = (new ReserveBoardService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->setOccupyData($params);
  43. return $this->success('获取成功', $ret);
  44. }
  45. }
  46. return $this->render('edit');
  47. }catch (\Exception $e){
  48. return $this->error($e->getMessage());
  49. }
  50. }
  51. public function actionCancelOccupy()
  52. {
  53. try {
  54. if (\Yii::$app->request->isAjax) {
  55. if(\Yii::$app->request->isPost){
  56. $params = \Yii::$app->request->post();
  57. $ret = (new ReserveBoardService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->canceledOccupy($params);
  58. return $this->success('获取成功', $ret);
  59. }
  60. }
  61. }catch (\Exception $e){
  62. return $this->error($e->getMessage());
  63. }
  64. }
  65. public function actionGetSkuList()
  66. {
  67. if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
  68. $params = \Yii::$app->request->get();
  69. $data = (new ReserveBoardService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->getSkuList();
  70. $this->success('获取成功', $data);
  71. return $this->success('获取成功', []);
  72. }
  73. return $this->render($this->action->id);
  74. }
  75. public function actionEdit()
  76. {
  77. try {
  78. if (\Yii::$app->request->isAjax) {
  79. if(\Yii::$app->request->isGet){
  80. $params = \Yii::$app->request->get();
  81. $ret = (new ReserveOrderService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->getEditData($params);
  82. $ret['store_name'] = $this->store['store_name']??'';
  83. return $this->success('获取成功', $ret);
  84. }elseif(\Yii::$app->request->isPost){
  85. $params = \Yii::$app->request->post();
  86. $params = $params['form'];
  87. if (empty($params['id'])) {
  88. if (!isset($params['service_type'])) {
  89. $params['service_type'] = ReserveServiceEnum::TO_STORE;
  90. }
  91. if (!isset($params['reservation_model'])) {
  92. $params['reservation_model'] = 2;
  93. }
  94. if (!isset($params['create_type'])) {
  95. $params['create_type'] = ReservationServiceEnum::SYSTEM_CREATION;
  96. }
  97. }
  98. $params['store'] = $this->store;
  99. $ret = (new ReserveBoardService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->setEditData($params);
  100. return $this->success('获取成功', $ret);
  101. }
  102. }
  103. return $this->render('edit');
  104. }catch (\Exception $e){
  105. return $this->error($e->getMessage());
  106. }
  107. }
  108. }