客户重复通知
This commit is contained in:
@@ -18,12 +18,13 @@ trait ResponseTrait
|
||||
*/
|
||||
public function success(
|
||||
$data = [],
|
||||
string $message = '请求成功',
|
||||
int $code = 200,
|
||||
string $message = '请求成功',
|
||||
string $status = 'success',
|
||||
int $code = 200,
|
||||
int $httpStatus = 200,
|
||||
array $header = ['Content-Type' => 'application/json']
|
||||
): Response {
|
||||
return $this->result('success', $code, $httpStatus, $message, $data, $header);
|
||||
return $this->result($status, $code, $httpStatus, $message, $data, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -339,11 +339,11 @@ class CustomerController extends BaseController
|
||||
$distinct = [
|
||||
'email' => $email,
|
||||
'phone' => $phone,
|
||||
'whatsapp' => $whatsApp,
|
||||
'whatsApp' => $whatsApp,
|
||||
];
|
||||
$dis = (new CustomerService())->distinct($distinct,$corpId);
|
||||
if($dis){
|
||||
return $this->error('客户线索重复,已经有人在跟进');
|
||||
return $this->success($dis,'客户线索重复,已经业务跟进','distinct');
|
||||
}
|
||||
$res = Customer::create($data);
|
||||
} else {
|
||||
@@ -361,6 +361,25 @@ class CustomerController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重复通知
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function distinctNotice(Request $request){
|
||||
$customer_id = Util::getParam($request, 'customer_id');
|
||||
if (Util::isEmpty($customer_id)) {
|
||||
return $this->error('客户id不能为空');
|
||||
}
|
||||
$res = (new CustomerService())->distinctNotice($customer_id);
|
||||
|
||||
if ($res) {
|
||||
return $this->success($res, '成功');
|
||||
} else {
|
||||
return $this->error(trans('fail'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -322,24 +322,40 @@ class CustomerService
|
||||
|
||||
public function distinct($params,$corpId){
|
||||
|
||||
$customer = Customer::Orwhere('email', '=', $params['email'])
|
||||
$customer = Customer::where('corp_id',$corpId)
|
||||
->Orwhere('email', '=', $params['email'])
|
||||
->Orwhere('phone', '=', $params['phone'])
|
||||
->Orwhere('whatsApp', '=', $params['whatsApp'])
|
||||
->first();
|
||||
if (!empty($customer)) {
|
||||
//客户重复,消息通知
|
||||
$user = User::where('id', $customer->user_id)->first();
|
||||
if($corpId != $customer->corp_id){
|
||||
return false;
|
||||
}
|
||||
$contacts = $customer->contacts??$params['phone'];
|
||||
$contacts = $contacts??$params['whatsApp'];
|
||||
$contacts = $contacts??$params['email'];
|
||||
// if($corpId != $customer->corp_id){
|
||||
// return false;
|
||||
// }
|
||||
return $customer;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户重复通知
|
||||
* @param $params
|
||||
* @param $corpId
|
||||
* @return Customer|false|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object
|
||||
*/
|
||||
public function distinctNotice($customer_id){
|
||||
|
||||
$customer = Customer::where('id', $customer_id)
|
||||
->first();
|
||||
if (!empty($customer)) {
|
||||
$contacts = $customer->contacts??$customer['phone'];
|
||||
$contacts = $contacts??$customer['whatsApp'];
|
||||
$contacts = $contacts??$customer['email'];
|
||||
$data = [
|
||||
'sender_id' => 0, //发送人ID 0默认系统
|
||||
'sender_type' => 'system', //发送者类型 user admin system
|
||||
'title' => '客户跟进提醒 - ' . $contacts, //标题
|
||||
'content' => $contacts . '有新的询单,请及时跟进', //内容
|
||||
'content' => $contacts . ' 产生了新的询单,请及时跟进', //内容
|
||||
'scene' => 1, //场景 0系统公共 1系统通知
|
||||
'recipient' => [$customer->user_id], //接收人 空为全部
|
||||
'push_method' => 0 //推送方式0系统推送1手动推送
|
||||
@@ -347,7 +363,7 @@ class CustomerService
|
||||
|
||||
// 异步推送
|
||||
\Webman\RedisQueue\Redis::send('notice', $data);
|
||||
return true;
|
||||
return $customer;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -234,6 +234,7 @@ Route::group('/crm', function () {
|
||||
Route::any('/customer/getCountry', [app\crm\controller\CustomerController::class, 'getCountry']);
|
||||
Route::any('/customer/followNext', [app\crm\controller\CustomerController::class, 'followNext']);
|
||||
Route::any('/customer/report', [app\crm\controller\CustomerController::class, 'report']);
|
||||
Route::any('/customer/distinctNotice', [app\crm\controller\CustomerController::class, 'distinctNotice']);
|
||||
|
||||
Route::any('/tagGroup/list', [app\crm\controller\TagGroupController::class, 'list']);
|
||||
Route::any('/tagGroup/updatePivot', [app\crm\controller\TagGroupController::class, 'updatePivot']);
|
||||
|
||||
Reference in New Issue
Block a user