edit inquiry
This commit is contained in:
@@ -25,11 +25,11 @@ class InquiryLogController extends BaseController
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
$data['countdown'] = time()-1;
|
||||
if (isset($data['r_time'])) {
|
||||
$countdown = 60 * 60;
|
||||
$data['countdown'] = (time() - $data['r_time']) < $countdown ? $data['r_time'] + (60*60) : time()-1;
|
||||
}
|
||||
// $data['countdown'] = time()-1;
|
||||
// if (isset($data['r_time'])) {
|
||||
// $countdown = 60 * 60;
|
||||
// $data['countdown'] = (time() - $data['r_time']) < $countdown ? $data['r_time'] + (60*60) : time()-1;
|
||||
// }
|
||||
|
||||
if (isset($data['created_at'])) {
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
@@ -46,7 +46,7 @@ class InquiryLogController extends BaseController
|
||||
if (isset($data['t_time'])) {
|
||||
$data['t_time'] = $data['t_time'] > 0 ? date('Y-m-d H:i:s', $data['t_time']) : 0;
|
||||
}
|
||||
// var_dump($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,23 @@ class InquiryLogController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新分配
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function reAllocation(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'allocation');
|
||||
$res = $this->service->serviceReAllocation($request, $data);
|
||||
return $this->success([], '重新分配成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 导出
|
||||
// public function export(Request $request)
|
||||
// {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user