|
@@ -4079,18 +4079,28 @@ class WholeController extends Curd
|
|
|
$order = Order::where('order_id',$orderId)
|
|
|
->select('order_id','order_status_payment')
|
|
|
->first();
|
|
|
+ Db::beginTransaction();
|
|
|
try {
|
|
|
if ($orderStatusPayment == 'AWAITING' && $order->order_status_payment != 'PENDING'){
|
|
|
return json_fail('当前订单不允许挂账');
|
|
|
}
|
|
|
- if ($order->order_status_payment == 'PENDING' && !empty($orderStatusPayment)){
|
|
|
+ // 挂账,释放餐桌
|
|
|
+ if ($order->order_status_payment == 'PENDING' && $orderStatusPayment == 'AWAITING'){
|
|
|
$order->order_status_payment = $orderStatusPayment;
|
|
|
+ // 如果有餐桌,释放
|
|
|
+ if(!empty($order->order_config_json)){
|
|
|
+ $orderConfigJson = json_decode($order->order_config_json,true);
|
|
|
+ if (!empty($orderConfigJson['tableid'])){
|
|
|
+ SysDept::where('dept_id',$orderConfigJson['tableid'])->update(['dept_status'=>'ACTIVED']);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
$order->save();
|
|
|
|
|
|
+ Db::commit();
|
|
|
return json_success('success');
|
|
|
}catch (\Exception $e){
|
|
|
+ Db::rollBack();
|
|
|
return json_fail('修改订单状态失败');
|
|
|
}
|
|
|
|