|
@@ -525,17 +525,17 @@ class WholeController extends Curd
|
|
|
continue;
|
|
|
}
|
|
|
$classify = CouponService::couponClassifyInfo($coupon->coupon_classify, $coupon->coupon_category, $coupon->coupon_value, $coupon->coupon_minimum_limit);
|
|
|
- $discount['coupon_name'] .= $coupon->coupon_classify . ':' . $coupon->coupon_name . '(优惠¥' . $discountItem['coupon_value'] . '), ';
|
|
|
+ $discount['coupon_name'] .= $coupon->coupon_classify . ':' . $coupon->coupon_name . '(优惠¥' . sprintf("%.2f", $discountItem['coupon_value']) . '), ';
|
|
|
}
|
|
|
if (empty($discountItem['coupon_id']) && !empty($discountItem['coupon_classify'])) {
|
|
|
if (!empty($discountItem['coupon_detail_id'])) {
|
|
|
- $discount['classify'] .= $discountItem['coupon_detail_id'][0] . '(优惠¥' . round($discountItem['coupon_value'], 2) . '), ';
|
|
|
+ $discount['classify'] .= $discountItem['coupon_detail_id'][0] . '(优惠¥' . sprintf("%.2f", $discountItem['coupon_value']) . '), ';
|
|
|
} else {
|
|
|
- $discount['classify'] .= $discountItem['coupon_classify'] . '(优惠¥' . round($discountItem['coupon_value'], 2) . '), ';
|
|
|
+ $discount['classify'] .= $discountItem['coupon_classify'] . '(优惠¥' . sprintf("%.2f", $discountItem['coupon_value']) . '), ';
|
|
|
}
|
|
|
}
|
|
|
if (!empty($discountItem['coupon_value'])) {
|
|
|
- $discount['value'] += round($discountItem['coupon_value'], 2);
|
|
|
+ $discount['value'] += $discountItem['coupon_value'];
|
|
|
}
|
|
|
}
|
|
|
if (!empty($discount['coupon_name'])) {
|
|
@@ -545,6 +545,7 @@ class WholeController extends Curd
|
|
|
$discount['classify'] = rtrim($discount['classify'], ', ');
|
|
|
}
|
|
|
}
|
|
|
+ $discount['value'] = sprintf("%.2f", $discount['value']);
|
|
|
$order->discount = $discount;
|
|
|
|
|
|
$order->premises = $order->premises ?? $premises;
|
|
@@ -4402,15 +4403,17 @@ class WholeController extends Curd
|
|
|
$orderId = $request->post('order_id', '');
|
|
|
$orderStatusPayment = $request->post('order_status_payment', '');
|
|
|
$order = Order::where('order_id', $orderId)
|
|
|
- ->select('order_id', 'order_status_payment', 'order_config_json')
|
|
|
+ ->select('order_id', 'order_groupby', 'order_status_payment', 'order_config_json', 'order_amount_total')
|
|
|
->first();
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
if ($orderStatusPayment == 'AWAITING' && $order->order_status_payment != 'PENDING') {
|
|
|
- return json_fail('当前订单不允许挂账');
|
|
|
+ throw new BusinessException("当前订单不允许挂账");
|
|
|
+ } else if ($orderStatusPayment == 'FREE' && $order->order_status_payment != 'PENDING') {
|
|
|
+ throw new BusinessException("当前订单不允许免单");
|
|
|
}
|
|
|
// 挂账,释放餐桌
|
|
|
- if ($order->order_status_payment == 'PENDING' && $orderStatusPayment == 'AWAITING') {
|
|
|
+ if (in_array($orderStatusPayment, ['AWAITING', 'FREE'])) {
|
|
|
$order->order_status_payment = $orderStatusPayment;
|
|
|
// 如果有餐桌,释放
|
|
|
if (!empty($order->order_config_json)) {
|
|
@@ -4420,10 +4423,41 @@ class WholeController extends Curd
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if ($orderStatusPayment == 'FREE') {
|
|
|
+ $orderDiscountJson = [];
|
|
|
+ if (!empty($order->order_discount_json)) {
|
|
|
+ $orderDiscountJson = json_decode($order->order_discount_json, true);
|
|
|
+ }
|
|
|
+ $orderDiscountJson[date('Y-m-d H:i:s')] = [
|
|
|
+ 'coupon_id' => null,
|
|
|
+ 'coupon_value' => $order->order_amount_total,
|
|
|
+ 'coupon_classify' => '免单',
|
|
|
+ 'coupon_detail_id' => ['免单'],
|
|
|
+ 'coupon_classify_en' => ['free']
|
|
|
+ ];
|
|
|
+ $order->order_discount_json = json_encode($orderDiscountJson, JSON_UNESCAPED_UNICODE);
|
|
|
+ $order->order_is_complete = 'Y';
|
|
|
+ $order->order_status_system = 'DONE';
|
|
|
+ $order->order_amount_pay = 0;
|
|
|
+
|
|
|
+ // sheet表
|
|
|
+ OrderSheet::where('join_sheet_order_id', $orderId)->update(['order_sheet_status' => 'DONE']);
|
|
|
+ // payDetail 表
|
|
|
+ PayDetail::where('join_pay_order_id', $order->order_groupby)
|
|
|
+ ->update([
|
|
|
+ 'pay_status' => 'SUCCESS',
|
|
|
+ 'pay_amount' => 0,
|
|
|
+ 'pay_prepayid' => 'MONEY',
|
|
|
+ 'pay_paytimes' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
$order->save();
|
|
|
|
|
|
Db::commit();
|
|
|
return json_success('success');
|
|
|
+ } catch (BusinessException $e) {
|
|
|
+ Db::rollBack();
|
|
|
+ return json_fail($e->getMessage());
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
return json_fail('修改订单状态失败');
|