|
@@ -106,16 +106,22 @@ class AppointmentService
|
|
|
$extendJson = json_decode($goods->goods_attribute_json, true);
|
|
|
foreach ($extendJson['times'] as $key => $time) {
|
|
|
if ($time['duration'] == $params['appointment_times']) {
|
|
|
- foreach ($appointments as $appointment) {
|
|
|
- $applyJson = json_decode($appointment['appointment_apply_json'], true);
|
|
|
- $applyJsonTimes = $applyJson['times'] ?? '';
|
|
|
+ if (!empty($appointments)){
|
|
|
+ foreach ($appointments as $appointment) {
|
|
|
+ $applyJson = json_decode($appointment['appointment_apply_json'], true);
|
|
|
+ $applyJsonTimes = $applyJson['times'] ?? '';
|
|
|
|
|
|
- if ($time['duration'] == $applyJsonTimes) {
|
|
|
- $extendJson['times'][$key]['person'] -= $applyJson['person'];
|
|
|
- if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
- return json_fail('当前时段名额不足,请选择其他时段');
|
|
|
+ if ($time['duration'] == $applyJsonTimes) {
|
|
|
+ $extendJson['times'][$key]['person'] -= $applyJson['person'];
|
|
|
+ if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
+ return json_fail('当前时段名额不足,请选择其他时段');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }else{
|
|
|
+ if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
+ return json_fail('当前时段名额不足,请选择其他时段');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -314,16 +320,22 @@ class AppointmentService
|
|
|
$extendJson = json_decode($goods->goods_attribute_json, true);
|
|
|
foreach ($extendJson['times'] as $key => $time) {
|
|
|
if ($time['duration'] == $params['appointment_times']) {
|
|
|
- foreach ($appointments as $appointment) {
|
|
|
- $applyJson = json_decode($appointment['appointment_apply_json'], true);
|
|
|
- $applyJsonTimes = $applyJson['times'] ?? '';
|
|
|
+ if (!empty($appointments)){
|
|
|
+ foreach ($appointments as $appointment) {
|
|
|
+ $applyJson = json_decode($appointment['appointment_apply_json'], true);
|
|
|
+ $applyJsonTimes = $applyJson['times'] ?? '';
|
|
|
|
|
|
- if ($time['duration'] == $applyJsonTimes) {
|
|
|
- $extendJson['times'][$key]['person'] -= $applyJson['person'];
|
|
|
- if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
- return json_fail('当前时段名额不足,请选择其他时段');
|
|
|
+ if ($time['duration'] == $applyJsonTimes) {
|
|
|
+ $extendJson['times'][$key]['person'] -= $applyJson['person'];
|
|
|
+ if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
+ return json_fail('当前时段名额不足,请选择其他时段');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }else{
|
|
|
+ if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
+ return json_fail('当前时段名额不足,请选择其他时段');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|