|
|
@@ -23,6 +23,7 @@ import beilv.vipCardAmountLog.domain.VipCardAmountLog;
|
|
|
import beilv.vipCardAmountLog.service.IVipCardAmountLogService;
|
|
|
import beilv.vipCardLog.domain.VipCardLog;
|
|
|
import beilv.vipCardLog.service.IVipCardLogService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
@@ -41,11 +43,10 @@ import java.time.temporal.ChronoUnit;
|
|
|
import static beilv.competition.domain.Constant.ORDER_QUEUE;
|
|
|
|
|
|
@Controller
|
|
|
+@Slf4j
|
|
|
@RequestMapping("/app-api/cardApp")
|
|
|
public class CardAppController extends BaseController {
|
|
|
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(CardAppController.class);
|
|
|
-
|
|
|
@Autowired
|
|
|
private ICarInformationService carInformationService;
|
|
|
|
|
|
@@ -116,8 +117,10 @@ public class CardAppController extends BaseController {
|
|
|
if (!validateOrder(vipCardLog)) {
|
|
|
return AjaxResult.error("订单验证失败");
|
|
|
}
|
|
|
- //开启订单的定时任务, 超过设定的时间则设置为取消订单.
|
|
|
- createOrderTaskQueue(uuid, vipCardLog.getOrderType(), vipCardLog.getBusId());
|
|
|
+ if("weChart".equals(vipCardLog.getPaymentType())){
|
|
|
+ //开启订单的定时任务, 超过设定的时间则设置为取消订单.
|
|
|
+ createOrderTaskQueue(uuid, vipCardLog.getOrderType(), vipCardLog.getBusId());
|
|
|
+ }
|
|
|
//写入订单表
|
|
|
return insertVipCardLog(vipCardLog, uuid);
|
|
|
}
|
|
|
@@ -247,7 +250,7 @@ public class CardAppController extends BaseController {
|
|
|
//如果是次卡支付, 则验证次卡信息并减少次数.
|
|
|
return validateNumCardPayment(vipCardLog);
|
|
|
} else {
|
|
|
- logger.error("未知支付类型: {}", paymentType);
|
|
|
+ log.error("未知支付类型: {}", paymentType);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -285,24 +288,25 @@ public class CardAppController extends BaseController {
|
|
|
private boolean validateVipCardPayment(VipCardLog vipCardLog) {
|
|
|
VipCard vipCard = vipCardService.selectVipCardById(vipCardLog.getPaymentId());
|
|
|
if (vipCard == null) {
|
|
|
- logger.error("会员卡不存在: {}", vipCardLog.getPaymentId());
|
|
|
+ log.error("会员卡不存在: {}", vipCardLog.getPaymentId());
|
|
|
return false;
|
|
|
}
|
|
|
- vipCard.setBalance(vipCard.getBalance().subtract(vipCardLog.getPracticalMoney()).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ VipCardAmountLog vipCardAmountLog = new VipCardAmountLog(vipCardLog.getUserId(), vipCardLog.getPaymentId(), vipCardLog.getId(), vipCard.getBalance(), vipCardLog.getPracticalMoney().negate(), "1");
|
|
|
+ vipCard.setBalance(vipCardAmountLog.getRemainingAmount());
|
|
|
vipCardService.updateVipCard(vipCard);
|
|
|
//写入会员卡流水
|
|
|
- vipCardLogService.insertAmountLog(new VipCardAmountLog(vipCardLog.getUserId(), vipCardLog.getPaymentId(), vipCardLog.getId(), vipCard.getBalance(), vipCardLog.getPracticalMoney().negate()));
|
|
|
+ vipCardLogService.insertAmountLog(vipCardAmountLog);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private boolean validateNumCardPayment(VipCardLog vipCardLog) {
|
|
|
UserMembershipCard userMembershipCard = userMembershipCardService.selectUserMembershipCardById(Long.valueOf(vipCardLog.getPaymentId()));
|
|
|
if (userMembershipCard == null) {
|
|
|
- logger.error("次卡不存在: {}", vipCardLog.getPaymentId());
|
|
|
+ log.error("次卡不存在: {}", vipCardLog.getPaymentId());
|
|
|
return false;
|
|
|
}
|
|
|
if (userMembershipCard.getRemainingNumber() == 0) {
|
|
|
- logger.error("次卡次数不足: {}", vipCardLog.getPaymentId());
|
|
|
+ log.error("次卡次数不足: {}", vipCardLog.getPaymentId());
|
|
|
return false;
|
|
|
}
|
|
|
userMembershipCard.setRemainingNumber(userMembershipCard.getRemainingNumber() - 1);
|