|
|
@@ -40,6 +40,7 @@ import com.cyksj.model.request.SpecialGoodsTicketReq;
|
|
|
import com.cyksj.model.request.TicketLoginReq;
|
|
|
import com.cyksj.model.response.NetflixErrorAccountStatus;
|
|
|
import com.cyksj.model.response.NetflixRecoverResp;
|
|
|
+import com.cyksj.model.response.NetflixRefundInfoResp;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.chatgpt.ChatGptAccountService;
|
|
|
@@ -1542,7 +1543,6 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
redisService.del(key);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
@Override
|
|
|
public List<GoodsCategorySkuView> getNetflixReplaceOtherSkus(long userId, Long relationId) throws Exception {
|
|
|
//校验奈飞账号状态
|
|
|
@@ -1573,6 +1573,48 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return goodsCategorySkuViews;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public NetflixRefundInfoResp refundNetflixInfo(Long userId, Long relationId) {
|
|
|
+ //校验奈飞账号状态
|
|
|
+ GroupsRelationView netflixRelationView = checkNetflixErrorStatus(relationId, userId);
|
|
|
+ Date expiryTime = netflixRelationView.getExpiryTime();
|
|
|
+ //小于15
|
|
|
+ Long betweenDay = DateUtil.betweenDay(DateTime.now(), expiryTime, false) + 1;
|
|
|
+ if (betweenDay > 15) {
|
|
|
+ throw BusinessRuntimeException.getInstance("车票有效期不超过15天可退款");
|
|
|
+ }
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ 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) {
|
|
|
+ throw BusinessRuntimeException.getInstance("对应车票订单不存在,请联系客服");
|
|
|
+ }
|
|
|
+ NetflixRefundInfoResp refundInfoResp = new NetflixRefundInfoResp();
|
|
|
+ refundInfoResp.setIsRefund(true);
|
|
|
+ Long skuId = netflixRelationView.getSkuId();
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
+ BigDecimal orderMoney = orderDon.getMoney();
|
|
|
+ if (orderMoney.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ refundInfoResp.setIsRefund(false);
|
|
|
+ }
|
|
|
+ //每天单价
|
|
|
+ BigDecimal dayPrice = sku.getPrice().divide(BigDecimal.valueOf(sku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
+ //需要退款金额
|
|
|
+ BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
+ if (refundMoney.compareTo(orderMoney) > 0) {
|
|
|
+ refundInfoResp.setIsRefund(false);
|
|
|
+ }
|
|
|
+ if (refundInfoResp.getIsRefund()) {
|
|
|
+ refundInfoResp.setPrice(refundMoney);
|
|
|
+ refundInfoResp.setRemainDays(betweenDay);
|
|
|
+ }
|
|
|
+ return refundInfoResp;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean refundNetflix(ErrorNetflixChangeReq req) throws Exception {
|
|
|
Long relationId = req.getRelationId();
|
|
|
@@ -1599,14 +1641,14 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
BigDecimal orderMoney = orderDon.getMoney();
|
|
|
if (orderMoney.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- return false;
|
|
|
+ throw BusinessRuntimeException.getInstance("不符合退款条件");
|
|
|
}
|
|
|
//每天单价
|
|
|
BigDecimal dayPrice = sku.getPrice().divide(BigDecimal.valueOf(sku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
//需要退款金额
|
|
|
BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
if (refundMoney.compareTo(orderMoney) > 0) {
|
|
|
- return false;
|
|
|
+ throw BusinessRuntimeException.getInstance("不符合退款条件");
|
|
|
}
|
|
|
//调用第三方接口退款
|
|
|
OrderRefundReq refundReq = new OrderRefundReq();
|