|
|
@@ -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);
|