计划null BUG

main
鹿和sa0ChunLuyu 3 days ago
parent 7796c2f5d8
commit 174c7a8c51

@ -110,6 +110,10 @@ public function GetList(Request $request)
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
foreach ($countsInfo as $k => $v) { foreach ($countsInfo as $k => $v) {
if ($value->id == $v->roster_detail_id) { if ($value->id == $v->roster_detail_id) {
$v->count = $v->count ?? 0;
$v->used_count = $v->used_count ?? 0;
$v->locked_count = $v->locked_count ?? 0;
$v->max_total = $v->max_total ?? 0;
$list[$key]->countsInfo[] = $v; $list[$key]->countsInfo[] = $v;
} }
} }
@ -146,6 +150,12 @@ public function GetDetail()
$info->max_total = 0; $info->max_total = 0;
if (count($info->coutsInfo) > 0) { if (count($info->coutsInfo) > 0) {
$info->max_total = $info->coutsInfo[0]->max_total; $info->max_total = $info->coutsInfo[0]->max_total;
foreach ($info->coutsInfo as $ci) {
$ci->count = $ci->count ?? 0;
$ci->used_count = $ci->used_count ?? 0;
$ci->locked_count = $ci->locked_count ?? 0;
$ci->max_total = $ci->max_total ?? 0;
}
} }
return \Yz::Return(true, '获取成功', $info); return \Yz::Return(true, '获取成功', $info);
} }

@ -250,7 +250,7 @@ public function Save(Request $request)
'roster_id' => $roster_id, 'roster_id' => $roster_id,
'appointment_type_id' => $v['id'], 'appointment_type_id' => $v['id'],
'max_total' => $planInfo['max_total'], 'max_total' => $planInfo['max_total'],
'count' => $v['count'], 'count' => $v['count'] ?? 0,
]); ]);
if (!$i_c) { if (!$i_c) {
DB::rollBack(); DB::rollBack();
@ -278,7 +278,7 @@ public function Save(Request $request)
'roster_id' => $roster_id, 'roster_id' => $roster_id,
'appointment_type_id' => $v['id'], 'appointment_type_id' => $v['id'],
'max_total' => $planInfo['max_total'], 'max_total' => $planInfo['max_total'],
'count' => $v['count'], 'count' => $v['count'] ?? 0,
]); ]);
if (!$i_c) { if (!$i_c) {
DB::rollBack(); DB::rollBack();
@ -297,14 +297,15 @@ public function Save(Request $request)
$i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data); $i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data);
$anyUpdate = false;
foreach ($planInfo['qudao_total'] as $k => $v) { foreach ($planInfo['qudao_total'] as $k => $v) {
$i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([ $i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([
'max_total' => $planInfo['max_total'], 'max_total' => $planInfo['max_total'],
'count' => $v['count'], 'count' => $v['count'] ?? 0,
]); ]);
if ($i_c) $anyUpdate = true;
} }
if ($i or $i_c) { if ($i or $anyUpdate) {
} else { } else {
DB::rollBack(); DB::rollBack();
return \Yz::echoError1('保存失败'); return \Yz::echoError1('保存失败');
@ -737,7 +738,7 @@ public function SaveAdmin(Request $request)
'roster_id' => $roster_id, 'roster_id' => $roster_id,
'appointment_type_id' => $v['id'], 'appointment_type_id' => $v['id'],
'max_total' => $planInfo['max_total'], 'max_total' => $planInfo['max_total'],
'count' => $v['count'], 'count' => $v['count'] ?? 0,
]); ]);
if (!$i_c) { if (!$i_c) {
DB::rollBack(); DB::rollBack();
@ -764,7 +765,7 @@ public function SaveAdmin(Request $request)
'roster_id' => $roster_id, 'roster_id' => $roster_id,
'appointment_type_id' => $v['id'], 'appointment_type_id' => $v['id'],
'max_total' => $planInfo['max_total'], 'max_total' => $planInfo['max_total'],
'count' => $v['count'], 'count' => $v['count'] ?? 0,
]); ]);
if (!$i_c) { if (!$i_c) {
DB::rollBack(); DB::rollBack();
@ -780,13 +781,15 @@ public function SaveAdmin(Request $request)
if($planInfo['id'] > 0) { if($planInfo['id'] > 0) {
$data['id'] = $planInfo['id']; $data['id'] = $planInfo['id'];
$i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data); $i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data);
$anyUpdate = false;
foreach ($planInfo['qudao_total'] as $k => $v) { foreach ($planInfo['qudao_total'] as $k => $v) {
$i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([ $i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([
'max_total' => $planInfo['max_total'], 'max_total' => $planInfo['max_total'],
'count' => $v['count'], 'count' => $v['count'] ?? 0,
]); ]);
if ($i_c) $anyUpdate = true;
} }
if ($i or $i_c) { if ($i or $anyUpdate) {
} else { } else {
DB::rollBack(); DB::rollBack();
return \Yz::echoError1('保存失败'); return \Yz::echoError1('保存失败');

@ -384,7 +384,7 @@ private function insertCountInfo($detailId, $rosterId) {
$success = DB::table('s_source_roster_detail_count')->insert([ $success = DB::table('s_source_roster_detail_count')->insert([
'roster_detail_id' => $detailId, 'roster_detail_id' => $detailId,
'appointment_type_id' => $info->appointment_type_id, 'appointment_type_id' => $info->appointment_type_id,
'count' => $info->count, 'count' => $info->count ?? 0,
'locked_count' => $info->locked_count, 'locked_count' => $info->locked_count,
'max_total' => $info->max_total, 'max_total' => $info->max_total,
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),

Loading…
Cancel
Save