SystemConfigServices.php 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\system\config;
  12. use app\dao\system\config\SystemConfigDao;
  13. use app\services\agent\AgentManageServices;
  14. use app\services\BaseServices;
  15. use crmeb\exceptions\AdminException;
  16. use crmeb\services\FileService;
  17. use crmeb\services\FormBuilder;
  18. use think\facade\Log;
  19. /**
  20. * 系统配置
  21. * Class SystemConfigServices
  22. * @package app\services\system\config
  23. * @method count(array $where = []) 获取指定条件下的count
  24. * @method save(array $data) 保存数据
  25. * @method get(int $id, ?array $field = []) 获取一条数据
  26. * @method update($id, array $data, ?string $key = null) 修改数据
  27. * @method delete(int $id, ?string $key = null) 删除数据
  28. * @method getUploadTypeList(string $configName) 获取上传配置中的上传类型
  29. */
  30. class SystemConfigServices extends BaseServices
  31. {
  32. /**
  33. * form表单句柄
  34. * @var FormBuilder
  35. */
  36. protected $builder;
  37. /**
  38. * 表单数据切割符号
  39. * @var string
  40. */
  41. protected $cuttingStr = '=>';
  42. /**
  43. * 表单提交url
  44. * @var string[]
  45. */
  46. protected $postUrl = [
  47. 'setting' => [
  48. 'url' => '/setting/config/save_basics',
  49. 'auth' => [],
  50. ],
  51. 'serve' => [
  52. 'url' => '/serve/sms_config/save_basics',
  53. 'auth' => ['short_letter_switch'],
  54. ],
  55. 'freight' => [
  56. 'url' => '/freight/config/save_basics',
  57. 'auth' => ['express'],
  58. ],
  59. 'agent' => [
  60. 'url' => '/agent/config/save_basics',
  61. 'auth' => ['fenxiao'],
  62. ],
  63. 'marketing' => [
  64. 'url' => '/marketing/integral_config/save_basics',
  65. 'auth' => ['point'],
  66. ]
  67. ];
  68. /**
  69. * 子集控制规则
  70. * @var array[]
  71. */
  72. protected $relatedRule = [
  73. 'brokerage_func_status' => [
  74. 'son_type' => [
  75. 'store_brokerage_statu' => [
  76. 'son_type' => ['store_brokerage_price' => ''],
  77. 'show_value' => 3
  78. ],
  79. 'brokerage_bindind' => '',
  80. 'store_brokerage_binding_status' => [
  81. 'son_type' => ['store_brokerage_binding_time' => ''],
  82. 'show_value' => 2
  83. ],
  84. 'spread_banner' => '',
  85. ],
  86. 'show_value' => 1
  87. ],
  88. 'brokerage_user_status' => [
  89. 'son_type' => [
  90. 'uni_brokerage_price' => '',
  91. 'day_brokerage_price_upper' => '',
  92. ],
  93. 'show_value' => 1
  94. ],
  95. 'wss_open' => [
  96. 'son_type' => [
  97. 'wss_local_cert' => '',
  98. 'wss_local_pk' => '',
  99. ],
  100. 'show_value' => 1
  101. ],
  102. 'invoice_func_status' => [
  103. 'son_type' => [
  104. 'special_invoice_status' => '',
  105. ],
  106. 'show_value' => 1
  107. ],
  108. 'member_func_status' => [
  109. 'son_type' => [
  110. 'order_give_exp' => '',
  111. 'sign_give_exp' => '',
  112. 'invite_user_exp' => ''
  113. ],
  114. 'show_value' => 1
  115. ],
  116. 'balance_func_status' => [
  117. 'son_type' => [
  118. 'recharge_attention' => '',
  119. 'recharge_switch' => '',
  120. 'store_user_min_recharge' => '',
  121. ],
  122. 'show_value' => 1
  123. ],
  124. 'ali_pay_status' => [
  125. 'son_type' => [
  126. 'ali_pay_appid' => '',
  127. 'alipay_merchant_private_key' => '',
  128. 'alipay_public_key' => '',
  129. ],
  130. 'show_value' => 1
  131. ],
  132. 'pay_weixin_open' => [
  133. 'son_type' => [
  134. 'pay_weixin_mchid' => '',
  135. 'pay_wechat_type' => [
  136. 'son_type' => [
  137. 'pay_weixin_key' => '',
  138. ],
  139. 'show_value' => 0
  140. ],
  141. 'pay_wechat_type@' => [
  142. 'son_type' => [
  143. 'pay_weixin_serial_no' => '',
  144. 'pay_weixin_key_v3' => ''
  145. ],
  146. 'show_value' => 1
  147. ],
  148. 'pay_weixin_client_cert' => '',
  149. 'pay_weixin_client_key' => '',
  150. ],
  151. 'show_value' => 1
  152. ],
  153. 'image_watermark_status' => [
  154. 'son_type' => [
  155. 'watermark_type' => [
  156. 'son_type' => [
  157. 'watermark_image' => '',
  158. 'watermark_opacity' => '',
  159. 'watermark_rotate' => '',
  160. ],
  161. 'show_value' => 1
  162. ],
  163. 'watermark_position' => '',
  164. 'watermark_x' => '',
  165. 'watermark_y' => '',
  166. 'watermark_type@' => [
  167. 'son_type' => [
  168. 'watermark_text' => '',
  169. 'watermark_text_size' => '',
  170. 'watermark_text_color' => '',
  171. 'watermark_text_angle' => ''
  172. ],
  173. 'show_value' => 2
  174. ],
  175. ],
  176. 'show_value' => 1
  177. ],
  178. 'customer_type' => [
  179. 'son_type' => [
  180. 'customer_phone' => '',
  181. ],
  182. 'show_value' => 1
  183. ],
  184. 'customer_type@' => [
  185. 'son_type' => [
  186. 'customer_url' => '',
  187. 'customer_corpId' => '',
  188. ],
  189. 'show_value' => 2
  190. ],
  191. 'pay_new_weixin_open' => [
  192. 'son_type' => [
  193. 'pay_new_weixin_mchid' => ''
  194. ],
  195. 'show_value' => 1
  196. ]
  197. ];
  198. /**
  199. * SystemConfigServices constructor.
  200. * @param SystemConfigDao $dao
  201. */
  202. public function __construct(SystemConfigDao $dao, FormBuilder $builder)
  203. {
  204. $this->dao = $dao;
  205. $this->builder = $builder;
  206. }
  207. public function getSonConfig()
  208. {
  209. $sonConfig = [];
  210. $rolateRule = $this->relatedRule;
  211. if ($rolateRule) {
  212. foreach ($rolateRule as $key => $value) {
  213. $sonConfig = array_merge($sonConfig, array_keys($value['son_type']));
  214. foreach ($value['son_type'] as $k => $v) {
  215. if (isset($v['son_type'])) {
  216. $sonConfig = array_merge($sonConfig, array_keys($v['son_type']));
  217. }
  218. }
  219. }
  220. }
  221. return $sonConfig;
  222. }
  223. /**
  224. * 获取单个系统配置
  225. * @param string $configName
  226. * @param null $default
  227. * @return mixed|null
  228. */
  229. public function getConfigValue(string $configName, $default = null)
  230. {
  231. $value = $this->dao->getConfigValue($configName);
  232. return is_null($value) ? $default : json_decode($value, true);
  233. }
  234. /**
  235. * 获取全部配置
  236. * @param array $configName
  237. * @return array
  238. */
  239. public function getConfigAll(array $configName = [])
  240. {
  241. return array_map(function ($item) {
  242. return json_decode($item, true);
  243. }, $this->dao->getConfigAll($configName));
  244. }
  245. /**
  246. * 获取配置并分页
  247. * @param array $where
  248. * @return array
  249. * @throws \think\db\exception\DataNotFoundException
  250. * @throws \think\db\exception\DbException
  251. * @throws \think\db\exception\ModelNotFoundException
  252. */
  253. public function getConfigList(array $where)
  254. {
  255. [$page, $limit] = $this->getPageValue();
  256. $list = $this->dao->getConfigList($where, $page, $limit);
  257. $count = $this->dao->count($where);
  258. $tidy_srr = [];
  259. foreach ($list as &$item) {
  260. $item['value'] = $item['value'] ? json_decode($item['value'], true) ?: '' : '';
  261. if ($item['type'] == 'radio' || $item['type'] == 'checkbox') {
  262. $item['value'] = $this->getRadioOrCheckboxValueInfo($item['menu_name'], $item['value']);
  263. }
  264. if ($item['type'] == 'upload' && !empty($item['value'])) {
  265. if ($item['upload_type'] == 1 || $item['upload_type'] == 3) {
  266. $item['value'] = [set_file_url($item['value'])];
  267. } elseif ($item['upload_type'] == 2) {
  268. $item['value'] = set_file_url($item['value']);
  269. }
  270. foreach ($item['value'] as $key => $value) {
  271. $tidy_srr[$key]['filepath'] = $value;
  272. $tidy_srr[$key]['filename'] = basename($value);
  273. }
  274. $item['value'] = $tidy_srr;
  275. }
  276. }
  277. return compact('count', 'list');
  278. }
  279. /**
  280. * 获取单选按钮或者多选按钮的显示值
  281. * @param $menu_name
  282. * @param $value
  283. * @return string
  284. * @throws \think\db\exception\DataNotFoundException
  285. * @throws \think\db\exception\ModelNotFoundException
  286. * @throws \think\exception\DbException
  287. */
  288. public function getRadioOrCheckboxValueInfo(string $menu_name, $value): string
  289. {
  290. $option = [];
  291. $config_one = $this->dao->getOne(['menu_name' => $menu_name]);
  292. if (!$config_one) {
  293. return '';
  294. }
  295. $parameter = explode("\n", $config_one['parameter']);
  296. foreach ($parameter as $k => $v) {
  297. if (isset($v) && strlen($v) > 0) {
  298. $data = explode('=>', $v);
  299. $option[$data[0]] = $data[1];
  300. }
  301. }
  302. $str = '';
  303. if (is_array($value)) {
  304. foreach ($value as $v) {
  305. $str .= $option[$v] . ',';
  306. }
  307. } else {
  308. $str .= !empty($value) ? $option[$value] ?? '' : $option[0] ?? '';
  309. }
  310. return $str;
  311. }
  312. /**
  313. * 获取系统配置信息
  314. * @param int $tabId
  315. * @return array
  316. * @throws \think\db\exception\DataNotFoundException
  317. * @throws \think\db\exception\DbException
  318. * @throws \think\db\exception\ModelNotFoundException
  319. */
  320. public function getReadList(int $tabId)
  321. {
  322. $info = $this->dao->getConfigTabAllList($tabId);
  323. foreach ($info as $k => $v) {
  324. if (!is_null(json_decode($v['value'])))
  325. $info[$k]['value'] = json_decode($v['value'], true);
  326. if ($v['type'] == 'upload' && !empty($v['value'])) {
  327. if ($v['upload_type'] == 1 || $v['upload_type'] == 3) $info[$k]['value'] = explode(',', $v['value']);
  328. }
  329. }
  330. return $info;
  331. }
  332. /**
  333. * 创建单行表单
  334. * @param string $type
  335. * @param array $data
  336. * @return array
  337. */
  338. public function createTextForm(string $type, array $data)
  339. {
  340. $formbuider = [];
  341. switch ($type) {
  342. case 'input':
  343. $data['value'] = isset($data['value']) ? json_decode($data['value'], true) : '';
  344. $formbuider[] = $this->builder->input($data['menu_name'], $data['info'], $data['value'])->info($data['desc'])->placeholder($data['desc'])->col(13);
  345. break;
  346. case 'number':
  347. $data['value'] = isset($data['value']) ? json_decode($data['value'], true) : 0;
  348. $formbuider[] = $this->builder->number($data['menu_name'], $data['info'], (float)$data['value'])->info($data['desc']);
  349. break;
  350. case 'dateTime':
  351. $formbuider[] = $this->builder->dateTime($data['menu_name'], $data['info'], $data['value'])->info($data['desc']);
  352. break;
  353. case 'color':
  354. $data['value'] = isset($data['value']) ? json_decode($data['value'], true) : '';
  355. $formbuider[] = $this->builder->color($data['menu_name'], $data['info'], $data['value'])->info($data['desc']);
  356. break;
  357. default:
  358. $data['value'] = isset($data['value']) ? json_decode($data['value'], true) : '';
  359. $formbuider[] = $this->builder->input($data['menu_name'], $data['info'], $data['value'])->info($data['desc'])->placeholder($data['desc'])->col(13);
  360. break;
  361. }
  362. return $formbuider;
  363. }
  364. /**
  365. * 创建多行文本框
  366. * @param array $data
  367. * @return mixed
  368. */
  369. public function createTextareaForm(array $data)
  370. {
  371. $data['value'] = json_decode($data['value'], true) ?: '';
  372. $formbuider[] = $this->builder->textarea($data['menu_name'], $data['info'], $data['value'])->placeholder($data['desc'])->info($data['desc'])->rows(6)->col(13);
  373. return $formbuider;
  374. }
  375. /**
  376. * 创建当选表单
  377. * @param array $data
  378. * @param array $control
  379. * @param array $control_two
  380. * @return array
  381. */
  382. public function createRadioForm(array $data, $control = [], $control_two = [])
  383. {
  384. $formbuider = [];
  385. $data['value'] = json_decode($data['value'], true) ?: '0';
  386. $parameter = explode("\n", $data['parameter']);
  387. $options = [];
  388. if ($parameter) {
  389. foreach ($parameter as $v) {
  390. if (strstr($v, $this->cuttingStr) !== false) {
  391. $pdata = explode($this->cuttingStr, $v);
  392. $options[] = ['label' => $pdata[1], 'value' => (int)$pdata[0]];
  393. }
  394. }
  395. $formbuider[] = $radio = $this->builder->radio($data['menu_name'], $data['info'], (int)$data['value'])->options($options)->info($data['desc'])->col(13);
  396. if ($control) {
  397. $radio->appendControl($data['show_value'] ?? 1, is_array($control) ? $control : [$control]);
  398. }
  399. if ($control_two && isset($data['show_value2'])) {
  400. $radio->appendControl($data['show_value2'] ?? 2, is_array($control_two) ? $control_two : [$control_two]);
  401. }
  402. return $formbuider;
  403. }
  404. }
  405. /**
  406. * 创建上传组件表单
  407. * @param int $type
  408. * @param array $data
  409. * @return array
  410. */
  411. public function createUploadForm(int $type, array $data)
  412. {
  413. $formbuider = [];
  414. switch ($type) {
  415. case 1:
  416. $data['value'] = json_decode($data['value'], true) ?: '';
  417. if ($data['value'] != '') $data['value'] = set_file_url($data['value']);
  418. $formbuider[] = $this->builder->frameImage($data['menu_name'], $data['info'], $this->url('admin/widget.images/index', ['fodder' => $data['menu_name']], true), $data['value'])
  419. ->icon('ios-image')->width('950px')->height('505px')->modal(['footer-hide' => true])->info($data['desc'])->col(13);
  420. break;
  421. case 2:
  422. $data['value'] = json_decode($data['value'], true) ?: [];
  423. if ($data['value'])
  424. $data['value'] = set_file_url($data['value']);
  425. $formbuider[] = $this->builder->frameImages($data['menu_name'], $data['info'], $this->url('admin/widget.images/index', ['fodder' => $data['menu_name'], 'type' => 'many', 'maxLength' => 5], true), $data['value'])
  426. ->maxLength(5)->icon('ios-images')->width('950px')->height('505px')->modal(['footer-hide' => true])
  427. ->info($data['desc'])->col(13);
  428. break;
  429. case 3:
  430. $data['value'] = json_decode($data['value'], true) ?: '';
  431. if ($data['value'] != '') $data['value'] = set_file_url($data['value']);
  432. $formbuider[] = $this->builder->uploadFile($data['menu_name'], $data['info'], $this->url('/adminapi/file/upload/1', ['type' => 1], false, true), $data['value'])
  433. ->name('file')->info($data['desc'])->col(13)->data(['menu_name' => $data['menu_name']])->headers([
  434. 'Authori-zation' => app()->request->header('Authori-zation'),
  435. ]);
  436. break;
  437. }
  438. return $formbuider;
  439. }
  440. /**
  441. * 创建单选框
  442. * @param array $data
  443. * @return array
  444. * @throws \FormBuilder\Exception\FormBuilderException
  445. */
  446. public function createCheckboxForm(array $data)
  447. {
  448. $formbuider = [];
  449. $data['value'] = json_decode($data['value'], true) ?: [];
  450. $parameter = explode("\n", $data['parameter']);
  451. $options = [];
  452. if ($parameter) {
  453. foreach ($parameter as $v) {
  454. if (strstr($v, $this->cuttingStr) !== false) {
  455. $pdata = explode($this->cuttingStr, $v);
  456. $options[] = ['label' => $pdata[1], 'value' => $pdata[0]];
  457. }
  458. }
  459. $formbuider[] = $this->builder->checkbox($data['menu_name'], $data['info'], $data['value'])->options($options)->info($data['desc'])->col(13);
  460. }
  461. return $formbuider;
  462. }
  463. /**
  464. * 创建选择框表单
  465. * @param array $data
  466. * @return array
  467. * @throws \FormBuilder\Exception\FormBuilderException
  468. */
  469. public function createSelectForm(array $data)
  470. {
  471. $formbuider = [];
  472. $data['value'] = json_decode($data['value'], true) ?: [];
  473. $parameter = explode("\n", $data['parameter']);
  474. $options = [];
  475. if ($parameter) {
  476. foreach ($parameter as $v) {
  477. if (strstr($v, $this->cuttingStr) !== false) {
  478. $pdata = explode($this->cuttingStr, $v);
  479. $options[] = ['label' => $pdata[1], 'value' => $pdata[0]];
  480. }
  481. }
  482. $formbuider[] = $this->builder->select($data['menu_name'], $data['info'], $data['value'])->options($options)->info($data['desc'])->col(13);
  483. }
  484. return $formbuider;
  485. }
  486. /**
  487. * 创建颜色选择器
  488. * @param array $data
  489. * @return mixed
  490. */
  491. public function createColorForm(array $data)
  492. {
  493. $data['value'] = json_decode($data['value'], true) ?: '';
  494. $formbuider[] = $this->builder->color($data['menu_name'], $data['info'], $data['value'])->info($data['desc'])->col(13);
  495. return $formbuider;
  496. }
  497. public function bindBuilderData($data, $relatedRule)
  498. {
  499. if (!$data) return false;
  500. $p_list = array();
  501. foreach ($relatedRule as $rk => $rv) {
  502. $p_list[$rk] = $data[$rk];
  503. if (isset($rv['son_type']) && is_array($rv['son_type'])) {
  504. foreach ($rv['son_type'] as $sk => $sv) {
  505. if (is_array($sv) && isset($sv['son_type'])) {
  506. foreach ($sv['son_type'] as $ssk => $ssv) {
  507. $tmp = $data[$sk];
  508. $tmp['console'] = $data[$ssk];
  509. $p_list[$rk]['console'][] = $tmp;
  510. }
  511. } else {
  512. $p_list[$rk]['console'][] = $data[$sk];
  513. }
  514. }
  515. }
  516. }
  517. return array_values($p_list);
  518. }
  519. /**
  520. * 获取系统配置表单
  521. * @param int $id
  522. * @param array $formData
  523. * @return array
  524. * @throws \think\db\exception\DataNotFoundException
  525. * @throws \think\db\exception\DbException
  526. * @throws \think\db\exception\ModelNotFoundException
  527. */
  528. public function formTypeShine($data, $control = false, $controle_two = [])
  529. {
  530. switch ($data['type']) {
  531. case 'text'://文本框
  532. return $this->createTextForm($data['input_type'], $data);
  533. case 'radio'://单选框
  534. return $this->createRadioForm($data, $control, $controle_two);
  535. case 'textarea'://多行文本框
  536. return $this->createTextareaForm($data);
  537. case 'upload'://文件上传
  538. return $this->createUploadForm((int)$data['upload_type'], $data);
  539. case 'checkbox'://多选框
  540. return $this->createCheckboxForm($data);
  541. case 'select'://多选框
  542. return $this->createSelectForm($data);
  543. case 'color':
  544. return $this->createColorForm($data);
  545. }
  546. }
  547. /**
  548. * @param int $tabId
  549. * @param array $formData
  550. * @param array $relatedRule
  551. * @return array|bool
  552. * @throws \think\db\exception\DataNotFoundException
  553. * @throws \think\db\exception\DbException
  554. * @throws \think\db\exception\ModelNotFoundException
  555. */
  556. public function createConfigForm(int $tabId, array $relatedRule)
  557. {
  558. $list = $this->dao->getConfigTabAllList($tabId);
  559. if (!$relatedRule) {
  560. $formbuider = $this->createNoCrontrolForm($list);
  561. } else {
  562. $formbuider = $this->createBindCrontrolForm($list, $relatedRule);
  563. }
  564. return $formbuider;
  565. }
  566. /**
  567. * 创建
  568. * @param array $list
  569. * @return array
  570. * @throws \FormBuilder\Exception\FormBuilderException
  571. * @throws \think\db\exception\DataNotFoundException
  572. * @throws \think\db\exception\DbException
  573. * @throws \think\db\exception\ModelNotFoundException
  574. */
  575. public function createForm(array $list)
  576. {
  577. if (!$list) return [];
  578. $list = array_combine(array_column($list, 'menu_name'), $list);
  579. $formbuider = [];
  580. $relateRule = $this->relatedRule;
  581. $sonConfig = $this->getSonConfig();
  582. foreach ($list as $key => $data) {
  583. if (in_array($key, $sonConfig)) {
  584. continue;
  585. }
  586. switch ($data['type']) {
  587. case 'text'://文本框
  588. $formbuider = array_merge($formbuider, $this->createTextForm($data['input_type'], $data));
  589. break;
  590. case 'radio'://单选框
  591. $builder = [];
  592. if (isset($relateRule[$key])) {
  593. $role = $relateRule[$key];
  594. $data['show_value'] = $role['show_value'];
  595. foreach ($role['son_type'] as $sk => $sv) {
  596. if (isset($list[$sk])) {
  597. $son_data = $list[$sk];
  598. $son_data['show_value'] = $role['show_value'];
  599. $son_build = [];
  600. if (isset($sv['son_type'])) {
  601. foreach ($sv['son_type'] as $ssk => $ssv) {
  602. $son_data['show_value'] = $sv['show_value'];
  603. $son_build[] = $this->formTypeShine($list[$ssk])[0];
  604. unset($list[$ssk]);
  605. }
  606. }
  607. $son_build_two = [];
  608. if (isset($role['son_type'][$sk . '@'])) {
  609. $son_type_two = $role['son_type'][$sk . '@'];
  610. $son_data['show_value2'] = $son_type_two['show_value'];
  611. if (isset($son_type_two['son_type'])) {
  612. foreach ($son_type_two['son_type'] as $ssk => $ssv) {
  613. if (isset($list[$ssk]['menu_name']) && $list[$ssk]['menu_name'] == 'watermark_text_color') $list[$ssk]['type'] = 'color';
  614. $son_build_two[] = $this->formTypeShine($list[$ssk])[0];
  615. unset($list[$ssk]);
  616. }
  617. }
  618. }
  619. $builder[] = $this->formTypeShine($son_data, $son_build, $son_build_two)[0];
  620. unset($list[$sk]);
  621. }
  622. }
  623. $data['show_value'] = $role['show_value'];
  624. }
  625. $builder_two = [];
  626. if (isset($relateRule[$key . '@'])) {
  627. $role = $relateRule[$key . '@'];
  628. $data['show_value2'] = $role['show_value'];
  629. foreach ($role['son_type'] as $sk => $sv) {
  630. $son_data = $list[$sk];
  631. $son_data['show_value'] = $role['show_value'];
  632. $builder_two[] = $this->formTypeShine($son_data)[0];
  633. }
  634. }
  635. $formbuider = array_merge($formbuider, $this->createRadioForm($data, $builder, $builder_two));
  636. break;
  637. case 'textarea'://多行文本框
  638. $formbuider = array_merge($formbuider, $this->createTextareaForm($data));
  639. break;
  640. case 'upload'://文件上传
  641. $formbuider = array_merge($formbuider, $this->createUploadForm((int)$data['upload_type'], $data));
  642. break;
  643. case 'checkbox'://多选框
  644. $formbuider = array_merge($formbuider, $this->createCheckboxForm($data));
  645. break;
  646. case 'select'://多选框
  647. $formbuider = array_merge($formbuider, $this->createSelectForm($data));
  648. break;
  649. }
  650. }
  651. return $formbuider;
  652. }
  653. /**无组件绑定规则
  654. * @param array $list
  655. * @return array|bool
  656. * @throws \FormBuilder\Exception\FormBuilderException
  657. * @throws \think\db\exception\DataNotFoundException
  658. * @throws \think\db\exception\DbException
  659. * @throws \think\db\exception\ModelNotFoundException
  660. */
  661. public function createNoCrontrolForm(array $list)
  662. {
  663. if (!$list) return false;
  664. $formbuider = [];
  665. foreach ($list as $key => $data) {
  666. switch ($data['type']) {
  667. case 'text'://文本框
  668. $formbuider = array_merge($formbuider, $this->createTextForm($data['input_type'], $data));
  669. break;
  670. case 'radio'://单选框
  671. $formbuider = array_merge($formbuider, $this->createRadioForm($data));
  672. break;
  673. case 'textarea'://多行文本框
  674. $formbuider = array_merge($formbuider, $this->createTextareaForm($data));
  675. break;
  676. case 'upload'://文件上传
  677. $formbuider = array_merge($formbuider, $this->createUploadForm((int)$data['upload_type'], $data));
  678. break;
  679. case 'checkbox'://多选框
  680. $formbuider = array_merge($formbuider, $this->createCheckboxForm($data));
  681. break;
  682. case 'select'://多选框
  683. $formbuider = array_merge($formbuider, $this->createSelectForm($data));
  684. break;
  685. }
  686. }
  687. return $formbuider;
  688. }
  689. /**
  690. * 有组件绑定规则
  691. * @param array $list
  692. * @param array $relatedRule
  693. * @return array|bool
  694. * @throws \FormBuilder\Exception\FormBuilderException
  695. * @throws \think\db\exception\DataNotFoundException
  696. * @throws \think\db\exception\DbException
  697. * @throws \think\db\exception\ModelNotFoundException
  698. */
  699. public function createBindCrontrolForm(array $list, array $relatedRule)
  700. {
  701. if (!$list || !$relatedRule) return false;
  702. $formbuider = [];
  703. $new_data = array();
  704. foreach ($list as $dk => $dv) {
  705. $new_data[$dv['menu_name']] = $dv;
  706. }
  707. foreach ($relatedRule as $rk => $rv) {
  708. if (isset($rv['son_type'])) {
  709. $data = $new_data[$rk];
  710. switch ($data['type']) {
  711. case 'text'://文本框
  712. $formbuider = array_merge($formbuider, $this->createTextForm($data['input_type'], $data));
  713. break;
  714. case 'radio'://单选框
  715. $son_builder = array();
  716. foreach ($rv['son_type'] as $sk => $sv) {
  717. if (isset($sv['son_type'])) {
  718. foreach ($sv['son_type'] as $ssk => $ssv) {
  719. $son_data = $new_data[$sk];
  720. $son_data['show_value'] = $sv['show_value'];
  721. $son_builder[] = $this->formTypeShine($son_data, $this->formTypeShine($new_data[$ssk])[0])[0];
  722. }
  723. } else {
  724. $son_data = $new_data[$sk];
  725. $son_data['show_value'] = $rv['show_value'];
  726. $son_builder[] = $this->formTypeShine($son_data)[0];
  727. }
  728. }
  729. $formbuider = array_merge($formbuider, $this->createRadioForm($data, $son_builder));
  730. break;
  731. case 'textarea'://多行文本框
  732. $formbuider = array_merge($formbuider, $this->createTextareaForm($data));
  733. break;
  734. case 'upload'://文件上传
  735. $formbuider = array_merge($formbuider, $this->createUploadForm((int)$data['upload_type'], $data));
  736. break;
  737. case 'checkbox'://多选框
  738. $formbuider = array_merge($formbuider, $this->createCheckboxForm($data));
  739. break;
  740. case 'select'://多选框
  741. $formbuider = array_merge($formbuider, $this->createSelectForm($data));
  742. break;
  743. }
  744. }
  745. }
  746. return $formbuider;
  747. }
  748. /**
  749. * 系统配置form表单创建
  750. * @param int $tabId
  751. * @return array
  752. * @throws \FormBuilder\Exception\FormBuilderException
  753. * @throws \think\db\exception\DataNotFoundException
  754. * @throws \think\db\exception\DbException
  755. * @throws \think\db\exception\ModelNotFoundException
  756. */
  757. public function getConfigForm($url, int $tabId)
  758. {
  759. /** @var SystemConfigTabServices $service */
  760. $service = app()->make(SystemConfigTabServices::class);
  761. $title = $service->value(['id' => $tabId], 'title');
  762. $list = $this->dao->getConfigTabAllList($tabId);
  763. $formbuider = $this->createForm($list);
  764. $name = 'setting';
  765. if ($url) {
  766. $name = explode('/', $url)[2] ?? $name;
  767. }
  768. $postUrl = $this->postUrl[$name]['url'] ?? '/setting/config/save_basics';
  769. return create_form($title, $formbuider, $this->url($postUrl), 'POST');
  770. }
  771. /**
  772. * 新增路由增加设置项验证
  773. * @param $url
  774. * @param $post
  775. * @return bool
  776. */
  777. public function checkParam($url, $post)
  778. {
  779. $name = '';
  780. if ($url) {
  781. $name = explode('/', $url)[2] ?? $name;
  782. }
  783. $auth = $this->postUrl[$name]['auth'] ?? false;
  784. if ($auth === false) {
  785. throw new AdminException(400601);
  786. }
  787. if ($auth) {
  788. /** @var SystemConfigTabServices $systemConfigTabServices */
  789. $systemConfigTabServices = app()->make(SystemConfigTabServices::class);
  790. foreach ($post as $key => $value) {
  791. $tab_ids = $systemConfigTabServices->getColumn([['eng_title', 'IN', $auth]], 'id');
  792. if (!$tab_ids || !in_array($key, $this->dao->getColumn([['config_tab_id', 'IN', $tab_ids]], 'menu_name'))) {
  793. throw new AdminException(400602);
  794. }
  795. }
  796. }
  797. return true;
  798. }
  799. /**
  800. * 修改配置获取form表单
  801. * @param int $id
  802. * @return array
  803. * @throws \FormBuilder\Exception\FormBuilderException
  804. * @throws \think\db\exception\DataNotFoundException
  805. * @throws \think\db\exception\DbException
  806. * @throws \think\db\exception\ModelNotFoundException
  807. */
  808. public function editConfigForm(int $id)
  809. {
  810. $menu = $this->dao->get($id)->getData();
  811. if (!$menu) {
  812. throw new AdminException(100026);
  813. }
  814. /** @var SystemConfigTabServices $service */
  815. $service = app()->make(SystemConfigTabServices::class);
  816. $formbuider = [];
  817. $formbuider[] = $this->builder->input('menu_name', '字段变量', $menu['menu_name'])->disabled(1);
  818. $formbuider[] = $this->builder->hidden('type', $menu['type']);
  819. $formbuider[] = $this->builder->select('config_tab_id', '分类', (int)$menu['config_tab_id'])->setOptions($service->getSelectForm());
  820. $formbuider[] = $this->builder->input('info', '配置名称', $menu['info'])->autofocus(1);
  821. $formbuider[] = $this->builder->input('desc', '配置简介', $menu['desc']);
  822. switch ($menu['type']) {
  823. case 'text':
  824. $menu['value'] = json_decode($menu['value'], true);
  825. $formbuider[] = $this->builder->select('input_type', '类型', $menu['input_type'])->setOptions([
  826. ['value' => 'input', 'label' => '文本框']
  827. , ['value' => 'dateTime', 'label' => '时间']
  828. , ['value' => 'color', 'label' => '颜色']
  829. , ['value' => 'number', 'label' => '数字']
  830. ]);
  831. //输入框验证规则
  832. $formbuider[] = $this->builder->input('value', '默认值', $menu['value']);
  833. if (!empty($menu['required'])) {
  834. $formbuider[] = $this->builder->number('width', '文本框宽(%)', (int)$menu['width']);
  835. $formbuider[] = $this->builder->input('required', '验证规则', $menu['required'])->placeholder('多个请用,隔开例如:required:true,url:true');
  836. }
  837. break;
  838. case 'textarea':
  839. $menu['value'] = json_decode($menu['value'], true);
  840. //多行文本
  841. if (!empty($menu['high'])) {
  842. $formbuider[] = $this->builder->textarea('value', '默认值', $menu['value'])->rows(5);
  843. $formbuider[] = $this->builder->number('width', '文本框宽(%)', (int)$menu['width']);
  844. $formbuider[] = $this->builder->number('high', '多行文本框高(%)', (int)$menu['high']);
  845. } else {
  846. $formbuider[] = $this->builder->input('value', '默认值', $menu['value']);
  847. }
  848. break;
  849. case 'radio':
  850. $formbuider = array_merge($formbuider, $this->createRadioForm($menu));
  851. //单选和多选参数配置
  852. if (!empty($menu['parameter'])) {
  853. $formbuider[] = $this->builder->textarea('parameter', '配置参数', $menu['parameter'])->placeholder("参数方式例如:\n1=>白色\n2=>红色\n3=>黑色");
  854. }
  855. break;
  856. case 'checkbox':
  857. $formbuider = array_merge($formbuider, $this->createCheckboxForm($menu));
  858. //单选和多选参数配置
  859. if (!empty($menu['parameter'])) {
  860. $formbuider[] = $this->builder->textarea('parameter', '配置参数', $menu['parameter'])->placeholder("参数方式例如:\n1=>白色\n2=>红色\n3=>黑色");
  861. }
  862. break;
  863. case 'upload':
  864. $formbuider = array_merge($formbuider, $this->createUploadForm(($menu['upload_type']), $menu));
  865. //上传类型选择
  866. if (!empty($menu['upload_type'])) {
  867. $formbuider[] = $this->builder->radio('upload_type', '上传类型', $menu['upload_type'])->options([['value' => 1, 'label' => '单图'], ['value' => 2, 'label' => '多图'], ['value' => 3, 'label' => '文件']]);
  868. }
  869. break;
  870. }
  871. $formbuider[] = $this->builder->number('sort', '排序', (int)$menu['sort']);
  872. $formbuider[] = $this->builder->radio('status', '状态', $menu['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 2, 'label' => '隐藏']]);
  873. return create_form('编辑字段', $formbuider, $this->url('/setting/config/' . $id), 'PUT');
  874. }
  875. /**
  876. * 字段状态
  877. * @return array
  878. */
  879. public function formStatus(): array
  880. {
  881. return [['value' => 1, 'label' => '显示'], ['value' => 2, 'label' => '隐藏']];
  882. }
  883. /**
  884. * 选择文文件类型
  885. * @return array
  886. */
  887. public function uploadType(): array
  888. {
  889. return [
  890. ['value' => 1, 'label' => '单图']
  891. , ['value' => 2, 'label' => '多图']
  892. , ['value' => 3, 'label' => '文件']
  893. ];
  894. }
  895. /**
  896. * 选择文本框类型
  897. * @return array
  898. */
  899. public function textType(): array
  900. {
  901. return [
  902. ['value' => 'input', 'label' => '文本框']
  903. , ['value' => 'dateTime', 'label' => '时间']
  904. , ['value' => 'color', 'label' => '颜色']
  905. , ['value' => 'number', 'label' => '数字']
  906. ];
  907. }
  908. /**
  909. * 获取创建配置规格表单
  910. * @param int $type
  911. * @param int $tab_id
  912. * @return array
  913. */
  914. public function createFormRule(int $type, int $tab_id): array
  915. {
  916. /** @var SystemConfigTabServices $service */
  917. $service = app()->make(SystemConfigTabServices::class);
  918. $formbuider = [];
  919. $form_type = '';
  920. $info_type = [];
  921. $parameter = [];
  922. switch ($type) {
  923. case 0://文本框
  924. $form_type = 'text';
  925. $info_type = $this->builder->select('input_type', '类型')->setOptions($this->textType());
  926. $parameter[] = $this->builder->input('value', '默认值');
  927. $parameter[] = $this->builder->number('width', '文本框宽(%)', 100);
  928. $parameter[] = $this->builder->input('required', '验证规则')->placeholder('多个请用,隔开例如:required:true,url:true');
  929. break;
  930. case 1://多行文本框
  931. $form_type = 'textarea';
  932. $parameter[] = $this->builder->textarea('value', '默认值');
  933. $parameter[] = $this->builder->number('width', '文本框宽(%)', 100);
  934. $parameter[] = $this->builder->number('high', '多行文本框高(%)', 5);
  935. break;
  936. case 2://单选框
  937. $form_type = 'radio';
  938. $parameter[] = $this->builder->textarea('parameter', '配置参数')->placeholder("参数方式例如:\n1=>男\n2=>女\n3=>保密");
  939. $parameter[] = $this->builder->input('value', '默认值');
  940. break;
  941. case 3://文件上传
  942. $form_type = 'upload';
  943. $parameter[] = $this->builder->radio('upload_type', '上传类型', 1)->options($this->uploadType());
  944. break;
  945. case 4://多选框
  946. $form_type = 'checkbox';
  947. $parameter[] = $this->builder->textarea('parameter', '配置参数')->placeholder("参数方式例如:\n1=>白色\n2=>红色\n3=>黑色");
  948. break;
  949. case 5://下拉框
  950. $form_type = 'select';
  951. $parameter[] = $this->builder->textarea('parameter', '配置参数')->placeholder("参数方式例如:\n1=>白色\n2=>红色\n3=>黑色");
  952. break;
  953. }
  954. if ($form_type) {
  955. $formbuider[] = $this->builder->hidden('type', $form_type);
  956. $formbuider[] = $this->builder->select('config_tab_id', '分类', $tab_id)->setOptions($service->getSelectForm());
  957. if ($info_type) {
  958. $formbuider[] = $info_type;
  959. }
  960. $formbuider[] = $this->builder->input('info', '配置名称')->autofocus(1);
  961. $formbuider[] = $this->builder->input('menu_name', '字段变量')->placeholder('例如:site_url');
  962. $formbuider[] = $this->builder->input('desc', '配置简介');
  963. $formbuider = array_merge($formbuider, $parameter);
  964. $formbuider[] = $this->builder->number('sort', '排序', 0);
  965. $formbuider[] = $this->builder->radio('status', '状态', 1)->options($this->formStatus());
  966. }
  967. return create_form('添加字段', $formbuider, $this->url('/setting/config'), 'POST');
  968. }
  969. /**
  970. * radio 和 checkbox规则的判断
  971. * @param $data
  972. * @return bool
  973. */
  974. public function valiDateRadioAndCheckbox($data)
  975. {
  976. $option = [];
  977. $option_new = [];
  978. $data['parameter'] = str_replace("\r\n", "\n", $data['parameter']);//防止不兼容
  979. $parameter = explode("\n", $data['parameter']);
  980. if (count($parameter) < 2) {
  981. throw new AdminException(400603);
  982. }
  983. foreach ($parameter as $k => $v) {
  984. if (isset($v) && !empty($v)) {
  985. $option[$k] = explode('=>', $v);
  986. }
  987. }
  988. if (count($option) < 2) {
  989. throw new AdminException(400603);
  990. }
  991. $bool = 1;
  992. foreach ($option as $k => $v) {
  993. $option_new[$k] = $option[$k][0];
  994. foreach ($v as $kk => $vv) {
  995. $vv_num = strlen($vv);
  996. if (!$vv_num) {
  997. $bool = 0;
  998. }
  999. }
  1000. }
  1001. if (!$bool) {
  1002. throw new AdminException(400603);
  1003. }
  1004. $num1 = count($option_new);//提取该数组的数目
  1005. $arr2 = array_unique($option_new);//合并相同的元素
  1006. $num2 = count($arr2);//提取合并后数组个数
  1007. if ($num1 > $num2) {
  1008. throw new AdminException(400603);
  1009. }
  1010. return true;
  1011. }
  1012. /**
  1013. * 验证参数
  1014. * @param $data
  1015. * @return bool
  1016. */
  1017. public function valiDateValue($data)
  1018. {
  1019. if (!$data || !isset($data['required']) || !$data['required']) {
  1020. return true;
  1021. }
  1022. $valids = explode(',', $data['required']);
  1023. foreach ($valids as $valid) {
  1024. $valid = explode(':', $valid);
  1025. if (isset($valid[0]) && isset($valid[1])) {
  1026. $k = strtolower(trim($valid[0]));
  1027. $v = strtolower(trim($valid[1]));
  1028. switch ($k) {
  1029. case 'required':
  1030. if ($v == 'true' && $data['value'] === '') {
  1031. throw new AdminException(400604, ['name' => $data['info'] ?? '']);
  1032. }
  1033. break;
  1034. case 'url':
  1035. if ($v == 'true' && !check_link($data['value'])) {
  1036. throw new AdminException(400605, ['name' => $data['info'] ?? '']);
  1037. }
  1038. break;
  1039. }
  1040. }
  1041. }
  1042. }
  1043. /**保存平台电子面单打印信息
  1044. * @param array $data
  1045. * @return bool
  1046. */
  1047. public function saveExpressInfo(array $data)
  1048. {
  1049. if (!is_array($data) || !$data) return false;
  1050. // config_export_id 快递公司id
  1051. // config_export_temp_id 快递公司模板id
  1052. // config_export_com 快递公司编码
  1053. // config_export_to_name 发货人姓名
  1054. // config_export_to_tel 发货人电话
  1055. // config_export_to_address 发货人详细地址
  1056. // config_export_siid 电子面单打印机编号
  1057. foreach ($data as $key => $value) {
  1058. $this->dao->update(['menu_name' => 'config_export_' . $key], ['value' => json_encode($value)]);
  1059. }
  1060. \crmeb\services\CacheService::clear();
  1061. return true;
  1062. }
  1063. /**
  1064. * 获取分享海报 兼容方法
  1065. */
  1066. public function getSpreadBanner()
  1067. {
  1068. //配置
  1069. $banner = sys_config('spread_banner', []);
  1070. if (!$banner) {
  1071. //组合数据
  1072. $banner = sys_data('routine_spread_banner');
  1073. if ($banner) {
  1074. $banner = array_column($banner, 'pic');
  1075. $this->dao->update(['menu_name' => 'spread_banner'], ['value' => json_encode($banner)]);
  1076. \crmeb\services\CacheService::clear();
  1077. }
  1078. }
  1079. return $banner;
  1080. }
  1081. /**
  1082. * 保存wss配置
  1083. * @param int $wssOpen
  1084. * @param string $wssLocalpk
  1085. * @param string $wssLocalCert
  1086. */
  1087. public function saveSslFilePath(int $wssOpen, string $wssLocalpk, string $wssLocalCert)
  1088. {
  1089. $wssFile = root_path() . '.wss';
  1090. $content = <<<WSS
  1091. wssOpen = $wssOpen
  1092. wssLocalpk = $wssLocalpk
  1093. wssLocalCert = $wssLocalCert
  1094. WSS;
  1095. try {
  1096. file_put_contents($wssFile, $content);
  1097. } catch (\Throwable $e) {
  1098. throw new AdminException(400606);
  1099. }
  1100. }
  1101. /**
  1102. * 获取wss配置
  1103. * @param string $key
  1104. * @return array|false|mixed
  1105. */
  1106. public function getSslFilePath(string $key = '')
  1107. {
  1108. $wssFile = root_path() . '.wss';
  1109. try {
  1110. $content = parse_ini_file($wssFile);
  1111. } catch (\Throwable $e) {
  1112. $content = [];
  1113. }
  1114. return $content[$key] ?? $content;
  1115. }
  1116. /**
  1117. * 检测缩略图水印配置是否更改
  1118. * @param array $post
  1119. * @return bool
  1120. */
  1121. public function checkThumbParam(array $post)
  1122. {
  1123. unset($post['upload_type'], $post['image_watermark_status']);
  1124. /** @var SystemConfigTabServices $systemConfigTabServices */
  1125. $systemConfigTabServices = app()->make(SystemConfigTabServices::class);
  1126. //上传配置->基础配置
  1127. $tab_id = $systemConfigTabServices->getColumn(['eng_title' => 'base_config'], 'id');
  1128. if ($tab_id) {
  1129. $all = $this->dao->getColumn(['config_tab_id' => $tab_id], 'value', 'menu_name');
  1130. if (array_intersect(array_keys($all), array_keys($post))) {
  1131. foreach ($post as $key => $item) {
  1132. //配置更改删除原来生成的缩略图
  1133. if (isset($all[$key]) && $item != json_decode($all[$key], true)) {
  1134. try {
  1135. FileService::delDir(public_path('uploads/thumb_water'));
  1136. break;
  1137. } catch (\Throwable $e) {
  1138. }
  1139. }
  1140. }
  1141. }
  1142. }
  1143. return true;
  1144. }
  1145. /**
  1146. * 变更分销绑定关系模式
  1147. * @param array $post
  1148. * @return bool
  1149. */
  1150. public function checkBrokerageBinding(array $post)
  1151. {
  1152. try {
  1153. $config_data = $post['store_brokerage_binding_status'];
  1154. $config_one = $this->dao->getOne(['menu_name' => 'store_brokerage_binding_status']);
  1155. $config_old = json_decode($config_one['value'], true);
  1156. if ($config_old != 2 && $config_data == 2) {
  1157. //自动解绑上级绑定
  1158. /** @var AgentManageServices $agentManage */
  1159. $agentManage = app()->make(AgentManageServices::class);
  1160. $agentManage->resetSpreadTime();
  1161. }
  1162. } catch (\Throwable $e) {
  1163. Log::error('变更分销绑定模式重置绑定时间失败,失败原因:' . $e->getMessage());
  1164. return false;
  1165. }
  1166. return true;
  1167. }
  1168. }