WeibanExternal.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php namespace App\Http\Controllers\Admin;
  2. use App\Models\Custom;
  3. use App\Models\WeiBan\External as Model;
  4. use App\Models\WeiBan\Tags as WeiBanTags;
  5. use Illuminate\Support\Carbon;
  6. /**
  7. * 客户管理
  8. *
  9. * @author 刘相欣
  10. *
  11. */
  12. class WeibanExternal extends Auth{
  13. protected function _initialize(){
  14. parent::_initialize();
  15. $this->assign('breadcrumb1','用户管理');
  16. $this->assign('breadcrumb2','微伴客户');
  17. }
  18. /**
  19. * 列表页
  20. *
  21. * */
  22. public function index(Model $Model,Custom $Custom,WeiBanTags $WeiBanTags ){
  23. // 接受参数
  24. $id = request('id','');
  25. $status = request('status');
  26. $name = request('name');
  27. $phone = request('phone');
  28. $remark = request('remark');
  29. $startTime = request('start_time','');
  30. // 查询条件
  31. $map = [];
  32. // 编码ID
  33. if( $id ) $map[] = ['weiban_external.id','=',$id];
  34. if( $name ) $map[] = ['weiban_external.name','=',$name];
  35. if( $phone ) $map[] = ['weiban_follow.phone_number','=',$phone];
  36. if( $remark ) $map[] = ['weiban_follow.remark','=',$remark];
  37. if( $startTime ) $map[] = ['weiban_external.insert_time','>=',Carbon::createFromFormat('Y-m-d',$startTime)->startOfDay()->getTimestamp()];
  38. if( $startTime ) $map[] = ['weiban_external.insert_time','<=',Carbon::createFromFormat('Y-m-d',$startTime)->endOfDay()->getTimestamp()];
  39. if( !is_null($status) ) $map[] = ['weiban_external.status','=',$status];
  40. // 查询数据
  41. $list = $Model->query()->join('weiban_follow','weiban_follow.weiban_extid','=','weiban_external.id')->where($map)->orderByDesc('insert_time')->paginate(config('page_num',10),['weiban_external.*','weiban_follow.staff_id','weiban_follow.staff_name','weiban_follow.remark','weiban_follow.phone_number'])->appends(request()->all());
  42. // 循环处理数据
  43. foreach ($list as $key => $value) {
  44. // id转编号
  45. $value['custom_code'] = $value['custom_uid'] ? $Custom->idToCode($value['custom_uid']) : '';
  46. // 获取标签
  47. $value['tags_list'] = $WeiBanTags->getListByWeibanExtid($value['id']);
  48. // 重组
  49. $list[$key] = $value;
  50. }
  51. // 分配数据
  52. $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
  53. $this->assign('list',$list);
  54. // 加载模板
  55. return $this->fetch();
  56. }
  57. }