edit inquiry

This commit is contained in:
mzl@hnxinyouhe.com
2025-08-06 18:55:37 +08:00
parent 601936a129
commit 3537d2fc3c
12 changed files with 2023 additions and 106 deletions
+123 -23
View File
@@ -32,28 +32,7 @@ class InquiryLogService
return new $this->validator;
}
/**
* 发布
*/
public function serviceRelease(Request $request, array $data = [])
{
$data = $this->preProcess('Release', $data, $request);
$config = $this->buildQueryConfig($request, 'release');
$updated = $this->logicUpdateBy($config, $data);
return $this->postProcess('Release', $data);
}
/**
* 分配
*/
public function serviceAllocation(Request $request, array $data = [])
{
$data = $this->preProcess('Allocation', $data, $request);
$config = $this->buildQueryConfig($request, 'allocation');
$updated = $this->logicUpdateBy($config, $data);
return $this->postProcess('Allocation', $data);
}
/**
* 构建查询条件
*/
@@ -108,6 +87,7 @@ class InquiryLogService
case 'destroy':
case 'release':
case 'allocation':
case 'reAllocation':
$config['where']['id'] = $p['id'];
case 'store':
break;
@@ -116,6 +96,40 @@ class InquiryLogService
return $config;
}
/**
* 发布
*/
public function serviceRelease(Request $request, array $data = [])
{
$data = $this->preProcess('Release', $data, $request);
$config = $this->buildQueryConfig($request, 'release');
$updated = $this->logicUpdateBy($config, $data);
return $this->postProcess('Release', $data);
}
/**
* 分配
*/
public function serviceAllocation(Request $request, array $data = [])
{
$data = $this->preProcess('Allocation', $data, $request);
$config = $this->buildQueryConfig($request, 'allocation');
$updated = $this->logicUpdateBy($config, $data);
return $this->postProcess('Allocation', $data);
}
/**
* 重新分配
*/
public function serviceReAllocation(Request $request, array $data = [])
{
$data = $this->preProcess('ReAllocation', $data, $request);
$config = $this->buildQueryConfig($request, 'reAllocation');
$updated = $this->logicUpdateBy($config, $data);
return $this->postProcess('ReAllocation', $data);
}
// ====== 前置处理 ======
/**
* 添加前置处理
*/
@@ -123,7 +137,7 @@ class InquiryLogService
{
$data['order_no'] = orderNum();
$data['enter_user_id'] = $request->user->uid;
$data['recipient'] = 0;
// $data['recipient'] = 0;
$data['email'] = trim($data["email"]);
$data['tel'] = trim($data['tel']);
$data['whatsapp'] = trim($data['whatsapp']);
@@ -143,6 +157,50 @@ class InquiryLogService
$data['content']
);
// 如果添加时填写了接单人
if (isset($data['recipient']) && $data['recipient']) {
$data['r_time'] = time();
$data['t_time'] = time();
$data['status'] = 2;
}
return $data;
}
/**
* 更新前置处理
*/
public function beforeServiceUpdate($data, Request $request)
{
$info = $this->findByPk($request->post('id'));
if (!$info) {
throw new BusinessException('数据不存在');
}
// 处理富文本
if (md5(normalizeRichText($data['content'])) !== md5(normalizeRichText($info->content))) {
$ossDomain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com/';
$proxyPath = getenv('MAIN_DOMAIN').'/proxy/ossurl?file=';
$data['content'] = str_replace(
'?Expires=',
'&Expires=',
$data['content']
);
$data['content'] = str_replace(
$ossDomain,
$proxyPath,
$data['content']
);
}
// 如果更新时操作了跟单人
if ($info->recipient) {
$info->recipient == $data['recipient'] ?: $data['t_time'] = time();
} else {
$data['r_time'] = time();
$data['t_time'] = time();
$data['status'] = 2;
}
return $data;
}
@@ -183,6 +241,20 @@ class InquiryLogService
return $data;
}
/**
* 重新分配前置处理
*/
public function beforeServiceReAllocation($data, Request $request)
{
$info = $this->findByPk($request->post('id'));
if (!$info) {
throw new BusinessException('数据不存在');
}
$data['t_time'] = time();
return $data;
}
// ====== 后置处理 ======
/**
* 发布后置处理
*/
@@ -201,6 +273,34 @@ class InquiryLogService
return $res;
}
/**
* 添加后置处理
*/
protected function afterServiceStore($res)
{
RedisQueueRedis::send('inquiry-to-crm', $res);
return $res;
}
/**
* 更新后置处理
*/
protected function afterServiceUpdate($res)
{
if ($res['recipient']) {
RedisQueueRedis::send('inquiry-to-crm-update', $res);
}
return $res;
}
/**
* 重新分配后置处理
*/
protected function afterServiceReAllocation($res)
{
RedisQueueRedis::send('inquiry-to-crm-update', $res);
return $res;
}
/**
* 获取询单ById