增加询单发布&分配&用户全量

This commit is contained in:
mzl
2025-07-23 17:06:48 +08:00
parent b22db8ac35
commit 36288fa64d
9 changed files with 149 additions and 539 deletions
+67 -17
View File
@@ -5,6 +5,7 @@ namespace app\inquiry\service;
use app\common\validate\InquiryLogValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\InquiryLog;
use support\exception\BusinessException;
use support\Request;
class InquiryLogService
@@ -30,7 +31,31 @@ 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', $updated);
}
/**
* 分配
*/
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', $updated);
}
/**
* 构建查询条件
*/
protected function buildQueryConfig(Request $request, string $scene = 'index'): array
{
$p = $request->all();
@@ -39,19 +64,18 @@ class InquiryLogService
$config['model'] = $this->modelClass;
switch ($scene) {
case 'index':
// 排序
// ====== ====== 排序 ====== ======
$config['order']['id'] = 'desc';
// ====== ====== 筛选 ====== ======
// 渠道
if (isset($p['channel']) && $p['channel']) {
$config['where']['channel'] = $p['channel'];
}
// 国家
if (isset($p['country']) && $p['country']) {
$config['where']['country'] = $p['country'];
}
// 时间
if (isset($p['time']) && $p['time']) {
$time = explode(' - ', $p['time']);
@@ -59,12 +83,10 @@ class InquiryLogService
'between', [strtotime($time[0]), strtotime($time[1])]
];
}
// 状态
if (isset($p['status']) && $p['status']) {
$config['where']['status'] = $p['status'];
}
// 关键字
if (isset($p['keyword']) && $p['keyword']) {
$k = '%' . $p['keyword'] . '%';
@@ -73,28 +95,29 @@ class InquiryLogService
}
}
// 关联
// ====== ====== 关联 ====== ======
$config['with']['country'][] = 'cn_addr';
$config['with']['country'][] = 'steering';
$config['with']['enter'][] = 'name';
$config['with']['recipient'][] = 'name';
$config['with']['channel'][] = 'name';
break;
case 'show':
$config['where']['id'] = $p['id'];
break;
case 'store':
break;
case 'update':
$config['where']['id'] = $p['id'];
break;
case 'destroy':
case 'release':
case 'allocation':
$config['where']['id'] = $p['id'];
case 'store':
break;
}
return $config;
}
/**
* 添加前置处理
*/
public function beforeServiceStore($data, Request $request)
{
$data['order_no'] = orderNum();
@@ -106,10 +129,37 @@ class InquiryLogService
return $data;
}
// public function afterServiceList($data)
// {
// var_dump($data);
/**
* 发布前置处理
*/
public function beforeServiceRelease($data, Request $request)
{
$info = $this->findByPk($request->post('id'));
if (!$info) {
throw new BusinessException('数据不存在');
}
if ($info->status != 0) {
throw new BusinessException('询单已发布');
}
$data['r_time'] = time();
$data['status'] = 1;
return $data;
}
// return $data;
// }
/**
* 分配前置处理
*/
public function beforeServiceAllocation($data, Request $request)
{
$info = $this->findByPk($request->post('id'));
if (!$info) {
throw new BusinessException('数据不存在');
}
if ($info->status == 2) {
throw new BusinessException('询单已被分配');
}
$data['t_time'] = time();
$data['status'] = 2;
return $data;
}
}