| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- namespace addons\Happiness\api\modules\v1\controllers;
- use addons\Happiness\common\service\StoreService;
- use common\enums\GoodsTypeEnum;
- use common\enums\OrderCommentEnum;
- use common\enums\StatusEnum;
- use common\helpers\LocationHelper;
- use common\models\common\Region;
- use common\models\goods\GoodsCateRelate;
- use common\models\order\OrderComments;
- use common\models\user\User;
- use common\models\user\UserLevel;
- use common\logic\common\GoodsLogic;
- use Yii;
- use Exception;
- use api\controllers\OnAuthController;
- /**
- * 幸福小店门店
- *
- * Class DefaultController
- * @package addons\Store\api\modules\v1\controllers
- */
- class StoreController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = ['index', 'detail', 'cate-goods-list', 'list', 'recommend', 'comments-list', 'get-platform-goods'];
- //获取门店列表
- public function actionGetStoreList()
- {
- $request = Yii::$app->request;
- if ($request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['page', 'limit', 'shipping_type'], 'integer'],
- [['longitude', 'latitude', 'keyword', 'attr_id', 'attr_ids', 'goods_ids'], 'string'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- if (!empty($get['attr_ids'])) $get['attr_ids'] = explode(',', $get['attr_ids']);
- if (!empty($get['goods_ids'])) $get['goods_ids'] = explode(',', $get['goods_ids']);
- $list = (new StoreService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]))->getStoreList($get);
- return $this->success('获取成功', $list);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //匹配最近门店
- public function actionGetStore()
- {
- $request = Yii::$app->request;
- if ($request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['longitude', 'latitude', 'shipping_type', 'attr_id', 'attr_ids', 'goods_ids'], 'string'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $get['mall_id'] = $this->mall_id;
- $get['user_id'] = $this->user_id;
- if (!empty($get['attr_ids'])) $get['attr_ids'] = explode(',', $get['attr_ids']);
- if (!empty($get['goods_ids'])) $get['goods_ids'] = explode(',', $get['goods_ids']);
- $info = (new StoreService())->getStore($get);
- return $this->success('获取成功', $info);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //获取历史门店
- public function actionGetHistory()
- {
- $request = Yii::$app->request;
- if ($request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['longitude', 'latitude'], 'string']
- ]);
- $list = (new StoreService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]))->getHistoryStore($get);
- return $this->success('获取成功', ['list' => $list]);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //删除历史门店
- public function actionDelHistoryStore()
- {
- $request = Yii::$app->request;
- if ($request->isPost) {
- try {
- $post = $request->post();
- $res = Yii::$app->services->validate->validate($post, [
- [['id'], 'integer'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $res = (new StoreService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]))->delHistoryStore($post);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //获取门店详情
- public function actionGetStoreDetail()
- {
- $request = Yii::$app->request;
- if ($request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['store_id'], 'integer'],
- [['longitude', 'latitude'], 'string'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $info = (new StoreService(['mall_id' => $this->mall_id]))->getStoreDetail($get);
- return $this->success('获取成功', $info);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- }
|