123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <?php
- namespace app\admin\controller\sys_manage;
- use app\admin\service\sys_manage\ConfigService;
- use app\admin\validate\sys_manage\ConfigValidate;
- use app\model\SysConfig;
- use support\Request;
- class ConfigController
- {
- /**
- * @Desc 配置列表
- * @Author Gorden
- * @Date 2024/2/22 16:35
- *
- * @param Request $request
- * @return \support\Response
- */
- public function configList(Request $request)
- {
- return ConfigService::configList($request);
- }
- /**
- * @Desc 配置详情
- * @Author Gorden
- * @Date 2024/2/22 16:36
- *
- * @param $id
- * @return \support\Response
- */
- public function configInfo($id)
- {
- return ConfigService::configInfo($id);
- }
- /**
- * @Desc 添加配置
- * @Author Gorden
- * @Date 2024/2/22 15:57
- *
- * @param Request $request
- * @return \support\Response
- */
- public function addConfig(Request $request)
- {
- $validate = new ConfigValidate();
- if (!$validate->scene('add')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return ConfigService::addConfig($request->post());
- }
- /**
- * @Desc 修改配置
- * @Author Gorden
- * @Date 2024/2/22 16:24
- *
- * @param $id
- * @param Request $request
- * @return \support\Response
- */
- public function updateConfig($id, Request $request)
- {
- $validate = new ConfigValidate();
- if (!$validate->scene('update')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return ConfigService::updateConfig($id, $request->post());
- }
- /**
- * @Desc 修改配置状态
- * @Author Gorden
- * @Date 2024/2/22 16:38
- *
- * @param $id
- * @param Request $request
- * @return \support\Response
- */
- public function updateStatus($id, Request $request)
- {
- $validate = new ConfigValidate();
- if (!$validate->scene('update_status')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return ConfigService::updateStatus($id, $request->post());
- }
- /**
- * @Desc 删除配置
- * @Author Gorden
- * @Date 2024/2/22 16:39
- *
- * @param $id
- * @return \support\Response
- */
- public function delConfig(Request $request)
- {
- return ConfigService::delConfig($request);
- }
- public function bottomMenuList()
- {
- $config = SysConfig::where('config_name', 'APP底部菜单')->first()->toArray();
- return json_success('', json_decode($config['config_value_json']));
- }
- public function bottomMenuSave(Request $request)
- {
- try {
- SysConfig::where('config_name', 'APP底部菜单')->update(['config_value_json' => json_encode($request->post())]);
- return json_success('success');
- } catch (\Exception $e) {
- return json_fail('APP底部菜单保存失败');
- }
- }
- public function navMenuList()
- {
- $config = SysConfig::where('config_name', 'APP导航菜单')->first()->toArray();
- return json_success('', json_decode($config['config_value_json']));
- }
- public function navMenuSave(Request $request)
- {
- try {
- SysConfig::where('config_name', 'APP导航菜单')->update(['config_value_json' => json_encode($request->post())]);
- return json_success('success');
- } catch (\Exception $e) {
- return json_fail('APP底部菜单保存失败');
- }
- }
- public function paramsList(Request $request)
- {
- $type = $request->get('type', '');
- return ConfigService::getParams($this->getType($type));
- }
- public function paramsSave(Request $request)
- {
- return ConfigService::paramsSave($request, $this->getType($request->post('type', '')));
- }
- public function partnerParamsInfo()
- {
- $config = SysConfig::where('config_key', 'app-identity-partner-config')->first()->toArray();
- $config['config_value_json'] = json_decode($config['config_value_json'], true);
- if (!empty($config['config_value_json']['account']['added'])) {
- $config['config_value_json']['account']['added'] = round($config['config_value_json']['account']['added'] * 100, 2);
- }
- if (!empty($config['config_value_json']['commission'])) {
- $config['config_value_json']['commission']['direct'] = round($config['config_value_json']['commission']['direct'] * 100, 2);
- $config['config_value_json']['commission']['indirect'] = round($config['config_value_json']['commission']['indirect'] * 100, 2);
- $config['config_value_json']['commission']['relate_consum'] = round($config['config_value_json']['commission']['relate-consum'] * 100, 2);
- $config['config_value_json']['commission']['invite_non_identity'] = round($config['config_value_json']['commission']['invite-non-identity'] * 100, 2);
- $config['config_value_json']['commission']['agent_senior_join'] = round($config['config_value_json']['commission']['agent-senior-join'] * 100, 2);
- $config['config_value_json']['commission']['agent_senior_strategy'] = round($config['config_value_json']['commission']['agent-senior-strategy'] * 100, 2);
- }
- return json_success('success', $config);
- }
- public function setPartnerParams(Request $request)
- {
- $params = $request->post();
- if (!empty($params['account']['added'])) {
- $params['account']['added'] = $params['account']['added'] / 100;
- }
- if (!empty($params['commission'])) {
- $params['commission']['direct'] = $params['commission']['direct'] / 100;
- $params['commission']['indirect'] = $params['commission']['indirect'] / 100;
- $params['commission']['relate-consum'] = $params['commission']['relate_consum'] / 100;
- $params['commission']['invite-non-identity'] = $params['commission']['invite_non_identity'] / 100;
- $params['commission']['agent-senior-join'] = $params['commission']['agent_senior_join'] / 100;
- $params['commission']['agent-senior-strategy'] = $params['commission']['agent_senior_strategy'] / 100;
- unset($params['commission']['relate_consum'], $params['commission']['invite_non_identity'], $params['commission']['agent_senior_join'], $params['commission']['agent_senior_strategy']);
- }
- try {
- SysConfig::where('config_key', 'app-identity-partner-config')->update(['config_value_json' => json_encode($params)]);
- return json_success('success');
- } catch (\Exception $e) {
- return json_fail("保存失败");
- }
- }
- private function getType($type)
- {
- switch ($type) {
- case 'sys':
- return 'sys';
- break;
- case 'pay':
- return 'app-pay-unionpay';
- break;
- case 'msg':
- return 'app-sms-aliyun';
- break;
- case 'face':
- return 'app-face-aliyun';
- break;
- case 'ocr':
- return 'app-cert-ocr-aliyun';
- break;
- case 'ws':
- return 'app-websocket';
- break;
- case 'shortcutMenu':
- return 'app-menu-shortcut';
- break;
- case 'navigationMenu':
- return 'app-menu-navigation';
- break;
- case 'footerMenu':
- return 'app-menu-footer';
- break;
- default:
- return '';
- break;
- }
- }
- }
|