Merge branch 'test6.9.1' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.1
Showing
7 changed files
with
115 additions
and
37 deletions
@@ -17,14 +17,21 @@ public interface InviteSettlementItemMapper { | @@ -17,14 +17,21 @@ public interface InviteSettlementItemMapper { | ||
17 | @Param("tagStatus") Integer tagStatus, | 17 | @Param("tagStatus") Integer tagStatus, |
18 | @Param("inviteSettlementId") Integer inviteSettlementId); | 18 | @Param("inviteSettlementId") Integer inviteSettlementId); |
19 | 19 | ||
20 | + int updateToSettledRollback(@Param("uid") Integer uid, | ||
21 | + @Param("type") Integer type, | ||
22 | + @Param("srcStatus") Integer srcStatus, | ||
23 | + @Param("tagStatus") Integer tagStatus, | ||
24 | + @Param("inviteSettlementId") Integer inviteSettlementId, | ||
25 | + @Param("ids") List<Integer> ids); | ||
26 | + | ||
20 | int updateStatusByUidAndInviteSettlementId(@Param("uid") Integer uid, @Param("inviteSettlementId") Integer inviteSettlementId, | 27 | int updateStatusByUidAndInviteSettlementId(@Param("uid") Integer uid, @Param("inviteSettlementId") Integer inviteSettlementId, |
21 | @Param("status") Integer status); | 28 | @Param("status") Integer status); |
22 | 29 | ||
23 | InviteSettlementItem selectByUidAndBuyerOrderCode(@Param("uid") Integer uid, @Param("buyerOrderCode") Long buyerOrderCode); | 30 | InviteSettlementItem selectByUidAndBuyerOrderCode(@Param("uid") Integer uid, @Param("buyerOrderCode") Long buyerOrderCode); |
24 | 31 | ||
25 | InviteSettlementItem selectOneByUidTypeAndStatus(@Param("uid") Integer uid, | 32 | InviteSettlementItem selectOneByUidTypeAndStatus(@Param("uid") Integer uid, |
26 | - @Param("type") Integer type, | ||
27 | - @Param("status") Integer status); | 33 | + @Param("type") Integer type, |
34 | + @Param("status") Integer status); | ||
28 | 35 | ||
29 | int selectCountByUidTypeAndInviteSettlementId(@Param("uid") Integer uid, | 36 | int selectCountByUidTypeAndInviteSettlementId(@Param("uid") Integer uid, |
30 | @Param("type") Integer type, | 37 | @Param("type") Integer type, |
@@ -42,9 +49,9 @@ public interface InviteSettlementItemMapper { | @@ -42,9 +49,9 @@ public interface InviteSettlementItemMapper { | ||
42 | @Param("sellerUid") Integer sellerUid); | 49 | @Param("sellerUid") Integer sellerUid); |
43 | 50 | ||
44 | 51 | ||
45 | - | ||
46 | /** | 52 | /** |
47 | * 查询type1 结算方式的待结算、已结算和已付款订单数 | 53 | * 查询type1 结算方式的待结算、已结算和已付款订单数 |
54 | + * | ||
48 | * @param inviterUid | 55 | * @param inviterUid |
49 | * @return | 56 | * @return |
50 | */ | 57 | */ |
@@ -52,6 +59,7 @@ public interface InviteSettlementItemMapper { | @@ -52,6 +59,7 @@ public interface InviteSettlementItemMapper { | ||
52 | 59 | ||
53 | /** | 60 | /** |
54 | * 根据条件查询,待结算、已结算和已付款的统计数据 | 61 | * 根据条件查询,待结算、已结算和已付款的统计数据 |
62 | + * | ||
55 | * @param uid | 63 | * @param uid |
56 | * @param type | 64 | * @param type |
57 | * @param startTime | 65 | * @param startTime |
@@ -66,6 +74,7 @@ public interface InviteSettlementItemMapper { | @@ -66,6 +74,7 @@ public interface InviteSettlementItemMapper { | ||
66 | 74 | ||
67 | /** | 75 | /** |
68 | * 根据条件查询,待结算、已结算和已付款的数据 | 76 | * 根据条件查询,待结算、已结算和已付款的数据 |
77 | + * | ||
69 | * @param uid | 78 | * @param uid |
70 | * @param type | 79 | * @param type |
71 | * @param startTime | 80 | * @param startTime |
@@ -59,6 +59,19 @@ | @@ -59,6 +59,19 @@ | ||
59 | and status = #{srcStatus,jdbcType=INTEGER} | 59 | and status = #{srcStatus,jdbcType=INTEGER} |
60 | </update> | 60 | </update> |
61 | 61 | ||
62 | + <update id="updateToSettledRollback"> | ||
63 | + update invite_settlement_item | ||
64 | + set status = #{tagStatus,jdbcType=INTEGER}, | ||
65 | + invite_settlement_id = #{inviteSettlementId,jdbcType=INTEGER} | ||
66 | + where uid = #{uid,jdbcType=INTEGER} | ||
67 | + and type = #{type,jdbcType=INTEGER} | ||
68 | + and status = #{srcStatus,jdbcType=INTEGER} | ||
69 | + and id in | ||
70 | + <foreach collection="ids" item="id" open="(" separator="," close=")"> | ||
71 | + #{id} | ||
72 | + </foreach> | ||
73 | + </update> | ||
74 | + | ||
62 | <update id="updateStatusByUidAndInviteSettlementId"> | 75 | <update id="updateStatusByUidAndInviteSettlementId"> |
63 | update invite_settlement_item | 76 | update invite_settlement_item |
64 | set status = #{status,jdbcType=INTEGER} | 77 | set status = #{status,jdbcType=INTEGER} |
@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
11 | import org.springframework.web.bind.annotation.RequestParam; | 11 | import org.springframework.web.bind.annotation.RequestParam; |
12 | import org.springframework.web.bind.annotation.RestController; | 12 | import org.springframework.web.bind.annotation.RestController; |
13 | 13 | ||
14 | +import java.time.LocalDateTime; | ||
15 | +import java.time.format.DateTimeFormatter; | ||
14 | import java.util.List; | 16 | import java.util.List; |
15 | import java.util.Objects; | 17 | import java.util.Objects; |
16 | 18 | ||
@@ -56,12 +58,8 @@ public class InviteSettlementController { | @@ -56,12 +58,8 @@ public class InviteSettlementController { | ||
56 | } | 58 | } |
57 | 59 | ||
58 | @RequestMapping(value = "/erp/invite/settlement/help/settle") | 60 | @RequestMapping(value = "/erp/invite/settlement/help/settle") |
59 | - public ApiResponse settle(@RequestParam(value = "uid", required = false) Integer uid) { | ||
60 | - if (Objects.nonNull(uid)) { | ||
61 | - inviteSettlementService.settle(uid); | ||
62 | - } else { | ||
63 | - inviteSettlementService.settle(); | ||
64 | - } | 61 | + public ApiResponse settle(@RequestParam(value = "settle_time", required = false) String settleTime) { |
62 | + inviteSettlementService.settle(Objects.nonNull(settleTime) ? LocalDateTime.parse(settleTime, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) : LocalDateTime.now()); | ||
65 | return new ApiResponse.ApiResponseBuilder().code(200).message("ok").build(); | 63 | return new ApiResponse.ApiResponseBuilder().code(200).message("ok").build(); |
66 | } | 64 | } |
67 | 65 |
@@ -3,6 +3,7 @@ package com.yohoufo.order.service; | @@ -3,6 +3,7 @@ package com.yohoufo.order.service; | ||
3 | import com.yohoufo.order.model.InviteSettlementItemListVO; | 3 | import com.yohoufo.order.model.InviteSettlementItemListVO; |
4 | import com.yohoufo.order.model.InviteSettlementListVO; | 4 | import com.yohoufo.order.model.InviteSettlementListVO; |
5 | 5 | ||
6 | +import java.time.LocalDateTime; | ||
6 | import java.util.List; | 7 | import java.util.List; |
7 | 8 | ||
8 | public interface IInviteSettlementService { | 9 | public interface IInviteSettlementService { |
@@ -20,7 +21,7 @@ public interface IInviteSettlementService { | @@ -20,7 +21,7 @@ public interface IInviteSettlementService { | ||
20 | /** | 21 | /** |
21 | * 结算 | 22 | * 结算 |
22 | */ | 23 | */ |
23 | - void settle(); | 24 | + void settle(LocalDateTime settleTime); |
24 | 25 | ||
25 | /** | 26 | /** |
26 | * 结算 | 27 | * 结算 |
@@ -193,9 +193,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService { | @@ -193,9 +193,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService { | ||
193 | } | 193 | } |
194 | 194 | ||
195 | @Override | 195 | @Override |
196 | - public void settle() { | 196 | + public void settle(LocalDateTime settleTime) { |
197 | inviterMapper.selectAll().stream() | 197 | inviterMapper.selectAll().stream() |
198 | - .forEach(inviterSettleService::settle); | 198 | + .forEach(inviter -> inviterSettleService.settle(inviter, settleTime)); |
199 | } | 199 | } |
200 | 200 | ||
201 | @Override | 201 | @Override |
@@ -20,10 +20,13 @@ import com.yohoufo.order.common.InviterType; | @@ -20,10 +20,13 @@ import com.yohoufo.order.common.InviterType; | ||
20 | import com.yohoufo.order.utils.IdUtils; | 20 | import com.yohoufo.order.utils.IdUtils; |
21 | import com.yohoufo.order.utils.InviteSettlementUtils; | 21 | import com.yohoufo.order.utils.InviteSettlementUtils; |
22 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
23 | +import org.apache.commons.collections.CollectionUtils; | ||
24 | +import org.apache.commons.lang3.tuple.Pair; | ||
23 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
24 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
25 | 27 | ||
26 | import java.math.BigDecimal; | 28 | import java.math.BigDecimal; |
29 | +import java.time.LocalDateTime; | ||
27 | import java.util.List; | 30 | import java.util.List; |
28 | import java.util.Map; | 31 | import java.util.Map; |
29 | import java.util.Objects; | 32 | import java.util.Objects; |
@@ -58,10 +61,10 @@ public class InviterSettleService { | @@ -58,10 +61,10 @@ public class InviterSettleService { | ||
58 | 61 | ||
59 | public void settle(Integer uid) { | 62 | public void settle(Integer uid) { |
60 | inviterMapper.selectInviteCodeByUid(uid) | 63 | inviterMapper.selectInviteCodeByUid(uid) |
61 | - .forEach(this::settle); | 64 | + .forEach(inviter -> this.settle(inviter, LocalDateTime.now())); |
62 | } | 65 | } |
63 | 66 | ||
64 | - public void settle(Inviter inviter) { | 67 | + public void settle(Inviter inviter, LocalDateTime settleTime) { |
65 | log.info("settle for {}", inviter); | 68 | log.info("settle for {}", inviter); |
66 | int uid = inviter.getUid(); | 69 | int uid = inviter.getUid(); |
67 | int now = DateUtil.getCurrentTimeSecond(); | 70 | int now = DateUtil.getCurrentTimeSecond(); |
@@ -100,7 +103,7 @@ public class InviterSettleService { | @@ -100,7 +103,7 @@ public class InviterSettleService { | ||
100 | .withStopStrategy(StopStrategies.stopAfterAttempt(3)) | 103 | .withStopStrategy(StopStrategies.stopAfterAttempt(3)) |
101 | .withWaitStrategy(WaitStrategies.fixedWait(50, TimeUnit.MILLISECONDS)) | 104 | .withWaitStrategy(WaitStrategies.fixedWait(50, TimeUnit.MILLISECONDS)) |
102 | .build().call(() -> { | 105 | .build().call(() -> { |
103 | - updateSettleAmount(uid, settleType, settlement); | 106 | + updateSettleAmount(uid, settleTime, settleType, settlement); |
104 | return null; | 107 | return null; |
105 | }); | 108 | }); |
106 | } catch (ExecutionException | RetryException e) { | 109 | } catch (ExecutionException | RetryException e) { |
@@ -109,7 +112,7 @@ public class InviterSettleService { | @@ -109,7 +112,7 @@ public class InviterSettleService { | ||
109 | log.info("settle for {} end settle amount for settlement {} is {}.", uid, settlement.getId(), settlement.getSettleAmount()); | 112 | log.info("settle for {} end settle amount for settlement {} is {}.", uid, settlement.getId(), settlement.getSettleAmount()); |
110 | } | 113 | } |
111 | 114 | ||
112 | - private void updateSettleAmount(int uid, int settleType, InviteSettlement settlement) { | 115 | + private void updateSettleAmount(int uid, LocalDateTime settleTime, int settleType, InviteSettlement settlement) { |
113 | int settlementId = settlement.getId(); | 116 | int settlementId = settlement.getId(); |
114 | log.info("settle for {} calculate settle amount for settlement {}.", uid, settlementId); | 117 | log.info("settle for {} calculate settle amount for settlement {}.", uid, settlementId); |
115 | BigDecimal settleAmount; | 118 | BigDecimal settleAmount; |
@@ -120,14 +123,14 @@ public class InviterSettleService { | @@ -120,14 +123,14 @@ public class InviterSettleService { | ||
120 | uid, settlementId, settleAmount); | 123 | uid, settlementId, settleAmount); |
121 | } else { | 124 | } else { |
122 | // type2方式结算金额 | 125 | // type2方式结算金额 |
123 | - settleAmount = calculateSettleAmountOfType2(uid, settlementId); | 126 | + settleAmount = calculateSettleAmountOfType2(uid, settleTime, settlementId); |
124 | log.info("settle for {} calculate settle amount for settlement {}, the amount of type2 is {}.", | 127 | log.info("settle for {} calculate settle amount for settlement {}, the amount of type2 is {}.", |
125 | uid, settlementId, settleAmount); | 128 | uid, settlementId, settleAmount); |
126 | } | 129 | } |
127 | // 更新结算金额 | 130 | // 更新结算金额 |
128 | settlement.setSettleCode(IdUtils.derangement(settlementId)); | 131 | settlement.setSettleCode(IdUtils.derangement(settlementId)); |
129 | settlement.setSettleAmount(settleAmount); | 132 | settlement.setSettleAmount(settleAmount); |
130 | - settlement.setSettleTime(DateUtil.getCurrentTimeSecond()); | 133 | + settlement.setSettleTime((int) settleTime.toEpochSecond(InviteSettlementUtils.zoneOffset())); |
131 | settlement.setStatus(InviteSettlement.STATUS_WAIT_PAY); | 134 | settlement.setStatus(InviteSettlement.STATUS_WAIT_PAY); |
132 | inviteSettlementMapper.updateByUidAndId(settlement); | 135 | inviteSettlementMapper.updateByUidAndId(settlement); |
133 | } | 136 | } |
@@ -158,7 +161,7 @@ public class InviterSettleService { | @@ -158,7 +161,7 @@ public class InviterSettleService { | ||
158 | * @param settlementId | 161 | * @param settlementId |
159 | * @return | 162 | * @return |
160 | */ | 163 | */ |
161 | - private BigDecimal calculateSettleAmountOfType2(int uid, int settlementId) { | 164 | + private BigDecimal calculateSettleAmountOfType2(int uid, LocalDateTime settleTime, int settlementId) { |
162 | int type = 2; | 165 | int type = 2; |
163 | inviteSettlementItemMapper.updateToSettled( | 166 | inviteSettlementItemMapper.updateToSettled( |
164 | uid, | 167 | uid, |
@@ -173,10 +176,25 @@ public class InviterSettleService { | @@ -173,10 +176,25 @@ public class InviterSettleService { | ||
173 | .collect(Collectors.toMap(InviteRecord::getInviteeUid, InviteRecord::getCreateTime)); | 176 | .collect(Collectors.toMap(InviteRecord::getInviteeUid, InviteRecord::getCreateTime)); |
174 | 177 | ||
175 | return statsList.stream() | 178 | return statsList.stream() |
176 | - .map(stats -> InviteSettlementUtils.calculateSettleAmountOfType2( | ||
177 | - newLocalDateTimeOfEpochSecond(invitees.getOrDefault(stats.getSellerUid(), 0)), | ||
178 | - inviteSettlementItemMapper.selectByUidTypeInviteSettlementIdAndSellerUid(uid, type, settlementId, stats.getSellerUid()) | ||
179 | - )) | 179 | + .map(stats -> { |
180 | + Pair<BigDecimal, List<InviteSettlementItem>> settle = InviteSettlementUtils.calculateSettleAmountOfType2( | ||
181 | + newLocalDateTimeOfEpochSecond(invitees.getOrDefault(stats.getSellerUid(), 0)), | ||
182 | + settleTime, | ||
183 | + inviteSettlementItemMapper.selectByUidTypeInviteSettlementIdAndSellerUid(uid, type, settlementId, stats.getSellerUid()) | ||
184 | + ); | ||
185 | + List<Integer> ids = settle.getRight().stream().map(InviteSettlementItem::getId).collect(Collectors.toList()); | ||
186 | + if (CollectionUtils.isNotEmpty(ids)) { | ||
187 | + inviteSettlementItemMapper.updateToSettledRollback( | ||
188 | + uid, | ||
189 | + type, | ||
190 | + InviteSettlementItem.STATUS_SETTLED, | ||
191 | + InviteSettlementItem.STATUS_ENABLE, | ||
192 | + 0, | ||
193 | + ids | ||
194 | + ); | ||
195 | + } | ||
196 | + return settle.getLeft(); | ||
197 | + }) | ||
180 | .reduce(BigDecimal.ZERO, BigDecimal::add); | 198 | .reduce(BigDecimal.ZERO, BigDecimal::add); |
181 | } | 199 | } |
182 | 200 |
1 | package com.yohoufo.order.utils; | 1 | package com.yohoufo.order.utils; |
2 | 2 | ||
3 | import com.yohoufo.dal.order.model.InviteSettlementItem; | 3 | import com.yohoufo.dal.order.model.InviteSettlementItem; |
4 | +import org.apache.commons.lang3.tuple.Pair; | ||
4 | 5 | ||
5 | import java.math.BigDecimal; | 6 | import java.math.BigDecimal; |
6 | import java.math.RoundingMode; | 7 | import java.math.RoundingMode; |
8 | +import java.time.LocalDate; | ||
7 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
10 | +import java.time.LocalTime; | ||
8 | import java.time.ZoneOffset; | 11 | import java.time.ZoneOffset; |
9 | import java.util.List; | 12 | import java.util.List; |
10 | import java.util.Objects; | 13 | import java.util.Objects; |
11 | import java.util.function.BiPredicate; | 14 | import java.util.function.BiPredicate; |
15 | +import java.util.stream.Collectors; | ||
12 | 16 | ||
13 | /** | 17 | /** |
14 | * @author LUOXC | 18 | * @author LUOXC |
@@ -56,25 +60,48 @@ public class InviteSettlementUtils { | @@ -56,25 +60,48 @@ public class InviteSettlementUtils { | ||
56 | * @param items 待结算订单 | 60 | * @param items 待结算订单 |
57 | * @return | 61 | * @return |
58 | */ | 62 | */ |
59 | - public static BigDecimal calculateSettleAmountOfType2(LocalDateTime inviteTime, List<InviteSettlementItem> items) { | ||
60 | - // 一个月内 | 63 | + public static Pair<BigDecimal, List<InviteSettlementItem>> calculateSettleAmountOfType2(LocalDateTime inviteTime, LocalDateTime settleTime, List<InviteSettlementItem> items) { |
64 | + // 被邀请当月月初开始计算 | ||
65 | + LocalDateTime calculateStartTime = LocalDateTime.of(LocalDate.of(inviteTime.getYear(), inviteTime.getMonth(), 1), LocalTime.MIN); | ||
66 | + | ||
67 | + LocalDateTime afterOneMonth = calculateStartTime.plusMonths(1); | ||
68 | + | ||
69 | + LocalDateTime afterFiveMonth = calculateStartTime.plusMonths(5); | ||
70 | + | ||
71 | + // 被邀请来年元旦 | ||
72 | + LocalDateTime calculateFinnalEndTime = LocalDateTime.of(LocalDate.of(inviteTime.getYear() + 1, 1, 1), LocalTime.MIN); | ||
73 | + | ||
74 | + BiPredicate<InviteSettlementItem, LocalDateTime> iaAfterOrEqual = (item, month) -> { | ||
75 | + LocalDateTime createTime = newLocalDateTimeOfEpochSecond(item.getCreateTime()); | ||
76 | + return createTime.isAfter(month) || createTime.isEqual(month); | ||
77 | + }; | ||
78 | + | ||
79 | + // 一个月内无需结算 | ||
80 | + if (settleTime.isBefore(afterOneMonth)) { | ||
81 | + return Pair.of(BigDecimal.ZERO, items); | ||
82 | + } | ||
83 | + | ||
84 | + | ||
85 | + // 一个月内结算金额 | ||
61 | BigDecimal inOneMonthTotalSettleAmount = items.stream() | 86 | BigDecimal inOneMonthTotalSettleAmount = items.stream() |
62 | - .filter(item -> newLocalDateTimeOfEpochSecond(item.getCreateTime()).isBefore(inviteTime.plusMonths(1))) | 87 | + .filter(item -> newLocalDateTimeOfEpochSecond(item.getCreateTime()).isBefore(afterOneMonth)) |
63 | .map(InviteSettlementItem::getOrderAmount) | 88 | .map(InviteSettlementItem::getOrderAmount) |
64 | .reduce(BigDecimal.ZERO, BigDecimal::add) | 89 | .reduce(BigDecimal.ZERO, BigDecimal::add) |
65 | .multiply(BigDecimal.valueOf(0.02)); | 90 | .multiply(BigDecimal.valueOf(0.02)); |
66 | 91 | ||
67 | - BiPredicate<InviteSettlementItem, Integer> iaAfterOrEqual = (item, months) -> { | ||
68 | - LocalDateTime createTime = newLocalDateTimeOfEpochSecond(item.getCreateTime()); | ||
69 | - LocalDateTime afterInviteMonth = inviteTime.plusMonths(months); | ||
70 | - return createTime.isAfter(afterInviteMonth) || createTime.isEqual(afterInviteMonth); | ||
71 | - }; | 92 | + // 五个月内只结算1个月内的订单 |
93 | + if (settleTime.isBefore(afterFiveMonth)) { | ||
94 | + return Pair.of( | ||
95 | + inOneMonthTotalSettleAmount, | ||
96 | + items.stream().filter(item -> iaAfterOrEqual.test(item, afterOneMonth)).collect(Collectors.toList()) | ||
97 | + ); | ||
98 | + } | ||
72 | 99 | ||
73 | - // 五个月内 | 100 | + // 五个月内结算金额 |
74 | BigDecimal inFiveMonthTotalSettleAmount; | 101 | BigDecimal inFiveMonthTotalSettleAmount; |
75 | BigDecimal inFiveMonthTotalOrderAmount = items.stream() | 102 | BigDecimal inFiveMonthTotalOrderAmount = items.stream() |
76 | - .filter(item -> iaAfterOrEqual.test(item, 1)) | ||
77 | - .filter(item -> newLocalDateTimeOfEpochSecond(item.getCreateTime()).isBefore(inviteTime.plusMonths(5))) | 103 | + .filter(item -> iaAfterOrEqual.test(item, afterOneMonth)) |
104 | + .filter(item -> newLocalDateTimeOfEpochSecond(item.getCreateTime()).isBefore(calculateFinnalEndTime.isBefore(afterFiveMonth) ? calculateFinnalEndTime : afterFiveMonth)) | ||
78 | .map(InviteSettlementItem::getOrderAmount) | 105 | .map(InviteSettlementItem::getOrderAmount) |
79 | .reduce(BigDecimal.ZERO, BigDecimal::add); | 106 | .reduce(BigDecimal.ZERO, BigDecimal::add); |
80 | if (inFiveMonthTotalOrderAmount.compareTo(BigDecimal.valueOf(100_0000)) < 0) { | 107 | if (inFiveMonthTotalOrderAmount.compareTo(BigDecimal.valueOf(100_0000)) < 0) { |
@@ -87,10 +114,19 @@ public class InviteSettlementUtils { | @@ -87,10 +114,19 @@ public class InviteSettlementUtils { | ||
87 | inFiveMonthTotalSettleAmount = inFiveMonthTotalOrderAmount.multiply(BigDecimal.valueOf(0.020)); | 114 | inFiveMonthTotalSettleAmount = inFiveMonthTotalOrderAmount.multiply(BigDecimal.valueOf(0.020)); |
88 | } | 115 | } |
89 | 116 | ||
90 | - // 五个月以后 | 117 | + // 五个月以后,1年内只结算五个月内的订单 |
118 | + if (settleTime.isBefore(afterFiveMonth)) { | ||
119 | + return Pair.of( | ||
120 | + inOneMonthTotalSettleAmount.add(inFiveMonthTotalSettleAmount), | ||
121 | + items.stream().filter(item -> iaAfterOrEqual.test(item, calculateFinnalEndTime.isBefore(afterFiveMonth) ? calculateFinnalEndTime : afterFiveMonth)).collect(Collectors.toList()) | ||
122 | + ); | ||
123 | + } | ||
124 | + | ||
125 | + // 五个月以后结算金额 | ||
91 | BigDecimal outFiveMonthTotalSettleAmount; | 126 | BigDecimal outFiveMonthTotalSettleAmount; |
92 | BigDecimal outFiveMonthTotalOrderAmount = items.stream() | 127 | BigDecimal outFiveMonthTotalOrderAmount = items.stream() |
93 | - .filter(item -> iaAfterOrEqual.test(item, 5)) | 128 | + .filter(item -> iaAfterOrEqual.test(item, afterFiveMonth)) |
129 | + .filter(item -> newLocalDateTimeOfEpochSecond(item.getCreateTime()).isBefore(calculateFinnalEndTime)) | ||
94 | .map(InviteSettlementItem::getOrderAmount) | 130 | .map(InviteSettlementItem::getOrderAmount) |
95 | .reduce(BigDecimal.ZERO, BigDecimal::add); | 131 | .reduce(BigDecimal.ZERO, BigDecimal::add); |
96 | if (outFiveMonthTotalOrderAmount.compareTo(BigDecimal.valueOf(180_0000)) < 0) { | 132 | if (outFiveMonthTotalOrderAmount.compareTo(BigDecimal.valueOf(180_0000)) < 0) { |
@@ -103,7 +139,10 @@ public class InviteSettlementUtils { | @@ -103,7 +139,10 @@ public class InviteSettlementUtils { | ||
103 | outFiveMonthTotalSettleAmount = outFiveMonthTotalOrderAmount.multiply(BigDecimal.valueOf(0.018)); | 139 | outFiveMonthTotalSettleAmount = outFiveMonthTotalOrderAmount.multiply(BigDecimal.valueOf(0.018)); |
104 | } | 140 | } |
105 | 141 | ||
106 | - return inOneMonthTotalSettleAmount.add(inFiveMonthTotalSettleAmount).add(outFiveMonthTotalSettleAmount); | 142 | + return Pair.of( |
143 | + inOneMonthTotalSettleAmount.add(inFiveMonthTotalSettleAmount).add(outFiveMonthTotalSettleAmount), | ||
144 | + items.stream().filter(item -> iaAfterOrEqual.test(item, calculateFinnalEndTime)).collect(Collectors.toList()) | ||
145 | + ); | ||
107 | } | 146 | } |
108 | 147 | ||
109 | public static ZoneOffset zoneOffset() { | 148 | public static ZoneOffset zoneOffset() { |
-
Please register or login to post a comment