diff --git a/src/main/java/com/ai/da/service/impl/CollectionSortServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionSortServiceImpl.java index 727cbb72..52964140 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionSortServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionSortServiceImpl.java @@ -269,13 +269,17 @@ public class CollectionSortServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper() + .eq(CollectionSort::getProjectId, projectId) + .orderByAsc(CollectionSort::getSort); + + if (parentId != null) { + wrapper.eq(CollectionSort::getParentId, parentId); + } else { + wrapper.isNull(CollectionSort::getParentId); + } // 2. 查询同组数据,按原排序升序 - List list = baseMapper.selectList( - new LambdaQueryWrapper() - .eq(CollectionSort::getProjectId, projectId) - .eq(CollectionSort::getParentId, parentId) - .orderByAsc(CollectionSort::getSort) - ); + List list = baseMapper.selectList(wrapper); // 3. 重新编号 sort,从 1 开始 for (int i = 0; i < list.size(); i++) { diff --git a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java index 9442d076..b39843ce 100644 --- a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java @@ -27,6 +27,7 @@ import io.netty.util.internal.StringUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; @@ -224,6 +225,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl qwSI = new QueryWrapper<>(); if (!StringUtil.isNullOrEmpty(subscriptionId)) { - qwSI.eq("subscription_id", subscriptionId); + // 区分当前订阅的时段,从而确定是新订单还是续订订单的记录 + qwSI.lambda().eq(SubscriptionInfo::getSubscriptionId, subscriptionId) + .lt(SubscriptionInfo::getCurrentPeriodStart, secondsTimestamp) + .gt(SubscriptionInfo::getCurrentPeriodEnd, secondsTimestamp); List subscriptionInfoList = subscriptionInfoMapper.selectList(qwSI); if (subscriptionInfoList.isEmpty()){ @@ -1024,7 +1035,9 @@ public class StripeServiceImpl implements StripeService { } } }else if (!StringUtil.isNullOrEmpty(orderNo)) { - qwSI.eq("order_no", orderNo); + qwSI.lambda().eq(SubscriptionInfo::getOrderNo, orderNo) + .gt(SubscriptionInfo::getCurrentPeriodStart, secondsTimestamp) + .lt(SubscriptionInfo::getCurrentPeriodEnd, secondsTimestamp); subscriptionInfo = subscriptionInfoMapper.selectOne(qwSI); if (Objects.isNull(subscriptionInfo)){ log.info("不发送邮件,原因:【根据order_no:{},查询到的subscriptionInfo为空】", orderNo); @@ -1036,7 +1049,12 @@ public class StripeServiceImpl implements StripeService { } QueryWrapper qwPI = new QueryWrapper<>(); - qwPI.eq("order_no", subscriptionInfo.getOrderNo()).orderByDesc("id"); + String periodStart = DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodStart(), "seconds", CommonConstant.TIME_FORMAT_yyyy_MM_dd_HH_mm_ss); + String periodEnd = DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_yyyy_MM_dd_HH_mm_ss); + + qwPI.lambda().eq(PaymentInfo::getOrderNo, subscriptionInfo.getOrderNo()) + .between(PaymentInfo::getCreateTime, periodStart, periodEnd) + .orderByDesc(PaymentInfo::getId); List paymentInfos = paymentInfoMapper.selectList(qwPI); if (paymentInfos.isEmpty()) { log.info("不发送邮件,原因:【根据order_no:{},查询到的paymentInfos为空】", orderNo);