|
|
@@ -1,10 +1,14 @@
|
|
|
package beilv.vipCardLog.service.impl;
|
|
|
|
|
|
+import beilv.admissionticket.domain.AdmissionTicket;
|
|
|
+import beilv.admissionticket.mapper.AdmissionTicketMapper;
|
|
|
+import beilv.admissionticket.service.IAdmissionTicketService;
|
|
|
import beilv.carinformation.domain.CarInformation;
|
|
|
import beilv.carinformation.service.ICarInformationService;
|
|
|
import beilv.common.core.domain.AjaxResult;
|
|
|
import beilv.common.core.text.Convert;
|
|
|
import beilv.common.utils.DateUtils;
|
|
|
+import beilv.common.utils.StringUtils;
|
|
|
import beilv.common.utils.uuid.IdUtils;
|
|
|
import beilv.competition.domain.Competition;
|
|
|
import beilv.competition.service.ICompetitionService;
|
|
|
@@ -46,6 +50,9 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
@Autowired
|
|
|
private ICarInformationService carInformationService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AdmissionTicketMapper ticketMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询充值记录
|
|
|
*
|
|
|
@@ -115,9 +122,71 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
|
|
|
@Override
|
|
|
public int updateVipCardLogByOrderId(VipCardLog vipCardLog) {
|
|
|
+ if (StringUtils.isEmpty(vipCardLog.getId())) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ VipCardLog cardLog = vipCardLogMapper.selectVipCardLogById(vipCardLog.getId());
|
|
|
+ if ("chongzhi".equals(cardLog.getOrderType())) {
|
|
|
+ charging(vipCardLog);
|
|
|
+ } else {
|
|
|
+ other(vipCardLog);
|
|
|
+ }
|
|
|
return vipCardLogMapper.updateVipCardLog(vipCardLog);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 充值回调
|
|
|
+ *
|
|
|
+ * @param vipCardLog
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void charging(VipCardLog vipCardLog) {
|
|
|
+ if ("payment_status_have_paid".equals(vipCardLog.getPaymentStatus())) {
|
|
|
+ //拉取订单信息
|
|
|
+ VipCardLog orderInfo = vipCardLogMapper.selectVipCardLogById(vipCardLog.getId());
|
|
|
+ //获取会员卡信息
|
|
|
+ VipCard vipCard = vipCardService.selectVipCardByUserId(orderInfo.getUserId());
|
|
|
+ if (null == vipCard) {
|
|
|
+ //true 没有会员卡; 新增会员卡, 并且设置本次充值金额
|
|
|
+ vipCardService.insertVipCard(new VipCard(Long.parseLong(orderInfo.getUserId()), orderInfo.getPracticalMoney()));
|
|
|
+ } else {
|
|
|
+ //false 有会员卡,
|
|
|
+ vipCardService.updateVipCard(new VipCard(Long.parseLong(orderInfo.getUserId()), orderInfo.getPracticalMoney().add(vipCard.getBalance()).setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ }
|
|
|
+ vipCardLog.setPaymentTime(DateUtils.getNowDate());
|
|
|
+ } else if ("payment_status_cancelled".equals(vipCardLog.getPaymentStatus())) {
|
|
|
+ vipCardLog.setCancellationTime(DateUtils.getNowDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其他支付回调
|
|
|
+ *
|
|
|
+ * @param vipCardLog
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void other(VipCardLog vipCardLog) {
|
|
|
+ //拉取订单信息
|
|
|
+ VipCardLog orderInfo = vipCardLogMapper.selectVipCardLogById(vipCardLog.getId());
|
|
|
+ if ("payment_status_have_paid".equals(vipCardLog.getPaymentStatus())) {
|
|
|
+ vipCardLog.setPaymentTime(DateUtils.getNowDate());
|
|
|
+ String orderType = orderInfo.getOrderType();
|
|
|
+ if ("gouka".equals(orderType)) {
|
|
|
+ CarInformation carInformation = carInformationService.selectCarInformationById(Long.valueOf(orderInfo.getBusId()));
|
|
|
+ //购卡订单, 支付成功, 生成卡片写入到次卡表
|
|
|
+ userMembershipCardService.insertUserMembershipCard(new UserMembershipCard(orderInfo.getUserId(), vipCardLog.getId(), carInformation.getTotalNumber(), "0", "3", DateUtils.getNowDate()));
|
|
|
+ }
|
|
|
+ } else if ("payment_status_cancelled".equals(vipCardLog.getPaymentStatus())) {
|
|
|
+ vipCardLog.setCancellationTime(DateUtils.getNowDate());
|
|
|
+ if ("yueqiu".equals(orderInfo.getOrderType())) {
|
|
|
+ AdmissionTicket admissionTicket = new AdmissionTicket();
|
|
|
+ admissionTicket.setId(orderInfo.getBusId());
|
|
|
+ admissionTicket.setAdmissionTicketStatus("0");
|
|
|
+ ticketMapper.updateBeilvAdmissionTicket(admissionTicket);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int getRegistrantsNumber(VipCardLog vipCardLog) {
|
|
|
return vipCardLogMapper.getRegistrantsNumber(vipCardLog);
|
|
|
@@ -128,19 +197,19 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
//拉去订单信息
|
|
|
VipCardLog orderInfo = vipCardLogMapper.selectVipCardLogById(vipCardLog.getId());
|
|
|
|
|
|
- if("payment_status_to_be_paid".equals(orderInfo.getPaymentStatus())){
|
|
|
+ if ("payment_status_to_be_paid".equals(orderInfo.getPaymentStatus())) {
|
|
|
return AjaxResult.error("订单未支付, 无需退款!");
|
|
|
}
|
|
|
|
|
|
- if("payment_status_cancelled".equals(orderInfo.getPaymentStatus())){
|
|
|
+ if ("payment_status_cancelled".equals(orderInfo.getPaymentStatus())) {
|
|
|
return AjaxResult.error("订单已取消, 无需退款!");
|
|
|
}
|
|
|
|
|
|
- if("payment_status_refunded".equals(orderInfo.getPaymentStatus())){
|
|
|
+ if ("payment_status_refunded".equals(orderInfo.getPaymentStatus())) {
|
|
|
return AjaxResult.error("订单已退款, 无需重复操作!");
|
|
|
}
|
|
|
|
|
|
- if("payment_status_verification".equals(orderInfo.getPaymentStatus())){
|
|
|
+ if ("payment_status_verification".equals(orderInfo.getPaymentStatus())) {
|
|
|
return AjaxResult.error("订单已核销, 无法退款!");
|
|
|
}
|
|
|
|
|
|
@@ -149,15 +218,15 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
|
|
|
int refundSum = 0;
|
|
|
|
|
|
- if("yueqiu".equals(orderInfo.getOrderType())){
|
|
|
+ if ("yueqiu".equals(orderInfo.getOrderType())) {
|
|
|
|
|
|
- if("numCard".equals(orderInfo.getPaymentType())){
|
|
|
+ if ("numCard".equals(orderInfo.getPaymentType())) {
|
|
|
refundSum++;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
refundPrice = refundPrice.add(orderInfo.getPracticalMoney());
|
|
|
}
|
|
|
|
|
|
- }else if("gouka".equals(orderInfo.getOrderType())){
|
|
|
+ } else if ("gouka".equals(orderInfo.getOrderType())) {
|
|
|
|
|
|
//拿到次卡信息, 得到剩余使用次数
|
|
|
UserMembershipCard userMembershipCard = userMembershipCardService.selectUserMembershipCardRecordId(orderInfo.getId());
|
|
|
@@ -165,7 +234,7 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
CarInformation carInformation = carInformationService.selectCarInformationById(Long.valueOf(orderInfo.getBusId()));
|
|
|
|
|
|
//计算已使用次数
|
|
|
- BigDecimal useSum = BigDecimal.valueOf(carInformation.getTotalNumber()-userMembershipCard.getRemainingNumber());
|
|
|
+ BigDecimal useSum = BigDecimal.valueOf(carInformation.getTotalNumber() - userMembershipCard.getRemainingNumber());
|
|
|
|
|
|
//计算需要支付的金额
|
|
|
BigDecimal userPrice = useSum.multiply(carInformation.getOriginalPrice());
|
|
|
@@ -179,36 +248,36 @@ public class VipCardLogServiceImpl implements IVipCardLogService {
|
|
|
//计算退款金额
|
|
|
refundPrice = refundPrice.add(refundMoner);
|
|
|
|
|
|
- }else if("cansai".equals(orderInfo.getOrderType()) || "menpiao".equals(orderInfo.getOrderType())){
|
|
|
+ } else if ("cansai".equals(orderInfo.getOrderType()) || "menpiao".equals(orderInfo.getOrderType())) {
|
|
|
|
|
|
//验证赛事状态, 已经开始/已经结束/已经关闭 无法退款
|
|
|
Competition competition = competitionService.selectCompetitionById(Integer.valueOf(orderInfo.getBusId()));
|
|
|
- if("competiton_state_5".equals(competition.getCompetitionState())){
|
|
|
+ if ("competiton_state_5".equals(competition.getCompetitionState())) {
|
|
|
return AjaxResult.error("赛事已开始, 无法退票!");
|
|
|
}
|
|
|
- if("competiton_state_6".equals(competition.getCompetitionState())){
|
|
|
+ if ("competiton_state_6".equals(competition.getCompetitionState())) {
|
|
|
return AjaxResult.error("赛事已结束, 无法退票!");
|
|
|
}
|
|
|
- if("competiton_state_3".equals(competition.getCompetitionState())){
|
|
|
+ if ("competiton_state_3".equals(competition.getCompetitionState())) {
|
|
|
return AjaxResult.error("报名已结束, 无法退票!");
|
|
|
}
|
|
|
- if("competiton_state_4".equals(competition.getCompetitionState())){
|
|
|
+ if ("competiton_state_4".equals(competition.getCompetitionState())) {
|
|
|
return AjaxResult.error("赛事已关闭, 无法退票!");
|
|
|
}
|
|
|
//计算退款金额
|
|
|
refundPrice = refundPrice.add(orderInfo.getPracticalMoney());
|
|
|
}
|
|
|
|
|
|
- if("vipCard".equals(orderInfo.getPaymentType())){
|
|
|
+ if ("vipCard".equals(orderInfo.getPaymentType())) {
|
|
|
//查询会员卡信息
|
|
|
VipCard vipCard = vipCardService.selectVipCardById(orderInfo.getPaymentId());
|
|
|
vipCard.setBalance(vipCard.getBalance().add(refundPrice));
|
|
|
vipCardService.updateVipCard(vipCard);
|
|
|
- }else if("weChart".equals(orderInfo.getPaymentType())){
|
|
|
+ } else if ("weChart".equals(orderInfo.getPaymentType())) {
|
|
|
//微信支付, 退款到微信
|
|
|
|
|
|
|
|
|
- }else if("numCard".equals(orderInfo.getPaymentType())){
|
|
|
+ } else if ("numCard".equals(orderInfo.getPaymentType())) {
|
|
|
//查询次卡信息
|
|
|
UserMembershipCard userMembershipCard = userMembershipCardService.selectUserMembershipCardById(Long.valueOf(orderInfo.getPaymentId()));
|
|
|
//剩余使用次数+1
|