|
@@ -57,6 +57,7 @@ import com.cyksj.service.relation.GroupRelationClearService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
import com.cyksj.service.relation.GroupsRelationChangeService;
|
|
import com.cyksj.service.relation.GroupsRelationChangeService;
|
|
|
import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
|
|
|
+import com.cyksj.service.user.UserBenefitsService;
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.service.user.UserLoginRecordService;
|
|
import com.cyksj.service.user.UserLoginRecordService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
@@ -199,6 +200,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
|
|
private final GroupRelationClearService clearService;
|
|
private final GroupRelationClearService clearService;
|
|
|
|
|
|
|
|
|
|
+ private final UserBenefitsService userBenefitsService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account, String orderNo, Integer cmt) {
|
|
public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account, String orderNo, Integer cmt) {
|
|
|
User u = userMapper.selectById(userId);
|
|
User u = userMapper.selectById(userId);
|
|
@@ -1582,6 +1585,35 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
if (clearRelation != null) {
|
|
if (clearRelation != null) {
|
|
|
clearService.clearTicket(clearRelation, UserTicketClearedRecord.Source.ticket_replace);
|
|
clearService.clearTicket(clearRelation, UserTicketClearedRecord.Source.ticket_replace);
|
|
|
}
|
|
}
|
|
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .eq(OrderDon::getRelationId, relationId)
|
|
|
|
|
+ .in(OrderDon::getUserId, userIdList)
|
|
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (orderDon != null) {
|
|
|
|
|
+ BigDecimal orderMoney = orderDon == null ? BigDecimal.ZERO : orderDon.getMoney();
|
|
|
|
|
+ if (orderMoney.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ //替换sku
|
|
|
|
|
+ GoodsDonSku replaceSku = goodsDonSkuMapper.selectById(skuId);
|
|
|
|
|
+ GoodsDonSku oriTicketSku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
|
|
+ //每天单价
|
|
|
|
|
+ BigDecimal dayPrice = oriTicketSku.getPrice().divide(BigDecimal.valueOf(oriTicketSku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
|
|
+ //需要退款金额
|
|
|
|
|
+ BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
|
|
+ BigDecimal balance = Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
|
|
+ if (refundMoney.compareTo(orderMoney.add(balance)) > 0) {
|
|
|
|
|
+ refundMoney = orderMoney.add(balance);
|
|
|
|
|
+ }
|
|
|
|
|
+ //车票价格高于替换的规格价格 退余额
|
|
|
|
|
+ if (refundMoney.compareTo(replaceSku.getPrice()) > 0) {
|
|
|
|
|
+ BigDecimal refundBalance = refundMoney.subtract(replaceSku.getPrice());
|
|
|
|
|
+ if (refundBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ userBenefitsService.addUserBalance(clearRelation.getUserId(), refundBalance, UserBalanceSourceRecord.Source.TICKET_REPLACE, 0L, orderDon.getId(), UserBalanceSourceRecord.Source.TICKET_REPLACE.getDesc(), true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} finally {
|
|
} finally {
|
|
|
redisService.del(key);
|
|
redisService.del(key);
|
|
|
}
|
|
}
|