| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <?php
- namespace addons\SecondaryCard\api\modules\v1\controllers;
- use addons\SecondaryCard\common\service\SecondaryCardOrderService;
- use addons\SecondaryCard\common\service\SecondaryCardRedemptionCodeService;
- use addons\SecondaryCard\common\service\SecondaryCardService;
- use addons\SecondaryCard\common\service\SecondaryCardUseLogService;
- use common\enums\ApiStatusEnum;
- use Yii;
- use api\controllers\OnAuthController;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\SecondaryCard\api\modules\v1\controllers
- */
- class DefaultController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = ['index'];
- /**
- * 次卡列表
- * @Author:hua
- * @Date:2024-03-05 16:33
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionSecondaryCardList()
- {
- try {
- $params = \Yii::$app->request->get();
- $params['mall_id'] = $this->mall_id;
- $data = SecondaryCardService::getListByH5($params);
- return $this->success('操作成功', $data);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 次卡详情
- * @Author:hua
- * @Date:2024-03-05 16:33
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionSecondaryCardDetail()
- {
- try {
- $params = \Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['id', 'latitude', 'longitude'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $data = SecondaryCardService::getDetailByH5($params);
- return $this->success('操作成功', $data);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 适用店铺列表
- * @Author:hua
- * @Date:2024-03-05 16:34
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionStoreList()
- {
- try {
- $params = \Yii::$app->request->get();
- $params['mall_id'] = $this->mall_id;
- $data = SecondaryCardService::getStoreListByH5($params);
- return $this->success('操作成功', $data);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 生成次卡订单
- * @Author:hua
- * @Date:2024-03-05 16:34
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionCreateOrder()
- {
- try {
- $params = \Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['secondary_card_id'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $res = SecondaryCardOrderService::createOrder($params);
- return $this->success('操作成功', $res);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 我的次卡列表
- * @Author:hua
- * @Date:2024-03-05 16:53
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionMySecondaryCard()
- {
- try {
- $params = \Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['order_status'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $res = SecondaryCardOrderService::getMySecondaryCard($params);
- return $this->success('操作成功', $res, ApiStatusEnum::CODE_SUCCESS, 0);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 我的次卡详情
- * @Author:hua
- * @Date:2024-03-05 16:54
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionMySecondaryCardDetail()
- {
- try {
- $params = \Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['id', 'latitude', 'longitude'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $data = SecondaryCardOrderService::getMySecondaryCardDetailByH5($params);
- return $this->success('操作成功', $data, ApiStatusEnum::CODE_SUCCESS, 0);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 兑换次卡
- * @Author:hua
- * @Date:2024-03-05 16:54
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionExchangeCode()
- {
- try {
- $params = \Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['code'], 'required'],
- [['secondary_card_id'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $data = SecondaryCardRedemptionCodeService::ExchangeCode($params);
- return $this->success('操作成功', $data);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- public function actionMySecondaryCardCounts()
- {
- try {
- $params = \Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['secondary_card_id'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $count = SecondaryCardOrderService::getMySecondaryCardCounts($this->mall_id, $this->user_id, $params['secondary_card_id']);
- return $this->success('操作成功', ['counts' => $count]);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 取消预约
- * @Author:hua
- * @Date:2024-03-08 11:07
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionCancelReservation()
- {
- try {
- $params = \Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['reservation_service_order_id','main_order_id'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $res = SecondaryCardOrderService::cancelReservation($params);
- if (is_string($res)) return $this->error($res);
- return $this->success();
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 申请退款
- * @Author:hua
- * @Date:2024-03-08 11:07
- * @Copyright:copyright(c)2024 广东七件事集团
- * @return mixed|void
- */
- public function actionApplyRefund()
- {
- if (\Yii::$app->request->isPost) {
- try {
- $params = \Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['id'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['user_id'] = $this->user_id;
- $params['mall_id'] = $this->mall_id;
- SecondaryCardOrderService::orderRefund($params);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- public function actionUseLogList()
- {
- try {
- $params = \Yii::$app->request->get();
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $data = SecondaryCardUseLogService::getPageListByH5($params);
- return $this->success('操作成功', $data);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- public function actionStoreCateList()
- {
- try {
- $params = \Yii::$app->request->get();
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $data = SecondaryCardService::getStoreCateList($params);
- return $this->success('操作成功', $data);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- public function actionGetEmployeeSelection()
- {
- $params = \Yii::$app->request->get();
- $params['mall_id'] = $this->mall_id;
- $data = SecondaryCardService::getEmployeeSelection($this->mall_id, $params['store_id']);
- return $this->success('操作成功', $data);
- }
- }
|