Wisdom.php 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <?php
  2. namespace app\sys\controller;
  3. use app\model\Building;
  4. use app\model\BuildingHousetype;
  5. use app\model\Community;
  6. use think\facade\View;
  7. use app\model\Setting;
  8. use app\model\SmartScreen;
  9. use think\facade\Request;
  10. use app\model\SmartScreenCate;
  11. use app\model\SmartScreenData;
  12. use toolkits\Aec;
  13. use app\model\CustomerVisitLog;
  14. use xiaohongwu\Vr;
  15. use app\model\Designer;
  16. use app\model\Employee;
  17. use app\model\User;
  18. use app\model\Customer;
  19. use app\model\Permission;
  20. use app\model\Company;
  21. use app\model\ConstructionStep;
  22. use app\model\CustomerWisdomImg;
  23. use app\model\RenovatePrice;
  24. use app\model\RenovatePriceItem;
  25. use app\model\SmartScreenLog;
  26. use app\model\VrGroup;
  27. use think\facade\Cache;
  28. use app\model\DesignerCollectionWorks;
  29. use app\model\Org;
  30. use app\model\SmartScreenConstruction;
  31. use app\model\SmartScreenProject;
  32. use app\model\Housetype;
  33. use app\model\SmartScreenProjectCate;
  34. use app\model\DesignerCustomerPlandata;
  35. use app\model\CustomerPortraitFieldSelect;
  36. use app\model\Decostyle;
  37. use openssl\Aes;
  38. class Wisdom
  39. {
  40. private $modular;
  41. private $root_id;
  42. private $employee_id;
  43. private $customer_id;
  44. public function __construct()
  45. {
  46. $this->modular = ['introduce' => '公司简介', 'pattern' => '模式优势', 'boutique' => '精品设计', 'science' => '材料', 'major' => '大牌软装', 'customized' => '定制家具', 'realistic' => '实景样板房', 'praise' => '口碑及服务', 'platinum' => '铂金工程'];
  47. $param = Request::only(['token' => '']);
  48. $value = '';
  49. if ($param['token']) {
  50. $aec = new Aec(config('app.aec_key'), config('app.aec_iv'));
  51. $value = $aec->decrypt($param['token']);
  52. }
  53. if(!$value){
  54. json(['code'=>1,'msg'=>'参数错误'])->send();
  55. exit;
  56. }
  57. $value = explode('#',$value);
  58. $this->root_id = $value[0];
  59. $this->employee_id = $value[1];
  60. $this->customer_id = $value[2];
  61. }
  62. /**
  63. * 面板
  64. */
  65. public function index()
  66. {
  67. //9个模块
  68. $modular = array_keys($this->modular);
  69. $where = [
  70. ['root_id', '=', $this->root_id],
  71. ['code', 'in', $modular]
  72. ];
  73. $res = SmartScreen::where($where)->column('*', 'code');
  74. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  75. foreach ($res as $k2 => $v2) {
  76. $res[$k2]['background_img'] = $v2['background_img'] ? 'https://' . $ali_oss_bindurl . '/' . $v2['background_img'] : '';
  77. $res[$k2]['lcon_img'] = $v2['lcon_img'] ? 'https://' . $ali_oss_bindurl . '/' . $v2['lcon_img'] : '';
  78. }
  79. $diff = array_diff($modular, array_keys($res));
  80. $row = [];
  81. foreach ($diff as $v) {
  82. $row[$v] = [
  83. 'title' => $this->modular[$v],
  84. 'code' => $v,
  85. 'background_img' => '',
  86. 'lcon_img' => ''
  87. ];
  88. }
  89. $row = array_merge($res, $row);
  90. //排序后的数据
  91. $where = [
  92. ['name', '=', 'wisdomMenuOrder'],
  93. ['root_id', '=', $this->root_id]
  94. ];
  95. $ids = Setting::where($where)->value('content');
  96. $order = Permission::where([['uri','like','%smartScreen/content?type=%']])->order('sort asc,id asc')->column('uri,id');
  97. if ($ids) {
  98. $ids = array_flip(explode(',',$ids));
  99. foreach ($order as $key => $value) {
  100. $order[$key]['order'] = $ids[$value['id']];
  101. }
  102. array_multisort(array_column($order,'order'),SORT_ASC, $order);
  103. }
  104. $order = array_column($order,'uri');
  105. $res = [];
  106. foreach ($order as $v2) {
  107. foreach ($row as $v3) {
  108. if(strpos($v2,$v3['code']) !== false){
  109. $res[$v3['code']] = $v3;
  110. break;
  111. }
  112. }
  113. }
  114. //前端跳需要转参数
  115. $url = SmartScreen::changeState('url');
  116. foreach ($res as $k4 => $v4) {
  117. $field = $url[$k4];
  118. $res[$k4] = array_merge($v4,$field);
  119. }
  120. //录音开关
  121. $where = [
  122. ['name', '=', 'recordingSwitch'],
  123. ['root_id', '=', $this->root_id]
  124. ];
  125. $info = Setting::where($where)->findOrEmpty();
  126. $switch = (!$info->isEmpty() && $info->content) ? 1 : 0;
  127. //公司名称
  128. $company_name = Company::where('root_id',$this->root_id)->value('company_name');
  129. $bind = $this->customer_id ? 1 : 0;
  130. //设计师编辑方案管理判断
  131. $empdata = Employee::with(['org'])->where([['root_id', '=', $this->root_id], ['id', '=', $this->employee_id]])->field('id,org_id')->find();
  132. $is_designer = !empty($empdata['org']['org_type']) && $empdata['org']['org_type'] == 2 ? 1 : 0;
  133. $designer_edit = $is_designer ? 1 : 0;
  134. $plandata = ['background_img' => '', 'code' => 'plandata', 'lcon_img' => '', 'logo' => 'icon-fanganguanli_mian', 'title' => '方案资料', 'url' => '/index/programme', 'sort' => 2];
  135. $res['plandata'] = $plandata;
  136. return json(['code' => 0, 'data' => $res, 'designer_edit' => $designer_edit, 'switch' => $switch, 'company_name' => $company_name, 'bind' => $bind]);
  137. }
  138. /**
  139. * 获取一级分类
  140. */
  141. public function getCate1()
  142. {
  143. $param = Request::only(['type'=>'']);
  144. $where = [
  145. ['root_id','=',$this->root_id],
  146. ['level','=',1],
  147. ['pid','=',0],
  148. ['del','=',0],
  149. ['code','=',$param['type']]
  150. ];
  151. $res = SmartScreenCate::where($where)->select()->toArray();
  152. return json(['code'=> 0, 'data'=> $res]);
  153. }
  154. /**
  155. * 获取二级分类
  156. */
  157. public function getCate2()
  158. {
  159. $param = Request::only(['type'=>'','pid'=>0]);
  160. $where = [
  161. ['root_id','=',$this->root_id],
  162. ['level','=',2],
  163. ['pid','=',$param['pid']],
  164. ['del','=',0],
  165. ['code','=',$param['type']]
  166. ];
  167. $cate2 = SmartScreenCate::where($where)->select()->toArray();
  168. $where = [
  169. ['root_id','=',$this->root_id],
  170. ['level','=',3],
  171. ['pid','in',array_column($cate2,'id')],
  172. ['del','=',0],
  173. ['code','=',$param['type']]
  174. ];
  175. $cate3 = SmartScreenCate::where($where)->select()->toArray();
  176. foreach ($cate2 as $k2 => $v2) {
  177. $cate2[$k2]['child'] = [];
  178. foreach ($cate3 as $k3 => $v3) {
  179. if ($v2['id']==$v3['pid']) {
  180. $cate2[$k2]['child'][] = $v3;
  181. }
  182. }
  183. }
  184. return json(['code'=> 0, 'data'=> $cate2]);
  185. }
  186. /**
  187. * 获取内容
  188. */
  189. public function getData()
  190. {
  191. $param = Request::only(['cate1'=>0,'cate2'=>0,'cate3'=>'','page'=>1,'limit'=>10,'community_id'=>0,'decostyle_id'=>0,'housetype_id'=>0]);
  192. $where[] = ['cate1','=',$param['cate1']];
  193. $where[] = ['del','=',0];
  194. $where[] = ['root_id','=',$this->root_id];
  195. if ($param['cate2']) $where[] = ['cate2','=',$param['cate2']];
  196. if ($param['cate3']){
  197. $ids = explode(',',$param['cate3']);
  198. $where[] = ['cate3','in',$ids];
  199. }
  200. if($param['community_id']) $where[] = ['community_id','=',$param['community_id']];
  201. if($param['decostyle_id']) $where[] = ['decostyle_id','=',$param['decostyle_id']];
  202. if($param['housetype_id']) $where[] = ['housetype_id','=',$param['housetype_id']];
  203. $list = SmartScreenData::with(['designer'=>function($query){
  204. $query->field('id,name')->bind(['designer_name'=>'name']);
  205. },'community'=>function($query){
  206. $query->field('id,title')->bind(['community_name'=>'title']);
  207. },'decostyle'=>function($query){
  208. $query->field('id,title')->bind(['decostyle_name'=>'title']);
  209. },'housetype'=>function($query){
  210. $query->field('id,title')->bind(['housetype_name'=>'title']);
  211. },'cate1'=>function($query){
  212. $query->field('id,title,is_case')->bind(['cate1_name'=>'title','is_case'=>'is_case']);
  213. },'cate2'=>function($query){
  214. $query->field('id,title')->bind(['cate2_name'=>'title']);
  215. },'cate3'=>function($query){
  216. $query->field('id,title')->bind(['cate3_name'=>'title']);
  217. }])->where($where)->page($param['page'],$param['limit'])->select()->toArray();
  218. $vrObj = new Vr();
  219. foreach ($list as $k => $v) {
  220. $list[$k]['vr_case_img'] = $v['vr_case'] ? getFirstImg($v['vr_case']) : '';
  221. //封面图
  222. if ($v['is_case']==0 && $v['difference']==3) {
  223. $list[$k]['leixing'] = 'VR';
  224. $list[$k]['covers'] = $v['vr_case'] ? getFirstImg($v['vr_case']) : '';
  225. }elseif ($v['is_case']==0 && $v['difference']==1){
  226. $list[$k]['leixing'] = '视频';
  227. if ($v['cover']) {
  228. $list[$k]['covers'] = $v['cover'];
  229. }elseif ($v['video_case']) {
  230. $list[$k]['covers'] = $v['video_case'].'?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast';
  231. }else{
  232. $list[$k]['covers'] = '';
  233. }
  234. // $list[$k]['covers'] = $v['cover'] ? $v['cover'].'?x-oss-process=image/resize,w_50' : '';
  235. // $list[$k]['covers'] = $v['covers'] ? $v['video_case'].'?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast' : '';
  236. }elseif ($v['is_case']==0 && $v['difference']==2){
  237. $list[$k]['leixing'] = '图文';
  238. $list[$k]['covers'] = $v['cover'];
  239. }elseif ($v['is_case']==0 && $v['difference']==4){
  240. $list[$k]['leixing'] = 'PDF';
  241. $list[$k]['covers'] = $v['cover'];
  242. }elseif($v['difference']==5){
  243. $list[$k]['leixing'] = 'VR作品';
  244. $list[$k]['covers'] = '';
  245. //VR作品
  246. if ($v['vr_case']) {
  247. $sid = str_replace(substr($v['vr_case'],0,-32),'',$v['vr_case']);
  248. $info = VrGroup::where('sid',$sid)->field('pic_path')->findOrEmpty();
  249. $list[$k]['covers'] = $info->isEmpty() ? '' : $info->pic_path;
  250. }
  251. }else{
  252. $list[$k]['leixing'] = '案例';
  253. $list[$k]['covers'] = $v['cover'];
  254. }
  255. }
  256. $count = SmartScreenData::where($where)->count();
  257. return json(['code'=> 0, 'data'=> $list,'count'=>$count]);
  258. }
  259. /**
  260. * 获取详情
  261. */
  262. public function getRead()
  263. {
  264. $param = Request::only(['id'=>0]);
  265. $where = [
  266. ['id','=',$param['id']]
  267. ];
  268. $vrObj = new Vr();
  269. $res = SmartScreenData::with(['designer'=>function($query){
  270. $query->field('id,name')->bind(['designer_name'=>'name','position'=>'position','image_photo'=>'image_photo']);
  271. },'community'=>function($query){
  272. $query->field('id,title')->bind(['community_name'=>'title']);
  273. },'decostyle'=>function($query){
  274. $query->field('id,title')->bind(['decostyle_name'=>'title']);
  275. },'housetype'=>function($query){
  276. $query->field('id,title')->bind(['housetype_name'=>'title']);
  277. },'cate1'=>function($query){
  278. $query->field('id,title')->bind(['cate1_name'=>'title','is_case'=>'is_case']);
  279. },'cate2'=>function($query){
  280. $query->field('id,title')->bind(['cate2_name'=>'title']);
  281. },'cate3'=>function($query){
  282. $query->field('id,title')->bind(['cate3_name'=>'title']);
  283. }])->where('id',$param['id'])->find();
  284. $res->vr_case_img = '';
  285. if ($res->vr_case && strpos($res->vr_case,'vr/#')) {
  286. //2023-06-02 vr作品获取封面图
  287. $sid = str_replace(substr($res->vr_case,0,-32),'',$res->vr_case);
  288. $info = VrGroup::where('sid',$sid)->field('pic_path')->findOrEmpty();
  289. $res->vr_case_img = $info->isEmpty() ? '' : $info->pic_path;
  290. }elseif ($res->vr_case) {
  291. $res->vr_case_img = $vrObj->getFirstImg($res->vr_case);
  292. }
  293. $res->good_at = [];
  294. if($res->designer_id){
  295. $designer = Designer::where('employee_id',$res->designer_id)->findOrEmpty();
  296. if (!$designer->isEmpty()) {
  297. $res->good_at = $designer->good_at;
  298. }
  299. }
  300. if ($res->vr_case) {
  301. $url_res = filter_var($res->vr_case, FILTER_VALIDATE_URL);
  302. if ($url_res === FALSE){
  303. $res->vr_case = '';
  304. }
  305. }
  306. $employee['phone'] = $employee['name'] = $employee['img'] = '';
  307. if ($this->employee_id) {
  308. $info = Employee::where('id',$this->employee_id)->find();
  309. $employee['phone'] = $info->phone;
  310. $employee['name'] = $info->name;
  311. $employee['img'] = User::where('id',$info->uid)->value('headimgurl');
  312. }
  313. return json(['code'=> 0, 'data'=> $res,'info'=>$employee]);
  314. }
  315. /**
  316. * 讲解记录
  317. * $time = 0#unix,1#unix,0#unix
  318. */
  319. public function saveLog()
  320. {
  321. if(!$this->employee_id || !$this->customer_id) return json(['code'=> 1, 'data'=> '未绑定客户','msg'=>'未绑定客户']);
  322. $param = Request::only(['file'=>'','time'=>'']);
  323. $info = Employee::where('id',$this->employee_id)->find();
  324. $customer_name = Customer::where('id',$this->customer_id)->value('name');
  325. $count = explode(',',$param['time']);
  326. if (count($count)<=1) {
  327. $param['time'] = '';
  328. $param['unix'] = 0;
  329. }else{
  330. $param['unix'] = end($count);
  331. $str = array_slice($count,0,count($count)-1);
  332. $param['time'] = implode('',$str);
  333. }
  334. $param['time'] = '接待了客户:'.$customer_name.',谈单时长:'.ceil($param['unix']/60).'分钟;<br/>智慧屏讲解内容:<br/>'.$param['time'];
  335. $save = [
  336. 'customer_id'=>$this->customer_id,
  337. 'type'=>1,
  338. 'remark'=>$param['time'].'@讲解智慧屏##'.$param['file'],
  339. 'employee_id'=>$this->employee_id,
  340. 'user_id' => $info->uid,
  341. 'customer_employee_id' => $this->employee_id,
  342. 'org_id' => $info->org_id,
  343. 'customer_org_id' => $info->org_id,
  344. 'state'=>'未到访',
  345. 'next_contact_date' =>date('Y-m-d'),
  346. 'talking_order_time'=> ceil($param['unix']/60)
  347. ];
  348. CustomerVisitLog::create($save);
  349. return json(['code'=> 0, 'data'=> '保存成功']);
  350. }
  351. /**
  352. * 获取客户智慧屏图片图片
  353. */
  354. public function getWisdomImg(){
  355. if(!$this->employee_id || !$this->customer_id) return json(['code'=> 0, 'data'=> [],'msg'=>'']);
  356. $param = Request::only(['type'=>0]);
  357. $where = [
  358. 'customer_id'=>$this->customer_id,
  359. 'type'=>$param['type'],
  360. 'root_id' => $this->root_id
  361. ];
  362. $list = CustomerWisdomImg::where($where)->field('id,img')->order('id asc')->select()->toArray();
  363. return json(['code'=> 0, 'data'=>$list, 'msg'=> '获取成功']);
  364. }
  365. /**
  366. * 获取报价套餐
  367. */
  368. public function getRenovatePackage(){
  369. if(!$this->employee_id || !$this->customer_id) return json(['code'=> 0, 'data'=> ['package_list'=>[],'cusdata'=>[]],'msg'=>'']);
  370. //$param = Request::only(['type'=>0]);
  371. $package_list = RenovatePrice::where([['root_id','=',$this->root_id],['status','=',0]])->field('id,package_name,addtime')->order('sort desc')->select()->toArray();
  372. $cusdata = Customer::where([['org_id','in',orgSubIds($this->root_id)],['id','=',$this->customer_id]])->field('id,name,phone,community_name,square,ext')->find();
  373. $cusdata['unit_number'] = '';
  374. if(!empty($cusdata['ext'])){
  375. $ext = json_decode($cusdata['ext'],true);
  376. foreach($ext as $key=>$val){
  377. if(!empty($val['keyname']) && $val['keyname'] == 'unit_number') $cusdata['unit_number'] = $val['value'];
  378. }
  379. }
  380. $data = ['package_list'=>$package_list,'cusdata'=>$cusdata];
  381. return json(['code'=> 0, 'data'=>$data, 'msg'=> '获取成功']);
  382. }
  383. /**
  384. * 计算报价
  385. */
  386. public function callRenovatePrice()
  387. {
  388. if(!$this->employee_id || !$this->customer_id) return json(['code'=>0,'data'=>[],'msg'=>'获取成功']);
  389. $param = Request::only(['hall'=>0,'room'=>0,'kitchen'=>0,'toilet'=>0,'square'=>0,'package_id'=>0,'out_square'=>0,'name'=>'','community_name'=>'']);
  390. $package_id = !empty($param['package_id']) ? explode(',',$param['package_id']) : '';
  391. if(empty($package_id)) return json(['code'=>'1','msg'=>'套餐参数错误']);
  392. if(empty($param['square'])) return json(['code'=>1,'msg'=>'面积为空']);
  393. $cusdata = Customer::where([['org_id','in',orgSubIds($this->root_id)],['id','=',$this->customer_id]])->find();
  394. if(!empty($param['name'])) $cusdata->name = $param['name'];
  395. if(!empty($param['community_name'])) $cusdata->community_name = $param['community_name'];
  396. if(!empty($param['square'])) $cusdata->square = $param['square'];
  397. $cusdata->save();
  398. $packdata = RenovatePrice::with('item')->where([['root_id','=',$this->root_id],['id','in',$package_id]])->select()->toArray();
  399. if(empty($packdata)) return json(['code'=>1,'msg'=>'套餐不存在']);
  400. foreach($packdata as $k=>$v){
  401. $price = 0;
  402. $discount_price = 0;
  403. //$item = $v['item'] ? $v['item'] : [];
  404. //if(empty($item)) $price = 0;
  405. //rule 1=>单价*套内建筑面积 2=>单价*建筑面积 3=>单价*卧室数 4=>单价*卫生间数 5=>单价*厨房数 6=>固定价 7=>单价*客厅数
  406. foreach($v['item'] as $key=>$val){
  407. if($val['rule']==1 && !empty($param['square'])){
  408. $price+= $val['price'] * $param['square'];
  409. $discount_price+= $val['discount_price'];
  410. $packdata[$k]['item'][$key]['item_price'] = round($val['price'] * $param['square'] * $v['service_price'],2);
  411. }
  412. if($val['rule']==2 && !empty($param['out_square'])){
  413. $price+= $val['price'] * $param['out_square'];
  414. $discount_price+= $val['discount_price'];
  415. $packdata[$k]['item'][$key]['item_price'] = round($val['price'] * $param['out_square'] * $v['service_price'],2);
  416. }
  417. if($val['rule']==3 && !empty($param['room'])){
  418. $price+= $val['price'] * $param['room'];
  419. $discount_price+= $val['discount_price'];
  420. $packdata[$k]['item'][$key]['item_price'] = round($val['price'] * $param['room'] * $v['service_price'],2);
  421. }
  422. if($val['rule']==4 && !empty($param['toilet'])){
  423. $price+= $val['price'] * $param['toilet'];
  424. $discount_price+= $val['discount_price'];
  425. $packdata[$k]['item'][$key]['item_price'] = round($val['price'] * $param['toilet'] * $v['service_price'],2);
  426. }
  427. if($val['rule']==5 && !empty($param['kitchen'])){
  428. $price+= $val['price'] * $param['kitchen'];
  429. $discount_price+= $val['discount_price'];
  430. $packdata[$k]['item'][$key]['item_price'] = round($val['price'] * $param['kitchen'] * $v['service_price'],2);
  431. }
  432. if($val['rule']==6){
  433. $price+= $val['price'];
  434. $discount_price+= $val['discount_price'];
  435. $packdata[$k]['item'][$key]['item_price'] = round($val['price'] * $v['service_price'],2);
  436. }
  437. if($val['rule']==7 && !empty($param['hall'])){
  438. $price+= $val['price'] * $param['hall'];
  439. $discount_price+= $val['discount_price'];
  440. $packdata[$k]['item'][$key]['item_price'] = round($val['price'] * $param['hall'] * $v['service_price'],2);
  441. }
  442. }
  443. $price = $price * $v['service_price'] + $v['devise_price'] - $discount_price;
  444. $packdata[$k]['price'] = round($price,2);
  445. $packdata[$k]['discount_price'] = $discount_price;
  446. $packdata[$k]['yuan_price'] = round($price,2) + $discount_price;
  447. }
  448. $remark = '客户'.$cusdata->name.'于'.date('Y-m-d H:i:s').'使用';
  449. $msg = '';
  450. foreach($packdata as $k=>$v){
  451. $msg.= $v['package_name'].'套餐进行装修报价,价格为'.$v['price'].'元,优惠金额为'.$v['discount_price'].'元';
  452. }
  453. //echo ($remark.trim($msg,','));exit;
  454. $info = Employee::where([['root_id','=',$this->root_id],['id','=',$this->employee_id]])->find();
  455. //增加客户计算报价的记录
  456. $save = [
  457. 'customer_id'=>$this->customer_id,
  458. 'type'=>1,
  459. 'remark'=>$remark.trim($msg,','),
  460. 'employee_id'=>$this->employee_id,
  461. 'user_id' => $info->uid,
  462. 'customer_employee_id' => $this->employee_id,
  463. 'org_id' => $info->org_id,
  464. 'customer_org_id' => $info->org_id,
  465. 'state'=>$cusdata->state != '待确认' ? 10 : 1,
  466. 'next_contact_date' =>date('Y-m-d')
  467. ];
  468. CustomerVisitLog::create($save);
  469. return json(['code'=>0,'data'=>$packdata,'msg'=>'获取成功']);
  470. }
  471. /**
  472. * 生成绑定二维码
  473. * 每次刷新都是新码
  474. *
  475. */
  476. public function getQrcode()
  477. {
  478. $list = scandir('upload');
  479. foreach ($list as $v) {
  480. if(strpos($v,'wisdomqrcode') !== false) @unlink('upload/'.$v); //删除失效文件
  481. }
  482. $str = 'wisdomqrcode'.uniqid().'@'.$this->root_id.'@';
  483. $name = $str.'.jpg';
  484. $img = qrcode($str, 'upload/'.$name);
  485. $url = request()->domain().'/'.'upload/'.$name;
  486. return json(['code'=>0,'data'=>$url,'msg'=>'获取成功','str'=>$str]);
  487. }
  488. /**
  489. * 循环调用api
  490. */
  491. public function ergodic()
  492. {
  493. $param = Request::only(['str'=>'']);
  494. if(!$param['str']) return json(['code'=>1,'data'=>'未绑定','msg'=>'未绑定']);
  495. $res = Cache::get($param['str']);
  496. if($res){
  497. $aec = new Aec(config('app.aec_key'), config('app.aec_iv'));
  498. $value = $aec->decrypt($res);
  499. $value = explode('#',$value);
  500. $root_id = $value[0];
  501. $employee_id = $value[1];
  502. $customer_id = $value[2];
  503. $log_data['root_id'] = $root_id;
  504. $log_data['employee_id'] = $employee_id;
  505. $log_data['customer_id'] = $customer_id;
  506. $log_data['str'] = $res;
  507. $log_data['time'] = 0;
  508. SmartScreenLog::create($log_data);
  509. return json(['code'=>0,'data'=>$res,'msg'=>'获取成功']);
  510. }else{
  511. return json(['code'=>1,'data'=>'未绑定','msg'=>'未绑定']);
  512. }
  513. }
  514. /**
  515. * 解绑
  516. */
  517. public function logout()
  518. {
  519. $param = Request::only(['str'=>'']);
  520. $log_where[] = ['root_id', '=', $this->root_id];
  521. $log_where[] = ['employee_id', '=', $this->employee_id];
  522. $log_where[] = ['customer_id', '=', $this->customer_id];
  523. $log_where[] = ['str', '=', $param['str']];
  524. $find = SmartScreenLog::where($log_where)->findOrEmpty();
  525. if (!$find->isEmpty()) {
  526. $time = time() - strtotime($find['addtime']);
  527. $find->time = $time;
  528. $find->endtime = date('Y-m-d H:i:s');
  529. $find->save();
  530. }
  531. $res = Cache::delete($param['str']);
  532. $aec = new Aec(config('app.aec_key'), config('app.aec_iv'));
  533. $str = $aec->encrypt($this->root_id.'#0#0');
  534. return json(['code'=>0,'data'=>$str,'msg'=>'解绑成功']);
  535. }
  536. /**
  537. * 客户设计师列表
  538. */
  539. public function cus_designer_list()
  540. {
  541. $orgids = orgSubIds($this->root_id);
  542. $where[] = ['org_id', 'in', $orgids];
  543. $where[] = ['id', '=', $this->customer_id];
  544. $assign = Customer::where($where)->value('assigned_personnel');
  545. $list = [];
  546. if (!empty($assign)) {
  547. $list = Employee::hasWhere('org', ['org_type' => 2])->where('Employee.id', 'in', explode(',', $assign))->column('Employee.id,Employee.name');
  548. }
  549. return json(['code' => 0, 'data' => $list, 'msg' => '获取成功']);
  550. }
  551. /**
  552. * 设计师个人介绍
  553. */
  554. public function designer_detail($designer_id)
  555. {
  556. $dw[] = ['root_id', '=', $this->root_id];
  557. $dw[] = ['employee_id', '=', $designer_id];
  558. $data = Designer::where($dw)->field('headimgurl,good_at,desc,position,work_years,good_house,design_concept,vcr')->find();
  559. $data['is_designer'] = !empty($data) ? 1 : 2;
  560. $data['employee_name'] = Employee::where([['root_id', '=', $this->root_id], ['id', '=', $this->employee_id]])->value('name');
  561. return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']);
  562. }
  563. /**
  564. * 设计师作品集
  565. */
  566. public function designer_worklist()
  567. {
  568. $param = Request::only(['page' => 1, 'limit' => 10, 'housetype_id' => 0, 'designer_id']);
  569. if (empty($param['designer_id'])) return json(['code' => 1, 'msg' => '请选择设计师']);
  570. $dw[] = ['root_id', '=', $this->root_id];
  571. $dw[] = ['employee_id', '=', $param['designer_id']];
  572. if (!empty($param['housetype_id'])) $dw[] = ['housetype_id', '=', $param['housetype_id']];
  573. $list = DesignerCollectionWorks::with(['decostyle', 'housetype'])->where($dw)->page($param['page'], $param['limit'])->select()->toArray();
  574. foreach ($list as $key => $val) {
  575. if ($val['type'] == 2 && !empty($val['vr_case'])) {
  576. $list[$key]['cover_img'] = !empty($val['vr_case'][0]['vr_img']) ? $val['vr_case'][0]['vr_img'] : '';
  577. }
  578. }
  579. return json(['code' => 0, 'data' => $list, 'msg' => '获取成功']);
  580. }
  581. /**
  582. * 作品集户型分类
  583. */
  584. public function work_housetype($designer_id)
  585. {
  586. $dw[] = ['root_id', '=', $this->root_id];
  587. $dw[] = ['employee_id', '=', $designer_id];
  588. $ids = DesignerCollectionWorks::where($dw)->group('housetype_id')->column('housetype_id');
  589. $list = Housetype::where([['root_id', '=', $this->root_id], ['id', 'in', $ids]])->column('id,name');
  590. return json(['code' => 0, 'data' => $list, 'msg' => '获取成功']);
  591. }
  592. /**
  593. * 设计师作品详情
  594. */
  595. public function designer_workdet()
  596. {
  597. $param = Request::only(['designer_id' => 0, 'id' => 0]);
  598. $where[] = ['root_id', '=', $this->root_id];
  599. $where[] = ['employee_id', '=', $param['designer_id']];
  600. $where[] = ['id', '=', $param['id']];
  601. $data = DesignerCollectionWorks::with(['decostyle', 'housetype'])->where($where)->find();
  602. $info = Employee::with(['user' => function ($query) {
  603. $query->field('id,headimgurl');
  604. }])->where([['root_id', '=', $this->root_id], ['id', '=', $this->employee_id]])->field('uid,name,phone')->find()->toArray();
  605. $info['img'] = !empty($info['user']['headimgurl']) ? $info['user']['headimgurl'] : '';
  606. if (empty($data)) return json(['code' => 1, 'msg' => '数据不存在']);
  607. return json(['code' => 0, 'data' => $data, 'info' => $info, 'msg' => '获取成功']);
  608. }
  609. /**
  610. * 工地状态
  611. */
  612. public function construction_step()
  613. {
  614. $root_id = $this->root_id;
  615. $step_list = ConstructionStep::where('root_id', '=', $root_id)->order('order asc')->select()->toArray();
  616. return json(['code' => 0, 'data' => $step_list]);
  617. }
  618. /**
  619. * 在施工地
  620. */
  621. public function construction()
  622. {
  623. $root_id = $this->root_id;
  624. $param = request()->only(['page'=> 1, 'limit'=> 15, 'keyword'=> '', 'emp_name'=> '', 'status'=> '']);
  625. $model = SmartScreenConstruction::with(['designer', 'employee'])->where([['root_id', '=', $root_id]]);
  626. if (!empty($param['keyword'])){
  627. $where_k = [['owner_name|address', 'like', '%' . $param['keyword'] . '%']];
  628. $model = $model->where($where_k);
  629. }
  630. if (!empty($param['emp_name'])) {
  631. $where_e = [['project_manager|inspection', 'like', '%' . $param['emp_name'] . '%']];
  632. $emp_name = $param['emp_name'];
  633. $designer_org = Org::where([['path', 'like', $root_id . '%'], ['org_type', '=', 2], ['status', '=', 1]])->column('id');
  634. $designer_id = Employee::where([['root_id', '=', $root_id], ['name', 'like', '%' . $param['emp_name'] . '%'], ['state', '=', '在职'], ['org_id', 'in', $designer_org]])->column('id');
  635. $where_d = [['designer_id', 'in', $designer_id]];
  636. if (empty($designer_id)) {
  637. $model = $model->where($where_e);
  638. } else {
  639. $model = $model->where(function ($query) use ($emp_name, $where_d) {
  640. $query->whereOr([[['project_manager', 'like', '%' . $emp_name . '%']], [['inspection', 'like', '%' . $emp_name . '%']], $where_d]);
  641. });
  642. }
  643. }
  644. if (!empty($param['status'])) {
  645. $where_s = [['status', '=', $param['status']]];
  646. $model = $model->where($where_s);
  647. }
  648. $count = $model->count();
  649. $list = $model->order('addtime desc')->page($param['page'], $param['limit'])->select()->toArray();
  650. return json(['code'=> 0, 'data'=> $list, 'count'=> $count]);
  651. }
  652. /**
  653. * 项目清单
  654. */
  655. public function project(){
  656. $root_id = $this->root_id;
  657. $param = request()->only(['page'=> 1, 'limit'=> 15, 'keyword'=> '']);
  658. $where[] = ['root_id', '=', $root_id];
  659. $keyword = $param['keyword'];
  660. $list = SmartScreenProjectCate::with(['project'=> function($query) use ($keyword){
  661. if ($keyword) {
  662. $query->where('name', 'like', '%' . $keyword . '%')->with('employee');
  663. } else {
  664. $query->with('employee');
  665. }
  666. }])->withCount(['project'=> function($query) use ($keyword){
  667. $query->where('name', 'like', '%' . $keyword . '%')->with('employee');
  668. }])->where('root_id', '=', $root_id)->page($param['page'], $param['limit'])->select()->toArray();
  669. $count = SmartScreenProjectCate::where($where)->count();
  670. return json(['code'=> 0, 'data'=> $list, 'count'=> $count]);
  671. }
  672. /**
  673. * 获取设计师的所有客户
  674. */
  675. public function designer_cuslist()
  676. {
  677. $param = request()->only(['page' => 1, 'limit' => 15, 'keyword' => '']);
  678. $check = Employee::with(['org'])->where([['root_id', '=', $this->root_id], ['id', '=', $this->employee_id]])->find();
  679. if (!empty($check['org']) && $check['org']['org_type'] != 2) return json(['code' => 1, 'data' => [], 'msg' => '获取成功']);
  680. $orgids = orgSubIds($this->root_id);
  681. $where[] = ['org_id', 'in', $orgids];
  682. $where[] = ['designer_id|assigned_personnel', 'find in set', $this->employee_id];
  683. $where[] = ['state', 'not in', Customer::changeState('无效', 'chaos')];
  684. $orCondition = [];
  685. if (!empty($param['keyword'])) {
  686. $aec = new Aes(config('app.aec_key'), config('app.aec_iv'));
  687. $aecPhone = $aec->encrypt($param['keyword']);
  688. $orCondition = [
  689. [['name', 'like', '%'.$param['keyword'].'%']],
  690. [['phone', '=', $aecPhone]]
  691. ];
  692. }
  693. if (empty($orCondition))
  694. $list = Customer::with(['plandata'])->where($where)->field('id,name,community_name,sex,ext')->page($param['page'], $param['limit'])->order('assign_time desc')->select()->toArray();
  695. else
  696. $list = Customer::with(['plandata'])->where($where)->where(function ($query) use ($orCondition) {
  697. $query->whereOr($orCondition);
  698. })->field('id,name,community_name,sex,ext')->page($param['page'], $param['limit'])->order('assign_time desc')->select()->toArray();
  699. foreach ($list as &$val) {
  700. $imglist = CustomerWisdomImg::where(['customer_id' => $val['id']])->field('img')->select()->toArray();
  701. $val['img_cont'] = count($imglist);
  702. $val['vr_cont'] = !empty($val['plandata']['vrurl']) ? count($val['plandata']['vrurl']) : 0;
  703. $val['pdf_cont'] = !empty($val['plandata']['pdfurl']) ? count($val['plandata']['pdfurl']) : 0;
  704. $val['plandata']['imgurl'] = !empty($imglist) ? array_column($imglist,'img') : '';
  705. $housetype_arrow = '';
  706. if (!empty($val['ext'])) {
  707. $ext_data = json_decode($val['ext'], true);
  708. foreach ($ext_data as $k => $v) {
  709. if (isset($v['keyname']) && $v['keyname'] == 'housetype_arrow' && !empty($v['value'])) {
  710. $housetype_arrow = CustomerPortraitFieldSelect::where([['pid', '=', $v['id']], ['id', '=', $v['value']]])->value('name');
  711. }
  712. }
  713. }
  714. $val['housetype_arrow'] = $housetype_arrow;
  715. }
  716. $count = Customer::where($where)->count();
  717. return json(['code' => 0, 'data' => $list, 'count' => $count, 'msg' => '获取成功']);
  718. }
  719. /**
  720. * 客户的方案资料详情
  721. */
  722. public function planDetail($cid = null)
  723. {
  724. $cid = empty($cid) ? $this->customer_id : $cid;
  725. $orgids = orgSubIds($this->root_id);
  726. $customer = Customer::where([['id', '=', $cid], ['org_id', 'in', $orgids]])->find();
  727. if (empty($customer)) return json(['code' => 0, 'data' => [], 'msg' => '获取失败']);
  728. $data = DesignerCustomerPlandata::where([['root_id', '=', $this->root_id], ['designer_id', '=', $this->employee_id], ['customer_id', '=', $cid]])->find();
  729. if (empty($data)) $data = [];
  730. else $data = $data->toArray();
  731. $imgList = CustomerWisdomImg::where([['root_id', '=', $this->root_id], ['customer_id', '=', $cid]])->order('addtime asc')->column('img');
  732. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  733. foreach ($imgList as $k => $img) {
  734. $imgList[$k] = 'https://' . $ali_oss_bindurl . '/' . $img;
  735. }
  736. $data['imgurl'] = $imgList;
  737. return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']);
  738. }
  739. /**
  740. * 设计师编辑客户的方案资料
  741. */
  742. public function designer_editplan()
  743. {
  744. $param = request()->only(['customer_id' => 0, 'imgurl' => '', 'vrurl' => '', 'pdfurl' => '']);
  745. if (empty($param['customer_id'])) return json(['code' => 1, 'msg' => '参数错误']);
  746. $where[] = ['root_id', '=', $this->root_id];
  747. $where[] = ['designer_id', '=', $this->employee_id];
  748. $where[] = ['customer_id', '=', $param['customer_id']];
  749. $check = DesignerCustomerPlandata::where($where)->find();
  750. $vrstr = '';
  751. if (!empty($param['vrurl'])) {
  752. $vrlist = explode(',', $param['vrurl']);
  753. foreach ($vrlist as $val) {
  754. $vrstr .= vrlinkSet($val) . ',';
  755. }
  756. $vrstr = trim($vrstr, ',');
  757. }
  758. $save = [
  759. 'vrurl' => $vrstr,
  760. 'pdfurl' => $param['pdfurl']
  761. ];
  762. if (empty($check)) {
  763. $save['designer_id'] = $this->employee_id;
  764. $save['customer_id'] = $param['customer_id'];
  765. $save['root_id'] = $this->root_id;
  766. DesignerCustomerPlandata::create($save);
  767. } else {
  768. $save['id'] = $check->id;
  769. DesignerCustomerPlandata::update($save);
  770. }
  771. if (!empty($param['imgurl'])) {
  772. $imgList = explode(',', $param['imgurl']);
  773. $domain = config('app.ali_oss_bindurl');
  774. $replaceDomain = 'https://' . $domain . '/';
  775. $nowHad = CustomerWisdomImg::where([
  776. ['root_id', '=', $this->root_id],
  777. ['customer_id', '=', $param['customer_id']]
  778. ])->column('id');
  779. $updateId = [];
  780. foreach ($imgList as $v) {
  781. $v = str_replace($replaceDomain, '', $v);
  782. $save = [
  783. 'root_id' => $this->root_id,
  784. 'customer_id' => $param['customer_id'],
  785. 'img' => $v
  786. ];
  787. $hadid = CustomerWisdomImg::where($save)->value('id');
  788. if ($hadid) {
  789. $updateId[] = $hadid;
  790. } else {
  791. $customerWisdomImg = CustomerWisdomImg::create($save);
  792. $updateId[] = $customerWisdomImg->id;
  793. }
  794. }
  795. $delId = array_diff($nowHad, $updateId);
  796. if ($delId)
  797. CustomerWisdomImg::where([['id', 'in', $delId]])->delete();
  798. }
  799. return json(['code' => 0, 'msg' => '编辑成功']);
  800. }
  801. /**
  802. * 获取VR链接第一帧
  803. */
  804. public function get_vrimg($url)
  805. {
  806. $url = vrlinkSet($url);
  807. $data = ['vr_link' => $url, 'vr_img' => getFirstImg($url)];
  808. return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']);
  809. }
  810. /**
  811. * 清空客户方案资料
  812. */
  813. public function delPlandata($cid)
  814. {
  815. $where[] = ['customer_id', '=', $cid];
  816. $where[] = ['root_id', '=', $this->root_id];
  817. $where[] = ['designer_id', '=', $this->employee_id];
  818. $check = DesignerCustomerPlandata::where($where)->find();
  819. if (empty($check)) return json(['code' => 1, 'msg' => '数据不存在']);
  820. $check->imgurl = $check->vrurl = $check->pdfurl = null;
  821. $check->save();
  822. CustomerWisdomImg::where([
  823. 'root_id' => $this->root_id,
  824. 'customer_id' => $cid,
  825. ])->delete();
  826. return json(['code' => 0, 'msg' => '清除成功']);
  827. }
  828. /*
  829. * 作品集户型
  830. */
  831. public function housetypelist()
  832. {
  833. $housetype = Housetype::where(['root_id' => $this->root_id])->field('id,name')->select();
  834. $decostyles = Decostyle::field('id,name')->where([['root_id', '=', $this->root_id], ['type', '=', 0]])->select();
  835. $data = ['housetype' => $housetype, 'decostyles' => $decostyles];
  836. return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']);
  837. }
  838. /**
  839. * 设计师增加个人作品
  840. */
  841. public function designer_add_works()
  842. {
  843. $param = Request::only(['id' => 0, 'title', 'style_id' => 0, 'housetype_id' => 0, 'square', 'money', 'type', 'desc' => '', 'vr_case' => '']);
  844. if (strlen($param['title']) > 50) {
  845. return json(['code' => 1, 'msg' => '作品名称过长']);
  846. }
  847. $cover_img = $vrstr = null;
  848. if (!empty($param['vr_case']) && $param['type'] == 2) {
  849. $vrlist = explode(',', $param['vr_case']);
  850. foreach ($vrlist as $val) {
  851. $vrstr .= vrlinkSet($val) . ',';
  852. }
  853. $vrstr = trim($vrstr, ',');
  854. }
  855. if (!empty($param['desc']) && $param['type'] == 1) {
  856. $imgs = explode(',', $param['desc']);
  857. $cover_img = $imgs[0];
  858. }
  859. $add = [
  860. 'title' => $param['title'],
  861. 'housetype_id' => $param['housetype_id'],
  862. 'square' => $param['square'],
  863. 'money' => $param['money'],
  864. 'type' => $param['type'],
  865. 'desc' => $param['desc'],
  866. 'cover_img' => $cover_img,
  867. 'vr_case' => $vrstr,
  868. 'style_id' => $param['style_id']
  869. ];
  870. if ($param['id']) {
  871. $check = DesignerCollectionWorks::where([['root_id', '=', $this->root_id], ['employee_id', '=', $this->employee_id], ['id', '=', $param['id']]])->find();
  872. if (empty($check)) return json(['code' => 1, 'msg' => '数据不存在']);
  873. $add['id'] = $param['id'];
  874. DesignerCollectionWorks::update($add);
  875. } else {
  876. $empdata = Employee::with(['org'])->where([['root_id', '=', $this->root_id], ['id', '=', $this->employee_id]])->field('id,org_id')->find();
  877. $add['employee_id'] = $this->employee_id;
  878. $add['root_id'] = $this->root_id;
  879. $add['designer_id'] = $empdata['org']['org_type'] == 2 ? $this->employee_id : 0;
  880. $ms = DesignerCollectionWorks::create($add);
  881. }
  882. return json(['code' => 0, 'msg' => '编辑成功']);
  883. }
  884. /**
  885. * 设计师个人作品详情
  886. */
  887. public function designer_worksdet()
  888. {
  889. $param = Request::only(['id']);
  890. $data = DesignerCollectionWorks::with(['decostyle', 'housetype'])->where([['root_id', '=', $this->root_id], ['employee_id', '=', $this->employee_id], ['id', '=', $param['id']]])->find();
  891. if (empty($data)) return json(['code' => 1, 'msg' => '数据不存在']);
  892. return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']);
  893. }
  894. /**
  895. * 设计师作品集列表
  896. */
  897. public function designer_work()
  898. {
  899. $param = Request::only(['page' => 1, 'limit' => 10, 'keyword', 'type', 'housetype_id']);
  900. $where[] = ['root_id', '=', $this->root_id];
  901. $where[] = ['employee_id', '=', $this->employee_id];
  902. if (!empty($param['keyword'])) $where[] = ['title', 'like', '%' . $param['keyword'] . '%'];
  903. if (!empty($param['type'])) $where[] = ['type', '=', $param['type']];
  904. if (!empty($param['housetype_id'])) $where[] = ['housetype_id', '=', $param['housetype_id']];
  905. $list = DesignerCollectionWorks::with(['decostyle', 'housetype'])->where($where)->page($param['page'], $param['limit'])->select()->toArray();
  906. foreach ($list as $key => $val) {
  907. if ($val['type'] == 2 && !empty($val['vr_case'])) {
  908. $list[$key]['cover_img'] = !empty($val['vr_case'][0]['vr_img']) ? $val['vr_case'][0]['vr_img'] : '';
  909. }
  910. }
  911. $count = DesignerCollectionWorks::where($where)->count();
  912. return json(['code' => 0, 'data' => $list, 'count' => $count, 'msg' => '获取成功']);
  913. }
  914. /**
  915. * 设计师个人作品集户型分类
  916. */
  917. public function designer_housetype()
  918. {
  919. $dw[] = ['root_id', '=', $this->root_id];
  920. $dw[] = ['employee_id', '=', $this->employee_id];
  921. $ids = DesignerCollectionWorks::where($dw)->group('housetype_id')->column('housetype_id');
  922. $list = Housetype::where([['root_id', '=', $this->root_id], ['id', 'in', $ids]])->column('id,name');
  923. return json(['code' => 0, 'data' => $list, 'msg' => '获取成功']);
  924. }
  925. /**
  926. * 内部资料
  927. */
  928. public function private_data(){
  929. $page = input('page', 1, 'intval');
  930. $limit = input('limit', 10, 'intval');
  931. $keyword = input('keyword', '', 'trim');
  932. $where[] = ['BuildingHousetype.root_id', '=', $this->root_id];
  933. if ($keyword) {
  934. $community_id = Community::where([['root_id', '=', $this->root_id], ['name', 'like', '%' . $keyword . '%']])->column('id');
  935. $building_id = Building::where([['root_id', '=', $this->root_id], ['community_id', 'in', $community_id]])->column('id');
  936. $where[] = ['BuildingHousetype.building_id', 'in', $building_id];
  937. }
  938. $list = BuildingHousetype::has('file', '>', 0)->with(['file', 'building'])->where($where)->page($page, $limit)->select()->toArray();
  939. $count = BuildingHousetype::has('file', '>', 0)->where($where)->count();
  940. return json(['code'=> 0, 'data'=> $list, 'msg'=> '获取成功', 'count'=> $count]);
  941. }
  942. }