| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace addons\WechatVideoShop\backend\controllers;
- use addons\WechatVideoShop\common\models\WechatVideoShop;
- use common\enums\StatusEnum;
- use common\models\common\Region;
- class ShopController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- *
- * @return string
- */
- public function actionIndex()
- {
- if ($this->request->isAjax) {
- if ($this->request->isGet) {
- $param = \Yii::$app->request->get();
- $params['where'] = [
- ['mall_id' => $this->mall_id],
- ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]],
- ];
- $params['limit'] = $param['limit'] ?? 15;
- $params['page'] = $param['page'] ?? 1;
- $list = WechatVideoShop::listPage($params);
- if ($list === false) {
- return $this->error(WechatVideoShop::getStaticError());
- }
- return $this->success('数据请求成功', $list);
- }
- }
- return $this->render($this->action->id);
- }
- /**
- * @Description: 店铺编辑
- * @Author: zsan
- * @DateTime 2023-06-23 14:56:48
- * @return mixed
- */
- public function actionEdit()
- {
- if ($this->request->isAjax) {
- if ($this->request->isGet) {
- $param = \Yii::$app->request->get();
- $where = [
- ['mall_id' => $this->mall_id],
- ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]],
- ['id' => $param['id']]
- ];
- $detail = WechatVideoShop::getOne($where, true, ['provinceInfo', 'cityInfo', 'districtInfo']);
- $detail['callback_url'] = \Yii::getAlias('@apiUrl') . "/wechat-video-shop/v1/event/callback";
- return $this->success('数据请求成功', $detail ?? []);
- } elseif ($this->request->isPost) {
- $param = \Yii::$app->request->post();
- $params = $param['setting'];
- $params['mall_id'] = $this->mall_id;
- // 获取店铺信息
- $model = WechatVideoShop::setData($params);
- if ($model === false) return $this->error(WechatVideoShop::getStaticError());
- return $this->success('数据保存成功');
- }
- }
- return $this->render($this->action->id, ['callback_url' => \Yii::getAlias('@apiUrl') . "/wechat-video-shop/v1/event/callback"]);
- }
- public function actionRegion()
- {
- $id = intval(\Yii::$app->request->get('region_id', 0));
- $ret = Region::lists([
- 'where' => [
- ['parent_id' => $id]
- ]
- ]);
- return $this->success('获取成功', $ret);
- }
- public function actionList()
- {
-
- }
- }
|