ConfigController.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <?php
  2. namespace app\admin\controller\sys_manage;
  3. use app\admin\service\sys_manage\ConfigService;
  4. use app\admin\validate\sys_manage\ConfigValidate;
  5. use app\model\SysConfig;
  6. use support\Request;
  7. class ConfigController
  8. {
  9. /**
  10. * @Desc 配置列表
  11. * @Author Gorden
  12. * @Date 2024/2/22 16:35
  13. *
  14. * @param Request $request
  15. * @return \support\Response
  16. */
  17. public function configList(Request $request)
  18. {
  19. return ConfigService::configList($request);
  20. }
  21. /**
  22. * @Desc 配置详情
  23. * @Author Gorden
  24. * @Date 2024/2/22 16:36
  25. *
  26. * @param $id
  27. * @return \support\Response
  28. */
  29. public function configInfo($id)
  30. {
  31. return ConfigService::configInfo($id);
  32. }
  33. /**
  34. * @Desc 添加配置
  35. * @Author Gorden
  36. * @Date 2024/2/22 15:57
  37. *
  38. * @param Request $request
  39. * @return \support\Response
  40. */
  41. public function addConfig(Request $request)
  42. {
  43. $validate = new ConfigValidate();
  44. if (!$validate->scene('add')->check($request->post())) {
  45. return json_fail($validate->getError());
  46. }
  47. return ConfigService::addConfig($request->post());
  48. }
  49. /**
  50. * @Desc 修改配置
  51. * @Author Gorden
  52. * @Date 2024/2/22 16:24
  53. *
  54. * @param $id
  55. * @param Request $request
  56. * @return \support\Response
  57. */
  58. public function updateConfig($id, Request $request)
  59. {
  60. $validate = new ConfigValidate();
  61. if (!$validate->scene('update')->check($request->post())) {
  62. return json_fail($validate->getError());
  63. }
  64. return ConfigService::updateConfig($id, $request->post());
  65. }
  66. /**
  67. * @Desc 修改配置状态
  68. * @Author Gorden
  69. * @Date 2024/2/22 16:38
  70. *
  71. * @param $id
  72. * @param Request $request
  73. * @return \support\Response
  74. */
  75. public function updateStatus($id, Request $request)
  76. {
  77. $validate = new ConfigValidate();
  78. if (!$validate->scene('update_status')->check($request->post())) {
  79. return json_fail($validate->getError());
  80. }
  81. return ConfigService::updateStatus($id, $request->post());
  82. }
  83. /**
  84. * @Desc 删除配置
  85. * @Author Gorden
  86. * @Date 2024/2/22 16:39
  87. *
  88. * @param $id
  89. * @return \support\Response
  90. */
  91. public function delConfig(Request $request)
  92. {
  93. return ConfigService::delConfig($request);
  94. }
  95. public function bottomMenuList()
  96. {
  97. $config = SysConfig::where('config_name', 'APP底部菜单')->first()->toArray();
  98. return json_success('', json_decode($config['config_value_json']));
  99. }
  100. public function bottomMenuSave(Request $request)
  101. {
  102. try {
  103. SysConfig::where('config_name', 'APP底部菜单')->update(['config_value_json' => json_encode($request->post())]);
  104. return json_success('success');
  105. } catch (\Exception $e) {
  106. return json_fail('APP底部菜单保存失败');
  107. }
  108. }
  109. public function navMenuList()
  110. {
  111. $config = SysConfig::where('config_name', 'APP导航菜单')->first()->toArray();
  112. return json_success('', json_decode($config['config_value_json']));
  113. }
  114. public function navMenuSave(Request $request)
  115. {
  116. try {
  117. SysConfig::where('config_name', 'APP导航菜单')->update(['config_value_json' => json_encode($request->post())]);
  118. return json_success('success');
  119. } catch (\Exception $e) {
  120. return json_fail('APP底部菜单保存失败');
  121. }
  122. }
  123. public function paramsList(Request $request)
  124. {
  125. $type = $request->get('type', '');
  126. return ConfigService::getParams($this->getType($type));
  127. }
  128. public function paramsSave(Request $request)
  129. {
  130. return ConfigService::paramsSave($request, $this->getType($request->post('type', '')));
  131. }
  132. public function partnerParamsInfo()
  133. {
  134. $config = SysConfig::where('config_key', 'app-identity-partner-config')->first()->toArray();
  135. $config['config_value_json'] = json_decode($config['config_value_json'], true);
  136. if (!empty($config['config_value_json']['account']['added'])) {
  137. $config['config_value_json']['account']['added'] = round($config['config_value_json']['account']['added'] * 100, 2);
  138. }
  139. if (!empty($config['config_value_json']['commission'])) {
  140. $config['config_value_json']['commission']['direct'] = round($config['config_value_json']['commission']['direct'] * 100, 2);
  141. $config['config_value_json']['commission']['indirect'] = round($config['config_value_json']['commission']['indirect'] * 100, 2);
  142. $config['config_value_json']['commission']['relate_consum'] = round($config['config_value_json']['commission']['relate-consum'] * 100, 2);
  143. $config['config_value_json']['commission']['invite_non_identity'] = round($config['config_value_json']['commission']['invite-non-identity'] * 100, 2);
  144. $config['config_value_json']['commission']['agent_senior_join'] = round($config['config_value_json']['commission']['agent-senior-join'] * 100, 2);
  145. $config['config_value_json']['commission']['agent_senior_strategy'] = round($config['config_value_json']['commission']['agent-senior-strategy'] * 100, 2);
  146. }
  147. return json_success('success', $config);
  148. }
  149. public function setPartnerParams(Request $request)
  150. {
  151. $params = $request->post();
  152. if (!empty($params['account']['added'])) {
  153. $params['account']['added'] = $params['account']['added'] / 100;
  154. }
  155. if (!empty($params['commission'])) {
  156. $params['commission']['direct'] = $params['commission']['direct'] / 100;
  157. $params['commission']['indirect'] = $params['commission']['indirect'] / 100;
  158. $params['commission']['relate-consum'] = $params['commission']['relate_consum'] / 100;
  159. $params['commission']['invite-non-identity'] = $params['commission']['invite_non_identity'] / 100;
  160. $params['commission']['agent-senior-join'] = $params['commission']['agent_senior_join'] / 100;
  161. $params['commission']['agent-senior-strategy'] = $params['commission']['agent_senior_strategy'] / 100;
  162. unset($params['commission']['relate_consum'], $params['commission']['invite_non_identity'], $params['commission']['agent_senior_join'], $params['commission']['agent_senior_strategy']);
  163. }
  164. try {
  165. SysConfig::where('config_key', 'app-identity-partner-config')->update(['config_value_json' => json_encode($params)]);
  166. return json_success('success');
  167. } catch (\Exception $e) {
  168. return json_fail("保存失败");
  169. }
  170. }
  171. /**
  172. * @Desc 加盟合伙人参数
  173. * @Author Gorden
  174. * @Date 2024/11/12 11:29
  175. *
  176. * @return \support\Response
  177. */
  178. public function franchiseeParamsInfo()
  179. {
  180. $config = SysConfig::where('config_key', 'app-identity-franchisee-config')->first()->toArray();
  181. $config['config_value_json'] = json_decode($config['config_value_json'], true);
  182. if (!empty($config['config_value_json']['account']['added'])) {
  183. $config['config_value_json']['account']['added'] = round($config['config_value_json']['account']['added'] * 100, 2);
  184. }
  185. if (!empty($config['config_value_json']['commission'])) {
  186. $config['config_value_json']['commission']['direct'] = round($config['config_value_json']['commission']['direct'] * 100, 2);
  187. $config['config_value_json']['commission']['indirect'] = round($config['config_value_json']['commission']['indirect'] * 100, 2);
  188. $config['config_value_json']['commission']['relate_consum'] = round($config['config_value_json']['commission']['relate-consum'] * 100, 2);
  189. $config['config_value_json']['commission']['invite_non_identity'] = round($config['config_value_json']['commission']['invite-non-identity'] * 100, 2);
  190. $config['config_value_json']['commission']['agent_senior_join'] = round($config['config_value_json']['commission']['agent-senior-join'] * 100, 2);
  191. $config['config_value_json']['commission']['agent_senior_strategy'] = round($config['config_value_json']['commission']['agent-senior-strategy'] * 100, 2);
  192. }
  193. return json_success('success', $config);
  194. }
  195. /**
  196. * @Desc 设置加盟合伙人参数
  197. * @Author Gorden
  198. * @Date 2024/11/12 11:29
  199. *
  200. * @param Request $request
  201. * @return \support\Response
  202. */
  203. public function setFranchiseeParams(Request $request)
  204. {
  205. $params = $request->post();
  206. if (!empty($params['account']['added'])) {
  207. $params['account']['added'] = $params['account']['added'] / 100;
  208. }
  209. if (!empty($params['commission'])) {
  210. $params['commission']['direct'] = $params['commission']['direct'] / 100;
  211. $params['commission']['indirect'] = $params['commission']['indirect'] / 100;
  212. $params['commission']['relate-consum'] = $params['commission']['relate_consum'] / 100;
  213. $params['commission']['invite-non-identity'] = $params['commission']['invite_non_identity'] / 100;
  214. $params['commission']['agent-senior-join'] = $params['commission']['agent_senior_join'] / 100;
  215. $params['commission']['agent-senior-strategy'] = $params['commission']['agent_senior_strategy'] / 100;
  216. unset($params['commission']['relate_consum'], $params['commission']['invite_non_identity'], $params['commission']['agent_senior_join'], $params['commission']['agent_senior_strategy']);
  217. }
  218. try {
  219. SysConfig::where('config_key', 'app-identity-franchisee-config')->update(['config_value_json' => json_encode($params)]);
  220. return json_success('success');
  221. } catch (\Exception $e) {
  222. return json_fail("保存失败");
  223. }
  224. }
  225. /**
  226. * @Desc 获取推荐官参数
  227. * @Author Gorden
  228. * @Date 2024/9/29 15:05
  229. *
  230. * @return \support\Response
  231. */
  232. public function referrerParamsInfo()
  233. {
  234. $config = SysConfig::where('config_key', 'app-identity-referrer-config')->first()->toArray();
  235. $config['config_value_json'] = json_decode($config['config_value_json'], true);
  236. if (!empty($config['config_value_json']['account']['added'])) {
  237. $config['config_value_json']['account']['added'] = round($config['config_value_json']['account']['added'] * 100, 2);
  238. }
  239. if (!empty($config['config_value_json']['commission'])) {
  240. $config['config_value_json']['commission']['direct'] = round($config['config_value_json']['commission']['direct'] * 100, 2);
  241. $config['config_value_json']['commission']['indirect'] = round($config['config_value_json']['commission']['indirect'] * 100, 2);
  242. $config['config_value_json']['commission']['relate_consum'] = round($config['config_value_json']['commission']['relate-consum'] * 100, 2);
  243. $config['config_value_json']['commission']['invite_non_identity'] = round($config['config_value_json']['commission']['invite-non-identity'] * 100, 2);
  244. $config['config_value_json']['commission']['agent_senior_join'] = round($config['config_value_json']['commission']['agent-senior-join'] * 100, 2);
  245. $config['config_value_json']['commission']['agent_senior_strategy'] = round($config['config_value_json']['commission']['agent-senior-strategy'] * 100, 2);
  246. }
  247. return json_success('success', $config);
  248. }
  249. /**
  250. * @Desc 设置推荐官参数
  251. * @Author Gorden
  252. * @Date 2024/9/29 15:06
  253. *
  254. * @param Request $request
  255. * @return \support\Response
  256. */
  257. public function setReferrerParams(Request $request)
  258. {
  259. $params = $request->post();
  260. if (!empty($params['account']['added'])) {
  261. $params['account']['added'] = $params['account']['added'] / 100;
  262. }
  263. if (!empty($params['commission'])) {
  264. $params['commission']['direct'] = $params['commission']['direct'] / 100;
  265. $params['commission']['indirect'] = $params['commission']['indirect'] / 100;
  266. $params['commission']['relate-consum'] = $params['commission']['relate_consum'] / 100;
  267. $params['commission']['invite-non-identity'] = $params['commission']['invite_non_identity'] / 100;
  268. $params['commission']['agent-senior-join'] = $params['commission']['agent_senior_join'] / 100;
  269. $params['commission']['agent-senior-strategy'] = $params['commission']['agent_senior_strategy'] / 100;
  270. unset($params['commission']['relate_consum'], $params['commission']['invite_non_identity'], $params['commission']['agent_senior_join'], $params['commission']['agent_senior_strategy']);
  271. }
  272. try {
  273. SysConfig::where('config_key', 'app-identity-referrer-config')->update(['config_value_json' => json_encode($params)]);
  274. return json_success('success');
  275. } catch (\Exception $e) {
  276. return json_fail("保存失败");
  277. }
  278. }
  279. private function getType($type)
  280. {
  281. switch ($type) {
  282. case 'sys':
  283. return 'sys';
  284. break;
  285. case 'pay':
  286. return 'app-pay-unionpay';
  287. break;
  288. case 'msg':
  289. return 'app-sms-aliyun';
  290. break;
  291. case 'face':
  292. return 'app-face-aliyun';
  293. break;
  294. case 'ocr':
  295. return 'app-cert-ocr-aliyun';
  296. break;
  297. case 'ws':
  298. return 'app-websocket';
  299. break;
  300. case 'shortcutMenu':
  301. return 'app-menu-shortcut';
  302. break;
  303. case 'navigationMenu':
  304. return 'app-menu-navigation';
  305. break;
  306. case 'footerMenu':
  307. return 'app-menu-footer';
  308. break;
  309. default:
  310. return '';
  311. break;
  312. }
  313. }
  314. }