|
@@ -21,12 +21,14 @@ class WriteOffController extends Curd
|
|
|
$page = $request->get('page', 1);
|
|
|
$pageSize = $request->get('pageSize', 50);
|
|
|
$keywords = $request->get('keywords','');
|
|
|
+ $userId = $request->get('user_id','');
|
|
|
+ $premises = $request->get('premises','');
|
|
|
$date = $request->get('date',[]);
|
|
|
|
|
|
$appointmentList = Db::table('appointment')
|
|
|
->leftJoin('member','member.member_id' ,'=','appointment.join_appointment_member_id')
|
|
|
->leftJoin('member_cert','member_cert.join_cert_member_id' ,'=','appointment.join_appointment_member_id')
|
|
|
- ->select('appointment.appointment_id as quota_id', 'appointment.join_appointment_member_id as member_id', 'appointment.appointment_done_json as used_json', 'appointment.appointment_done_datetime as used_time','appointment.join_appointment_member_benefit_id as benefit_id',
|
|
|
+ ->select('appointment.appointment_id as quota_id', 'appointment.join_appointment_member_id as member_id','appointment.appointment_classify as classify', 'appointment.appointment_done_json as used_json', 'appointment.appointment_done_datetime as used_time','appointment.join_appointment_member_benefit_id as benefit_id',
|
|
|
'member.member_mobile','member_cert.member_cert_name'
|
|
|
)
|
|
|
->when($keywords != '',function($query) use ($keywords){
|
|
@@ -36,11 +38,17 @@ class WriteOffController extends Curd
|
|
|
$date[1] = date('Y-m-d',strtotime($date[1])). ' 23:59:59';
|
|
|
$query->whereBetween('appointment.appointment_done_datetime',$date);
|
|
|
})
|
|
|
+ ->when($userId != '',function($query) use ($userId){
|
|
|
+ $query->whereJsonContains('appointment.appointment_done_json->charge->charge_user_id',$userId);
|
|
|
+ })
|
|
|
+ ->when($premises != '',function($query) use ($premises){
|
|
|
+ $query->whereJsonContains('appointment.appointment_done_json->charge->charge_premises',$premises);
|
|
|
+ })
|
|
|
->where('appointment_status', 'DONE');
|
|
|
$quotaList = Db::table('member_quota')
|
|
|
->leftJoin('member','member.member_id' ,'=','member_quota.join_quota_member_id')
|
|
|
->leftJoin('member_cert','member_cert.join_cert_member_id' ,'=','member_quota.join_quota_member_id')
|
|
|
- ->select('member_quota.member_quota_id as quota_id', 'member_quota.join_quota_member_id as member_id', 'member_quota.member_quota_used_json as used_json', "member_quota.member_quota_extend_json->writeOffTime as used_time","member_quota.join_member_rule_added_component_id as benefit_id",
|
|
|
+ ->select('member_quota.member_quota_id as quota_id', 'member_quota.join_quota_member_id as member_id','member_quota.member_quota_category as classify', 'member_quota.member_quota_used_json as used_json', "member_quota.member_quota_extend_json->writeOffTime as used_time","member_quota.join_member_rule_added_component_id as benefit_id",
|
|
|
'member.member_mobile','member_cert.member_cert_name')
|
|
|
|
|
|
->when($keywords != '',function($query) use ($keywords){
|
|
@@ -50,6 +58,12 @@ class WriteOffController extends Curd
|
|
|
$date[1] = date('Y-m-d',strtotime($date[1])). ' 23:59:59';
|
|
|
$query->whereBetween('member_quota.member_quota_extend_json->writeOffTime',$date);
|
|
|
})
|
|
|
+ ->when($userId != '',function($query) use ($userId){
|
|
|
+ $query->whereJsonContains('member_quota.member_quota_used_json->charge->charge_user_id',$userId);
|
|
|
+ })
|
|
|
+ ->when($premises != '',function($query) use ($premises){
|
|
|
+ $query->whereJsonContains('member_quota.member_quota_used_json->charge->charge_premises',$premises);
|
|
|
+ })
|
|
|
->where('member_quota_status', 'USED')
|
|
|
// ->toSql();
|
|
|
->union($appointmentList);
|
|
@@ -78,8 +92,12 @@ class WriteOffController extends Curd
|
|
|
$benefitName = RuleAddedComponent::where('rule_added_component_id',$item->benefit_i)->value('rule_added_component_name');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ $classify = "SERVICE";
|
|
|
+ if(substr($item->quota_id,0,2) == "MQ"){
|
|
|
+ $classify = "QUOTA";
|
|
|
+ }elseif(!empty($item->classify) && $item->classify == 'PACKAGE'){
|
|
|
+ $classify = "PACKAGE";
|
|
|
+ }
|
|
|
$rows[] = [
|
|
|
'quota_id' => $item->quota_id,
|
|
|
'username' => $username,
|
|
@@ -88,6 +106,7 @@ class WriteOffController extends Curd
|
|
|
'used_time'=>$item->used_time,
|
|
|
'member_name' => $item->member_cert_name ? $item->member_cert_name.'-' : '',
|
|
|
'member_mobile' => $item->member_mobile ? $item->member_mobile : '',
|
|
|
+ 'classify'=>$classify,
|
|
|
'nbr'=>1
|
|
|
];
|
|
|
|