| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- namespace addons\WechatVideoShop\backend\controllers;
- use addons\WechatVideoShop\common\enums\WechatVideoShopCateAuditStatusEnums;
- use addons\WechatVideoShop\common\expand\sdk\weixin\src\request\cate\CategoryInfoRequest;
- use addons\WechatVideoShop\common\models\WechatVideoShopCate;
- use addons\WechatVideoShop\common\models\WechatVideoShopCateAudit;
- use addons\WechatVideoShop\common\service\CateService;
- use addons\WechatVideoShop\common\service\ShopService;
- use common\enums\StatusEnum;
- use Yii;
- class CateController extends BaseController
- {
- public $enableCsrfValidation = false;
- public function actionIndex()
- {
- if (\Yii::$app->request->isAjax) {
- $service = new CateService();
- if (\Yii::$app->request->isPost) {
- } else {
- $data = Yii::$app->request->get();
- $valid = Yii::$app->services->validate->validate($data, [
- [['status', 'shop_id'], 'integer'],
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $ret = $service->index($this->mall_id, $data);
- // 获取所有店铺键值对
- $ret['shop'] = (new ShopService())->ShopArr($this->mall_id);
- return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
- }
- }
- return $this->render('index');
- }
- /**
- * @return mixed|void|null
- * @throws \Exception
- */
- public function actionCreate()
- {
- if (\Yii::$app->request->isPost) {
- $data = Yii::$app->request->post();
- $valid = Yii::$app->services->validate->validate($data, [
- [['cats', 'certificate'], 'safe'],
- [['shop_id'], 'integer'],
- [['cats', 'shop_id'], 'required'],
- ], [
- 'cats' => '类目',
- 'certificate' => '资质',
- 'shop_id' => '店铺',
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $ret = (new CateService())->create($this->mall_id, $data);
- return is_string($ret) ? $this->error($ret) : $this->success('提交成功');
- }
- }
- /**
- * 撤回类目审核
- * @return mixed|null
- */
- public function actionCancelAudit()
- {
- return $this->success('');
- }
- /**
- * 删除类目
- * @return mixed|null
- */
- public function actionDelete()
- {
- return $this->success('');
- }
- /**
- * @return mixed|null
- */
- public function actionWxList()
- {
- // 取出第一个店铺
- $shop_id = (new ShopService())->firstShopId($this->mall_id);
- if (empty($shop_id)) return $this->error("请先绑定小店");
- $ret = (new CateService($shop_id))->wxList($this->mall_id, $shop_id);
- return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
- }
- /**
- * @return array|false|mixed|string
- */
- public function actionList()
- {
- $data = Yii::$app->request->get();
- $valid = Yii::$app->services->validate->validate($data, [
- [['shop_id'], 'integer'],
- [['shop_id'], 'required'],
- ], [
- 'shop_id' => '店铺',
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $ret = (new CateService())->enableList($this->mall_id, $data['shop_id']);
- return is_string($ret) ? $this->error($ret) : $this->success("获取成功", $ret);
- }
- /**
- * @return mixed|null
- */
- public function actionWxInfo()
- {
- $data = Yii::$app->request->get();
- $valid = Yii::$app->services->validate->validate($data, [
- [['id', 'shop_id'], 'integer'],
- [['id', 'shop_id'], 'required'],
- ], [
- 'id' => '类目',
- 'shop_id' => '店铺',
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $ret = (new CateService($data['shop_id']))->wxCatInfo($data['id']);
- return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
- }
- }
|