|
|
@@ -415,6 +415,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
private final SysLogMapper sysLogMapper;
|
|
|
|
|
|
+ private final GroupRelationClearService clearService;
|
|
|
+
|
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
|
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@@ -1621,12 +1623,61 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ //单个支付宝 限制最多购买2次codex
|
|
|
+ if (orderDon.getGoodsId() == Constant.CODEX_GOODS_ID) {
|
|
|
+ //通过buyeId 查询到对应的用户id 看codex对应的数量是否超过2
|
|
|
+ Integer count = orderDonMapper.selectCodexUserIdsByBuyerId(Constant.CODEX_GOODS_ID, buyerId);
|
|
|
+ if (count >= 2) {
|
|
|
+ notifyRefundCodeOrderDon(orderDon, goodsDon, sku);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//回调
|
|
|
unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
|
}
|
|
|
|
|
|
- public void setRelation(GroupsRelation relation) {
|
|
|
+ private void notifyRefundCodeOrderDon(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) throws Exception {
|
|
|
+ //退款
|
|
|
+ OrderRefundReq orderRefundReq = new OrderRefundReq();
|
|
|
+ orderRefundReq.setOrderId(orderDon.getId());
|
|
|
+ orderRefundReq.setRefundType("ALI_PAY");
|
|
|
+ orderRefundReq.setRefundMoney(orderDon.getMoney());
|
|
|
+ orderRefundReq.setRefundBalance(orderDon.getBalance());
|
|
|
+ orderDon.setRefundDesc("codex限购");
|
|
|
+ String outNo = orderRefundService.centerRefund(orderRefundReq, orderDon);
|
|
|
+
|
|
|
+ orderDon.setStatus(OrderDon.Status.refund);
|
|
|
+ orderDon.setRefundMoney(orderRefundReq.getRefundMoney());
|
|
|
+ orderDon.setRefundBalance(orderRefundReq.getRefundBalance());
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
+
|
|
|
+ String refundType = getRefundType(orderRefundReq.getRefundMoney(), orderRefundReq.getRefundBalance(), orderDon);
|
|
|
+
|
|
|
+ clearService.clearTicket(groupsRelationMapper.selectById(orderDon.getRelationId()), UserTicketClearedRecord.Source.refund);
|
|
|
+ if (orderRefundReq.getRefundBalance() != null && orderRefundReq.getRefundBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ userBenefitsService.addUserBalance(orderDon.getUserId(), orderRefundReq.getRefundBalance(), UserBalanceSourceRecord.Source.refund, null, orderDon.getId(), orderDon.getPayTitle() + UserBalanceSourceRecord.Source.refund.getDesc(), true);
|
|
|
+ }
|
|
|
+ //记录退款
|
|
|
+ orderRefundService.refundRecord(orderDon, orderRefundReq.getRefundMoney(), orderRefundReq.getRefundBalance(), null, goodsDon, sku, outNo, refundType, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRefundType(BigDecimal refundMoney, BigDecimal refundBalance, OrderDon orderDon) {
|
|
|
+ refundMoney = Optional.ofNullable(refundMoney).orElse(BigDecimal.ZERO);
|
|
|
+ refundBalance = Optional.ofNullable(refundBalance).orElse(BigDecimal.ZERO);
|
|
|
+
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ return refundType;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void setRelation(GroupsRelation relation) {
|
|
|
Long relationId = relation.getId();
|
|
|
Long userId = relation.getUserId();
|
|
|
Long groupsId = relation.getGroupsId();
|