Pārlūkot izejas kodu

fix 续费 流程更改,等待发车无法续费

chenbiao 3 gadi atpakaļ
vecāks
revīzija
ad4ea38158

+ 7 - 3
netflix-service/src/main/java/com/cyksj/service/mange/group/CmsGroupServiceImpl.java

@@ -18,6 +18,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
@@ -75,6 +76,7 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
     }
 
     @Override
+    @Transactional(rollbackFor = Throwable.class)
     public void setAccount(GroupsTrips groupsTrips) {
         int count = count(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getAccountId, groupsTrips.getAccountId()));
         if (count > 0) {
@@ -83,19 +85,21 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
         List<GroupsRelation> groupsRelations = relationMapper.selectList(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsTrips.getId()).eq(GroupsRelation::getStatus, GroupsRelation.Status.validity));
        groupsRelations.forEach((relation)->{
            if (relation.getExpiryTime() == null) {
-               OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, relation.getUserId()).eq(OrderDon::getRelationId, relation.getId()).eq(OrderDon::getStatus, OrderDon.Status.hasPayment));
-               if (orderDon != null) {
+               List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, relation.getUserId()).eq(OrderDon::getRelationId, relation.getId()).eq(OrderDon::getStatus, OrderDon.Status.hasPayment));
+               orderDonList.forEach((orderDon)->{
                    //如果续费增加时间,如果首次则设置当前时间为初始时间
                    Date expiryTime = Optional.ofNullable(relation.getExpiryTime()).orElse(new Date());
+                   log.info("设置账号,该用户 {} 初始时间:{} ",orderDon.getUserId(),DateUtil.format(expiryTime,"yyyy-MM-dd HH:mm:ss"));
                    GoodsDonSku donSku = skuMapper.selectById(getById(groupsTrips.getId()).getSkuId());
 
                    Date newDate = DateUtil.offset(expiryTime, DateField.MONTH, donSku.getMonths() * orderDon.getNum());
                    relation.setExpiryTime(newDate);
+                   log.info("设置账号,该用户 {} 过期时间:{} ",orderDon.getUserId(),DateUtil.format(newDate,"yyyy-MM-dd HH:mm:ss"));
                    relation.setStartTime(relation.getStartTime() == null ? new Date() : null);
                    relationMapper.updateById(relation);
                    orderDon.setStatus(OrderDon.Status.complete);
                    orderDonMapper.updateById(orderDon);
-               }
+               });
            }
        });
        groupsTrips.setStatus(GroupsTrips.Status.validity);

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -428,6 +428,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
         if (!relation.getUserId().equals(user.getId())) {
             throw new BusinessRuntimeException("");
         }
+        GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
+
+        if (GroupsTrips.Status.waiting.equals(groupsTrips.getStatus())) {
+            throw new BusinessRuntimeException("亲,该车次还未发车,需等待客服发车才能续费哦.");
+        }
 
         GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
         if (goodsDon == null || !goodsDon.getStatus()) {