Commit fab6ddfa by 朱继来

售后添加账期查询

parent 960936b8
......@@ -30,58 +30,75 @@ class OrderServiceModel extends Model
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['service_sn'] = $request->input('service_sn', ''); // 售后单号
$map['order_sn'] = $request->input('order_sn', ''); // 订单号
$map['apply_id'] = $request->input('apply_id', ''); // 申请人
$map['service_status'] = $request->input('service_status', ''); // 售后状态
$map['refund_status'] = $request->input('refund_status', ''); // 退款状态
$map['return_status'] = $request->input('return_status', ''); // 退货状态
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$map['service_sn'] = $request->input('service_sn', ''); // 售后单号
$map['order_sn'] = $request->input('order_sn', ''); // 订单号
$map['apply_id'] = $request->input('apply_id', ''); // 申请人
$map['service_status'] = $request->input('service_status', ''); // 售后状态
$map['refund_status'] = $request->input('refund_status', ''); // 退款状态
$map['return_status'] = $request->input('return_status', ''); // 退货状态
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$map['is_account_order'] = $request->input('is_account_order', ''); // 账期订单
$perm = new PermController;
$role = $perm->getUserRole($request); // 用户角色
$list = $this->where(function($query) use ($map, $request, $role, $perm) {
$field = ['s.id', 's.service_sn', 's.order_id', 's.order_sn', 's.user_id', 's.service_type', 's.service_status', 's.refund_status', 's.return_status', 's.apply_id', 's.apply_name', 's.auditor_id', 's.auditor_name', 's.create_time', 's.auditor_time'];
$list = $this->from('lie_order_service as s');
if ($map['is_account_order'] !== '') {
$list = $list->join('lie_order as o', 's.order_id', '=', 'o.order_id')
->where(function($query) use($map) {
if ($map['is_account_order'] == 1) {
$query->where('o.order_pay_type', 3);
} else {
$query->where('o.order_pay_type', '<>', 3);
}
});
}
$list = $list->where(function($query) use ($map, $request, $role, $perm) {
// 售后单号
if ($map['service_sn']) {
$query->where('service_sn', '=', $map['service_sn']);
$query->where('s.service_sn', '=', $map['service_sn']);
}
// 订单号
if ($map['order_sn']) {
$query->where('order_sn', '=', $map['order_sn']);
$query->where('s.order_sn', '=', $map['order_sn']);
}
// 申请人
if ($map['apply_id']) {
$query->where('apply_id', '=', $map['apply_id']);
$query->where('s.apply_id', '=', $map['apply_id']);
}
// 售后状态
if ($map['service_status']) {
$query->where('service_status', '=', $map['service_status']);
$query->where('s.service_status', '=', $map['service_status']);
}
// 退款状态
if ($map['refund_status']) {
$query->where('refund_status', '=', $map['refund_status']);
$query->where('s.refund_status', '=', $map['refund_status']);
}
// 退货状态
if ($map['return_status']) {
$query->where('return_status', '=', $map['return_status']);
$query->where('s.return_status', '=', $map['return_status']);
}
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
$query->whereBetween('s.create_time', [$map['begin_time'], $map['end_time']]);
}
else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
$query->where('s.create_time', '>=', $map['begin_time']);
}
else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
$query->where('s.create_time', '<=', $map['end_time']);
}
switch ($role) {
......@@ -95,6 +112,7 @@ class OrderServiceModel extends Model
break;
}
})
->select($field)
->orderBy('id', 'desc');
// $tmp = str_replace('?', '"'.'%s'.'"', $list->toSql());
// $tmp = vsprintf($tmp, $list->getBindings());
......
......@@ -92,6 +92,17 @@
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">账期订单</label>
<div class="layui-input-inline">
<select name="is_account_order" lay-verify="" lay-search>
<option value=""></option>
<option value="1"></option>
<option value="-1"></option>
</select>
</div>
</div>
</div>
<div class="layui-form-item">
......
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