12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php namespace App\Http\Controllers\Admin;
- use App\Models\Custom;
- use App\Models\WeiBan\External as Model;
- use App\Models\WeiBan\Tags as WeiBanTags;
- use Illuminate\Support\Carbon;
- /**
- * 客户管理
- *
- * @author 刘相欣
- *
- */
- class WeibanExternal extends Auth{
- protected function _initialize(){
- parent::_initialize();
- $this->assign('breadcrumb1','用户管理');
- $this->assign('breadcrumb2','微伴客户');
- }
- /**
- * 列表页
- *
- * */
- public function index(Model $Model,Custom $Custom,WeiBanTags $WeiBanTags ){
- // 接受参数
- $id = request('id','');
- $status = request('status');
- $name = request('name');
- $phone = request('phone');
- $remark = request('remark');
- $startTime = request('start_time','');
- // 查询条件
- $map = [];
- // 编码ID
- if( $id ) $map[] = ['weiban_external.id','=',$id];
- if( $name ) $map[] = ['weiban_external.name','=',$name];
- if( $phone ) $map[] = ['weiban_follow.phone_number','=',$phone];
- if( $remark ) $map[] = ['weiban_follow.remark','=',$remark];
- if( $startTime ) $map[] = ['weiban_external.insert_time','>=',Carbon::createFromFormat('Y-m-d',$startTime)->startOfDay()->getTimestamp()];
- if( $startTime ) $map[] = ['weiban_external.insert_time','<=',Carbon::createFromFormat('Y-m-d',$startTime)->endOfDay()->getTimestamp()];
- if( !is_null($status) ) $map[] = ['weiban_external.status','=',$status];
- // 查询数据
- $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());
- // 循环处理数据
- foreach ($list as $key => $value) {
- // id转编号
- $value['custom_code'] = $value['custom_uid'] ? $Custom->idToCode($value['custom_uid']) : '';
- // 获取标签
- $value['tags_list'] = $WeiBanTags->getListByWeibanExtid($value['id']);
- // 重组
- $list[$key] = $value;
- }
- // 分配数据
- $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
- $this->assign('list',$list);
- // 加载模板
- return $this->fetch();
- }
- }
|