123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace app\api\controller;
- use app\model\Activity;
- use app\model\Customer;
- use app\model\CustomerClue;
- use app\model\CustomerVisitLog;
- use app\model\MaterialCase;
- use app\model\Decostyle;
- use app\model\Org;
- use app\model\Employee;
- use app\model\Construction;
- use app\model\Community;
- use app\model\MaterialEvidence;
- use app\model\Building;
- use app\model\BuildingSpecialEmp;
- use app\model\CompanyVrshow;
- class Index extends Base
- {
- /*
- * 首页顶部汇总数据
- */
- public function datacount()
- {
- $first = date('Y-m-d 00:00:00', strtotime('first day of this month'));
- $last = date('Y-m-d 23:59:59', strtotime('last day of this month'));
- // 本月建档
- $customer = Customer::where([['addtime', 'between', [$first, $last]], ['employee_id', '=', $this->request->token['employee_id']]])->count();
- // 本月定金
- $ding = CustomerVisitLog::where([['addtime', 'between', [$first, $last]], ['employee_id', '=', $this->request->token['employee_id']], ['state', 'in', CustomerVisitLog::changeState('交定', 'chaos')]])->count();
- // 本月签单
- $sign = CustomerVisitLog::where([['addtime', 'between', [$first, $last]], ['employee_id', '=', $this->request->token['employee_id']], ['state', 'in', CustomerVisitLog::changeState('签单', 'chaos')]])->count();
- // 本月线索
- $clue = CustomerClue::where([['addtime', 'between', [$first, $last]], ['employee_id', '=', $this->request->token['employee_id']]])->count();
- // 现有客户总量
- $total = Customer::where([['employee_id', '=', $this->request->token['employee_id']]])->count();
- // 数据整理
- $data = [
- 'ding' => $ding,
- 'sign' => $sign,
- 'customer' => $customer,
- 'clue' => $clue
- ];
- return json(['code' => self::success, 'month' => $data, 'total' => $total]);
- }
- //批量审核回答
- public function all_approve_comment()
- {
- $data['id'] = input('id');
- $data['status'] = input('status', 0);
- $data['sum'] = mt_rand(1000, 333444);
- return json(['code' => 0, 'data' => $data, 'count' => 0, 'msg' => '获取成功']);
- exit;
- }
- //案例,风格,设计师,在施工地,小区楼盘,业主好评等数量统计
- public function afszxy_count()
- {
- $token = $this->request->token;
- $where[] = ['type', '=', 0];
- $where[] = ['root_id', '=', $token['root_org']];
- $communityArr = Community::where($where)->field('id,name,pinyin,case_num')->select()->toArray();
- $comidlist = array_column($communityArr, 'id');
- $case_num = MaterialCase::where([['community_id', 'in', $comidlist], ['del', '=', 0], ['publish', '=', 1]])->count();
- $style_num = Decostyle::where([['root_id', '=', $token['root_org']], ['type', '=', 0]])->count();
- $w[] = ['path', 'like', $token['root_org'] . '-%'];
- $w[] = ['org_type', '=', 2];
- $orgs = Org::where($w)->column('id');
- $designer_num = Employee::where([['org_id', 'in', $orgs], ['root_id', '=', $token['root_org']], ['show', '=', 0], ['state', '=', '在职']])->count();
- $construction_num = Construction::where([['root_id', '=', $token['root_org']],['del','=',0],['status','=',1]])->count();
- $employee_id = $this->request->token['employee_id'];
- //查询设置可见人信息
- $special = BuildingSpecialEmp::where('root_id', $this->request->token['root_org'])->value('assign_employee');
- $assign_employee = !empty($special) ? explode(',', $special) : [];
- if (in_array($employee_id, $assign_employee)) {
- $communities_num = Building::where('root_id', '=', $token['root_org'])->count();
- } else {
- $communities_num = Building::where('root_id', '=', $token['root_org'])->where(function ($query) use ($employee_id) {
- $query->whereRaw("FIND_IN_SET(" . $employee_id . " , assign_employee)")
- ->whereOr('assign_employee', '=', NULL)
- ->whereOr('assign_employee', '=', '');
- })->where(function ($query) use ($employee_id) {
- $query->whereRaw("`from` = 0 or (`from` =1 and `org_id` =" . $this->request->token['org_id'] . ") or ( `from` = 1 and (FIND_IN_SET(" . $employee_id . " , assign_employee)))");
- })->count();
- }
- $evidence_num = MaterialEvidence::where([['del', '=', 0], ['root_id', '=', $token['root_org']], ['publish', '=', 1]])->count();
- // 活动数量统计
- $activity_num = Activity::where([['del', '=', 0], ['show', '=', 1], ['root_id', '=', $token['root_org']], ['end_date', '>=', date('Y-m-d')]])->count();
-
- /**----------------需要演示乐尚企业,展示数量进行调整,正式使用系统时删除此代码------------------------*/
- if($token['root_org'] == 1793) {
- $case_num = 2680;
- $evidence_num = 1652;
- $construction_num = 1286;
- }
- /*-----------------------------------------------------------------------------------------------------*/
- $data = ['case_num' => $case_num, 'style_num' => $style_num, 'designer_num' => $designer_num, 'construction_num' => $construction_num, 'communities_num' => $communities_num, 'evidence_num' => $evidence_num, 'activity_num' => $activity_num
- ];
- return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']);
- }
- /**
- * 公司线上展厅列表
- */
- public function compvrshow_list()
- {
- $token = $this->request->token;
- $where[] = ['type', '=', 1];
- $where[] = ['root_id', '=', $token['root_org']];
- $list = CompanyVrshow::where($where)->select()->toArray();
- return json(['code' => 0, 'data' => $list, 'msg' => '获取成功']);
- }
- }
|