|
|
@@ -24,17 +24,21 @@ import beilv.vipCardLog.mapper.VipCardLogMapper;
|
|
|
import beilv.vipCardLog.service.IVipCardLogService;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import static beilv.competition.domain.Constant.ORDER_QUEUE;
|
|
|
+
|
|
|
/**
|
|
|
* 充值记录Service业务层处理
|
|
|
*
|
|
|
@@ -67,6 +71,9 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
@Resource
|
|
|
private VipCardAmountLogMapper amountLogMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StringRedisTemplate stringRedisTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* 查询充值记录
|
|
|
*
|
|
|
@@ -170,12 +177,12 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
String vipCardId;
|
|
|
if (null == vipCard) {
|
|
|
//true 没有会员卡; 新增会员卡, 并且设置本次充值金额
|
|
|
- vipCardId = vipCardService.insertVipCard(new VipCard(Long.parseLong(orderInfo.getUserId()), orderInfo.getPracticalMoney()));
|
|
|
+ vipCardId = vipCardService.insertVipCard(new VipCard(Long.parseLong(orderInfo.getUserId()), orderInfo.getPracticalMoney(), BigDecimal.ZERO));
|
|
|
} else {
|
|
|
balance = vipCard.getBalance();
|
|
|
vipCardId = vipCard.getId();
|
|
|
//false 有会员卡,
|
|
|
- vipCardService.updateVipCard(new VipCard(Long.parseLong(orderInfo.getUserId()), orderInfo.getPracticalMoney().add(vipCard.getBalance()).setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ vipCardService.updateVipCard(new VipCard(Long.parseLong(orderInfo.getUserId()), orderInfo.getPracticalMoney().add(vipCard.getBalance()).setScale(2, RoundingMode.HALF_UP), vipCard.getScore()));
|
|
|
}
|
|
|
//设定支付时间
|
|
|
vipCardLog.setPaymentTime(DateUtils.getNowDate());
|
|
|
@@ -183,7 +190,7 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
insertAmountLog(new VipCardAmountLog(orderInfo.getUserId(), vipCardId, orderInfo.getId(), balance, orderInfo.getPracticalMoney(),"1"));
|
|
|
|
|
|
//支付成功移除定时任务
|
|
|
-
|
|
|
+ stringRedisTemplate.delete(ORDER_QUEUE+orderInfo.getId());
|
|
|
} else if ("payment_status_cancelled".equals(vipCardLog.getPaymentStatus())) {
|
|
|
//如果是取消, 设置支付状态为取消支付
|
|
|
vipCardLog.setCancellationTime(DateUtils.getNowDate());
|
|
|
@@ -271,29 +278,33 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
|
|
|
if ("yueqiu".equals(orderInfo.getOrderType())) {
|
|
|
|
|
|
- if(isOnline){
|
|
|
- //获取设定的取消时间范围(分钟)
|
|
|
+ if (isOnline) {
|
|
|
+ // 获取设定的取消时间范围(分钟)
|
|
|
long cancelMinutes = Long.parseLong(configService.selectConfigByKey("cancel.minutes"));
|
|
|
- //根据订单获取约场的开始时间
|
|
|
+ // 根据订单获取约场的开始时间
|
|
|
AdmissionTicket admissionTicket = ticketService.selectBeilvAdmissionTicketById(orderInfo.getBusId());
|
|
|
+ String format = new SimpleDateFormat("yyyy-MM-dd").format(admissionTicket.getTicketDate());
|
|
|
String startTime = admissionTicket.getSession().split("-")[0]; // 10:00
|
|
|
|
|
|
// 当前时间
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
+ // 定义日期时间格式器
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+
|
|
|
// 将 startTime 转换为 LocalDateTime
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
- LocalDateTime startDateTime = LocalDateTime.of(now.toLocalDate(), LocalDateTime.parse(startTime, formatter).toLocalTime());
|
|
|
+ LocalDateTime startDateTime = LocalDateTime.parse(format + " " + startTime, formatter);
|
|
|
|
|
|
// 计算 startTime 减去 cancelMinutes 后的时间
|
|
|
LocalDateTime cancelTime = startDateTime.minus(cancelMinutes, ChronoUnit.MINUTES);
|
|
|
|
|
|
- //判断当前时间是否可以退款
|
|
|
- if(now.isBefore(cancelTime)){
|
|
|
- return AjaxResult.error("距离开场仅剩"+cancelMinutes+"分钟, 不允许线上退款!如需退款请线下联系工作人员!");
|
|
|
+ // 判断当前时间是否可以退款
|
|
|
+ if (cancelTime.isBefore(now)) {
|
|
|
+ return AjaxResult.error("距离开场不足" + cancelMinutes + "分钟, 不允许线上退款!如需退款请线下联系工作人员!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if ("numCard".equals(orderInfo.getPaymentType())) {
|
|
|
refundSum++;
|
|
|
} else {
|
|
|
@@ -347,10 +358,11 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
if("vipCard".equals(orderInfo.getPaymentType())){
|
|
|
//查询会员卡信息
|
|
|
VipCard vipCard = vipCardService.selectVipCardById(orderInfo.getPaymentId());
|
|
|
- vipCard.setBalance(vipCard.getBalance().add(refundPrice));
|
|
|
- vipCardService.updateVipCard(vipCard);
|
|
|
//写入会员卡流水
|
|
|
- amountLogMapper.insertVipCardAmountLog(new VipCardAmountLog(orderInfo.getUserId(), orderInfo.getPaymentId(), orderInfo.getId(), vipCard.getBalance(), refundPrice,"1"));
|
|
|
+ VipCardAmountLog vipCardAmountLog = new VipCardAmountLog(orderInfo.getUserId(), orderInfo.getPaymentId(), orderInfo.getId(), vipCard.getBalance(), refundPrice, "1");
|
|
|
+ amountLogMapper.insertVipCardAmountLog(vipCardAmountLog);
|
|
|
+ vipCard.setBalance(vipCardAmountLog.getRemainingAmount());
|
|
|
+ vipCardService.updateVipCard(vipCard);
|
|
|
|
|
|
} else if ("weChart".equals(orderInfo.getPaymentType())) {
|
|
|
orderInfo.setRefundPrice(refundPrice);
|