Merge branch 'hotfix/customer0827' into develop
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use support\Command;
|
||||
use support\Db;
|
||||
use Symfony\Component\Console\Command\Command as SymfonyCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class UpdateInquiryLogFromCrmCustomerCommand extends SymfonyCommand
|
||||
{
|
||||
protected static $defaultName = 'inquiry:update-from-crm-customer';
|
||||
protected static $defaultDescription = '将crm_customer表的部分字段更新到inquiry_log表';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setHelp('该命令将crm_customer表的user_id更新到inquiry_log表的recipient字段,将obtain字段更新到t_time字段。')
|
||||
->addOption('dry-run', null, InputOption::VALUE_NONE, '仅显示将要执行的更新操作,不实际执行')
|
||||
->addOption('limit', 'l', InputOption::VALUE_OPTIONAL, '限制处理的记录数量', 5000);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$isDryRun = $input->getOption('dry-run');
|
||||
$limit = (int) $input->getOption('limit');
|
||||
|
||||
if ($isDryRun) {
|
||||
$output->writeln('<info>DRY RUN 模式 - 不会实际执行更新操作</info>');
|
||||
}
|
||||
|
||||
$output->writeln('<info>开始更新 inquiry_log 表...</info>');
|
||||
$output->writeln("<info>处理限制: {$limit} 条记录</info>");
|
||||
|
||||
try {
|
||||
// 使用事务确保数据一致性
|
||||
DB::transaction(function () use ($output, $isDryRun, $limit) {
|
||||
// 查询需要更新的记录
|
||||
$customers = Db::table('crm_customer')
|
||||
->select('id', 'sn', 'user_id', 'obtain','created_at')
|
||||
->whereNotNull('sn')
|
||||
->where('sn', '<>', '')
|
||||
->offset($limit)
|
||||
->limit(4000)
|
||||
->orderBy('id', 'asc')
|
||||
->get();
|
||||
|
||||
$output->writeln("<info>找到 " . count($customers) . " 条客户记录需要处理</info>");
|
||||
|
||||
$updatedCount = 0;
|
||||
$skippedCount = 0;
|
||||
$defaultTimestamp = strtotime('2025-08-26 00:00:00');
|
||||
|
||||
$output->writeln("<info>找到 " . count($customers) . " 条客户记录需要处理</info>");
|
||||
$step = [];
|
||||
$updateId = [];
|
||||
foreach ($customers as $customer) {
|
||||
$output->writeln("<info>处理客户 ID: {$customer->id}, SN: {$customer->sn}, User ID: {$customer->user_id}, obtain: {$customer->obtain}, created_at: {$customer->created_at}</info>");
|
||||
// 查找匹配的 inquiry_log 记录
|
||||
$inquiryLog = Db::table('inquiry_log')
|
||||
->where('order_no', $customer->sn)
|
||||
->first(['id', 'recipient', 't_time']);
|
||||
|
||||
if (!$inquiryLog) {
|
||||
$step[] = $customer->id;
|
||||
$output->writeln("<comment>跳过客户 ID {$customer->id} (sn: {$customer->sn}) - 未找到对应的 inquiry_log 记录</comment>");
|
||||
$skippedCount++;
|
||||
continue;
|
||||
}
|
||||
$output->writeln("<info>$inquiryLog->id</info>");
|
||||
|
||||
// 准备更新数据
|
||||
$updateData = [];
|
||||
|
||||
// 更新 recipient 字段 (user_id)
|
||||
if ($customer->user_id != $inquiryLog->recipient) {
|
||||
$updateData['recipient'] = $customer->user_id;
|
||||
$output->writeln("<comment>客户 ID {$customer->id}: recipient 将从 {$inquiryLog->recipient} 更新为 {$customer->user_id}</comment>");
|
||||
}
|
||||
|
||||
if(empty($customer->obtain)&& !empty($customer->user_id)){
|
||||
if($customer->user_id == $inquiryLog->recipient){
|
||||
$obtain = $inquiryLog->t_time;
|
||||
}else{
|
||||
$obtain = strtotime('2025-08-01 10:00:00');
|
||||
$obtain = $customer->created_at > $obtain?$customer->created_at:$obtain;
|
||||
}
|
||||
Db::table('crm_customer')
|
||||
->where('id', $customer->id)
|
||||
->update(['obtain' => $obtain]);
|
||||
$output->writeln("<info>更新obtain $obtain</info>");
|
||||
}
|
||||
|
||||
// 更新 t_time 字段 (obtain)
|
||||
$newTTime = $customer->obtain > 0 ? $customer->obtain : $defaultTimestamp;
|
||||
if ($newTTime != $inquiryLog->t_time && !empty($updateData['recipient'])) {
|
||||
$updateData['t_time'] = $newTTime;
|
||||
$timeStr = date('Y-m-d H:i:s', $newTTime);
|
||||
$output->writeln("<comment>客户 ID {$customer->id}: t_time 将从 " . ($inquiryLog->t_time ? date('Y-m-d H:i:s', $inquiryLog->t_time) : 'NULL') . " 更新为 {$timeStr}</comment>");
|
||||
}
|
||||
if($customer->user_id == 0 && $inquiryLog->recipient != 0){
|
||||
$updateData['recipient'] = 0;
|
||||
$updateData['t_time'] = time();
|
||||
$updateData['status'] = 1;
|
||||
$updateData['r_time'] = time();
|
||||
|
||||
}
|
||||
|
||||
// 如果有需要更新的字段,执行更新
|
||||
if (!empty($updateData)) {
|
||||
$updateId[] = $customer->id;
|
||||
if (!$isDryRun) {
|
||||
Db::table('inquiry_log')
|
||||
->where('id', $inquiryLog->id)
|
||||
->update($updateData);
|
||||
}
|
||||
$updatedCount++;
|
||||
$output->writeln("<info>已更新 inquiry_log ID {$inquiryLog->id}</info>");
|
||||
} else {
|
||||
$output->writeln("<comment>客户 ID {$customer->id} - 无需更新</comment>");
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln("<info>处理完成!</info>");
|
||||
$output->writeln("<info>总记录数: " . count($customers) . "</info>");
|
||||
$updateIdstr = implode(",", $updateId);
|
||||
$output->writeln("<info>更新记录数: {$updatedCount},更新id:$updateIdstr</info>");
|
||||
$stepstr = implode(",", $step);
|
||||
$output->writeln("<info>跳过记录数: {$skippedCount},跳过id: {$stepstr}</info>");
|
||||
|
||||
if ($isDryRun) {
|
||||
$output->writeln("<info>DRY RUN 模式 - 未实际执行任何更新操作</info>");
|
||||
}
|
||||
});
|
||||
|
||||
return self::SUCCESS;
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln('<error>执行过程中发生错误: ' . $e->getMessage() . '</error>');
|
||||
$output->writeln('<error>错误位置: ' . $e->getFile() . ':' . $e->getLine() . '</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class CrmCustomer extends Model
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'sn', 'corp_abbr', 'user_id', 'user_sn', 'type', 'grade', 'sex', 'channel_id', 'country_id', 'car_type_id', 'magnitude', 'email', 'phone', 'WhatsApp', 'contacts', 'describe', 'desc_collect', 'address', 'lat', 'lng', 'follow_last', 'follow_next', 'warn', 'follow_remark', 'enter_user_id', 'created_at', 'updated_at', 'deleted_at'];
|
||||
protected $fillable = ['id', 'sn', 'corp_id', 'user_id', 'user_sn', 'type', 'grade', 'sex', 'channel_id', 'country_id', 'car_type_id', 'magnitude', 'email', 'phone', 'WhatsApp', 'contacts', 'describe', 'desc_collect', 'address', 'lat', 'lng', 'follow_last', 'follow_next', 'warn', 'follow_remark', 'enter_user_id', 'created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -480,7 +480,7 @@ class Emails
|
||||
// 同步客户
|
||||
$crmCustomer = new CrmCustomer();
|
||||
$crmCustomer->sn = $inquiryLogResult->order_no;
|
||||
$crmCustomer->corp_abbr = $recipientInfo->corp_id;
|
||||
$crmCustomer->corp_id = $recipientInfo->corp_id;
|
||||
$crmCustomer->user_id = $assignedUid;
|
||||
$crmCustomer->type = 1;
|
||||
$crmCustomer->channel_id = $inquiryLogResult->channel;
|
||||
|
||||
@@ -163,7 +163,7 @@ class CustomerController extends BaseController
|
||||
$perPage = $request->input('size', 10);
|
||||
$where = [
|
||||
['user_id', '=', $userId],
|
||||
// ['corp_abbr', '=', $request->basic_data['corp_abbr']],
|
||||
//['corp_abbr', '=', $request->basic_data['corp_abbr']],
|
||||
['follow_next', '<>', 0],
|
||||
];
|
||||
|
||||
@@ -306,7 +306,8 @@ class CustomerController extends BaseController
|
||||
$contacts = Util::getParam($request, 'contacts');
|
||||
$email = Util::getParam($request, 'email');
|
||||
$phone = Util::getParam($request, 'phone');
|
||||
if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone)) {
|
||||
$whatsApp = Util::getParam($request, 'WhatsApp', '');
|
||||
if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone) && Util::isEmpty($whatsApp)) {
|
||||
return $this->error(trans('contacts_not_null'));
|
||||
}
|
||||
|
||||
@@ -314,7 +315,7 @@ class CustomerController extends BaseController
|
||||
$corpId = $corpInfo->id;
|
||||
$data = [
|
||||
'user_id' => $request->user->uid,
|
||||
'corp_abbr' => $corpId,
|
||||
'corp_id' => $corpId,
|
||||
'grade' => Util::getParam($request, 'grade', 0),
|
||||
'channel_id' => $channel_id,
|
||||
'country_id' => $country_id,
|
||||
@@ -322,7 +323,7 @@ class CustomerController extends BaseController
|
||||
'magnitude' => Util::getParam($request, 'magnitude', 0),
|
||||
'email' => $email,
|
||||
'phone' => $phone,
|
||||
'WhatsApp' => Util::getParam($request, 'WhatsApp', ''),
|
||||
'WhatsApp' => $whatsApp,
|
||||
'contacts' => $contacts,
|
||||
'describe' => Util::getParam($request, 'describe'),
|
||||
'lat' => Util::getParam($request, 'lat', 0),
|
||||
@@ -335,6 +336,15 @@ class CustomerController extends BaseController
|
||||
|
||||
if (Util::isEmpty($id)) {
|
||||
$data['enter_user_id'] = $request->user->uid;
|
||||
$distinct = [
|
||||
'email' => $email,
|
||||
'phone' => $phone,
|
||||
'whatsApp' => $whatsApp,
|
||||
];
|
||||
$dis = (new CustomerService())->distinct($distinct,$corpId);
|
||||
if($dis){
|
||||
return $this->success($dis,'客户线索重复,已经业务跟进','distinct');
|
||||
}
|
||||
$res = Customer::create($data);
|
||||
} else {
|
||||
unset($data['grade']);
|
||||
@@ -351,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'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -415,6 +444,8 @@ class CustomerController extends BaseController
|
||||
'user_his' => $userId,
|
||||
'user_id' => 0,
|
||||
]);
|
||||
|
||||
CustomerService::inquiryUpdate($customer);
|
||||
}
|
||||
|
||||
//软删除
|
||||
@@ -506,12 +537,14 @@ class CustomerController extends BaseController
|
||||
{
|
||||
$customerId = Util::getParam($request, 'customer_id');
|
||||
$userId = $request->user->uid;
|
||||
$user = User::where(['id' => $userId])->first();
|
||||
if (Util::isEmpty($customerId)) {
|
||||
return $this->error(trans('customer_id').trans('not_null'));
|
||||
}
|
||||
$data = [
|
||||
'user_id' => $request->user->uid,
|
||||
'obtain' => time(),
|
||||
'corp_id' => $user->corp_id,
|
||||
];
|
||||
|
||||
try {
|
||||
@@ -531,13 +564,8 @@ class CustomerController extends BaseController
|
||||
'user_his' => 0,
|
||||
'user_id' => $userId,
|
||||
]);
|
||||
if (!empty($customer->sn) && $customer->type==1){
|
||||
$inquiryLog = InquiryLog::where('order_no', $customer->sn)->first();
|
||||
if (!empty($inquiryLog)) {
|
||||
$inquiryLog->recipient = $userId;
|
||||
$inquiryLog->save();
|
||||
}
|
||||
}
|
||||
|
||||
CustomerService::inquiryUpdate($customer, $data['user_id']);
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
@@ -578,13 +606,8 @@ class CustomerController extends BaseController
|
||||
'user_his' => $item->user_id,
|
||||
'user_id' => $user['id'],
|
||||
]);
|
||||
if (!empty($customer->sn) && $customer->type==1){
|
||||
$inquiryLog = InquiryLog::where('order_no', $customer->sn)->first();
|
||||
if (!empty($inquiryLog)) {
|
||||
$inquiryLog->recipient = $userId;
|
||||
$inquiryLog->save();
|
||||
}
|
||||
}
|
||||
|
||||
CustomerService::inquiryUpdate($customer,$userId);
|
||||
|
||||
$item->restore();
|
||||
}
|
||||
@@ -592,6 +615,7 @@ class CustomerController extends BaseController
|
||||
$data = [
|
||||
'user_id' => $user->id,
|
||||
'obtain' => time(),
|
||||
'corp_id' => $user->corp_id,
|
||||
];
|
||||
$res = $query->update($data);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class FollowController extends BaseController
|
||||
$corpId = $corpInfo->id;
|
||||
$data = [
|
||||
'user_id' => $request->user->uid,
|
||||
'corp_abbr' => $corpId,
|
||||
'corp_id' => $corpId,
|
||||
'customer_id' => $customer_id,
|
||||
'type' => $type,
|
||||
'picture' => $picture,
|
||||
@@ -119,7 +119,7 @@ class FollowController extends BaseController
|
||||
$res = Follow::create($data);
|
||||
|
||||
$customer = Customer::find($customer_id);
|
||||
$customer->follow_last = strtotime($res->created_at);
|
||||
$customer->follow_last = $res->created_at;
|
||||
$customer->follow_next = null;
|
||||
$customer->warn = 0;
|
||||
$customer->save();
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\crm\service;
|
||||
|
||||
use app\common\model\Corp;
|
||||
use app\common\model\CustomerAudit;
|
||||
use app\common\model\InquiryLog;
|
||||
use app\common\model\User;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\crm\logic\CustomerLogic;
|
||||
@@ -15,6 +16,7 @@ use app\crm\model\CustomerHis;
|
||||
use app\crm\model\Follow;
|
||||
use app\crm\utils\Util;
|
||||
use config\constants\Constants;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use support\Request;
|
||||
|
||||
/**
|
||||
@@ -246,12 +248,44 @@ class CustomerService
|
||||
$customer->status = 2;
|
||||
$res = $customer->save();
|
||||
|
||||
self::inquiryUpdate($customer);
|
||||
|
||||
//软删除
|
||||
$customer->delete();
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 询单修改
|
||||
*/
|
||||
public static function inquiryUpdate($customer,$userId = null)
|
||||
{
|
||||
if(empty($customer->sn) || $customer->type!=1){
|
||||
return false;
|
||||
}
|
||||
|
||||
$inquiryLog = InquiryLog::where('order_no', $customer->sn)->first();
|
||||
if(empty($inquiryLog)){
|
||||
return false;
|
||||
}
|
||||
$userId = $userId??$customer->user_id;
|
||||
|
||||
if ($userId == 0){
|
||||
$inquiryLog->recipient = 0;
|
||||
$inquiryLog->t_time = time();
|
||||
$inquiryLog->status = 1;
|
||||
$inquiryLog->r_time = time();
|
||||
$inquiryLog->save();
|
||||
}else {
|
||||
$inquiryLog->recipient = $customer->user_id;
|
||||
$inquiryLog->t_time = time();
|
||||
$inquiryLog->save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
* @param $request
|
||||
@@ -319,4 +353,65 @@ class CustomerService
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询客户关系是否重复
|
||||
*/
|
||||
public function distinct($params,$corpId){
|
||||
|
||||
$customer = Customer::where('corp_id',$corpId)
|
||||
->where((function (Builder $query) use ($params) {
|
||||
if(!empty($params['email']))
|
||||
$query->Orwhere('email', '=', $params['email']);
|
||||
if(!empty($params['phone']))
|
||||
$query->Orwhere('phone', '=', $params['phone']);
|
||||
if(!empty($params['whatsApp']))
|
||||
$query->Orwhere('whatsApp', '=', $params['whatsApp']);
|
||||
// $query->where('email', '=', $params['email'])
|
||||
// ->Orwhere('phone', '=', $params['phone'])
|
||||
// ->Orwhere('whatsApp', '=', $params['whatsApp']);
|
||||
return $query;
|
||||
}))
|
||||
->first();
|
||||
|
||||
if (!empty($customer)) {
|
||||
//客户重复,消息通知
|
||||
// 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 . ' 产生了新的询单,请及时跟进', //内容
|
||||
'scene' => 1, //场景 0系统公共 1系统通知
|
||||
'recipient' => [$customer->user_id], //接收人 空为全部
|
||||
'push_method' => 0 //推送方式0系统推送1手动推送
|
||||
];
|
||||
|
||||
// 异步推送
|
||||
\Webman\RedisQueue\Redis::send('notice', $data);
|
||||
return $customer;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ class CustomerController extends BaseController
|
||||
try {
|
||||
$param = $request->all();
|
||||
$corp = Corp::where(['abbr' => $request->basic_data['corp_abbr']])->first();
|
||||
$param['corp_abbr'] = $corp->id;
|
||||
$param['corp_id'] = $corp->id;
|
||||
// $param['corp_abbr'] = $request->basic_data['corp_abbr'];
|
||||
$result = (new CustomerService())->list($param);
|
||||
|
||||
@@ -49,7 +49,7 @@ class CustomerController extends BaseController
|
||||
try {
|
||||
$param = $request->all();
|
||||
// $corp = Corp::where(['abbr' => $request->basic_data['corp_abbr']])->first();
|
||||
// $param['corp_abbr'] = $corp->id;
|
||||
// $param['corp_id'] = $corp->id;
|
||||
|
||||
$result = (new CustomerService())->export($param);
|
||||
$excelContent = file_get_contents($result['filepath']);
|
||||
|
||||
@@ -339,6 +339,7 @@ class CustomerService
|
||||
|
||||
$query= Customer::whereIn('id',explode(',',$customerId));
|
||||
$customer = $query->get();
|
||||
$user = User::where(['id' => $userId])->first();
|
||||
|
||||
foreach ($customer as $item) {
|
||||
//记录客户关系变化
|
||||
@@ -347,16 +348,12 @@ class CustomerService
|
||||
'user_his' => $item->user_id,
|
||||
'user_id' => $userId,
|
||||
]);
|
||||
if (!empty($item->sn) && $item->type==1){
|
||||
$inquiryLog = InquiryLog::where('order_no', $item->sn)->first();
|
||||
if (!empty($inquiryLog)) {
|
||||
$inquiryLog->recipient = $userId;
|
||||
$inquiryLog->save();
|
||||
}
|
||||
}
|
||||
|
||||
\app\crm\service\CustomerService::inquiryUpdate($item,$userId);
|
||||
}
|
||||
$data = [
|
||||
'user_id' => $userId,
|
||||
'corp_id' => $user->corp_id,
|
||||
'obtain' => time(),
|
||||
];
|
||||
$res = $query->update($data);
|
||||
@@ -389,6 +386,8 @@ class CustomerService
|
||||
'user_his' => $item->user_id,
|
||||
'user_id' => 0,
|
||||
]);
|
||||
|
||||
\app\crm\service\CustomerService::inquiryUpdate($item,0);
|
||||
}
|
||||
$res = $query->update(['user_id' => 0]);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class InquiryToCrm implements Consumer
|
||||
// 同步客户数据
|
||||
$crmCustomer = new CrmCustomer();
|
||||
$crmCustomer->sn = $info->order_no;
|
||||
$crmCustomer->corp_abbr = $corpId;
|
||||
$crmCustomer->corp_id = $corpId;
|
||||
$crmCustomer->user_id = $recipient;
|
||||
$crmCustomer->type = 1;
|
||||
$crmCustomer->channel_id = $info->channel;
|
||||
@@ -54,6 +54,9 @@ class InquiryToCrm implements Consumer
|
||||
$crmCustomer->desc_collect = $info->content;
|
||||
$crmCustomer->enter_user_id = $info->enter_user_id;
|
||||
$crmCustomer->obtain = time();
|
||||
if(empty($recipient)){
|
||||
$crmCustomer->deleted_at = time();
|
||||
}
|
||||
// 修改同步CRM状态
|
||||
$info->sync_crm = 1;
|
||||
// 保存
|
||||
|
||||
@@ -105,7 +105,7 @@ class InquiryToCrmNew implements Consumer
|
||||
}
|
||||
|
||||
$udata = [
|
||||
'corp_abbr' => $uInfo['corpId'],
|
||||
'corp_id' => $uInfo['corpId'],
|
||||
'user_id' => $info->recipient,
|
||||
'channel_id' => $info->channel,
|
||||
'country_id' => $info->country,
|
||||
@@ -122,7 +122,7 @@ class InquiryToCrmNew implements Consumer
|
||||
} else {
|
||||
$crmCustomer = new CrmCustomer();
|
||||
$crmCustomer->sn = $info->order_no;
|
||||
$crmCustomer->corp_abbr = $uInfo['corpId'];
|
||||
$crmCustomer->corp_id = $uInfo['corpId'];
|
||||
$crmCustomer->user_id = $uInfo['recipient'];
|
||||
$crmCustomer->type = 1;
|
||||
$crmCustomer->channel_id = $info->channel;
|
||||
@@ -135,6 +135,9 @@ class InquiryToCrmNew implements Consumer
|
||||
$crmCustomer->desc_collect = $info->content;
|
||||
$crmCustomer->enter_user_id = $info->enter_user_id;
|
||||
$crmCustomer->obtain = time();
|
||||
if(empty($uInfo['recipient'])){
|
||||
$crmCustomer->deleted_at = time();
|
||||
}
|
||||
// 修改同步CRM状态
|
||||
$info->sync_crm = 1;
|
||||
// 保存
|
||||
|
||||
@@ -38,7 +38,7 @@ class InquiryToCrmUpdate implements Consumer
|
||||
$crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first();
|
||||
if ($crmCustomerInfo) {
|
||||
$udata = [
|
||||
'corp_abbr' => $corpId,
|
||||
'corp_id' => $corpId,
|
||||
'user_id' => $info->recipient,
|
||||
'channel_id' => $info->channel,
|
||||
'country_id' => $info->country,
|
||||
@@ -54,7 +54,7 @@ class InquiryToCrmUpdate implements Consumer
|
||||
// 同步客户数据
|
||||
$crmCustomer = new CrmCustomer();
|
||||
$crmCustomer->sn = $info->order_no;
|
||||
$crmCustomer->corp_abbr = $corpId;
|
||||
$crmCustomer->corp_id = $corpId;
|
||||
$crmCustomer->user_id = $info->recipient;
|
||||
$crmCustomer->type = 1;
|
||||
$crmCustomer->channel_id = $info->channel;
|
||||
@@ -66,6 +66,9 @@ class InquiryToCrmUpdate implements Consumer
|
||||
$crmCustomer->contacts = $info->contacts;
|
||||
$crmCustomer->desc_collect = $info->content;
|
||||
$crmCustomer->enter_user_id = $info->enter_user_id;
|
||||
if(empty($info->recipient)){
|
||||
$crmCustomer->deleted_at = time();
|
||||
}
|
||||
// 修改同步CRM状态
|
||||
$info->sync_crm = 1;
|
||||
// 保存
|
||||
|
||||
@@ -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