修改查询助手

This commit is contained in:
mzl
2025-07-22 19:30:27 +08:00
parent b53cfe6bf7
commit 283b21b1f8
3 changed files with 122 additions and 54 deletions
+18 -17
View File
@@ -38,12 +38,8 @@ class InquiryLogService
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'default':
$config['where']['status'] = 1;
$config['order']['sort'] = 'desc';
$config['order']['id'] = 'desc';
break;
case 'index':
// 排序
$config['order']['id'] = 'desc';
// 渠道
@@ -58,10 +54,14 @@ class InquiryLogService
// 时间
if (isset($p['time']) && $p['time']) {
$time = explode(' - ', $p['time']);
// $time = explode(' - ', $p['time']);
// $config['where']['created_at'] = [
// ['>=', strtotime($time[0])],
// ['<=', strtotime($time[1])],
// ];
$config['where']['created_at'] = [
['>=', strtotime($time[0])],
['<=', strtotime($time[1])],
strtotime(explode(' - ', $p['time'])[0]),
strtotime(explode(' - ', $p['time'])[1]),
];
}
@@ -72,17 +72,18 @@ class InquiryLogService
// 关键字
if (isset($p['keyword']) && $p['keyword']) {
// $config['where']['order_no|email|tel|whatsapp|contacts'] = ['like', '%' . $p['keyword'] . '%'];
$k = '%' . $p['keyword'] . '%';
foreach (['order_no','email','tel','whatsapp','contacts'] as $col) {
$config['orWhere'][] = [$col, 'like', $k];
}
}
$config['with'][] = 'enter';
$config['with'][] = 'recipient';
$config['withFields']['enter'][] = 'id';
$config['withFields']['enter'][] = 'name';
$config['withFields']['recipient'][] = 'id';
$config['withFields']['recipient'][] = 'name';
// 关联
$config['with'][] = 'country';
$config['with']['enter'][] = 'id';
$config['with']['enter'][] = 'name';
$config['with']['recipient'][] = 'id';
$config['with']['recipient'][] = 'name';
break;
case 'show':
$config['where']['id'] = $p['id'];