|
@@ -647,22 +647,13 @@ class OrderController extends AuthController
|
|
}
|
|
}
|
|
|
|
|
|
if ($order['product_type'] == 3) {
|
|
if ($order['product_type'] == 3) {
|
|
- if ($order['order_patient']['appoint_start_time'] + 1800 > time()) {
|
|
|
|
|
|
+ if ($order['order_patient']['appoint_start_time'] - 1800 < time()) {
|
|
return out(null, 10003, '预约时间临近,不能取消订单了');
|
|
return out(null, 10003, '预约时间临近,不能取消订单了');
|
|
}
|
|
}
|
|
|
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
try {
|
|
try {
|
|
- //改变订单状态
|
|
|
|
- Order::where('id', $req['order_id'])->update(['order_status' => 5]);
|
|
|
|
- //退钱到余额
|
|
|
|
- User::changeBalance($order['user_id'], $order['payment_amount'], 4, $order['id'], '取消订单退款');
|
|
|
|
- //预约时间段的订单数减1
|
|
|
|
- $orderPatient = OrderPatient::select(['time_period_id', 'appoint_start_time'])->where('order_id', $req['order_id'])->first();
|
|
|
|
- $schedule_date = date('Y-m-d', $orderPatient['appoint_start_time']);
|
|
|
|
- SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->decrement('order_num');
|
|
|
|
- //更新医生的服务人数
|
|
|
|
- Docter::where('id', $order['docter_id'])->decrement('service_persons');
|
|
|
|
|
|
+ Order::orderCancel($req['order_id']);
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|