Index.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <?php
  2. namespace app\empcrm\controller;
  3. use app\BaseController;
  4. use app\model\Org;
  5. use app\model\User;
  6. use app\model\Admin;
  7. use think\facade\View;
  8. use think\facade\Session;
  9. use app\model\Employee;
  10. use app\model\Company;
  11. use app\model\CustomerVisitLog;
  12. use app\model\Customer;
  13. use app\model\CustomerPackage;
  14. class Index extends BaseController
  15. {
  16. /**
  17. * 面板
  18. */
  19. public function index()
  20. {
  21. $request = request();
  22. $empdata = $request->empcrm;
  23. View::assign('empdata', $empdata);
  24. $root_id = $request->empcrm->root_id;
  25. if ($empdata['empcrm_module'] == 1) $allmenu = $this->get_pcmenu($empdata);
  26. if ($empdata['empcrm_module'] == 2) $allmenu = $this->get_sqmenu($empdata);
  27. View::assign('menu', $allmenu['menu']);
  28. View::assign('leftnav', $allmenu['leftnav']);
  29. $switch_type = 0;
  30. if ($empdata['empcrm_module'] == 1 && $empdata['community_disable'] == 0) $switch_type = 2;
  31. if ($empdata['empcrm_module'] == 2 && $empdata['empcrm_disable'] == 0) $switch_type = 1;
  32. View::assign('switch_type', $switch_type);
  33. //查询加入的公司
  34. $login_type = session('empcrm_login_type');
  35. $where = [
  36. ['root_id', '<>', $request->empcrm->root_id],
  37. ['state', '=', '在职'],
  38. ['uid', '>', 0],
  39. ];
  40. if ($login_type == 'phone_login') {
  41. $where[] = ['phone', '=', cypherphone($request->empcrm->phone)];
  42. }
  43. if ($login_type == 'wx_login') {
  44. $field = 'unionid';
  45. $empcrm = session('empcrm');
  46. // $user_id = User::where($field, '=', $empcrm[$field])->column('id');
  47. // $where[] = ['uid', 'in', $user_id];
  48. $where[] = [$field, '=', $empcrm->$field];
  49. }
  50. $root_ids = Employee::where($where)->column('id', 'root_id');
  51. $ydate = date('Y-m-d', strtotime('-1 day'));
  52. $condition = [
  53. ['root_id', 'in', array_keys($root_ids)],
  54. ['end_date', '>', $ydate . ' 23:59:59'],
  55. ['status', '=', 0]
  56. ];
  57. $shop = Company::with(['brand'])->where($condition)->field('company_name,root_id,logo,company_brand')->select()->toArray();
  58. foreach ($shop as $key => $value) {
  59. $shop[$key]['employee_id'] = $root_ids[$value['root_id']];
  60. if ($value['brand'] && $value['brand']['logo'] && !$value['logo']) {
  61. $shop[$key]['logo'] = $value['brand']['logo'];
  62. }
  63. }
  64. View::assign('shop', $shop);
  65. return View::fetch();
  66. }
  67. /**
  68. * 获取PC端的菜单
  69. */
  70. public function get_pcmenu($empdata)
  71. {
  72. $channel_setting = Company::where(['root_id' => $empdata['root_id']])->value('channel_setting');
  73. if ($empdata->is_manager == 1) {
  74. $menu = [
  75. ['name' => '首页', 'url' => 'empcrm/index'],
  76. ['name' => '客户池', 'url' => 'empcrm/list'],
  77. ['name' => '指派客户', 'url' => 'manager_emp/shareList'],
  78. ['name' => '分配资源', 'url' => 'empcrm/resources_list'],
  79. ['name' => '资源库管理', 'url' => 'manager_emp/resource'],
  80. ['name' => '转移客户', 'url' => 'empcrm/assignment_list'],
  81. ['name' => '待回访', 'url' => 'empcrm/repay_list'],
  82. //['name'=>'待确认','url'=>'empcrm/stay_confirm_list'],
  83. ['name' => '见面', 'url' => 'empcrm/confirm_visit_list'],
  84. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'url' => 'empcrm/jiaoding_list'],
  85. ['name' => '有效申请', 'url' => 'valid_check/list'],
  86. ['name' => '公共库', 'url' => 'empcrm/pool_list'],
  87. ['name' => '账户明细', 'url' => 'manager_emp/extension_report'],
  88. ['name' => '账户渠道', 'url' => 'manager_emp/account_report'],
  89. ['name' => '日报', 'url' => 'empcrm/daily'],
  90. ['name' => '校对', 'url' => 'manager_emp/proofread'],
  91. ['name' => '员工统计', 'url' => 'empcrm/generalStatistics'],
  92. ['name' => '客户统计', 'url' => 'manager_emp/customer_statistics_list'],
  93. ];
  94. if (isset($channel_setting)) {
  95. $tmp_data = json_decode($channel_setting, true);
  96. if (isset($tmp_data['fish_access_token']) && $empdata['clue_disable'] == 0) $menu[] = ['name' => '渠道统计', 'url' => 'empcrm/fish_total'];
  97. if (isset($tmp_data['fish_access_token']) && $empdata['clue_disable'] == 0) $menu[] = ['name' => '飞鱼线索', 'url' => 'empcrm/fish_list'];
  98. if (isset($tmp_data['tx_access_token']) && !empty($tmp_data['tx_adv']) && $empdata['clue_disable'] == 0) $menu[] = ['name' => '腾讯线索', 'url' => 'empcrm/tencent_list'];
  99. }
  100. $leftnav = [
  101. ['name' => '首页', 'ishref' => 1, 'url' => 'empcrm/index', 'child' => []],
  102. ['name' => '客户数据', 'ishref' => 0, 'url' => '', 'child' => [
  103. ['name' => '客户池', 'ishref' => 1, 'url' => 'empcrm/list'],
  104. ['name' => '分配资源', 'url' => 'empcrm/resources_list'],
  105. ['name' => '资源库管理', 'url' => 'manager_emp/resource'],
  106. ['name' => '见面', 'ishref' => 1, 'url' => 'empcrm/confirm_visit_list'],
  107. ['name' => '待确认', 'ishref' => 1, 'url' => 'empcrm/stay_confirm_list'],
  108. ['name' => '待回访', 'ishref' => 1, 'url' => 'empcrm/repay_list'],
  109. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'ishref' => 1, 'url' => 'empcrm/jiaoding_list'],
  110. ['name' => $empdata['xinjushang'] == 1 ? '签单' : '转单', 'ishref' => 1, 'url' => 'empcrm/achment_list'],
  111. ]],
  112. ['name' => '相关报表', 'ishref' => 0, 'url' => '', 'child' => [
  113. ['name' => '年报明细', 'url' => 'manager_emp/year_report'],
  114. ['name' => '推广明细', 'url' => 'manager_emp/extension_report'],
  115. ['name' => '日报', 'ishref' => 1, 'url' => 'empcrm/daily'],
  116. ['name' => '账户渠道', 'ishref' => 1, 'url' => 'manager_emp/account_report'],
  117. ['name' => '员工报表', 'ishref' => 1, 'url' => 'empcrm/emp_daily'],
  118. ['name' => '设计师报表', 'ishref' => 1, 'url' => 'manager_emp/designer_report'],
  119. ['name' => '无效报表', 'ishref' => 1, 'url' => 'empcrm/invalid_report']
  120. ]],
  121. ['name' => '新报表', 'ishref' => 0, 'url' => '', 'child' => [
  122. ['name' => '销售报表', 'url' => 'statistics2/sale'],
  123. ['name' => '设计师部门报表', 'ishref' => 1, 'url' => 'statistics2/designerDepartment'],
  124. ['name' => '渠道报表', 'url' => 'statistics2/source']
  125. ]],
  126. ['name' => '公共库', 'ishref' => 1, 'url' => 'empcrm/pool_list', 'child' => []],
  127. ['name' => '搜索', 'ishref' => 1, 'url' => 'empcrm/search_list', 'child' => []],
  128. ['name' => '校对', 'ishref' => 1, 'url' => 'manager_emp/proofread', 'child' => []],
  129. ];
  130. } else {
  131. $menu = [
  132. ['name' => '首页', 'url' => 'empcrm/index'],
  133. ['name' => '搜索', 'url' => 'empcrm/search_list'],
  134. ['name' => '日报', 'url' => 'empcrm/daily'],
  135. ['name' => '客户池', 'url' => 'empcrm/list'],
  136. ['name' => '指派客户', 'url' => 'manager_emp/shareList'],
  137. ['name' => '分配资源', 'url' => 'empcrm/resources_list'],
  138. ['name' => '待回访', 'url' => 'empcrm/repay_list'],
  139. ['name' => '待确认', 'url' => 'empcrm/stay_confirm_list'],
  140. ['name' => '见面', 'url' => 'empcrm/confirm_visit_list'],
  141. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'url' => 'empcrm/jiaoding_list'],
  142. ['name' => '有效申请', 'url' => 'valid_check/apply_list'],
  143. ['name' => '转移客户', 'url' => 'empcrm/assignment_list'],
  144. ['name' => '公共库', 'url' => 'empcrm/pool_list'],
  145. ['name' => '校对', 'url' => 'manager_emp/proofread'],
  146. ];
  147. if (isset($channel_setting)) {
  148. // dump($empdata['clue_disable']);
  149. $tmp_data = json_decode($channel_setting, true);
  150. if (isset($tmp_data['fish_access_token']) && $empdata['clue_disable'] == 0) $menu[] = ['name' => '飞鱼线索', 'url' => 'empcrm/fish_list'];
  151. if (isset($tmp_data['tx_access_token']) && !empty($tmp_data['tx_adv']) && $empdata['clue_disable'] == 0) $menu[] = ['name' => '腾讯线索', 'url' => 'empcrm/tencent_list'];
  152. }
  153. $leftnav = [
  154. ['name' => '首页', 'ishref' => 1, 'url' => 'empcrm/index', 'child' => []],
  155. ['name' => '客户数据', 'ishref' => 0, 'url' => '', 'child' => [
  156. ['name' => '客户池', 'ishref' => 1, 'url' => 'empcrm/list'],
  157. ['name' => '分配资源', 'url' => 'empcrm/resources_list'],
  158. ['name' => '见面', 'ishref' => 1, 'url' => 'empcrm/confirm_visit_list'],
  159. ['name' => '待确认', 'ishref' => 1, 'url' => 'empcrm/stay_confirm_list'],
  160. ['name' => '待回访', 'ishref' => 1, 'url' => 'empcrm/repay_list'],
  161. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'ishref' => 1, 'url' => 'empcrm/jiaoding_list'],
  162. ['name' => $empdata['xinjushang'] == 1 ? '签单' : '转单', 'ishref' => 1, 'url' => 'empcrm/achment_list'],
  163. ]],
  164. ['name' => '统计学习', 'ishref' => 0, 'url' => '', 'child' => [
  165. ['name' => '日报', 'url' => 'empcrm/daily'],
  166. ['name' => '员工报表', 'url' => 'empcrm/emp_daily'],
  167. ['name' => '无效报表', 'ishref' => 1, 'url' => 'empcrm/invalid_report'],
  168. ['name' => '公共库', 'ishref' => 1, 'url' => 'empcrm/pool_list'],
  169. ]],
  170. ['name' => '搜索', 'ishref' => 1, 'url' => 'empcrm/search_list', 'child' => []],
  171. ];
  172. }
  173. return ['menu' => $menu, 'leftnav' => $leftnav];
  174. }
  175. /**
  176. * 获取社群端的菜单
  177. */
  178. public function get_sqmenu($empdata)
  179. {
  180. if ($empdata->is_manager == 1) {
  181. $menu = [
  182. ['name' => '首页', 'url' => 'community/index'],
  183. ['name' => '客户池', 'url' => 'community/list'],
  184. ['name' => '待回访', 'url' => 'community/repay_list'],
  185. ['name' => '见面', 'url' => 'community/confirm_visit_list'],
  186. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'url' => 'community/jiaoding_list'],
  187. ['name' => $empdata['xinjushang'] == 1 ? '签单' : '转单', 'ishref' => 1, 'url' => 'community/achment_list'],
  188. ['name' => '公共库', 'url' => 'community/pool_list'],
  189. ['name' => '搜索', 'url' => 'community/search_list'],
  190. ['name' => '日报', 'url' => 'community/daily'],
  191. ['name' => '楼盘报表', 'url' => 'community/community_report'],
  192. ['name' => '业务报表', 'url' => 'community/employee_report'],
  193. ['name' => '汇总报表', 'url' => 'community/summary_report'],
  194. ['name' => '运营报表', 'url' => 'community/operate_report'],
  195. ['name' => '运营', 'url' => 'community/operate_list']
  196. ];
  197. $leftnav = [
  198. ['name' => '首页', 'ishref' => 1, 'url' => 'community/index', 'child' => []],
  199. ['name' => '数据统计', 'ishref' => 0, 'url' => '', 'child' => [
  200. ['name' => '日报', 'ishref' => 1, 'url' => 'community/daily'],
  201. ['name' => '楼盘报表', 'ishref' => 1, 'url' => 'community/community_report'],
  202. ['name' => '员工报表', 'ishref' => 1, 'url' => 'community/employee_report'],
  203. ['name' => '设计师报表', 'ishref' => 1, 'url' => 'community/designer_report'],
  204. ['name' => '年报汇总', 'url' => 'community/summary_report']
  205. ]],
  206. ['name' => '客户数据', 'ishref' => 0, 'url' => '', 'child' => [
  207. ['name' => '客户池', 'ishref' => 1, 'url' => 'community/list'],
  208. ['name' => '分派', 'url' => 'community/assignment_list'],
  209. ['name' => '见面', 'url' => 'community/confirm_visit_list'],
  210. ['name' => '待回访', 'ishref' => 1, 'url' => 'community/repay_list'],
  211. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'ishref' => 1, 'url' => 'community/jiaoding_list'],
  212. ['name' => $empdata['xinjushang'] == 1 ? '签单' : '转单', 'ishref' => 1, 'url' => 'community/achment_list'],
  213. //['name'=>'故事力','ishref'=>1,'url'=>''],
  214. ]],
  215. ['name' => '其它统计', 'ishref' => 1, 'url' => '', 'child' => [
  216. ['name' => '登陆详情', 'ishref' => 1, 'url' => 'community/login_record'],
  217. ]]
  218. ];
  219. } else {
  220. $menu = [
  221. ['name' => '首页', 'url' => 'community/index'],
  222. ['name' => '客户池', 'url' => 'community/list'],
  223. ['name' => '待回访', 'url' => 'community/repay_list'],
  224. ['name' => '见面', 'url' => 'community/confirm_visit_list'],
  225. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'url' => 'community/jiaoding_list'],
  226. ['name' => $empdata['xinjushang'] == 1 ? '签单' : '转单', 'ishref' => 1, 'url' => 'community/achment_list'],
  227. ['name' => '公共库', 'url' => 'community/pool_list'],
  228. ['name' => '搜索', 'url' => 'community/search_list'],
  229. ['name' => '日报', 'url' => 'community/daily']
  230. ];
  231. $leftnav = [
  232. ['name' => '首页', 'ishref' => 1, 'url' => 'community/index', 'child' => []],
  233. ['name' => '客户数据', 'ishref' => 0, 'url' => '', 'child' => [
  234. ['name' => '客户池', 'ishref' => 1, 'url' => 'community/list'],
  235. ['name' => '分派', 'url' => 'community/assignment_list'],
  236. ['name' => '见面', 'url' => 'community/confirm_visit_list'],
  237. ['name' => '待回访', 'ishref' => 1, 'url' => 'community/repay_list'],
  238. ['name' => $empdata['xinjushang'] == 1 ? '交定' : '签单', 'ishref' => 1, 'url' => 'community/jiaoding_list'],
  239. ['name' => $empdata['xinjushang'] == 1 ? '签单' : '转单', 'ishref' => 1, 'url' => 'community/achment_list'],
  240. //['name'=>'故事力','ishref'=>1,'url'=>''],
  241. ]],
  242. ['name' => '数据统计', 'ishref' => 0, 'url' => '', 'child' => [
  243. ['name' => '日报', 'url' => 'community/daily'],
  244. ['name' => '员工报表', 'url' => 'community/employee_report']
  245. ]]
  246. ];
  247. }
  248. return ['menu' => $menu, 'leftnav' => $leftnav];
  249. }
  250. /**
  251. * 多企业选择页面
  252. */
  253. public function company()
  254. {
  255. $request = request();
  256. $rootId = $request->param('rootid');
  257. $uid = $request->param('uid');
  258. $phone = session('empcrm');
  259. $login_type = session('empcrm_login_type');
  260. if (is_object($phone)) return redirect(url('index/index'));
  261. if ($rootId && $uid) {
  262. $domain = request()->domain();
  263. $field = 'phone|unionid';
  264. if ($login_type == 'phone_login')
  265. $employee = Employee::where([[$field, '=', $phone], ['root_id', '=', $rootId], ['uid', '<>', 0], ['state', 'in', ['在职']]])->find();
  266. if ($login_type == 'wx_login')
  267. $employee = Employee::where([['uid', '=', $uid], ['root_id', '=', $rootId], ['state', 'in', ['在职']]])->find();
  268. if (!empty($employee)) {
  269. $company = Company::where('root_id', $employee['root_id'])->find();
  270. if ($company['status'] == 1) {
  271. return json(['code' => 1, 'msg' => '账号被禁用,请联系管理员']);
  272. } elseif ($company['end_date'] . ' 23:59:59' < date('Y-m-d H:i:s', time())) {
  273. return json(['code' => 1, 'msg' => '账号已过期,请联系管理员']);
  274. }
  275. $orgType = Org::where('id', $employee['org_id'])->value('org_type');
  276. $employee['org_type'] = $orgType;
  277. session('empcrm', $employee);
  278. event('SysOperate', [$employee, '登录']);
  279. cache('empcrm_' . $employee['phone'], Session::getId());
  280. return redirect(url('index/index'));
  281. }
  282. }
  283. if ($login_type == 'phone_login')
  284. $companys = Employee::with(['company', 'companys'])->where([['phone|openid', '=', $phone], ['uid', '<>', 0], ['state', 'in', ['在职']]])->select()->toArray();
  285. if ($login_type == 'wx_login') {
  286. $domain = request()->domain();
  287. $field = 'unionid';
  288. $companys = Employee::with(['company', 'companys'])->where('uid', 'in', explode(',', $phone))->where([['state', 'in', ['在职']], [$field, '<>', '']])->select()->toArray();
  289. }
  290. foreach ($companys as $k => $v) {
  291. if ($v['account_status'] == 1) {
  292. $companys[$k]['off'] = 1;
  293. $companys[$k]['off_remark'] = '账号被禁用';
  294. } elseif ($v['account_end_date'] . ' 23:59:59' < date('Y-m-d H:i:s', time())) {
  295. $companys[$k]['off'] = 1;
  296. $companys[$k]['off_remark'] = '账号已过期';
  297. } else {
  298. $companys[$k]['off'] = 0;
  299. $companys[$k]['off_remark'] = '账号正常';
  300. }
  301. }
  302. View::assign('companys', $companys);
  303. return View::fetch();
  304. }
  305. /*
  306. * 首页数据中心
  307. */
  308. public function welcome()
  309. {
  310. $request = request();
  311. $root_id = $request->empcrm->root_id;
  312. $empcrm = $request->empcrm;
  313. $today = date('Y-m-d H:i:s', time());
  314. $firstday = $today;
  315. $lastday = date('Y-m-d 00:00:00', strtotime("$firstday -2 day"));
  316. if ($empcrm['empcrm_module'] == 2) {
  317. $org_employee = Employee::where([['root_id', '=', $root_id], ['org_id', '=', $request->empcrm->org_id], ['community_disable', '=', 0]])->column('id');
  318. $where[] = ['customer_employee_id', 'in', $org_employee];
  319. }
  320. $where[] = ['org_id', '=', $request->empcrm->org_id];
  321. $where[] = ['addtime', 'between', [$lastday, $firstday]];
  322. $where[] = ['state', 'in', array_merge(CustomerVisitLog::changeState('已交定', 'chaos'), CustomerVisitLog::changeState('已签单', 'chaos'))];
  323. $list = CustomerVisitLog::with(['employee' => function ($query) {
  324. $query->field('id,name');
  325. }])->where($where)->order('addtime desc')->select()->toArray();
  326. $empmod = new Empcrm($this->app);
  327. foreach ($list as $key => $val) {
  328. $list[$key]['package_name'] = !empty($val['package_id']) ? CustomerPackage::where('id', $val['package_id'])->value('name') : '';
  329. $cusdata = Customer::with(['designer'])->where('id', $val['customer_id'])->field('name,community_name,deposit_money,signed_money,addtime,designer_id')->find();
  330. //如果客户不存在直接销毁跳过本次循环
  331. if (empty($cusdata)) {
  332. unset($list[$key]);
  333. continue;
  334. }
  335. $cusdata['deposit_moneys'] = !empty($cusdata->getData('deposit_money')) ? number_format($cusdata->getData('deposit_money'), 2, '.', ',') : 0;
  336. $cusdata['signed_moneys'] = !empty($cusdata->getData('signed_money')) ? number_format($cusdata->getData('signed_money'), 2, '.', ',') : 0;
  337. $list[$key]['cusdata'] = $cusdata;
  338. }
  339. $company_name = Company::where('root_id', $root_id)->value('company_name');
  340. View::assign('company_name', $company_name);
  341. View::assign('list', $list);
  342. return View::fetch();
  343. return View::fetch();
  344. }
  345. /**
  346. * 退出登陆
  347. */
  348. public function logout()
  349. {
  350. Session::delete('empcrm');
  351. Session::delete('empcrm_login_type');
  352. Session::delete('empcrm_module');
  353. $domain = request()->domain();
  354. $url = strpos($domain, "zqxg.cc") !== false ? url('manage/login/index') : url('login/index');
  355. $url = Session('login_source') == 1 ? $domain : $url;
  356. Session::delete('login_source');
  357. return redirect($url);
  358. }
  359. /**
  360. * 切换店面
  361. */
  362. public function switch_shop()
  363. {
  364. $request = request();
  365. $rootId = $request->param('rootid');
  366. $employee_id = $request->param('employee_id');
  367. if ($rootId) {
  368. $employee = Employee::where([['id', '=', $employee_id], ['root_id', '=', $rootId], ['state', '=', '在职'], ['uid', '>', 0]])->find();
  369. if (!empty($employee)) {
  370. $company = Company::where('root_id', $employee['root_id'])->find();
  371. if ($company['status'] == 1) {
  372. return json(['code' => 1, 'msg' => '所在企业被禁用,请联系管理员']);
  373. } elseif ($company['end_date'] . ' 23:59:59' < date('Y-m-d H:i:s', time())) {
  374. return json(['code' => 1, 'msg' => '企业账号已过期,请联系管理员']);
  375. }
  376. $orgType = Org::where('id', $employee['org_id'])->value('org_type');
  377. $employee['org_type'] = $orgType;
  378. Session::delete('empcrm_module');
  379. session('empcrm', $employee);
  380. event('SysOperate', [$employee, '登录']);
  381. cache('empcrm_' . $employee['phone'], Session::getId());
  382. return json(['code' => 0, 'msg' => '切换店面成功']);
  383. }
  384. }
  385. return json(['code' => 1, 'msg' => '切换失败']);
  386. }
  387. /**
  388. * 切换社群或PC端
  389. */
  390. public function switch_model()
  391. {
  392. $request = request();
  393. $root_id = $request->empcrm->root_id;
  394. $type = $request->param('type');
  395. $employee_id = $request->param('employee_id');
  396. $empdata = Employee::where([['id', '=', $employee_id], ['root_id', '=', $root_id]])->find();
  397. if ($type == 1 && $empdata['empcrm_disable'] == 0) {
  398. session('empcrm_module', 1); // 1、网销 2、社群
  399. }
  400. if ($type == 2 && $empdata['community_disable'] == 0) {
  401. session('empcrm_module', 2); // 1、网销 2、社群
  402. }
  403. return json(['code' => 0, 'msg' => '切换后台成功']);
  404. }
  405. }