| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace addons\Store\client\controllers;
- use addons\ReservationService\common\enums\ReservationServiceEnum;
- use addons\Store\common\enums\ReserveServiceEnum;
- use addons\Store\common\services\ReserveBoardService;
- use addons\Store\common\services\ReserveOrderService;
- class ReserveBoardController extends BaseController
- {
- /**
- * 预约看板
- *
- * @return string
- */
- public function actionIndex()
- {
- if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
- $params = \Yii::$app->request->get();
- $params['store'] = $this->store;
- $data = (new ReserveBoardService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->index($params);
- $this->success('获取成功', $data);
- return $this->success('获取成功', []);
- }
- return $this->render($this->action->id);
- }
- public function actionGetTimeRange()
- {
- if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
- $params = \Yii::$app->request->get();
- $params['store'] = $this->store;
- $data = (new ReserveBoardService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->getTimeRange($params);
- $this->success('获取成功', $data);
- return $this->success('获取成功', []);
- }
- return $this->render($this->action->id);
- }
- public function actionSetOccupy()
- {
- try {
- if (\Yii::$app->request->isAjax) {
- if(\Yii::$app->request->isPost){
- $params = \Yii::$app->request->post();
- $ret = (new ReserveBoardService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->setOccupyData($params);
- return $this->success('获取成功', $ret);
- }
- }
- return $this->render('edit');
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- }
- public function actionCancelOccupy()
- {
- try {
- if (\Yii::$app->request->isAjax) {
- if(\Yii::$app->request->isPost){
- $params = \Yii::$app->request->post();
- $ret = (new ReserveBoardService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->canceledOccupy($params);
- return $this->success('获取成功', $ret);
- }
- }
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- }
- public function actionGetSkuList()
- {
- if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
- $params = \Yii::$app->request->get();
- $data = (new ReserveBoardService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->getSkuList();
- $this->success('获取成功', $data);
- return $this->success('获取成功', []);
- }
- return $this->render($this->action->id);
- }
- public function actionEdit()
- {
- try {
- if (\Yii::$app->request->isAjax) {
- if(\Yii::$app->request->isGet){
- $params = \Yii::$app->request->get();
- $ret = (new ReserveOrderService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->getEditData($params);
- $ret['store_name'] = $this->store['store_name']??'';
- return $this->success('获取成功', $ret);
- }elseif(\Yii::$app->request->isPost){
- $params = \Yii::$app->request->post();
- $params = $params['form'];
- if (empty($params['id'])) {
- if (!isset($params['service_type'])) {
- $params['service_type'] = ReserveServiceEnum::TO_STORE;
- }
- if (!isset($params['reservation_model'])) {
- $params['reservation_model'] = 2;
- }
- if (!isset($params['create_type'])) {
- $params['create_type'] = ReservationServiceEnum::SYSTEM_CREATION;
- }
- }
- $params['store'] = $this->store;
- $ret = (new ReserveBoardService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->setEditData($params);
- return $this->success('获取成功', $ret);
- }
- }
- return $this->render('edit');
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- }
- }
|