123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 客户模块设置
  4. // +----------------------------------------------------------------------
  5. // | Author: Michael_xu | gengxiaoxu@5kcrm.com
  6. // +----------------------------------------------------------------------
  7. namespace app\crm\controller;
  8. use app\admin\controller\ApiCommon;
  9. use app\admin\model\Message;
  10. use think\Hook;
  11. use think\Request;
  12. use think\Db;
  13. class Setting extends ApiCommon
  14. {
  15. /**
  16. * 用于判断权限
  17. * @permission 无限制
  18. * @allow 登录用户可访问
  19. * @other 其他根据系统设置
  20. **/
  21. public function _initialize()
  22. {
  23. $action = [
  24. 'permission' => [''],
  25. 'allow' => [
  26. 'config', 'configdata', 'team', 'teamsave', 'contractday', 'recordlist', 'recordedit', 'customerconfiglist',
  27. 'customerconfigsave', 'customerconfigupdate', 'customerconfigdelete', 'numberSequenceAdd', 'quitteam',
  28. 'setvisitday', 'getvisitday', 'setnumber', 'customerconfigdel', 'numbersequencelist',
  29. ]
  30. ];
  31. Hook::listen('check_auth', $action);
  32. $request = Request::instance();
  33. $a = strtolower($request->action());
  34. if (!in_array($a, $action['permission'])) {
  35. parent::_initialize();
  36. }
  37. }
  38. /**
  39. * 客户相关配置
  40. *
  41. * @return \think\response\Json
  42. */
  43. public function config()
  44. {
  45. //权限判断
  46. if (!checkPerByAction('admin', 'crm', 'pool')) {
  47. header('Content-Type:application/json; charset=utf-8');
  48. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  49. }
  50. $configModel = model('ConfigData');
  51. $param = $this->param;
  52. if ((int)$param['follow_day'] > (int)$param['deal_day']) {
  53. return resultArray(['error' => '成交设置时长不能大于跟进设置时长']);
  54. }
  55. $res = $configModel->createData($param);
  56. if ($res) {
  57. return resultArray(['data' => '设置成功']);
  58. } else {
  59. return resultArray(['error' => $configModel->getError()]);
  60. }
  61. }
  62. /**
  63. * 客户相关配置(详情)
  64. *
  65. * @return \think\response\Json
  66. */
  67. public function configData()
  68. {
  69. $configModel = model('ConfigData');
  70. $data = $configModel->getData();
  71. return resultArray(['data' => $data]);
  72. }
  73. /**
  74. * 相关团队列表
  75. *
  76. * @return \think\response\Json
  77. * @throws \think\db\exception\DataNotFoundException
  78. * @throws \think\db\exception\ModelNotFoundException
  79. * @throws \think\exception\DbException
  80. */
  81. public function team()
  82. {
  83. $param = $this->param;
  84. $userModel = new \app\admin\model\User();
  85. if (!$param['types'] || !$param['types_id']) {
  86. return resultArray(['error' => '参数错误']);
  87. }
  88. switch ($param['types']) {
  89. case 'crm_leads' :
  90. $dataModel = new \app\crm\model\Leads();
  91. break;
  92. case 'crm_customer' :
  93. $dataModel = new \app\crm\model\Customer();
  94. break;
  95. case 'crm_contacts' :
  96. $dataModel = new \app\crm\model\Contacts();
  97. break;
  98. case 'crm_business' :
  99. $dataModel = new \app\crm\model\Business();
  100. break;
  101. case 'crm_contract' :
  102. $dataModel = new \app\crm\model\Contract();
  103. break;
  104. }
  105. $resData = $dataModel->getDataById($param['types_id']);
  106. $ro_user_ids = $resData['ro_user_id'] ? array_filter(explode(',', $resData['ro_user_id'])) : []; //只读权限
  107. $rw_user_ids = $resData['rw_user_id'] ? array_filter(explode(',', $resData['rw_user_id'])) : []; //读写权限
  108. $ro_user_arr = [];
  109. $rw_user_arr = [];
  110. $owner_user_arr = ['1' => ['user_id' => $resData['owner_user_id'], 'type' => 0, 'group_name' => '负责人', 'authority' => '负责人权限']]; //负责人
  111. //转换为二维数组
  112. foreach ($ro_user_ids as $k => $v) {
  113. $ro_user_arr[$k]['user_id'] = $v;
  114. $ro_user_arr[$k]['type'] = 1;
  115. $ro_user_arr[$k]['group_name'] = '普通成员';
  116. $ro_user_arr[$k]['authority'] = '只读';
  117. }
  118. foreach ($rw_user_ids as $k => $v) {
  119. $rw_user_arr[$k]['user_id'] = $v;
  120. $rw_user_arr[$k]['type'] = 2;
  121. $rw_user_arr[$k]['group_name'] = '普通成员';
  122. $rw_user_arr[$k]['authority'] = '读写';
  123. }
  124. $user_list = array_merge($owner_user_arr, $rw_user_arr, $ro_user_arr);
  125. $new_user_list = [];
  126. foreach ($user_list as $k => $v) {
  127. if ($v['user_id']) {
  128. $userInfo = [];
  129. $userInfo = $userModel->getUserById($v['user_id']) ?: [];
  130. $userInfo['group_name'] = $v['group_name'];
  131. $userInfo['authority'] = $v['authority'];
  132. $userInfo['type'] = $v['type'];
  133. $new_user_list[] = $userInfo;
  134. }
  135. }
  136. return resultArray(['data' => $new_user_list]);
  137. }
  138. /**
  139. * 退出团队
  140. *
  141. * @return \think\response\Json
  142. * @throws \think\Exception
  143. * @throws \think\db\exception\DataNotFoundException
  144. * @throws \think\db\exception\ModelNotFoundException
  145. * @throws \think\exception\DbException
  146. * @throws \think\exception\PDOException
  147. */
  148. public function quitTeam()
  149. {
  150. if (empty($this->param['types']) || empty($this->param['types_id'])) return resultArray(['error' => '参数错误']);
  151. if (!in_array($this->param['types'], ['crm_customer', 'crm_contacts', 'crm_business', 'crm_contract'])) {
  152. return resultArray(['error' => '参数错误']);
  153. }
  154. $userId = $this->userInfo['id'];
  155. $primaryKey = ['crm_customer' => 'customer_id', 'crm_contacts' => 'contacts_id', 'crm_business' => 'business_id', 'crm_contract' => 'contract_id'];
  156. $data = Db::name($this->param['types'])->field([$primaryKey[$this->param['types']], 'ro_user_id', 'rw_user_id', 'owner_user_id,name'])
  157. ->where($primaryKey[$this->param['types']], $this->param['types_id'])->find();
  158. if ($data['owner_user_id'] == $userId) return resultArray(['error' => '负责人不能退出团队!']);
  159. $data[$primaryKey[$this->param['types']]] = $this->param['types_id'];
  160. $data['ro_user_id'] = str_replace(',' . $userId, '', $data['ro_user_id']);
  161. $data['rw_user_id'] = str_replace(',' . $userId, '', $data['rw_user_id']);
  162. if (!Db::name($this->param['types'])->update($data)) {
  163. return resultArray(['error' => '操作失败!']);
  164. }
  165. $type = '';
  166. switch ($this->param['types']) {
  167. case 'crm_customer':
  168. $type = Message::CUSTOMER_PASS;
  169. break;
  170. case 'crm_business':
  171. $type = Message::BUSINESS_PASS;
  172. break;
  173. case 'crm_contract':
  174. $type = Message::CONTRACT_END;
  175. break;
  176. }
  177. //站内信
  178. $send_user_id = stringToArray($userId);
  179. if ($send_user_id && empty($param['check_status'])) {
  180. (new Message())->send(
  181. $type,
  182. [
  183. 'title' => $data['name'],
  184. 'action_id' => $this->param['types_id']
  185. ],
  186. $send_user_id
  187. );
  188. }
  189. return resultArray(['data' => '操作成功!']);
  190. }
  191. /**
  192. * 相关团队创建
  193. *
  194. * @return \think\response\Json
  195. * @throws \think\db\exception\DataNotFoundException
  196. * @throws \think\db\exception\ModelNotFoundException
  197. * @throws \think\exception\DbException
  198. */
  199. public function teamSave()
  200. {
  201. $param = $this->param;
  202. $userInfo = $this->userInfo;
  203. $settingModel = model('Setting');
  204. $userModel = new \app\admin\model\User();
  205. $types_id = $param['types_id'];
  206. if (!$param['types'] || !$types_id) {
  207. return resultArray(['error' => '参数错误']);
  208. }
  209. if (!$param['user_id']) {
  210. return resultArray(['error' => '请先选择协作人']);
  211. }
  212. $errorMessage = [];
  213. foreach ($types_id as $k => $v) {
  214. $error = false;
  215. $typesName = '';
  216. //权限判断
  217. switch ($param['types']) {
  218. case 'crm_customer' :
  219. $typesName = '客户';
  220. $customerModel = new \app\crm\model\Customer();
  221. $dataInfo = db('crm_customer')->where(['customer_id' => $v])->find();
  222. //判断权限
  223. $auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'teamSave');
  224. //判断是否客户池数据
  225. $wherePool = $customerModel->getWhereByPool();
  226. $resPool = db('crm_customer')->alias('customer')->where(['customer.customer_id' => $v])->where($wherePool)->find();
  227. if (!$resPool && !in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
  228. $error = true;
  229. $errorMessage = "客户'" . $dataInfo['name'] . "'操作失败,错误原因:无权操作";
  230. }
  231. if (in_array($dataInfo['owner_user_id'], $param['user_id'])) {
  232. $error = true;
  233. $errorMessage = "客户'" . $dataInfo['name'] . "'操作失败,错误原因:不能对负责人进行添加或移出操作!";
  234. }
  235. $message_type = Message::TEAM_CUSTOMER;
  236. continue;
  237. case 'crm_business' :
  238. $typesName = '商机';
  239. $businessModel = new \app\crm\model\Business();
  240. $dataInfo = db('crm_business')->where(['business_id' => $v])->find();
  241. //判断权限
  242. $auth_user_ids = $userModel->getUserByPer('crm', 'business', 'teamSave');
  243. if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
  244. $error = true;
  245. $errorMessage = "商机'" . $dataInfo['name'] . "'操作失败,错误原因:无权操作";
  246. }
  247. if (in_array($dataInfo['owner_user_id'], $param['user_id'])) {
  248. $error = true;
  249. $errorMessage = "商机'" . $dataInfo['name'] . "'操作失败,错误原因:不能对负责人进行添加或移出操作!";
  250. }
  251. $message_type = Message::TEAM_BUSINESS;
  252. continue;
  253. case 'crm_contract' :
  254. $typesName = '合同';
  255. $contractModel = new \app\crm\model\Contract();
  256. $dataInfo = db('crm_contract')->where(['contract_id' => $v])->find();
  257. //判断权限
  258. $auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'teamSave');
  259. if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
  260. $error = true;
  261. $errorMessage = "合同'" . $dataInfo['name'] . "'操作失败,错误原因:无权操作";
  262. }
  263. if (in_array($dataInfo['owner_user_id'], $param['user_id'])) {
  264. $error = true;
  265. $errorMessage = "合同'" . $dataInfo['name'] . "'操作失败,错误原因:不能对负责人进行添加或移出操作!";
  266. }
  267. $message_type = Message::TEAM_CONTRACT;
  268. continue;
  269. }
  270. if ($error !== true) {
  271. $param['type_id'] = $v;
  272. $param['type'] = $param['type'] ?: 1;
  273. $param['is_del'] = $param['is_del'] ?: 3;
  274. $param['owner_user_id'] = $userInfo['id'];
  275. if (empty($param['is_del'])) {
  276. $res = $settingModel->createTeamData($param);
  277. if (!$res) {
  278. $errorMessage = $typesName . $dataInfo['name'] . "'操作失败,错误原因:修改失败";
  279. } else {
  280. (new Message())->send(
  281. $message_type,
  282. [
  283. 'title' => $dataInfo['name'],
  284. 'action_id' => $v
  285. ],
  286. $param['user_id']
  287. );
  288. $username=db('admin_user')->where('id',['in',$param['user_id']])->column('realname');
  289. RecordActionLog($userInfo['id'], 'crm_customer', 'teamSave',$dataInfo['name'], '','','给' . $typesName. $dataInfo['name'].'添加了团队成员 :'.implode(',',$username));
  290. }
  291. } else {
  292. $res = $settingModel->createTeamData($param);
  293. if (!$res) {
  294. $errorMessage = $typesName . $dataInfo['name'] . "'操作失败,错误原因:修改失败";
  295. }else{
  296. (new Message())->send(
  297. Message::TEAM_END,
  298. [
  299. 'title' => $dataInfo['name'],
  300. 'action_id' => $v
  301. ],
  302. $param['user_id']
  303. );
  304. }
  305. $username=db('admin_user')->where('id',['in',$param['user_id']])->column('realname');
  306. RecordActionLog($userInfo['id'], 'crm_customer', 'teamSave',$dataInfo['name'], '','','移除了' . $typesName. $dataInfo['name'].'团队成员 :'.implode(',',$username));
  307. }
  308. }
  309. }
  310. if ($errorMessage) {
  311. return resultArray(['error' => $errorMessage]);
  312. } else {
  313. return resultArray(['data' => '保存成功']);
  314. }
  315. }
  316. /**
  317. * 合同到期提醒天数
  318. *
  319. * @return \think\response\Json
  320. * @throws \think\Exception
  321. * @throws \think\exception\PDOException
  322. */
  323. public function contractDay()
  324. {
  325. //权限判断
  326. if (!checkPerByAction('admin', 'crm', 'setting')) {
  327. header('Content-Type:application/json; charset=utf-8');
  328. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  329. }
  330. $param = $this->param;
  331. $userInfo=$this->userInfo;
  332. $data = [];
  333. $contract_day = $param['contract_day'] ? intval($param['contract_day']) : 0;
  334. $contract_config = $param['contract_config'] ? intval($param['contract_config']) : 0;
  335. $res = db('crm_config')->where(['name' => 'contract_config'])->update(['value' => $contract_config]);
  336. if ($contract_day && $contract_config == 1) $res = db('crm_config')->where(['name' => 'contract_day'])->update(['value' => $contract_day]);
  337. # 系统操作日志
  338. SystemActionLog($userInfo['id'], 'crm_config','customer', 1, 'update','' , '', '','编辑了合同到期提醒设置');
  339. return resultArray(['data' => '设置成功']);
  340. }
  341. /**
  342. * 记录类型编辑
  343. *
  344. * @return \think\response\Json
  345. * @throws \think\Exception
  346. * @throws \think\db\exception\DataNotFoundException
  347. * @throws \think\db\exception\ModelNotFoundException
  348. * @throws \think\exception\DbException
  349. * @throws \think\exception\PDOException
  350. */
  351. public function recordEdit()
  352. {
  353. $param = $this->param;
  354. $userInfo=$this->userInfo;
  355. //权限判断
  356. if (!checkPerByAction('admin', 'crm', 'setting')) {
  357. header('Content-Type:application/json; charset=utf-8');
  358. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  359. }
  360. if ($param['value']) {
  361. $array = json_encode($param['value']);
  362. $record_type = db('crm_config')->where(['name' => 'record_type'])->find();
  363. if ($record_type) {
  364. $res = db('crm_config')->where(['name' => 'record_type'])->update(['value' => $array]);
  365. $id=$record_type['id'];
  366. } else {
  367. $data = array();
  368. $data['name'] = 'record_type';
  369. $data['value'] = $array;
  370. $data['description'] = '跟进记录类型';
  371. $res = db('crm_config')->insertGetId($data);
  372. $id=$res;
  373. $record_type['description']='跟进记录类型';
  374. }
  375. if ($res) {
  376. SystemActionLog($userInfo['id'], 'crm_config','customer', $id, 'update',$record_type['description'] , '', '','编辑了跟进记录类型:'.$record_type['description']);
  377. return resultArray(['data' => '设置成功']);
  378. } else {
  379. return resultArray(['error' => '设置失败,请重试!']);
  380. }
  381. } else {
  382. $record_type = db('crm_config')->where(['name' => 'record_type'])->find();
  383. $record_type['value'] = json_decode($record_type['value']);
  384. return resultArray(['data' => $record_type]);
  385. }
  386. }
  387. /**
  388. * 跟进记录 记录方式展示
  389. *
  390. * @return \think\response\Json
  391. * @throws \think\db\exception\DataNotFoundException
  392. * @throws \think\db\exception\ModelNotFoundException
  393. * @throws \think\exception\DbException
  394. */
  395. public function recordList()
  396. {
  397. $record_type = db('crm_config')->where(['name' => 'record_type'])->find();
  398. if ($record_type) {
  399. $arr = json_decode($record_type['value']);
  400. return resultArray(['data' => $arr]);
  401. } else {
  402. return resultArray(['data' => array()]);
  403. }
  404. }
  405. /**
  406. * 拥有、锁定客户数限制列表
  407. *
  408. * @return \think\response\Json
  409. * @throws \think\Exception
  410. * @throws \think\db\exception\DataNotFoundException
  411. * @throws \think\db\exception\ModelNotFoundException
  412. * @throws \think\exception\DbException
  413. */
  414. public function customerConfigList()
  415. {
  416. $param = $this->param;
  417. $param['types'] = $param['types'] ?: 1;
  418. $customerConfigModel = new \app\crm\model\CustomerConfig();
  419. $data = $customerConfigModel->getDataList($param);
  420. return resultArray(['data' => $data]);
  421. }
  422. /**
  423. * 拥有、锁定客户数限制 创建/编辑 todo 创建和编辑走一个接口,前端非要这么搞
  424. *
  425. * @return \think\response\Json
  426. * @throws \think\db\exception\DataNotFoundException
  427. * @throws \think\db\exception\ModelNotFoundException
  428. * @throws \think\exception\DbException
  429. */
  430. public function customerConfigSave()
  431. {
  432. //权限判断
  433. if (!checkPerByAction('admin', 'crm', 'setting')) {
  434. header('Content-Type:application/json; charset=utf-8');
  435. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  436. }
  437. $customerConfigModel = new \app\crm\model\CustomerConfig();
  438. if (!$customerConfigModel->createData($this->param)) {
  439. return resultArray(['error' => $customerConfigModel->getError()]);
  440. }
  441. return resultArray(['data' => empty($param['id']) ? '创建成功!' : '编辑成功!']);
  442. }
  443. /**
  444. * 拥有、锁定客户数限制 编辑 todo 编辑不走这个接口,前端非要走创建接口
  445. *
  446. * @return \think\response\Json
  447. */
  448. public function customerConfigUpdate()
  449. {
  450. //权限判断
  451. if (!checkPerByAction('admin', 'crm', 'setting')) {
  452. header('Content-Type:application/json; charset=utf-8');
  453. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  454. }
  455. $param = $this->param;
  456. $customerConfigModel = new \app\crm\model\CustomerConfig();
  457. $res = $customerConfigModel->updateDataById($param, $param['id']);
  458. if (!$res) {
  459. return resultArray(['error' => $customerConfigModel->getError()]);
  460. }
  461. return resultArray(['data' => '编辑成功']);
  462. }
  463. /**
  464. * 拥有、锁定客户数限制 删除
  465. *
  466. * @return \think\response\Json
  467. */
  468. public function customerConfigDel()
  469. {
  470. //权限判断
  471. if (!checkPerByAction('admin', 'crm', 'setting')) {
  472. header('Content-Type:application/json; charset=utf-8');
  473. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  474. }
  475. $param = $this->param;
  476. $customerConfigModel = new \app\crm\model\CustomerConfig();
  477. $res = $customerConfigModel->delDataById($param['id']);
  478. if (!$res) {
  479. return resultArray(['error' => $customerConfigModel->getError()]);
  480. }
  481. return resultArray(['data' => '删除成功']);
  482. }
  483. /**
  484. * 编号列表
  485. *
  486. * @return \think\response\Json
  487. * @throws \think\db\exception\DataNotFoundException
  488. * @throws \think\db\exception\ModelNotFoundException
  489. * @throws \think\exception\DbException
  490. */
  491. public function numberSequenceList()
  492. {
  493. $param = $this->param;
  494. $numberSequenceModel = new \app\crm\model\NumberSequence();
  495. $data = $numberSequenceModel->getDataList($param);
  496. return resultArray(['data' => $data]);
  497. }
  498. /**
  499. * 编号修改
  500. *
  501. * @return \think\response\Json
  502. */
  503. public function numberSequenceUpdate()
  504. {
  505. //权限判断
  506. if (!checkPerByAction('admin', 'crm', 'setting')) {
  507. header('Content-Type:application/json; charset=utf-8');
  508. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  509. }
  510. $param = $this->param;
  511. $numberSequenceModel = new \app\crm\model\NumberSequence();
  512. $res = $numberSequenceModel->numberSequenceUpdate($param, $param['id']);
  513. if (!$res) {
  514. return resultArray(['error' => $numberSequenceModel->getError()]);
  515. }
  516. return resultArray(['data' => '编辑成功']);
  517. }
  518. /**
  519. * 编号删除
  520. *
  521. * @return \think\response\Json
  522. */
  523. public function numberSequenceDel()
  524. {
  525. //权限判断
  526. if (!checkPerByAction('admin', 'crm', 'setting')) {
  527. header('Content-Type:application/json; charset=utf-8');
  528. exit(json_encode(['code' => 102, 'error' => '无权操作']));
  529. }
  530. $param = $this->param;
  531. $numberSequenceModel = new \app\crm\model\NumberSequence();
  532. $res = $numberSequenceModel->delDataById($param['id']);
  533. if (!$res) {
  534. return resultArray(['error' => $numberSequenceModel->getError()]);
  535. }
  536. return resultArray(['data' => '删除成功']);
  537. }
  538. /**
  539. * 设置回访提醒
  540. *
  541. * @return \think\response\Json
  542. * @throws \think\Exception
  543. * @throws \think\exception\PDOException
  544. */
  545. public function setVisitDay()
  546. {
  547. $status = !empty($this->param['status']) ? $this->param['status'] : 0;
  548. $day = !empty($this->param['day']) ? $this->param['day'] : 0;
  549. $settingModel = new \app\crm\model\Setting();
  550. if (!$settingModel->setVisitDay($status, $day)) return resultArray(['error' => '操作失败!']);
  551. return resultArray(['data' => '操作成功!']);
  552. }
  553. /**
  554. * 获取回访提醒
  555. *
  556. * @return \think\response\Json
  557. */
  558. public function getVisitDay()
  559. {
  560. $settingModel = new \app\crm\model\Setting();
  561. $data = $settingModel->getVisitDay();
  562. return resultArray(['data' => $data]);
  563. }
  564. /**
  565. * 设置自动编号
  566. *
  567. * @return \think\response\Json
  568. */
  569. public function setNumber()
  570. {
  571. if (empty($this->param) || !is_array($this->param)) return resultArray(['error' => '参数错误!']);
  572. $settingModel = new \app\crm\model\Setting();
  573. if ($settingModel->setNumber($this->param) === false) return resultArray(['error' => '操作失败!']);
  574. return resultArray(['data' => '操作成功!']);
  575. }
  576. }