Ver código fonte

修改

master
chenx 2 anos atrás
pai
commit
ce35504ec8

+ 1
- 1
application/admin/controller/Appoint.php Ver arquivo

@@ -266,7 +266,7 @@ class Appoint extends BaseController
//修改客户的status
if ($this->param['is_deal'] == 2) {//未成交
$Customer_status = 5;
$Appoint_data = ['status' => $Customer_status, 'is_deal' => $this->param['is_deal'], 'reason' => $this->param['reason'], 'update_time' => $_SERVER['REQUEST_TIME']];
$Appoint_data = ['status' => $Customer_status, 'is_deal' => $this->param['is_deal'], 'reason' => $this->param['reason'], 'update_time' => $_SERVER['REQUEST_TIME'], 'feedback' => $this->param['feedback']];
} else {
$Customer_status = 4;
$Appoint_data = ['status' => $Customer_status, 'is_deal' => $this->param['is_deal'], 'collection' => $this->param['collection'], 'update_time' => $_SERVER['REQUEST_TIME']];

+ 6
- 0
application/admin/controller/User.php Ver arquivo

@@ -227,6 +227,12 @@ class User extends BaseController
if ($this->userInfo['id'] == $this->param[$User_model->getPk()]) {
tojson(10000, '不能删除自己');
}
//已绑定客户,不能删除
$Customer_model = new \app\admin\model\Customer();
$check = $Customer_model->where('user_id', $this->param[$User_model->getPk()])->value('id');
if ($check) {
tojson(10000, '已绑定客户,不能删除');
}
$result = $User_model->where($User_model->getPk(), $this->param[$User_model->getPk()])->delete();
if ($result) {
tojson(200, '删除成功');

+ 23
- 10
application/admin/model/Appoint.php Ver arquivo

@@ -71,16 +71,22 @@ class Appoint extends Model
// $whereOr[] = ['a.status', 'in', [3, 6]];
// $whereOr[] = ['a.appoint_time', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
// $where[] = ['a.is_returnvisit', '=', 1];
// $where[] = ['a.return_visit', '=', 0];
$where[] = ['a.return_visit', '=', 0];
$where[] = ['a.feedback', '=', ''];
// $where[] = ['a.status', 'between', [4, 6]];
$where[] = ['a.status', 'in', [1, 2, 4, 5, 6]];
//连表
$where[] = ['a.appoint_time', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$where[] = ['a.appoint_time', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59'))]];
} else {
$where[] = ['a.status', 'in', [1, 6]];
}
} else {
$where[] = ['a.status', '=', $param['status']];
//已预约包含已改约
if ($param['status'] == 1) {
$where[] = ['a.status', 'in', [$param['status'], 6]];
} else {
$where[] = ['a.status', '=', $param['status']];
}
}
}
if ($userInfo['role'] == 3) {
@@ -129,7 +135,7 @@ class Appoint extends Model
}
$with = ['getDistrictOneData', 'getHospitalOneData', 'getUserOneData', 'getCollectioOneData'];
$Customer_model = new \app\admin\model\Customer();
$field = 'a.id,a.city_id,a.status,a.is_remind,a.remark,a.hospital_id,a.customer_id,a.is_returnvisit,FROM_UNIXTIME(a.appoint_time) as appoint_time,c.demand,c.age,c.name as customer_name,c.user_id,c.sex,a.satisfaction,a.equity,a.price,a.programme,a.concerns,a.is_complaint,a.complaint,c.phone,c.information,FROM_UNIXTIME(a.update_time) as update_time,FROM_UNIXTIME(a.create_time) as create_time,a.reason,a.return_visit';
$field = 'a.id,a.city_id,a.status,a.is_remind,a.remark,a.hospital_id,a.customer_id,a.is_returnvisit,FROM_UNIXTIME(a.appoint_time) as appoint_time,c.demand,c.age,c.name as customer_name,c.user_id,c.sex,a.satisfaction,a.equity,a.price,a.programme,a.concerns,a.is_complaint,a.complaint,c.phone,c.information,FROM_UNIXTIME(a.update_time) as update_time,FROM_UNIXTIME(a.create_time) as create_time,a.reason,a.return_visit,a.feedback';
// if (isset($whereOr)) {
// $result = $this->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id')->field($field)->where($where)->whereOr(function ($query) use ($whereOr) {
// $query->where($whereOr);
@@ -140,7 +146,7 @@ class Appoint extends Model
// } else {
if (isset($param['dgx']) && $param['dgx'] == 1) {
$Collection_model = new \app\admin\model\Collection();
$result = $this->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id')->join($Collection_model->getTable() . ' t', 'c.id = t.customer_id')->field($field)->where($where)->with($with)->select()->toArray();
$result = $this->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id')->field($field)->where($where)->with($with)->select()->toArray();//->join($Collection_model->getTable() . ' t', 'c.id = t.customer_id')
} else {
$result = $this->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id')->field($field)->where($where)->with($with)->limit($page, $pageSize)->select();
$total = $this->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id')->where($where)->count();
@@ -180,9 +186,16 @@ class Appoint extends Model
}
break;
}
if (empty($v['feedback'])) {
$result[$k]['feedback'] = $v['feedback2'];
}
if (isset($param['dgx']) && $param['dgx'] == 1) {
if (!empty($v['feedback']) || $v['return_visit'] == 1) {
unset($result[$k]);
$check = $Collection_model->where('appoint_id', $v['id'])->where('is_examine', 1)->where('customer_id', $v['customer_id'])->value('id');
if (!$check) {
$feedback = $Collection_model->where('appoint_id', $v['id'])->where('customer_id', $v['customer_id'])->value('feedback');
if (!empty($feedback)) {
unset($result[$k]);
}
}
}
}
@@ -211,7 +224,7 @@ class Appoint extends Model

public function getCollectioOneData()
{
return $this->hasOne(\app\admin\model\Collection::class, 'appoint_id', 'id')->bind(['feedback' => 'feedback', 'scene_zixun' => 'scene_zixun', 'visiting_doctor' => 'visiting_doctor']);
return $this->hasOne(\app\admin\model\Collection::class, 'appoint_id', 'id')->bind(['feedback2' => 'feedback', 'scene_zixun' => 'scene_zixun', 'visiting_doctor' => 'visiting_doctor']);
}

public function getCustomerOneData()
@@ -251,9 +264,9 @@ class Appoint extends Model
if (strlen($v['months']) < 2) {
$result[$k]['months'] = ['0' . $v['months']];
} else {
$result[$k]['months'] = [$v['months']];
$result[$k]['months'] = [(string)$v['months']];
}
$result[$k]['days'] = [$v['days']];
$result[$k]['days'] = [(string)$v['days']];
$result[$k]['years'] = [$v['years']];
}
//calendarData: [

+ 5
- 2
application/admin/model/Customer.php Ver arquivo

@@ -135,8 +135,11 @@ class Customer extends Model
// $nowDate = date('Y-m-d');
// $now_start = strtotime($nowDate . ' 00:00:00');
// $now_end = strtotime($nowDate . ' 23:59:59');
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59'))]];
$whereOr[] = ['status', '=', 5];
if ($userInfo['role'] == 3) {
$whereOr[] = ['user_id', '=', $userInfo['id']];
}
}
if (isset($param['followup']) && $param['followup'] == 1) {
$where[] = ['followup_time', '=', 0];
@@ -212,7 +215,7 @@ class Customer extends Model
// $nowDate = date('Y-m-d');
// $now_start = strtotime($nowDate . ' 00:00:00');
// $now_end = strtotime($nowDate . ' 23:59:59');
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59'))]];
$whereOr[] = ['status', '=', 2];
} else {
$whereOr[] = ['status', '=', 1];

+ 54
- 14
application/admin/model/User.php Ver arquivo

@@ -28,13 +28,20 @@ class User extends Model
// $dgx = $Appoint_model->query($dgx);
// $dgx = (empty($dgx)) ? 0 : $dgx[0]['count'];
$Collection_model = new \app\admin\model\Collection();
$where[] = ['a.status', 'between', [1, 6]];
$where[] = ['a.status', 'in', [1, 2, 4, 5, 6]];
$where[] = ['a.return_visit', '=', 0];
$where[] = ['a.feedback', '=', ''];
//连表
$where[] = ['a.appoint_time', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$dgx2 = $Appoint_model->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id and c.user_id = ' . $userInfo['id'])->join($Collection_model->getTable() . ' t', 'c.id = t.customer_id')->field('a.id')->where($where)->with(['getCollectioOneData'])->select()->toArray();
$dgx2 = $Appoint_model->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id and c.user_id = ' . $userInfo['id'])->field('a.id,a.customer_id')->where($where)->select()->toArray();//->join($Collection_model->getTable() . ' t', 'c.id = t.customer_id')->with(['getCollectioOneData'])
//收款记录,审核不通过也要显示
foreach ($dgx2 as $k => $v) {
if (!empty($v['feedback'])) {
unset($dgx2[$k]);
$check = $Collection_model->where('appoint_id', $v['id'])->where('is_examine', 1)->where('customer_id', $v['customer_id'])->value('id');
if (!$check) {
$feedback = $Collection_model->where('appoint_id', $v['id'])->where('customer_id', $v['customer_id'])->value('feedback');
if (!empty($feedback)) {
unset($dgx2[$k]);
}
}
}
$dgx = array_values($dgx2);
@@ -56,7 +63,7 @@ class User extends Model
//跟进时间查询,如果是今天的话,就查询
// $now_start = strtotime($nowDate . ' 00:00:00');
// $now_end = strtotime($nowDate . ' 23:59:59');
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59'))]];
// $whereOr[] = ['followup_setting', 'between', [$now_start, $now_end]];
$whereOr[] = ['user_id', '=', $userInfo['id']];
$whereOr[] = ['status', '=', 2];
@@ -64,9 +71,10 @@ class User extends Model
$query->where($whereOr);
})->count();//待预约
$whereOr = [];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59'))]];
// $whereOr[] = ['followup_setting', 'between', [$now_start, $now_end]];
$whereOr[] = ['status', '=', 5];
$whereOr[] = ['user_id', '=', $userInfo['id']];
$wcj = $Customer_model->where('status', 5)->where('user_id', $userInfo['id'])->where('followup_time', 0)->whereOr(function ($query) use ($whereOr) {
$query->where($whereOr);
})->count();//未成交
@@ -84,7 +92,7 @@ class User extends Model
// }
// }
//本月排行榜
$Collection = $Customer_model->alias('t')->rightJoin($Appoint_model->getTable() . ' a', 't.id = a.customer_id')->group('t.user_id')->field('t.user_id,count(1) as count,t.id')->whereBetween('a.create_time', [$month_start, $month_end])->with(['getUserOneData'])->select()->toArray();
$Collection = $Customer_model->alias('t')->join($Appoint_model->getTable() . ' a', 't.id = a.customer_id')->group('t.user_id')->field('t.user_id,count(1) as count,t.id')->whereBetween('a.create_time', [$month_start, $month_end])->with(['getUserOneData'])->select()->toArray();
$Collection2 = $Customer_model->alias('t')->join($Collection_model->getTable() . ' c', 't.id = c.customer_id')->field('sum(collection_money) as collection_money,sum(refundcollection_money) as refundcollection_money,sum(deal_money) as deal_money,sum(newdeal_money) as newdeal_money,sum(refunddeal_money) as refunddeal_money,t.user_id,c.type')->whereBetween('c.collection_time', [$month_start, $month_end])->group('t.user_id')->select()->toArray();
$Collection3 = [];
foreach ($Collection2 as $k => $v) {
@@ -112,7 +120,11 @@ class User extends Model
if (!empty($Collection[$k]['all_collection_money'])) {
$Collection[$k]['all_collection_money'] = $Collection[$k]['all_collection_money'] / 100;
}
if (empty($v['username'])) {
unset($Collection[$k]);
}
}
$Collection = array_values($Collection);
array_multisort(array_column($Collection, 'all_deal_money'), SORT_DESC, $Collection);
foreach ($Collection as $k => $v) {
$Collection[$k]['id'] = $k + 1;
@@ -171,12 +183,19 @@ class User extends Model
// $dgx = $Appoint_model->where('is_returnvisit', 1)->where('return_visit', 0)->where('status', 4)->whereBetween('appoint_time', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))])->count();
$Collection_model = new \app\admin\model\Collection();
$where[] = ['a.status', 'in', [1, 2, 4, 5, 6]];
$where[] = ['a.return_visit', '=', 0];
$where[] = ['a.feedback', '=', ''];
//连表
$where[] = ['a.appoint_time', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$dgx2 = $Appoint_model->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id')->join($Collection_model->getTable() . ' t', 'c.id = t.customer_id')->field('a.id,a.return_visit')->where($where)->with(['getCollectioOneData'])->select()->toArray();
$dgx2 = $Appoint_model->alias('a')->join($Customer_model->getTable() . ' c', 'a.customer_id = c.id')->field('a.id,a.customer_id')->where($where)->select()->toArray();//->join($Collection_model->getTable() . ' t', 'c.id = t.customer_id')->with(['getCollectioOneData'])
//收款记录,审核不通过也要显示
foreach ($dgx2 as $k => $v) {
if (!empty($v['feedback']) || $v['return_visit'] == 1) {
unset($dgx2[$k]);
$check = $Collection_model->where('appoint_id', $v['id'])->where('is_examine', 1)->where('customer_id', $v['customer_id'])->value('id');
if (!$check) {
$feedback = $Collection_model->where('appoint_id', $v['id'])->where('customer_id', $v['customer_id'])->value('feedback');
if (!empty($feedback)) {
unset($dgx2[$k]);
}
}
}
$dgx = array_values($dgx2);
@@ -203,14 +222,14 @@ class User extends Model
// $now_start = strtotime($nowDate . ' 00:00:00');
// $now_end = strtotime($nowDate . ' 23:59:59');
$whereOr = [];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59'))]];
// $whereOr[] = ['followup_setting', 'between', [$now_start, $now_end]];
$whereOr[] = ['status', '=', 2];
$dyy = $Customer_model->where('status', 2)->where('followup_time', 0)->whereOr(function ($query) use ($whereOr) {
$query->where($whereOr);
})->count();//待预约
$whereOr = [];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))]];
$whereOr[] = ['followup_setting', 'between', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59'))]];
// $whereOr[] = ['followup_setting', 'between', [$now_start, $now_end]];
$whereOr[] = ['status', '=', 5];
$wcj = $Customer_model->where('status', 5)->where('followup_time', 0)->whereOr(function ($query) use ($whereOr) {
@@ -230,7 +249,7 @@ class User extends Model
// }
// }
//本月排行榜
$Collection = $Customer_model->alias('t')->rightJoin($Appoint_model->getTable() . ' a', 't.id = a.customer_id')->group('t.user_id')->field('t.user_id,count(1) as count,t.id')->whereBetween('a.create_time', [$month_start, $month_end])->with(['getUserOneData'])->select()->toArray();
$Collection = $Customer_model->alias('t')->join($Appoint_model->getTable() . ' a', 't.id = a.customer_id')->group('t.user_id')->field('t.user_id,count(1) as count,t.id')->whereBetween('a.create_time', [$month_start, $month_end])->with(['getUserOneData'])->select()->toArray();
$Collection2 = $Customer_model->alias('t')->join($Collection_model->getTable() . ' c', 't.id = c.customer_id')->field('sum(collection_money) as collection_money,sum(refundcollection_money) as refundcollection_money,sum(deal_money) as deal_money,sum(newdeal_money) as newdeal_money,sum(refunddeal_money) as refunddeal_money,t.user_id,c.type')->whereBetween('c.collection_time', [$month_start, $month_end])->group('t.user_id')->select()->toArray();
$Collection3 = [];
foreach ($Collection2 as $k => $v) {
@@ -258,7 +277,11 @@ class User extends Model
if (!empty($Collection[$k]['all_collection_money'])) {
$Collection[$k]['all_collection_money'] = $Collection[$k]['all_collection_money'] / 100;
}
if (empty($v['username'])) {
unset($Collection[$k]);
}
}
$Collection = array_values($Collection);
// array_multisort(array_column($Collection, 'all_deal_money'), SORT_DESC, $Collection);
$Collection = self::sortArrByManyField($Collection, 'all_deal_money', SORT_DESC, 'count', SORT_DESC);
foreach ($Collection as $k => $v) {
@@ -842,7 +865,24 @@ class User extends Model
$ddcjl = bcdiv($cj, $dd, 2) * 100 . '%';//到店成交率
}
}

if (count(explode('.', $cj_money)) == 2) {
$cj_money_check = explode('.', $cj_money);
if ($cj_money_check[1] == '0') {
$cj_money = $cj_money_check[0];
}
}
if (count(explode('.', $sk_money)) == 2) {
$sk_money_check = explode('.', $sk_money);
if ($sk_money_check[1] == '0') {
$sk_money = $sk_money_check[0];
}
}
if (count(explode('.', $pjkdj)) == 2) {
$pjkdj_check = explode('.', $pjkdj);
if ($pjkdj_check[1] == '0') {
$pjkdj = $pjkdj_check[0];
}
}
return ['kh' => $kh, 'yy' => $yy, 'ydd' => $ydd, 'dd' => $dd, 'cj' => $cj, 'cj_money' => $cj_money, 'sk_money' => $sk_money, 'tk_money' => $tk_money, 'pjkdj' => $pjkdj, 'xsyyl' => $xsyyl, 'yyddl' => $yyddl, 'ddcjl' => $ddcjl];
}
//$today_kh = $Customer_model->whereBetween('create_time', [$today_start, $today_end])->count();//新增客户数

+ 1
- 1
thinkphp/library/think/exception/RouteNotFoundException.php Ver arquivo

@@ -27,7 +27,7 @@ class RouteNotFoundException extends HttpException
$task->name = '定时器任务';
$task->count = 1;//开启多少个进程运行定时任务,注意多进程并发问题
$task->onWorkerStart = function ($task) {
Timer::add(1, array('\app\crontab\controller\Crontab', 'task'), array(), true);
Timer::add(10, array('\app\crontab\controller\Crontab', 'task'), array(), true);
};

// 运行worker

Carregando…
Cancelar
Salvar