|
@@ -4,7 +4,13 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
-import shop.alien.entity.store.*;
|
|
|
|
|
|
|
+import shop.alien.entity.store.MerchantPaymentOrder;
|
|
|
|
|
+import shop.alien.entity.store.StoreBookingCategory;
|
|
|
|
|
+import shop.alien.entity.store.StoreBookingTable;
|
|
|
|
|
+import shop.alien.entity.store.StoreInfo;
|
|
|
|
|
+import shop.alien.entity.store.UserReservation;
|
|
|
|
|
+import shop.alien.entity.store.UserReservationOrder;
|
|
|
|
|
+import shop.alien.entity.store.UserReservationTable;
|
|
|
import shop.alien.mapper.UserReservationTableMapper;
|
|
import shop.alien.mapper.UserReservationTableMapper;
|
|
|
import shop.alien.store.service.*;
|
|
import shop.alien.store.service.*;
|
|
|
import shop.alien.store.vo.ReservationOrderPageVo;
|
|
import shop.alien.store.vo.ReservationOrderPageVo;
|
|
@@ -31,12 +37,20 @@ public class ReservationOrderPageServiceImpl implements ReservationOrderPageServ
|
|
|
private static final int CANCELLATION_NOT_FREE = 1;
|
|
private static final int CANCELLATION_NOT_FREE = 1;
|
|
|
private static final int CANCELLATION_CONDITIONAL = 2;
|
|
private static final int CANCELLATION_CONDITIONAL = 2;
|
|
|
|
|
|
|
|
|
|
+ private static final int ORDER_STATUS_COMPLETED = 2;
|
|
|
|
|
+ private static final int ORDER_STATUS_EXPIRED = 3;
|
|
|
|
|
+ private static final int ORDER_STATUS_CANCELLED = 4;
|
|
|
|
|
+ private static final int ORDER_STATUS_CLOSED = 5;
|
|
|
|
|
+ private static final int ORDER_STATUS_REFUNDING = 6;
|
|
|
|
|
+ private static final int ORDER_STATUS_REFUNDED = 7;
|
|
|
|
|
+
|
|
|
private final UserReservationOrderService userReservationOrderService;
|
|
private final UserReservationOrderService userReservationOrderService;
|
|
|
private final StoreInfoService storeInfoService;
|
|
private final StoreInfoService storeInfoService;
|
|
|
private final UserReservationService userReservationService;
|
|
private final UserReservationService userReservationService;
|
|
|
private final UserReservationTableMapper userReservationTableMapper;
|
|
private final UserReservationTableMapper userReservationTableMapper;
|
|
|
private final StoreBookingTableService storeBookingTableService;
|
|
private final StoreBookingTableService storeBookingTableService;
|
|
|
private final StoreBookingCategoryService storeBookingCategoryService;
|
|
private final StoreBookingCategoryService storeBookingCategoryService;
|
|
|
|
|
+ private final MerchantPaymentOrderService merchantPaymentOrderService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ReservationOrderPageVo getPageByOrderId(Integer orderId) {
|
|
public ReservationOrderPageVo getPageByOrderId(Integer orderId) {
|
|
@@ -55,7 +69,7 @@ public class ReservationOrderPageServiceImpl implements ReservationOrderPageServ
|
|
|
vo.setOrderId(order.getId());
|
|
vo.setOrderId(order.getId());
|
|
|
vo.setOrderSn(order.getOrderSn());
|
|
vo.setOrderSn(order.getOrderSn());
|
|
|
vo.setOrderStatus(order.getOrderStatus());
|
|
vo.setOrderStatus(order.getOrderStatus());
|
|
|
- vo.setPaymentStatus(derivePaymentStatus(order.getOrderStatus()));
|
|
|
|
|
|
|
+ vo.setPaymentStatus(order.getPaymentStatus() != null ? order.getPaymentStatus() : derivePaymentStatus(order.getOrderStatus()));
|
|
|
vo.setPayAmount(order.getDepositAmount() != null ? order.getDepositAmount() : BigDecimal.ZERO);
|
|
vo.setPayAmount(order.getDepositAmount() != null ? order.getDepositAmount() : BigDecimal.ZERO);
|
|
|
vo.setPaymentDeadlineMinutes(PAYMENT_DEADLINE_MINUTES);
|
|
vo.setPaymentDeadlineMinutes(PAYMENT_DEADLINE_MINUTES);
|
|
|
|
|
|
|
@@ -65,22 +79,28 @@ public class ReservationOrderPageServiceImpl implements ReservationOrderPageServ
|
|
|
vo.setPaymentSecondsLeft(secondsLeft);
|
|
vo.setPaymentSecondsLeft(secondsLeft);
|
|
|
vo.setCanContinuePay(Boolean.valueOf(ORDER_STATUS_UNPAID == order.getOrderStatus() && secondsLeft > 0));
|
|
vo.setCanContinuePay(Boolean.valueOf(ORDER_STATUS_UNPAID == order.getOrderStatus() && secondsLeft > 0));
|
|
|
|
|
|
|
|
- // 页面标题:待支付 / 预订成功(待使用兼容预订成功页)
|
|
|
|
|
|
|
+ // 页面标题与后缀(全状态)
|
|
|
Integer orderStatus = order.getOrderStatus();
|
|
Integer orderStatus = order.getOrderStatus();
|
|
|
- if (ORDER_STATUS_UNPAID == orderStatus) {
|
|
|
|
|
- vo.setPageTitle("待支付");
|
|
|
|
|
- vo.setPageTitleSuffix(buildPendingPaymentTitleSuffix(order.getCancellationPolicyType()));
|
|
|
|
|
- } else if (ORDER_STATUS_TO_USE == orderStatus) {
|
|
|
|
|
- vo.setPageTitle("预订成功");
|
|
|
|
|
- vo.setPageTitleSuffix(buildSuccessPageTitleSuffix(order.getCancellationPolicyType()));
|
|
|
|
|
- } else {
|
|
|
|
|
- vo.setPageTitle(null);
|
|
|
|
|
- vo.setPageTitleSuffix(buildPendingPaymentTitleSuffix(order.getCancellationPolicyType()));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ vo.setPageTitle(buildPageTitle(orderStatus));
|
|
|
|
|
+ vo.setPageTitleSuffix(buildPageTitleSuffixByStatus(orderStatus, order.getCancellationPolicyType(), order.getOrderCostType()));
|
|
|
|
|
+ vo.setStatusSubtitle(buildStatusSubtitle(order));
|
|
|
|
|
|
|
|
- // 操作按钮:取消预订、修改预订
|
|
|
|
|
|
|
+ // 操作按钮
|
|
|
vo.setCanCancelReservation(Boolean.valueOf(ORDER_STATUS_UNPAID == orderStatus || ORDER_STATUS_TO_USE == orderStatus));
|
|
vo.setCanCancelReservation(Boolean.valueOf(ORDER_STATUS_UNPAID == orderStatus || ORDER_STATUS_TO_USE == orderStatus));
|
|
|
vo.setCanModifyReservation(Boolean.valueOf(ORDER_STATUS_TO_USE == orderStatus));
|
|
vo.setCanModifyReservation(Boolean.valueOf(ORDER_STATUS_TO_USE == orderStatus));
|
|
|
|
|
+ boolean endState = orderStatus != null && (orderStatus == ORDER_STATUS_COMPLETED || orderStatus == ORDER_STATUS_EXPIRED
|
|
|
|
|
+ || orderStatus == ORDER_STATUS_CANCELLED || orderStatus == ORDER_STATUS_CLOSED
|
|
|
|
|
+ || orderStatus == ORDER_STATUS_REFUNDING || orderStatus == ORDER_STATUS_REFUNDED);
|
|
|
|
|
+ vo.setCanDelete(endState);
|
|
|
|
|
+ vo.setCanBookAgain(endState);
|
|
|
|
|
+
|
|
|
|
|
+ // 待支付时返回当前支付单的 outTradeNo(用于轮询 queryStatus)
|
|
|
|
|
+ if (orderStatus != null && ORDER_STATUS_UNPAID == orderStatus) {
|
|
|
|
|
+ MerchantPaymentOrder unpaid = merchantPaymentOrderService.getUnpaidByOrderId(order.getId());
|
|
|
|
|
+ if (unpaid != null) {
|
|
|
|
|
+ vo.setOutTradeNo(unpaid.getOutTradeNo());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 门店
|
|
// 门店
|
|
|
if (storeId != null) {
|
|
if (storeId != null) {
|
|
@@ -177,7 +197,56 @@ public class ReservationOrderPageServiceImpl implements ReservationOrderPageServ
|
|
|
return diff > 0 ? (int) diff : 0;
|
|
return diff > 0 ? (int) diff : 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 待支付页标题后缀 */
|
|
|
|
|
|
|
+ private String buildPageTitle(Integer orderStatus) {
|
|
|
|
|
+ if (orderStatus == null) return null;
|
|
|
|
|
+ switch (orderStatus) {
|
|
|
|
|
+ case 0: return "待支付";
|
|
|
|
|
+ case 1: return "预订成功";
|
|
|
|
|
+ case 2: return "已完成";
|
|
|
|
|
+ case 3: return "已过期";
|
|
|
|
|
+ case 4: return "已取消";
|
|
|
|
|
+ case 5: return "已关闭";
|
|
|
|
|
+ case 6: return "退款中";
|
|
|
|
|
+ case 7: return "已退款";
|
|
|
|
|
+ default: return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String buildPageTitleSuffixByStatus(Integer orderStatus, Integer cancellationPolicyType, Integer orderCostType) {
|
|
|
|
|
+ if (orderStatus == null) return "不可免责取消";
|
|
|
|
|
+ if (orderStatus == 0) return buildPendingPaymentTitleSuffix(cancellationPolicyType);
|
|
|
|
|
+ if (orderStatus == 1) return buildSuccessPageTitleSuffix(cancellationPolicyType);
|
|
|
|
|
+ if (orderStatus == 2 || orderStatus == 3 || orderStatus == 4 || orderStatus == 5 || orderStatus == 6 || orderStatus == 7) {
|
|
|
|
|
+ if (orderCostType != null && orderCostType == 0) return "免费预订";
|
|
|
|
|
+ if (cancellationPolicyType == null) return "不可免责取消";
|
|
|
|
|
+ if (cancellationPolicyType == CANCELLATION_FREE) return "免费预订";
|
|
|
|
|
+ if (cancellationPolicyType == CANCELLATION_CONDITIONAL) return "分情况是否免责";
|
|
|
|
|
+ return "不可免责取消";
|
|
|
|
|
+ }
|
|
|
|
|
+ return buildPendingPaymentTitleSuffix(cancellationPolicyType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String buildStatusSubtitle(UserReservationOrder order) {
|
|
|
|
|
+ if (order == null) return null;
|
|
|
|
|
+ Integer status = order.getOrderStatus();
|
|
|
|
|
+ if (ORDER_STATUS_COMPLETED == status && order.getPaymentStatus() != null && order.getPaymentStatus() == 2) {
|
|
|
|
|
+ return "退款成功,已按原支付路径返回";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ORDER_STATUS_REFUNDING == status) {
|
|
|
|
|
+ return "正在为您发起退款,请耐心等待";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ORDER_STATUS_CANCELLED == status) {
|
|
|
|
|
+ Integer refundType = order.getRefundType();
|
|
|
|
|
+ if (refundType != null && refundType == 0) {
|
|
|
|
|
+ if (order.getOrderCostType() != null && order.getOrderCostType() == 0) return "用户取消-免费预订";
|
|
|
|
|
+ if (order.getCancellationPolicyType() != null && order.getCancellationPolicyType() == CANCELLATION_NOT_FREE) return "用户取消-不可免费";
|
|
|
|
|
+ if (order.getCancellationPolicyType() != null && order.getCancellationPolicyType() == CANCELLATION_CONDITIONAL) return "用户取消-分情况是否免责";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (order.getPaymentStatus() != null && order.getPaymentStatus() == 2) return "取消成功,已将订单费用原路退还";
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private String buildPendingPaymentTitleSuffix(Integer cancellationPolicyType) {
|
|
private String buildPendingPaymentTitleSuffix(Integer cancellationPolicyType) {
|
|
|
if (cancellationPolicyType == null) return "不可免责取消";
|
|
if (cancellationPolicyType == null) return "不可免责取消";
|
|
|
if (cancellationPolicyType == CANCELLATION_FREE) return "免费预订";
|
|
if (cancellationPolicyType == CANCELLATION_FREE) return "免费预订";
|
|
@@ -185,7 +254,6 @@ public class ReservationOrderPageServiceImpl implements ReservationOrderPageServ
|
|
|
return "不可免责取消";
|
|
return "不可免责取消";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 预订成功页标题后缀(待使用状态) */
|
|
|
|
|
private String buildSuccessPageTitleSuffix(Integer cancellationPolicyType) {
|
|
private String buildSuccessPageTitleSuffix(Integer cancellationPolicyType) {
|
|
|
if (cancellationPolicyType == null) return "不可免责";
|
|
if (cancellationPolicyType == null) return "不可免责";
|
|
|
if (cancellationPolicyType == CANCELLATION_FREE) return "免费预订";
|
|
if (cancellationPolicyType == CANCELLATION_FREE) return "免费预订";
|