|
@@ -18,7 +18,7 @@ use Tinywan\Jwt\JwtToken;
|
|
|
|
|
|
class CustomService
|
|
|
{
|
|
|
- const DIFF_TIME = (60 * 60 * 24 * 30);
|
|
|
+ const DIFF_TIME = (60 * 60 * 24 * 30); //调入团队公池 x4 = 调入集团公池
|
|
|
/**
|
|
|
* Notes: 返回选项配置信息
|
|
|
* User: yb
|
|
@@ -222,10 +222,35 @@ class CustomService
|
|
|
->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)");
|
|
|
}];
|
|
|
} else {
|
|
|
- //已经流入公池
|
|
|
- $where[] = [function($query) use ($diffNums, $currentTime){
|
|
|
- $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
|
|
|
- }];
|
|
|
+ if (true === $deptIds) {
|
|
|
+ if (!empty($params['pub_status'])) {
|
|
|
+ if ($params['pub_status'] == 2) {
|
|
|
+ //仅检索团队公池
|
|
|
+ $where[] = [function($query) use ($diffNums, $currentTime){
|
|
|
+ $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
|
|
|
+ }];
|
|
|
+ } else {
|
|
|
+ //仅检索集团公池
|
|
|
+ $where[] = [function($query) use ($diffNums, $currentTime){
|
|
|
+ $query->orWhereRaw("((visit_time + ({$diffNums} * 4)) - {$currentTime} <= 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //超管权限
|
|
|
+ $where[] = [function($query) use ($diffNums, $currentTime){
|
|
|
+ $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (is_array($deptIds)) {
|
|
|
+ //团队权限
|
|
|
+ $where[] = [function($query) use ($diffNums, $currentTime){
|
|
|
+ $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
|
|
|
+ }];
|
|
|
+ } else {
|
|
|
+ //无权限
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -289,6 +314,15 @@ class CustomService
|
|
|
$visitTime = $item->visit_time;
|
|
|
$visitTimeStamp = strtotime($visitTime);
|
|
|
$diff = ($visitTimeStamp + $diffNums) - $currentTime;
|
|
|
+ if ($diff > 0) {
|
|
|
+ $item->belong_status = 1;
|
|
|
+ } else {
|
|
|
+ if (abs($diff) - (4*$diffNums) > 0) {
|
|
|
+ $item->belong_status = 3;
|
|
|
+ } else {
|
|
|
+ $item->belong_status = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
$item->diff_nums = ($diff > 0) ? $diff : 0;
|
|
|
$item->consultant_name = $consultantKeys[$item->consultant_id]['name'] ?? '';
|
|
|
$item->consultant_mobile = $consultantKeys[$item->consultant_id]['mobile'] ?? '';
|
|
@@ -606,7 +640,7 @@ class CustomService
|
|
|
$query->whereIn('consultant_id', $consultantIds);
|
|
|
}];
|
|
|
}
|
|
|
- $customList = MarketCustomer::where($whereCustom)->select(['id','consultant_id','dept_id'])->get();
|
|
|
+ $customList = MarketCustomer::where($whereCustom)->select(['id','consultant_id','dept_id','visit_time'])->get();
|
|
|
if (!$customList->isEmpty()) {
|
|
|
foreach ($customList as$item) {
|
|
|
$logsInertData[] = [
|
|
@@ -627,13 +661,19 @@ class CustomService
|
|
|
if (empty($logsInertData)) {
|
|
|
return json_fail('移交记录不能为空');
|
|
|
}
|
|
|
+ $diffTime = self::DIFF_TIME;
|
|
|
Db::beginTransaction();
|
|
|
$result = false;
|
|
|
try {
|
|
|
foreach ($customList as $item) {
|
|
|
if ($currentConsultantId != 0) {
|
|
|
//移交至指定顾问
|
|
|
- $item->visit_time = time();
|
|
|
+ //判断一下是否到了到访的过期时间,如果过期了就更新到访时间,没过期时间就不变
|
|
|
+ $visitTime = $item->visit_time;
|
|
|
+ $diff = strtotime($visitTime) + $diffTime - time();
|
|
|
+ if ($diff <= 0) {
|
|
|
+ $item->visit_time = time();
|
|
|
+ }
|
|
|
} else {
|
|
|
//移交至其他团队
|
|
|
$item->visit_time = time() - self::DIFF_TIME;
|