123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- /**
- * 系统设置控制器
- * Created by PhpStorm.
- * User: 小威
- * Date: 2019/11/19
- * Time: 16:00
- */
- namespace JinDouYun\Controller\SystemSettings;
- use Mall\Framework\Core\ErrorCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\SystemSettings\MSystem;
- /**
- * type
- * 1小程序设置
- * 2模板消息设置
- * 3分类模板设置
- * 4字节小程序设置
- * Class System
- * @package JinDouYun\Controller\SystemSettings
- */
- class System extends BaseController
- {
- private $objMSystem;
- public function __construct($isCheckAcl = false, $isMustLogin = true, $checkToken = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin, $checkToken);
- $this->objMSystem = new MSystem($this->onlineEnterpriseId);
- }
- /**
- * 修改系统设置
- */
- public function updateSystemSettings()
- {
- $id = $this->request->param('request_id');
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $updateData = [
- 'enterpriseId' => $this->onlineEnterpriseId,
- 'type' => isset($params['type']) ? $params['type'] : '',
- 'content' => isset($params['content']) ? $params['content'] : '',
- ];
- foreach ($updateData as $key => $value) {
- if (empty($value)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- if (!isset($updateData['content']['originalID'])) {
- parent::sendOutput('originalId参数错误', ErrorCode::$paramError);
- }
- $id && $updateData['id'] = $id;
- !$id && $updateData['createTime'] = time();
- $updateData['updateTime'] = time();
- $content = $updateData['content'];
- $updateData['content'] = json_encode($updateData['content']);
- $modelResult = $this->objMSystem->updateSystemSettings($updateData, $content['originalID']);
- if (!$modelResult->isSuccess()) {
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 查询系统设置
- */
- public function getSystemSettingsInfo()
- {
- $type = $this->request->param('request_id');
- if (empty($type)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $modelResult = $this->objMSystem->getSystemSettingsInfo($type);
- if (!$modelResult->isSuccess()) {
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 获取预授权码(pre_auth_code)
- * 官网文档地址: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Authorization_Process_Technical_Description.html
- */
- public function preAuthCode()
- {
- $modelResult = $this->objMSystem->preAuthCode();
- if (!$modelResult->isSuccess()) {
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * type 4 字节跳动设置
- * 保存字节跳动设置
- * {"type":4,"content":{"wxpay":{"micro_appid":"ttappid","micro_app_secret":"microappSecret","appid":"appid","merchant_id":"merchant_id","app_secret":"app_secret"},"alipay":{}}}
- *
- */
- public function saveByteDanceSetting()
- {
- $id = $this->request->param('request_id');
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = [
- 'enterpriseId' => $this->onlineEnterpriseId,
- 'type' => isset($params['type']) ? $params['type'] : '',//4
- 'content' => isset($params['content']) ? $params['content'] : '',
- ];
- foreach ($data as $key => $value) {
- if (empty($value)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- if (!empty($id)) $data['id'] = $id;
- $data['content'] = json_encode($data['content']);
- $modelResult = $this->objMSystem->saveByteDanceSetting($data);
- if (!$modelResult->isSuccess()) {
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- }
|