Commit 7b63e761 by 朱继来

调整报价列表

parent 4bf749d1
Showing with 74 additions and 38 deletions
......@@ -137,7 +137,7 @@ class QuoteModel extends Model
$map['start_time'] = !empty($input['start_time']) ? strtotime($input['start_time']) : '';
$map['end_time'] = !empty($input['end_time']) ? strtotime($input['end_time']) + 86399 : '';
$map = array_filter($map) ? $map : [];
// $map = array_filter($map) ? $map : [];
$field = [
'q.id',
'q.inquiry_id',
......@@ -165,42 +165,7 @@ class QuoteModel extends Model
'it.inquiry_number'
];
if ($map) {
$list = $this->from('quote as q')
->join('inquiry_items as it', 'q.inquiry_items_id', '=', 'it.id')
->where(function ($query) use ($map) {
if ($map['inquiry_sn']) {
$query->where('q.inquiry_sn', '=', $map['inquiry_sn']);
}
if ($map['goods_name']) {
$query->where('it.goods_name', 'like', $map['goods_name'] . '%');
}
if ($map['brand_name']) {
$query->where('it.brand_name', 'like', $map['brand_name'] . '%');
}
if ($map['quote_sn']) {
$query->where('q.quote_sn', '=', $map['quote_sn']);
}
if ($map['status']) {
$query->where('q.status', '=', $map['status']);
}
// 创建时间
if (!empty($map['start_time']) && !empty($map['end_time'])) {
$query->whereBetween('q.create_time', [$map['start_time'], $map['end_time']]);
} else {
if (!empty($map['start_time'])) {
$query->where('q.create_time', '>=', $map['start_time']);
} else {
if (!empty($map['end_time'])) {
$query->where('q.create_time', '<=', $map['end_time']);
}
}
}
});
$list = $this->commonQuery($map, $input);
} else {
$list = $this->from('quote as q')
->join('inquiry_items as it', 'q.inquiry_items_id', '=', 'it.id');
......@@ -249,10 +214,39 @@ class QuoteModel extends Model
$list['data'] = $this->handleData($list['data'], $type);
return [0, '获取成功', $list['data'], $list['total']];
if ($type == 1) { // 我的报价
if ($map['status']) {
switch($map['status']) {
case 1:
$list['count']['quoted_status'] = $this->commonQuery($map, $input, 2);
$list['count']['selected_status'] = 0;
$list['count']['confirmed_status'] = 0;
break;
case 2:
$list['count']['quoted_status'] = 0;
$list['count']['selected_status'] = $this->commonQuery($map, $input, 2);
$list['count']['confirmed_status'] = 0;
break;
case 3:
$list['count']['quoted_status'] = 0;
$list['count']['selected_status'] = 0;
$list['count']['confirmed_status'] = $this->commonQuery($map, $input, 2);
break;
}
} else {
$map['status'] = 1;
$list['count']['quoted_status'] = $this->commonQuery($map, $input, 2);
$map['status'] = 2;
$list['count']['selected_status'] = $this->commonQuery($map, $input, 2);
$map['status'] = 3;
$list['count']['confirmed_status'] = $this->commonQuery($map, $input, 2);
}
}
// return [0, '获取成功', $list['data'], $list['total']];
return [0, $list['count'], $list['data'], $list['total']];
}
}
// 获取历史报价
public function historyList($input)
......@@ -333,6 +327,48 @@ class QuoteModel extends Model
return $data;
}
// 通用查询
public function commonQuery($map, $input, $type=1)
{
$list = $this->from('quote as q')
->join('inquiry_items as it', 'q.inquiry_items_id', '=', 'it.id')
->where(function ($query) use ($map) {
if ($map['inquiry_sn']) {
$query->where('q.inquiry_sn', '=', $map['inquiry_sn']);
}
if ($map['goods_name']) {
$query->where('it.goods_name', 'like', $map['goods_name'] . '%');
}
if ($map['brand_name']) {
$query->where('it.brand_name', 'like', $map['brand_name'] . '%');
}
if ($map['quote_sn']) {
$query->where('q.quote_sn', '=', $map['quote_sn']);
}
if ($map['status']) {
$query->where('q.status', '=', $map['status']);
}
// 创建时间
if(!empty($map['start_time']) && !empty($map['end_time'])) {
$query->whereBetween('q.create_time', [$map['start_time'], $map['end_time']]);
} else if(!empty($map['start_time'])) {
$query->where('q.create_time', '>=', $map['start_time']);
} else if(!empty($map['end_time'])) {
$query->where('q.create_time', '<=', $map['end_time']);
}
});
if ($type == 1) return $list;
return $list->where('q.create_uid', $input['user_id'])->whereNotIn('q.status', [0, -1])->count();
}
// 撤销报价
public function cancel($input)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment