|
|
@@ -1304,9 +1304,6 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
if (renewalView.getGoodsId() != 1) {
|
|
|
throw BusinessRuntimeException.getInstance("只支持奈飞车票");
|
|
|
}
|
|
|
- if (renewalView.getDays() != null) {
|
|
|
- throw BusinessRuntimeException.getInstance("不支持奈飞天卡申请检测");
|
|
|
- }
|
|
|
String account = renewalView.getAccount();
|
|
|
String password = renewalView.getPassword();
|
|
|
|
|
|
@@ -1333,7 +1330,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
state = 3;
|
|
|
}
|
|
|
//如果账号下架了 直接失败
|
|
|
- if (StrUtil.equals(GroupsTrips.Status.down.name(), renewalView.getGroupsStatus()) && renewalView.getSkuNum() > 1) {
|
|
|
+ if (renewalView.getDays() == null && StrUtil.equals(GroupsTrips.Status.down.name(), renewalView.getGroupsStatus()) && renewalView.getSkuNum() > 1) {
|
|
|
state = 3;
|
|
|
}
|
|
|
}
|
|
|
@@ -1392,7 +1389,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
//车队是否已下架
|
|
|
GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
|
|
|
- if (groupsTrips != null && groupsTrips.getStatus() == GroupsTrips.Status.down) {
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(groupsTrips.getSkuId());
|
|
|
+ if (groupsTrips != null && sku.getDays() == null && groupsTrips.getStatus() == GroupsTrips.Status.down) {
|
|
|
state = 3;
|
|
|
//下架 异常
|
|
|
if (netflixUseAccountStatusRecord != null) {
|
|
|
@@ -1891,19 +1889,24 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
Long skuId = netflixRelationView.getSkuId();
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
BigDecimal orderMoney = orderDon == null ? BigDecimal.ZERO : orderDon.getMoney();
|
|
|
- if (orderMoney.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ BigDecimal balance = orderDon == null ? BigDecimal.ZERO : Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
+ if (orderMoney.add(balance).compareTo(BigDecimal.ZERO) == 0) {
|
|
|
refundInfoResp.setIsRefund(false);
|
|
|
}
|
|
|
//每天单价
|
|
|
- BigDecimal dayPrice = sku.getPrice().divide(BigDecimal.valueOf(sku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
+ BigDecimal dayPrice;
|
|
|
+ if (sku.getDays() != null) {
|
|
|
+ dayPrice = orderMoney.add(balance).divide(BigDecimal.valueOf(sku.getDays()), RoundingMode.DOWN);
|
|
|
+ } else {
|
|
|
+ dayPrice = sku.getPrice().divide(BigDecimal.valueOf(sku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
+ }
|
|
|
//需要退款金额
|
|
|
BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
refundInfoResp.setPrice(refundMoney);
|
|
|
- BigDecimal balance = orderDon == null ? BigDecimal.ZERO : Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
- //超过本身订单金额 不允许退款
|
|
|
- if (refundMoney.compareTo(orderMoney) > 0) {
|
|
|
- refundInfoResp.setIsRefund(false);
|
|
|
- }
|
|
|
+// //超过本身订单金额 不允许退款
|
|
|
+// if (refundMoney.compareTo(orderMoney) > 0) {
|
|
|
+// refundInfoResp.setIsRefund(false);
|
|
|
+// }
|
|
|
if (refundMoney.compareTo(orderMoney.add(balance)) > 0) {
|
|
|
refundInfoResp.setPrice(orderMoney.add(balance));
|
|
|
}
|
|
|
@@ -1936,26 +1939,52 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
Long skuId = netflixRelationView.getSkuId();
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
BigDecimal orderMoney = orderDon.getMoney();
|
|
|
- if (orderMoney.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ BigDecimal balance = orderDon == null ? BigDecimal.ZERO : Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
+ if (orderMoney.add(balance).compareTo(BigDecimal.ZERO) == 0) {
|
|
|
throw BusinessRuntimeException.getInstance("不符合退款条件");
|
|
|
}
|
|
|
//每天单价
|
|
|
- BigDecimal dayPrice = sku.getPrice().divide(BigDecimal.valueOf(sku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
+ BigDecimal dayPrice;
|
|
|
+ if (sku.getDays() != null) {
|
|
|
+ dayPrice = orderMoney.add(balance).divide(BigDecimal.valueOf(sku.getDays()), RoundingMode.DOWN);
|
|
|
+ } else {
|
|
|
+ dayPrice = sku.getPrice().divide(BigDecimal.valueOf(sku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
+ }
|
|
|
//需要退款金额
|
|
|
- BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
- if (refundMoney.compareTo(orderMoney) > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("不符合退款条件");
|
|
|
+ BigDecimal totalRefundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
+ BigDecimal refundMoney = totalRefundMoney;
|
|
|
+ BigDecimal refundBalance = BigDecimal.ZERO;
|
|
|
+ if (totalRefundMoney.compareTo(orderMoney) > 0) {
|
|
|
+ refundMoney = orderMoney;
|
|
|
+ refundBalance = totalRefundMoney.subtract(orderMoney);
|
|
|
+ }
|
|
|
+ String outNo = StrUtil.EMPTY;
|
|
|
+ if (refundMoney.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //调用第三方接口退款
|
|
|
+ OrderRefundReq refundReq = new OrderRefundReq();
|
|
|
+ refundReq.setRefundMoney(refundMoney);
|
|
|
+ refundReq.setRefundType("money");
|
|
|
+ outNo = orderRefundService.centerRefund(refundReq, orderDon);
|
|
|
+ orderDon.setRefundMoney(refundMoney);
|
|
|
}
|
|
|
- //调用第三方接口退款
|
|
|
- OrderRefundReq refundReq = new OrderRefundReq();
|
|
|
- refundReq.setRefundMoney(refundMoney);
|
|
|
- refundReq.setRefundType("money");
|
|
|
- String outNo = orderRefundService.centerRefund(refundReq, orderDon);
|
|
|
orderDon.setStatus(OrderDon.Status.refund);
|
|
|
- orderDon.setRefundMoney(refundMoney);
|
|
|
+ if (refundBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ orderDon.setRefundBalance(refundBalance);
|
|
|
+ }
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
orderDonMapper.updateById(orderDon);
|
|
|
- orderRefundService.refundRecord(orderDon, refundMoney, null, "系统", goodsDon, sku, outNo, orderDon.getType().name(), null);
|
|
|
+ if (refundBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ userBenefitsService.addUserBalance(orderDon.getUserId(), refundBalance, UserBalanceSourceRecord.Source.refund, null, orderDon.getId(), goodsDon.getTitle() + sku.getSpecVal() + UserBalanceSourceRecord.Source.refund.getDesc(), true);
|
|
|
+ }
|
|
|
+ String refundType;
|
|
|
+ if (refundMoney.compareTo(BigDecimal.ZERO) > 0 && refundBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ refundType = "bxj";
|
|
|
+ } else if (refundMoney.compareTo(BigDecimal.ZERO) == 0 && refundBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ refundType = "balance";
|
|
|
+ } else {
|
|
|
+ refundType = orderDon.getType().name();
|
|
|
+ }
|
|
|
+ orderRefundService.refundRecord(orderDon, refundMoney, refundBalance, "系统", goodsDon, sku, outNo, refundType, null);
|
|
|
//清除车票
|
|
|
GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
clearService.clearTicket(relation, UserTicketClearedRecord.Source.refund);
|