|
@@ -102,17 +102,15 @@ class AppointmentService
|
|
|
// 先检查选择的时段是否可预约
|
|
|
$goods = Goods::where('goods_id', $params['join_appointment_goods_id'])->first();
|
|
|
$appointments = Appointment::where('appointment_datetime', $params['appointment_datetime'])->get()->toArray();
|
|
|
- if ($goods->is_support_appointment == 'Y' && !empty($goods->goods_extend_json)) {
|
|
|
- // {"times": [{"person": 2, "appointmentTimeEnd": "07:00", "appointmentTimeStart": "06:30"}, {"person": 3, "appointmentTimeEnd": "07:30", "appointmentTimeStart": "07:00"}]}
|
|
|
- $extendJson = json_decode($goods->goods_extend_json, true);
|
|
|
+ if ($goods->is_support_appointment == 'Y' && !empty($goods->goods_attribute_json)) {
|
|
|
+ $extendJson = json_decode($goods->goods_attribute_json, true);
|
|
|
foreach ($extendJson['times'] as $key => $time) {
|
|
|
- $timesStr = $time['appointmentTimeStart'] . '~' . $time['appointmentTimeEnd'];
|
|
|
- if ($timesStr == $params['appointment_times']) {
|
|
|
+ if ($time['duration'] == $params['appointment_times']) {
|
|
|
foreach ($appointments as $appointment) {
|
|
|
$applyJson = json_decode($appointment['appointment_apply_json'], true);
|
|
|
$applyJsonTimes = $applyJson['times'] ?? '';
|
|
|
|
|
|
- if ($timesStr == $applyJsonTimes) {
|
|
|
+ if ($time['duration'] == $applyJsonTimes) {
|
|
|
$extendJson['times'][$key]['person'] -= $applyJson['person'];
|
|
|
if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
return json_fail('当前时段人数超出限制,请选择其他时段');
|
|
@@ -312,24 +310,21 @@ class AppointmentService
|
|
|
->where('appointment_id', '<>', $params['appointment_id'])
|
|
|
->get()
|
|
|
->toArray();
|
|
|
- if ($goods->is_support_appointment == 'Y' && !empty($goods->goods_extend_json)) {
|
|
|
- // {"times": [{"person": 2, "appointmentTimeEnd": "07:00", "appointmentTimeStart": "06:30"}, {"person": 3, "appointmentTimeEnd": "07:30", "appointmentTimeStart": "07:00"}]}
|
|
|
- $extendJson = json_decode($goods->goods_extend_json, true);
|
|
|
+ if ($goods->is_support_appointment == 'Y' && !empty($goods->goods_attribute_json)) {
|
|
|
+ $extendJson = json_decode($goods->goods_attribute_json, true);
|
|
|
foreach ($extendJson['times'] as $key => $time) {
|
|
|
- $timesStr = $time['appointmentTimeStart'] . '~' . $time['appointmentTimeEnd'];
|
|
|
- if ($timesStr == $params['appointment_times']) {
|
|
|
+ if ($time['duration'] == $params['appointment_times']) {
|
|
|
foreach ($appointments as $appointment) {
|
|
|
$applyJson = json_decode($appointment['appointment_apply_json'], true);
|
|
|
$applyJsonTimes = $applyJson['times'] ?? '';
|
|
|
-// dump($timesStr.'=='.$applyJsonTimes);
|
|
|
- if ($timesStr == $applyJsonTimes) {
|
|
|
+
|
|
|
+ if ($time['duration'] == $applyJsonTimes) {
|
|
|
$extendJson['times'][$key]['person'] -= $applyJson['person'];
|
|
|
+ if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
+ return json_fail('当前时段人数超出限制,请选择其他时段');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if ($extendJson['times'][$key]['person'] < $params['person']) {
|
|
|
- return json_fail('当前时段已满员,请选择其他时段');
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -485,7 +480,7 @@ class AppointmentService
|
|
|
})
|
|
|
->get()
|
|
|
->toArray();
|
|
|
- if ($goods->is_support_appointment == 'Y' && !empty($goods->goods_extend_json)) {
|
|
|
+ if ($goods->is_support_appointment == 'Y' && !empty($goods->goods_attribute_json)) {
|
|
|
$extendJson = json_decode($goods->goods_attribute_json, true);
|
|
|
$times = $extendJson['times'];
|
|
|
foreach ($times as $key => $time) {
|