|
@@ -53,6 +53,7 @@ import com.cyksj.model.request.*;
|
|
|
import com.cyksj.model.response.AliPayRefundRep;
|
|
import com.cyksj.model.response.AliPayRefundRep;
|
|
|
import com.cyksj.model.views.CouponNewUserView;
|
|
import com.cyksj.model.views.CouponNewUserView;
|
|
|
import com.cyksj.model.views.CouponUserView;
|
|
import com.cyksj.model.views.CouponUserView;
|
|
|
|
|
+import com.cyksj.model.views.GoodsDonSkuView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.coupon.CouponFontService;
|
|
import com.cyksj.service.coupon.CouponFontService;
|
|
|
import com.cyksj.service.distribute.equipment.EquipmentDistributeService;
|
|
import com.cyksj.service.distribute.equipment.EquipmentDistributeService;
|
|
@@ -62,6 +63,7 @@ import com.cyksj.service.market.MarketFrontService;
|
|
|
import com.cyksj.service.market.task.TaskService;
|
|
import com.cyksj.service.market.task.TaskService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
import com.cyksj.service.order.UserRealOrderBenefitsService;
|
|
import com.cyksj.service.order.UserRealOrderBenefitsService;
|
|
|
|
|
+import com.cyksj.service.relation.GroupRelationClearService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
import com.cyksj.service.template.TemplateCommonService;
|
|
import com.cyksj.service.template.TemplateCommonService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
@@ -184,6 +186,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
|
|
private final TransferAccountsRecordMapper transferAccountsRecordMapper;
|
|
private final TransferAccountsRecordMapper transferAccountsRecordMapper;
|
|
|
|
|
|
|
|
|
|
+ private final GroupRelationClearService groupRelationClearService;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserRenewChangeTicketRecordMapper userRenewChangeTicketRecordMapper;
|
|
|
|
|
+
|
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@@ -488,8 +494,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (order.getIsNoLogin()) {
|
|
if (order.getIsNoLogin()) {
|
|
|
order.setStatus(OrderDon.Status.hasPayment);
|
|
order.setStatus(OrderDon.Status.hasPayment);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (!order.getIsNoLogin()) {
|
|
if (!order.getIsNoLogin()) {
|
|
|
- updateCarParkAndSendMsg(goodsDon, sku, order);
|
|
|
|
|
|
|
+ if (order.getOrderType() == 2 && order.getIsChangeTicket()) {
|
|
|
|
|
+ //将奈飞月付车票更换成其他规格的车票
|
|
|
|
|
+ changeTicketAndRecord(order.getPreSkuId(), order.getRelationId(), order.getId(), order.getNum(), sku);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ updateCarParkAndSendMsg(goodsDon, sku, order);
|
|
|
|
|
+ }
|
|
|
if (order.getMoney().compareTo(BigDecimal.ZERO) > 0 && order.getIsDistribute()) {
|
|
if (order.getMoney().compareTo(BigDecimal.ZERO) > 0 && order.getIsDistribute()) {
|
|
|
TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
|
|
TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
|
|
|
}
|
|
}
|
|
@@ -590,29 +602,33 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
public OrderDon renewal(OrderPayRequest payRequest) throws Exception {
|
|
public OrderDon renewal(OrderPayRequest payRequest) throws Exception {
|
|
|
Long userId = payRequest.getUserId();
|
|
Long userId = payRequest.getUserId();
|
|
|
User user = userMapper.selectById(userId);
|
|
User user = userMapper.selectById(userId);
|
|
|
|
|
+ Long renewSkuId = payRequest.getSkuId();
|
|
|
CouponUser couponUser = null;
|
|
CouponUser couponUser = null;
|
|
|
if (StrUtil.isNotBlank(payRequest.getCouponExCode()) || payRequest.getCouponId() != null) {
|
|
if (StrUtil.isNotBlank(payRequest.getCouponExCode()) || payRequest.getCouponId() != null) {
|
|
|
- checkCouponStatus(payRequest.getSkuId(), payRequest.getCouponExCode(), payRequest.getCouponId(), payRequest.getUserId(), true);
|
|
|
|
|
|
|
+ checkCouponStatus(renewSkuId, payRequest.getCouponExCode(), payRequest.getCouponId(), payRequest.getUserId(), true);
|
|
|
//记录优惠券使用状态
|
|
//记录优惠券使用状态
|
|
|
couponUser = couponStatusRecord(payRequest.getCouponExCode(), payRequest.getCouponId(), payRequest.getUserId());
|
|
couponUser = couponStatusRecord(payRequest.getCouponExCode(), payRequest.getCouponId(), payRequest.getUserId());
|
|
|
}
|
|
}
|
|
|
Long relationId = payRequest.getRelationId();
|
|
Long relationId = payRequest.getRelationId();
|
|
|
- if (relationId == null || relationId <= 0 || payRequest.getSkuId() == null || payRequest.getNum() == null) {
|
|
|
|
|
|
|
+ if (relationId == null || relationId <= 0 || renewSkuId == null || payRequest.getNum() == null) {
|
|
|
throw new BusinessRuntimeException("缺少必填参数");
|
|
throw new BusinessRuntimeException("缺少必填参数");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- GoodsDonSku sku = goodsDonSkuMapper.selectById(payRequest.getSkuId());
|
|
|
|
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(renewSkuId);
|
|
|
|
|
|
|
|
GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
if (relation == null) {
|
|
if (relation == null) {
|
|
|
throw new BusinessRuntimeException("");
|
|
throw new BusinessRuntimeException("");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //todo 多账号同一用户绑定 续费
|
|
|
if (!relation.getUserId().equals(user.getId())) {
|
|
if (!relation.getUserId().equals(user.getId())) {
|
|
|
throw new BusinessRuntimeException("");
|
|
throw new BusinessRuntimeException("");
|
|
|
}
|
|
}
|
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
|
|
|
-
|
|
|
|
|
|
|
+ if (groupsTrips == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该车队不存在,请联系客服");
|
|
|
|
|
+ }
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
|
|
|
|
|
if (goodsDon == null || !goodsDon.getStatus()) {
|
|
if (goodsDon == null || !goodsDon.getStatus()) {
|
|
@@ -622,12 +638,32 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (goodsDon.getType() == 2) {
|
|
if (goodsDon.getType() == 2) {
|
|
|
throw new BusinessRuntimeException("实物不支持续费");
|
|
throw new BusinessRuntimeException("实物不支持续费");
|
|
|
}
|
|
}
|
|
|
|
|
+ //用户车票规格
|
|
|
|
|
+ Long tripsSkuId = groupsTrips.getSkuId();
|
|
|
|
|
+ GoodsDonSkuView goodsDonSkuView = beanSearcher.searchFirst(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getGoodsId, goodsDon.getId())
|
|
|
|
|
+ .field(GoodsDonSkuView::getSkuId, tripsSkuId).build());
|
|
|
|
|
+ if (goodsDonSkuView == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该续费规格不属于该车队");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (GroupsTrips.Status.waiting.equals(groupsTrips.getStatus())) {
|
|
if (GroupsTrips.Status.waiting.equals(groupsTrips.getStatus())) {
|
|
|
if (!noChekGoodsTemp.contains(goodsDon.getTitle())) {
|
|
if (!noChekGoodsTemp.contains(goodsDon.getTitle())) {
|
|
|
throw new BusinessRuntimeException("亲,该车次还未发车,需等待客服发车才能续费哦.");
|
|
throw new BusinessRuntimeException("亲,该车次还未发车,需等待客服发车才能续费哦.");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //netflix 续费逻辑 月付可续费所有规格 其他规格只能续费对应规格
|
|
|
|
|
+ //netflix月付 续费其他规格 更换车队车位
|
|
|
|
|
+ Boolean isChangeTicket = false;
|
|
|
|
|
+ if (goodsDon.getType() == 1 && goodsDon.getId() == 1) {
|
|
|
|
|
+ if (groupsTrips.getSkuId() != 4 && tripsSkuId != renewSkuId) {
|
|
|
|
|
+ if (groupsTrips.getSkuId() == 5) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("季付车票只能续费季付");
|
|
|
|
|
+ } else if (groupsTrips.getSkuId() == 6) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("年付车票只能续费年付");
|
|
|
|
|
+ } else throw BusinessRuntimeException.getInstance("请选择对应规格的车票续费");
|
|
|
|
|
+ }
|
|
|
|
|
+ isChangeTicket = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
String payOpenId = user.getOpenId();
|
|
String payOpenId = user.getOpenId();
|
|
|
|
|
|
|
@@ -637,12 +673,17 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setOrderNo(donNo);
|
|
orderDon.setOrderNo(donNo);
|
|
|
orderDon.setOpenId(payOpenId);
|
|
orderDon.setOpenId(payOpenId);
|
|
|
orderDon.setMoney(sku.getPrice().multiply(BigDecimal.valueOf(payRequest.getNum())));
|
|
orderDon.setMoney(sku.getPrice().multiply(BigDecimal.valueOf(payRequest.getNum())));
|
|
|
- orderDon.setSkuId(payRequest.getSkuId());
|
|
|
|
|
|
|
+ orderDon.setSkuId(renewSkuId);
|
|
|
orderDon.setRelationId(relation.getId());
|
|
orderDon.setRelationId(relation.getId());
|
|
|
//续费订单
|
|
//续费订单
|
|
|
orderDon.setOrderType(2);
|
|
orderDon.setOrderType(2);
|
|
|
orderDon.setStatus(OrderDon.Status.noPayment);
|
|
orderDon.setStatus(OrderDon.Status.noPayment);
|
|
|
orderDon.setUserId(user.getId());
|
|
orderDon.setUserId(user.getId());
|
|
|
|
|
+ //续费后 是否需要更换车票
|
|
|
|
|
+ if (isChangeTicket) {
|
|
|
|
|
+ orderDon.setIsChangeTicket(isChangeTicket);
|
|
|
|
|
+ orderDon.setPreSkuId(tripsSkuId);
|
|
|
|
|
+ }
|
|
|
orderDon.setGoodsId(goodsDon.getId());
|
|
orderDon.setGoodsId(goodsDon.getId());
|
|
|
//虚拟商品订单,是否是分销订单
|
|
//虚拟商品订单,是否是分销订单
|
|
|
if (goodsDon.getType() == 1) {
|
|
if (goodsDon.getType() == 1) {
|
|
@@ -974,7 +1015,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
.orderByDesc(OrderDon::getId)
|
|
.orderByDesc(OrderDon::getId)
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
if (otherOrder != null) {
|
|
if (otherOrder != null) {
|
|
|
- DateTime endTime = DateUtil.offsetMonth(otherOrder.getCreatedTime(), months * num);
|
|
|
|
|
|
|
+ Long otherSkuId = otherOrder.getSkuId();
|
|
|
|
|
+ GoodsDonSku otherGoodsSku = goodsDonSkuMapper.selectById(otherSkuId);
|
|
|
|
|
+ DateTime endTime = DateUtil.offsetMonth(otherOrder.getCreatedTime(), otherGoodsSku.getMonths() * num);
|
|
|
if (now.isBefore(endTime)) {
|
|
if (now.isBefore(endTime)) {
|
|
|
isFlag = false;
|
|
isFlag = false;
|
|
|
}
|
|
}
|
|
@@ -1751,4 +1794,45 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
Optional.ofNullable(transDate).ifPresent(transferTime -> record.setTransferTime(DateTime.of(transferTime, "yyyy-MM-dd HH:mm:ss")));
|
|
Optional.ofNullable(transDate).ifPresent(transferTime -> record.setTransferTime(DateTime.of(transferTime, "yyyy-MM-dd HH:mm:ss")));
|
|
|
transferAccountsRecordMapper.insert(record);
|
|
transferAccountsRecordMapper.insert(record);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param preSkuId 续费之前的规格id
|
|
|
|
|
+ * @param preRelationId 续费之前的座位id
|
|
|
|
|
+ * @param orderId 订单id
|
|
|
|
|
+ * @param afterSku 续费之后的规格
|
|
|
|
|
+ */
|
|
|
|
|
+ private void changeTicketAndRecord(Long preSkuId, Long preRelationId, Long orderId, Integer num, GoodsDonSku afterSku) {
|
|
|
|
|
+ Long afterSkuId = afterSku.getId();
|
|
|
|
|
+ //清理之前的车票
|
|
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectById(preRelationId);
|
|
|
|
|
+ if (relation != null) {
|
|
|
|
|
+ Long userId = relation.getUserId();
|
|
|
|
|
+ groupRelationClearService.clearRenewGroupRelation(relation);
|
|
|
|
|
+ //记录更换车票记录
|
|
|
|
|
+ Date preStartTime = relation.getStartTime();
|
|
|
|
|
+ Date preExpiryTime = relation.getStartTime();
|
|
|
|
|
+ UserRenewChangeTicketRecord record = new UserRenewChangeTicketRecord();
|
|
|
|
|
+ record.setUserId(userId);
|
|
|
|
|
+ record.setPreRelationId(relation.getId());
|
|
|
|
|
+ record.setPreSkuId(preSkuId);
|
|
|
|
|
+ record.setPreStartTime(preStartTime);
|
|
|
|
|
+ record.setPreExpiryTime(preExpiryTime);
|
|
|
|
|
+ record.setRenewOrderId(orderId);
|
|
|
|
|
+
|
|
|
|
|
+ //获取续费规格的车票
|
|
|
|
|
+ GroupsRelation afterRelation = exchangeCodeService.getRelationNoOrder(afterSku, userId);
|
|
|
|
|
+
|
|
|
|
|
+ record.setAfterSkuId(afterSkuId);
|
|
|
|
|
+ record.setAfterRelationId(afterRelation.getId());
|
|
|
|
|
+ DateTime afterExpiryTime = DateUtil.offsetMonth(preExpiryTime, num * afterSku.getMonths());
|
|
|
|
|
+ record.setAfterExpiryTime(afterExpiryTime);
|
|
|
|
|
+
|
|
|
|
|
+ afterRelation.setStartTime(preStartTime);
|
|
|
|
|
+ afterRelation.setExpiryTime(afterExpiryTime);
|
|
|
|
|
+ groupsRelationMapper.updateById(afterRelation);
|
|
|
|
|
+
|
|
|
|
|
+ userRenewChangeTicketRecordMapper.insert(record);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|