|
|
@@ -2686,26 +2686,30 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BigDecimal getCcRemainDeductMoney(long userId) {
|
|
|
+ public CcRefundDto getCcRemainDeductMoney(long userId) {
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
GroupsRelationView relationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
|
|
|
.field(GroupsRelationView::getGoodsId, Constant.CLAUDE_CODE_GOODS_ID)
|
|
|
.field(GroupsRelationView::getUserId, userIdList).op(Operator.InList)
|
|
|
.field(GroupsRelationView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
|
|
|
.build());
|
|
|
+ CcRefundDto refundDto = new CcRefundDto();
|
|
|
if (relationView == null) {
|
|
|
- return BigDecimal.ZERO;
|
|
|
+ refundDto.setDeductMoney(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ Long relationId = relationView.getId();
|
|
|
+ ClaudeCodeUser claudeCodeUser = claudeCodeUserMapper.selectOne(Wrappers.lambdaQuery(ClaudeCodeUser.class).eq(ClaudeCodeUser::getRelationId, relationId).last("limit 1"));
|
|
|
+ OrderDon oriOrderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getRelationId, relationId).in(OrderDon::getUserId, userIdList).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).eq(OrderDon::getOrderType, 1).orderByDesc(OrderDon::getId).last("limit 1"));
|
|
|
+ ClaudeCodeDeductDto claudeCodeDeductDto = claudeCodeService.getDeductMoney(relationId, oriOrderDon.getSkuId(), claudeCodeUser.getRenewSkuId(), claudeCodeUser.getRenewOrderId(), claudeCodeUser.getRenewExpiryTime(), relationView.getStartTime(), relationView.getExpiryTime(), DateTime.now(), userIdList, null);
|
|
|
+ refundDto.setDeductMoney(claudeCodeDeductDto.getDeductMoney());
|
|
|
+ refundDto.setRemainDays(DateUtil.betweenDay(DateTime.now(), relationView.getExpiryTime(), false)+ 1);
|
|
|
}
|
|
|
- Long relationId = relationView.getId();
|
|
|
- ClaudeCodeUser claudeCodeUser = claudeCodeUserMapper.selectOne(Wrappers.lambdaQuery(ClaudeCodeUser.class).eq(ClaudeCodeUser::getRelationId, relationId).last("limit 1"));
|
|
|
- OrderDon oriOrderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getRelationId, relationId).in(OrderDon::getUserId, userIdList).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).eq(OrderDon::getOrderType, 1).orderByDesc(OrderDon::getId).last("limit 1"));
|
|
|
- ClaudeCodeDeductDto claudeCodeDeductDto = claudeCodeService.getDeductMoney(relationId, oriOrderDon.getSkuId(), claudeCodeUser.getRenewSkuId(), claudeCodeUser.getRenewOrderId(), claudeCodeUser.getRenewExpiryTime(), relationView.getStartTime(), relationView.getExpiryTime(), DateTime.now(), userIdList, null);
|
|
|
- return claudeCodeDeductDto.getDeductMoney();
|
|
|
+ return refundDto;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void ccRefund(long userId) throws Exception {
|
|
|
- BigDecimal ccRemainDeductMoney = getCcRemainDeductMoney(userId);
|
|
|
+ BigDecimal ccRemainDeductMoney = getCcRemainDeductMoney(userId).getDeductMoney();
|
|
|
if (ccRemainDeductMoney.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
throw BusinessRuntimeException.getInstance("车票剩余价值为0,无法退款");
|
|
|
}
|
|
|
@@ -2728,7 +2732,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
@Override
|
|
|
public void ccTrans(long userId) {
|
|
|
- BigDecimal ccRemainDeductMoney = getCcRemainDeductMoney(userId);
|
|
|
+ BigDecimal ccRemainDeductMoney = getCcRemainDeductMoney(userId).getDeductMoney();
|
|
|
if (ccRemainDeductMoney.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
throw BusinessRuntimeException.getInstance("车票剩余价值为0,不可转换");
|
|
|
}
|