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()); } }