| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- namespace backend\modules\mall\controllers;
- use backend\controllers\MallController;
- use backend\modules\mall\services\MiniProgramService;
- use Yii;
- /**
- * 微信小程序设置
- * MiniProgramController class
- */
- class MiniProgramController extends MallController
- {
- /**
- * 公众号设置
- *
- * @return mixed
- */
- public function actionEdit()
- {
- if (Yii::$app->request->isAjax) {
- $service = new MiniProgramService(['mall_id' => $this->mall_id]);
- if (Yii::$app->request->isGet) {
- $mini_program = $service->getMiniProgramConfig();
- return $this->success('获取成功', compact('mini_program'));
- } else {
- $params = Yii::$app->request->post('form');
- $res = Yii::$app->services->validate->validate($params, [
- [['app_id', 'secret', 'name', 'original_id'], 'required'],
- [['app_id', 'secret', 'name', 'original_id', 'version', 'desc', 'secret_key_file', 'postUrl', 'upload_secret_key','index_url'], 'string'],
- [['is_live'], 'integer'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- return $service->setMiniProgramConfig($params)
- ? $this->success('保存成功')
- : $this->error($service->getError());
- }
- }
- return $this->render($this->action->id);
- }
- /**
- * 提交至微信审核小程序
- *
- * @return mixed
- */
- public function actionUploadWechat()
- {
- $service = new MiniProgramService(['mall_id' => $this->mall_id]);
- return ($data = $service->uploadToWechat())
- ? $this->success('提交成功', $data)
- : $this->error($service->getError());
- }
- /**
- * 小程序上传
- *
- * @return mixed
- */
- public function actionTask()
- {
- if (Yii::$app->request->isAjax) {
- $service = new MiniProgramService(['mall_id' => $this->mall_id]);
- if (Yii::$app->request->isGet) {
- $params = Yii::$app->request->get();
- return $this->success('获取成功', $service->getTaskPageList($params));
- } else {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['app_id', 'is_live', 'upload_secret_key', 'version', 'api_domain', 'static_domain', 'is_review'], 'required'],
- [['app_id', 'upload_secret_key', 'version', 'desc', 'api_domain', 'static_domain',], 'string'],
- [['is_live', 'is_review'], 'integer'],
- [['plugins'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_sign'] = $this->mall['mall_sign'];
- return $service->addTaskLog($params)
- ? $this->success('提交成功')
- : $this->error($service->getError());
- }
- }
- return $this->render($this->action->id);
- }
- //点击查看日志
- public function actionTaskLog()
- {
- $request = Yii::$app->request;
- if ($request->isGet) {
- $params = $request->get();
- $service = new MiniProgramService(['mall_id' => $this->mall_id]);
- return $this->success('获取成功', $service->getTaskLog($params));
- }
- }
- /**
- * 获取小程序配置
- *
- * @return mixed
- */
- public function actionGetMiniProgramConfig()
- {
- $service = new MiniProgramService(['mall_id' => $this->mall_id]);
- return $this->successStr('获取成功', $service->getTaskLogConfig());
- }
- /**
- * 修改状态
- *
- * @param integer $id
- * @return mixed
- */
- public function actionTaskChangeReview(int $id)
- {
- $service = new MiniProgramService(['mall_id' => $this->mall_id]);
- return $service->changeTaskReview($id)
- ? $this->success('修改成功')
- : $this->error($service->getError());
- }
- }
|