Agents.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <?php
  2. namespace app\api\controller;
  3. use app\model\Employee;
  4. use app\model\Org;
  5. use app\model\User as ModelUser;
  6. use app\model\AgentUser;
  7. use app\model\Customer;
  8. use think\facade\Db;
  9. use app\model\CreditsSetting;
  10. use app\model\AgentIntegral;
  11. use app\model\Activity;
  12. use app\logics\AgentsLogic;
  13. use app\model\UserCollect;
  14. use app\model\CustomerVisitLog;
  15. use app\event\FootPrints;
  16. use app\model\ActivitySign;
  17. use app\model\CustomerDropPool;
  18. use app\model\Setting;
  19. use app\model\AgentArticle;
  20. use app\model\ShareLog;
  21. use app\model\VrGroup;
  22. use app\model\AgentType;
  23. use app\model\AgentShareContent;
  24. use app\model\CustomerClue;
  25. use app\model\MaterialCase;
  26. use app\model\Article;
  27. use app\model\Video;
  28. use app\model\MaterialEvidence;
  29. use app\model\CompanyStrength;
  30. use app\model\Building;
  31. use xiaohongwu\Vr;
  32. class Agents extends Base
  33. {
  34. /**
  35. * 查询后台自定义的经纪板块中心主题名称
  36. */
  37. public function get_agent_name()
  38. {
  39. $token = $this->request->token;
  40. $name = Setting::where(['root_id' => $token['root_org'], 'name' => 'agentSettingName'])->value('content');
  41. return json(['code' => 0, 'msg' => '获取成功', 'name' => $name]);
  42. }
  43. /**
  44. * 弹框邀请说明
  45. */
  46. public function inviteShow()
  47. {
  48. $token = $this->request->token;
  49. $setdata = Setting::where([['root_id', '=', $token['root_org']], ['name', 'in', ['agentInviteShow', 'agentBackgroundImg']]])->column('content', 'name');
  50. $img = !empty($setdata['agentInviteShow']) ? 'https://' . config('app.ali_oss_bindurl') . '/' . $setdata['agentInviteShow'] : '';
  51. $img1 = !empty($setdata['agentBackgroundImg']) ? 'https://' . config('app.ali_oss_bindurl') . '/' . $setdata['agentBackgroundImg'] : '';
  52. $imgarr = ['agentInviteShow' => $img, 'agentBackgroundImg' => $img1];
  53. return json(['code' => 0, 'msg' => '获取成功', 'show' => !empty($setdata['agentInviteShow']) ? 'true' : 'false', 'content' => $imgarr]);
  54. }
  55. //经纪人报名
  56. public function add_agents()
  57. {
  58. $token = $this->request->token;
  59. $data = $this->request->only(['name' => '', 'phone', 'employee_id', 'wechat' => '', 'type']);
  60. if (empty($data['employee_id'])) {
  61. return json(['code' => 1, 'msg' => '所属员工id为空']);
  62. }
  63. if (empty($data['type'])) return json(['code' => 1, 'msg' => '经纪人类型错误']);
  64. $empdata = Employee::where([['root_id', '=', $token['root_org']], ['id', '=', $data['employee_id']]])->field('org_id,name')->find()->toArray();
  65. if (empty($empdata)) return json(['code' => 1, 'msg' => '员工信息不存在']);
  66. if ($token['isEmployee']) return json(['code' => 1, 'msg' => '员工不能成为经纪人']);
  67. //if(!empty($empdata['uid']) && $empdata['uid'] == $token['uid']) return json(['code' => 1, 'msg' => '员工不能成为经纪人']);
  68. $where[] = ['root_id', '=', $token['root_org']];
  69. $where[] = ['uid', '=', $token['uid']];
  70. $check = AgentUser::where($where)->find();
  71. if ($check) return json(['code' => 1, 'msg' => '已经报名']);
  72. $add = array(
  73. 'agent_name' => empty($data['name']) ? '游客' : $data['name'],
  74. 'agent_employee_id' => $data['employee_id'],
  75. 'agent_phone' => $data['phone'],
  76. 'type' => $data['type'],
  77. 'is_review' => 1,
  78. 'root_id' => $token['root_org'],
  79. 'uid' => $token['uid'],
  80. 'org_id' => $empdata['org_id'],
  81. 'wechat' => $data['wechat']
  82. );
  83. // 足迹
  84. $token = $this->request->token;
  85. if (!empty($token['uid']) && !$token['isEmployee']) {
  86. $footerArr = [
  87. 'agent_name' => $data['name'],
  88. 'agent_phone' => $data['phone'],
  89. ];
  90. event(new FootPrints($token['uid'], $token['share_employee'] ?? 0, $token['share_org'] ?? 0, $footerArr, 'agents'));
  91. }
  92. $ms = AgentUser::insertGetId($add);
  93. if ($ms) {
  94. return json(['code' => 0, 'msg' => '报名成功', 'data' => $ms]);
  95. } else {
  96. return json(['code' => 1, 'msg' => '报名失败', 'data' => '']);
  97. }
  98. }
  99. //查询经纪人是否已经报过名
  100. public function sel_sign_up()
  101. {
  102. $token = $this->request->token;
  103. $empdata = AgentUser::where([['uid', '=', $token['uid']], ['root_id', '=', $token['root_org']]])->find();
  104. if (empty($empdata)) {
  105. return json(['code' => 0, 'msg' => '报名信息不存在']);
  106. } else {
  107. if ($empdata['is_review'] == 1) {
  108. return json(['code' => 1, 'msg' => '请等待审核']);
  109. } else {
  110. return json(['code' => 2, 'msg' => '已经报名成功审核通过']);
  111. }
  112. }
  113. }
  114. //活动详情
  115. public function activity_detail($id)
  116. {
  117. $token = request()->token;
  118. $data = Activity::where(['id' => $id, 'del' => 0, 'root_id' => $token['root_org']])->field('id,cover,title,content,type,start_date,end_date,end_date as timestate,view,money,cate,address,poster,show')->find();
  119. //是否收藏
  120. $collectedIds = UserCollect::where(['user_id' => $token['uid'], 'content_type' => 'activity', 'content_id' => $id])->count();
  121. $data['collected'] = $collectedIds > 0 ? true : false;
  122. Activity::where('id', $id)->inc('view')->update();
  123. $qrcode = ActivitySign::where([['aid', '=', $id], ['uid', '=', $token['uid']]])->value('qrcode');
  124. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  125. $url = 'https://' . $ali_oss_bindurl . '/';
  126. $data['qrcode'] = $qrcode ? $url . $qrcode : '';
  127. return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']);
  128. }
  129. //通过活动报名的客户
  130. public function add_activity_customer()
  131. {
  132. $token = $this->request->token;
  133. $param = $this->request->only(['phone', 'sex', 'agent_id', 'aid']);
  134. $agtdata = AgentUser::where('id', $param['agent_id'])->find();
  135. if (empty($agtdata)) return json(['code' => 1, 'msg' => '所属经纪人信息为空']);
  136. if ($token['uid'] == $agtdata['id']) return json(['code' => 1, 'msg' => '您的身份是经纪人,不能参加活动']);
  137. if ($token['isEmployee']) return json(['code' => 1, 'msg' => '您的身份是业务员,不能参加活动']);
  138. //活动已经结束无法报名
  139. $info = Activity::where('id', $param['aid'])->find();
  140. if (empty($info)) return json(['code' => 1, 'msg' => '活动不存在']);
  141. if ($info['del'] == 1 || $info['show'] == 0 || date('Y-m-d') > $info['end_date']) {
  142. return json(['code' => 1, 'msg' => '活动结束或已下架,无法报名']);
  143. }
  144. // 设计师能否报备、获取客户
  145. $root_id = $agtdata['root_id'];
  146. $de_where[] = ['root_id', '=', $root_id];
  147. $de_where[] = ['name', '=', 'designer_get_customer'];
  148. $info_de_where = Setting::where($de_where)->findOrEmpty();
  149. $org_type = Org::where('id', '=', $agtdata['org_id'])->value('org_type');
  150. if (!$info_de_where->isEmpty() && $org_type == 2) {
  151. if ((int)$info_de_where['content'] != 1) {
  152. return json(['code' => 1, 'msg' => '请联系业务员进行报名']);
  153. }
  154. }
  155. $data['employee_id'] = $agtdata['agent_employee_id'];
  156. $data['org_id'] = $agtdata['org_id'];
  157. $data['state'] = 0;
  158. $data['level'] = 'C';
  159. $data['agents_id'] = $agtdata['id'];
  160. $data['agent_source_type'] = 2;
  161. $data['uid'] = $token['uid'];
  162. $data['name'] = ModelUser::where('id', $token['uid'])->value('nickname') ?: '';
  163. $data['sex'] = !empty($param['sex']) ? $param['sex'] : 1;
  164. $orgids = orgSubIds(!empty($token['root_org']) ? $token['root_org'] : $agtdata['root_id']);
  165. // 新建档,检测手机号是否重复
  166. $pharr = [$param['phone']];
  167. $tips = (new AgentsLogic())->checkPepeat($pharr, $orgids, $data['employee_id'], '', 'sign');
  168. if (!empty($tips)) return $tips;
  169. //检测用户是否已经建过档
  170. $aw[] = ['uid', '=', $token['uid']];
  171. $aw[] = ['org_id', 'in', $orgids];
  172. $customer = Customer::where($aw)->find();
  173. if (!empty($customer)) {
  174. return json(['code' => 1, 'msg' => '报名失败,你已经报备过']);
  175. }
  176. //插入经济人提报的客户
  177. $data['phone'] = cypherphone(trim($param['phone']));
  178. Db::startTrans();
  179. try {
  180. $ms = Customer::insertGetId($data);
  181. $empuid = Employee::where('id', $agtdata['agent_employee_id'])->value('uid');
  182. $visitlog = CustomerVisitLog::where([['customer_id', '=', $ms], ['state', 'in', CustomerVisitLog::changeState('待确认', 'chaos')]])->find();
  183. if (!$visitlog) {
  184. $save = [];
  185. $save['customer_id'] = $ms;
  186. $save['type'] = '';
  187. $save['remark'] = !empty($data['remark']) ? $data['remark'] : '通过经纪人分享的活动报名的客户';
  188. $save['employee_id'] = $agtdata['agent_employee_id'];
  189. $save['user_id'] = $empuid;
  190. $save['state'] = 1;
  191. //$save['aid'] = $param['aid'];
  192. CustomerVisitLog::insertGetId($save);
  193. }
  194. // if($agtdata['type']==2){
  195. // $rule_type='wanghong_integral';
  196. // $itg_rule=CreditsSetting::where([['code','=',$rule_type],['root_id','=',$agtdata['root_id']]])->value('value');
  197. // //$itg_rule=json_decode($itg_rule,true);
  198. // $state='网红活动录入客户';
  199. // $add = array(
  200. // 'agent_id' => $agtdata['id'],
  201. // 'type' => 4,
  202. // 'integral' => $itg_rule ?$itg_rule :1,
  203. // 'addtime' => time(),
  204. // 'state' => $state,
  205. // 'customer_id' => $ms,
  206. // 'status'=>1
  207. // );
  208. // AgentIntegral::insert($add);
  209. // }
  210. //生成报名二维码
  211. //二维码内容,活动id,报名人uid
  212. $qrcode_con = $param['aid'] . '&' . $ms . '&' . $token['uid'];
  213. $cate = Activity::where('id', $param['aid'])->value('cate');
  214. $qrcode_con = $qrcode_con . '&' . $cate;
  215. $name = uniqid() . '.jpg';
  216. $path = 'activityqrcode/' . $name;
  217. $img = qrcode($qrcode_con, 'upload/' . $name);
  218. $res = ossUpload($path, 'upload/' . $name);
  219. @unlink('upload/' . $name); //删除本地文件
  220. ActivitySign::insertGetId([
  221. 'aid' => $param['aid'],
  222. 'root_id' => $orgids,
  223. 'uid' => $token['uid'],
  224. 'share_uid' => $empuid,
  225. 'share_employee_id' => $agtdata['agent_employee_id'],
  226. 'qrcode' => $path,
  227. 'qrcode_con' => $qrcode_con,
  228. 'addtime' => date('Y-m-d H:i:s')
  229. ]);
  230. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  231. $url = 'https://' . $ali_oss_bindurl . '/' . $path;
  232. Db::commit();
  233. } catch (\Exception $e) {
  234. Db::rollback();
  235. var_dump($e->getMessage());
  236. return json(['code' => 1, 'msg' => '报名数据失败.']);
  237. }
  238. if ($ms) {
  239. return json(['code' => 0, 'msg' => '报名成功.', 'url' => $url]);
  240. } else {
  241. return json(['code' => 1, 'msg' => '报名失败.']);
  242. }
  243. }
  244. //核销规则
  245. public function wiped_rule()
  246. {
  247. $token = $this->request->token;
  248. $param = $this->request->only(['agent_id']);
  249. if (empty($param['agent_id'])) return json(['code' => 1, 'msg' => '经纪人参数错误']);
  250. $agtdata = AgentUser::where([['root_id', '=', $token['root_org']], ['id', '=', $param['agent_id']]])->find();
  251. if (empty($agtdata)) return json(['code' => 1, 'msg' => '经纪人不存在']);
  252. $hxtype = 'reduce_integral';
  253. $hxdata = CreditsSetting::where([['code', '=', $hxtype], ['root_id', '=', $agtdata['root_id']]])->value('value');
  254. if (empty($hxdata)) return json(['code' => 0, 'data' => '1积分等于0元', 'msg' => '请求成功']);
  255. $hx = json_decode($hxdata, true);
  256. $data = $hx['jifen'] . '积分等于' . $hx['money'] . '元';
  257. return json(['code' => 0, 'data' => $data, 'msg' => '请求成功']);
  258. }
  259. /**
  260. * 分享任务、分享内容(展示我分享过的)
  261. */
  262. public function share_article()
  263. {
  264. $param = $this->request->only(['page' => 1, 'limit' => 10, 'from' => '', 'type' => 1,'employee_id']);
  265. $token = $this->request->token;
  266. //$agtdata = $this->request->agtdata;
  267. if(empty($param['employee_id'])) return json(['code'=>1,'msg'=>'员工id为空']);
  268. $where = [
  269. ['root_id', '=', $token['root_org']],
  270. ['employee_id', '=', $param['employee_id']],
  271. ['disable', '=', 0],
  272. ['from','=',1]
  273. ];
  274. $data = AgentShareContent::where($where)->order('addtime desc')->order('addtime desc')->page($param['page'], $param['limit'])->select()->toArray();
  275. foreach ($data as &$item) {
  276. //分享量
  277. $item['share_num'] = ShareLog::where([['type', '=', $item['type']], ['data_id', '=', $item['data_id']], ['agent_id', '<>', 'NULL']])->count();
  278. //线索
  279. $item['clue_num'] = CustomerClue::where([['pipe_type', '=', $item['type']], ['pipe_id', '=', $item['data_id']], ['agent_id', '<>', 0]])->count();
  280. //是否未分享
  281. //$item['new'] = in_array($item['id'], $content_id) ? false : true;
  282. switch ($item['type']) {
  283. case 'Article':
  284. $find = Article::where([
  285. ['root_id', '=', $token['root_org']],
  286. ['delete_time', '=', 0],
  287. ['publish', '=', 1],
  288. ['id', '=', $item['data_id']]
  289. ])->field('id,title,cover_img')->find();
  290. $item['content_id'] = $find['id'];
  291. $item['title'] = $find['title'];
  292. $item['cover'] = $find['cover_img'];
  293. break;
  294. case 'MaterialCase':
  295. $find = MaterialCase::where([
  296. ['root_id', '=', $token['root_org']],
  297. ['del', '=', 0],
  298. ['publish', '=', 1],
  299. ['id', '=', $item['data_id']]
  300. ])->field('id,title,cover_img')->find();
  301. $item['content_id'] = $find['id'];
  302. $item['title'] = $find['title'];
  303. $item['cover'] = $find['cover_img'];
  304. break;
  305. case 'Video':
  306. $find = Video::where([
  307. ['root_id', '=', $token['root_org']],
  308. ['delete_time', '=', 0],
  309. ['publish', '=', 1],
  310. ['id', '=', $item['data_id']]
  311. ])->field('id,title,video_url')->find();
  312. $item['content_id'] = $find['id'];
  313. $item['title'] = $find['title'];
  314. $item['cover'] = $find['video_url'];
  315. break;
  316. case 'CompanyStrength':
  317. $find = CompanyStrength::where([
  318. ['root_id', '=', $token['root_org']],
  319. ['del', '=', 0],
  320. ['publish', '=', 1],
  321. ['id', '=', $item['data_id']]
  322. ])->field('id,title,cover,pics,difference')->find();
  323. $item['content_id'] = $find['id'];
  324. $item['title'] = $find['title'];
  325. $item['cover'] = $find['cover'];
  326. $item['pics'] = $find['pics'];
  327. $item['difference'] = $find['difference'];
  328. break;
  329. case 'MaterialEvidence':
  330. $find = MaterialEvidence::where([
  331. ['root_id', '=', $token['root_org']],
  332. ['del', '=', 0],
  333. ['publish', '=', 1],
  334. ['id', '=', $item['data_id']]
  335. ])->field('id,title,pics,difference')->find();
  336. $item['content_id'] = $find['id'];
  337. $item['title'] = $find['title'];
  338. $item['cover'] = $find['pics'];
  339. $item['difference'] = $find['difference'];
  340. break;
  341. case 'Building':
  342. $find = Building::where([
  343. ['root_id', '=', $token['root_org']],
  344. ['del', '=', 0],
  345. ['id', '=', $item['data_id']]
  346. ])->field('id,community_id,name,cover')->find();
  347. $item['content_id'] = $find['id'];
  348. $item['title'] = $find['name'];
  349. $item['cover'] = $find['cover'];
  350. break;
  351. case 'AgentArticle':
  352. $find = AgentArticle::where([
  353. ['root_id', '=', $token['root_org']],
  354. ['id', '=', $item['data_id']]
  355. ])->field('id,title,file,type')->find();
  356. $item['content_id'] = $find['id'];
  357. $item['title'] = $find['title'];
  358. $item['cover'] = $find['file'];
  359. $item['file_type'] = $find['type'];
  360. break;
  361. default:
  362. break;
  363. }
  364. }
  365. //查询分享的奖励规则
  366. $rule_data = AgentType::where([['root_id', '=', $token['root_org']], ['id', '=', $param['type']]])->value('count');
  367. $rule_list = !empty($rule_data) ? json_decode($rule_data, true) : '';
  368. $reward_rules = [];
  369. if (!empty($rule_list)) {
  370. $reward_rules[] = '1 推荐一个客户' . $rule_list['putong_integral'] . '积分';
  371. $reward_rules[] = '2 分享一条内容' . $rule_list['ptagentshare_integral'] . '积分';
  372. $reward_rules[] = '3 分享内容获得一条线索' . $rule_list['produceclue_integral'] . '积分';
  373. $reward_rules[] = '4 客户到店' . $rule_list['daodian_integral'] . '积分';
  374. $reward_rules[] = '5 客户签单' . $rule_list['jiaoding_integral'] . '积分';
  375. $reward_rules[] = '6 客户转单' . $rule_list['qiandan_integral'] . '积分';
  376. }
  377. //$reward_rules = !empty($rule_list) ? '分享一条内容'.$rule_list['ptagentshare_integral'].'积分' : '';
  378. $list = ['list' => $data, 'reward_rules' => $reward_rules];
  379. return json(['code' => 0, 'data' => $list]);
  380. }
  381. /**
  382. * 公司上传内容列表
  383. */
  384. public function company_artlist()
  385. {
  386. //$agtdata = $this->request->agtdata;
  387. $token = $this->request->token;
  388. $param = $this->request->only(['page' => 1, 'limit' => 10,'type']);
  389. $where = [
  390. ['root_id', '=', $token['root_org']],
  391. ['from', '=', 2],
  392. ['disable', '=', 0]
  393. ];
  394. $vrObj = new Vr();
  395. $list = AgentArticle::where($where)->field('id,title,file,type,content,addtime,vr_group_ids')->page($param['page'], $param['limit'])->select()->toArray();
  396. $show_url = config('app.vr_show_domain');
  397. foreach ($list as $key => $val) {
  398. //分享量
  399. $list[$key]['share_num'] = ShareLog::where([['type', '=', 'AgentArticle'], ['data_id', '=', $val['id']], ['agent_id', '<>', 'NULL']])->count();
  400. //线索
  401. $list[$key]['clue_num'] = CustomerClue::where([['pipe_type', '=', 'AgentArticle'], ['pipe_id', '=', $val['id']], ['agent_id', '<>', 0]])->count();
  402. $list[$key]['files'] = '';
  403. if ($val['type'] == 2) $list[$key]['cover'] = !empty($val['file'][0]) ? $val['file'][0] : '';
  404. if ($val['type'] == 3) {
  405. $list[$key]['files'] = !empty($val['file'][0]) ? str_replace('https://' . config('app.ali_oss_bindurl') . '/', '', $val['file'][0]) : '';
  406. $list[$key]['cover'] = !empty($val['file'][0]) ? $vrObj->getFirstImg(str_replace('https://' . config('app.ali_oss_bindurl') . '/', '', $val['file'][0])) : '';
  407. }
  408. if ($val['type'] == 4) {
  409. $group = VrGroup::where('id', $val['vr_group_ids'])->field('pic_path')->findOrEmpty();
  410. $list[$key]['cover'] = $group->isEmpty() ? '' : $group->pic_path;
  411. }
  412. $list[$key]['vr_group_url'] = '';
  413. if ($val['type'] == 4) {
  414. $group = VrGroup::where('id', $val['vr_group_ids'])->field('pic_path,sid')->findOrEmpty();
  415. if (!$group->isEmpty()) {
  416. $list[$key]['vr_group_url'] = $show_url . $group->sid;
  417. $list[$key]['file_img'] = $group->pic_path;
  418. }
  419. $data['file_img'] = $group->isEmpty() ? '' : $group->pic_path;
  420. }
  421. }
  422. //查询分享的奖励规则
  423. $rule_data = AgentType::where([['root_id', '=', $token['root_org']], ['id', '=', $param['type']]])->value('count');
  424. $rule_list = !empty($rule_data) ? json_decode($rule_data, true) : '';
  425. $reward_rules = [];
  426. if (!empty($rule_list)) {
  427. $reward_rules[] = '1 推荐一个客户' . $rule_list['putong_integral'] . '积分';
  428. $reward_rules[] = '2 分享一条内容' . $rule_list['ptagentshare_integral'] . '积分';
  429. $reward_rules[] = '3 分享内容获得一条线索' . $rule_list['produceclue_integral'] . '积分';
  430. $reward_rules[] = '4 客户到店' . $rule_list['daodian_integral'] . '积分';
  431. $reward_rules[] = '5 客户签单' . $rule_list['jiaoding_integral'] . '积分';
  432. $reward_rules[] = '6 客户转单' . $rule_list['qiandan_integral'] . '积分';
  433. }
  434. $list = ['list' => $list, 'reward_rules' => $reward_rules];
  435. return json(['code' => 0, 'data' => $list, 'msg' => '获取成功']);
  436. }
  437. /**
  438. * 分享任务详情
  439. */
  440. public function share_article_details()
  441. {
  442. $id = $this->request->param('id');
  443. $from = $this->request->param('from');
  444. $employee_id = $this->request->param('employee_id');
  445. $token = $this->request->token;
  446. //$agtdata = $this->request->agtdata;
  447. $where = [
  448. ['root_id', '=', $token['root_org']],
  449. ['id', '=', $id],
  450. ['disable', '=', 0]
  451. ];
  452. if (empty($from)) $where[] = ['employee_id', '=', $employee_id];
  453. $data = AgentArticle::where($where)->field('id,title,file,content,talkskill,type,vr_group_ids')->find();
  454. //var_dump($data);exit;
  455. $vrObj = new Vr();
  456. $data['file_img'] = $data['files'] = '';
  457. $show_url = config('app.vr_show_domain');
  458. if ($data['type'] == 3) {
  459. $data['files'] = !empty($data['file'][0]) ? str_replace('https://' . config('app.ali_oss_bindurl') . '/', '', $data['file'][0]) : '';
  460. $data['file_img'] = !empty($data['file'][0]) ? $vrObj->getFirstImg(str_replace('https://' . config('app.ali_oss_bindurl') . '/', '', $data['file'][0])) : '';
  461. }
  462. $data['vr_group_url'] = '';
  463. if ($data['type'] == 4) {
  464. $group = VrGroup::where('id', $data['vr_group_ids'])->field('pic_path,sid')->findOrEmpty();
  465. if (!$group->isEmpty()) {
  466. $data['vr_group_url'] = $show_url . $group->sid;
  467. $data['file_img'] = $group->pic_path;
  468. }
  469. $data['file_img'] = $group->isEmpty() ? '' : $group->pic_path;
  470. }
  471. return json(['code' => 0, 'data' => $data]);
  472. }
  473. /**
  474. * 经纪人端是否展示【推荐分享】板块(后台设置开关)
  475. */
  476. public function show_recommend_share()
  477. {
  478. $token = $this->request->token;
  479. $setdata = Setting::where([['root_id', '=', $token['root_org']], ['name', '=', 'agentEmployeeAdd']])->value('content');
  480. $setdata = $setdata ?: 'true';
  481. return json(['code' => 0, 'data' => $setdata]);
  482. }
  483. /**
  484. * 未成为经纪人时获取员工的uid
  485. */
  486. public function get_empuid($employee_id)
  487. {
  488. $token = $this->request->token;
  489. $uid = Employee::where([['root_id','=',$token['root_org']],['id','=',$employee_id],['state','in','在职'],['uid','>',0]])->value('uid');
  490. return json(['code' => 0, 'data' => $uid,'msg'=>'获取成功']);
  491. }
  492. }