修改查询助手
This commit is contained in:
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user