Authored by gemingdan

提现分批mq

@@ -234,7 +234,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -234,7 +234,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
234 private String IS_NEED_SIGN_UP = "union.need.signup.switch"; 234 private String IS_NEED_SIGN_UP = "union.need.signup.switch";
235 private String RANKLIST_FROM_DATE = "union.rank.from"; 235 private String RANKLIST_FROM_DATE = "union.rank.from";
236 236
237 - private static final int SETTLEMENT_ORDER_SPLIT_NUM=800; 237 + private static final int SETTLEMENT_ORDER_SPLIT_NUM=16;
238 238
239 239
240 240
@@ -3765,37 +3765,39 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -3765,37 +3765,39 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
3765 return -1; 3765 return -1;
3766 } 3766 }
3767 int count = unionShareOrdersMapper.selectOrderNumByCondition(settlementCode); 3767 int count = unionShareOrdersMapper.selectOrderNumByCondition(settlementCode);
3768 - if (count < 1) {  
3769 - return -2;  
3770 - }  
3771 - List<UnionShareOrdersBo> orderList = new ArrayList<>();//该提现对应的订单  
3772 int size = SETTLEMENT_ORDER_SPLIT_NUM; 3768 int size = SETTLEMENT_ORDER_SPLIT_NUM;
3773 - int page = count % size > 0 ? (count / size) + 1 : count / size;  
3774 boolean isFirst = true; 3769 boolean isFirst = true;
3775 - for (int i = 0; i < page; i++) {  
3776 - int offset = i * size ;  
3777 - List<UnionShareOrders> periodOrders = unionShareOrdersMapper.selectOrderByCondition(settlementCode, offset, size);  
3778 - if (CollectionUtils.isEmpty(periodOrders) || periodOrders.get(0) == null) {  
3779 - break;  
3780 - }  
3781 - periodOrders.forEach(o->{  
3782 - UnionShareOrdersBo b = new UnionShareOrdersBo();  
3783 - BeanUtils.copyProperties(o,b);  
3784 - if (b.getActivityId()>0) {  
3785 - b.setActivityType(2); 3770 + if (count > 0 ) {
  3771 + List<UnionShareOrdersBo> orderList = new ArrayList<>();//该提现对应的订单
  3772 + int page = count % size > 0 ? (count / size) + 1 : count / size;
  3773 +
  3774 + for (int i = 0; i < page; i++) {
  3775 + int offset = i * size ;
  3776 + List<UnionShareOrders> periodOrders = unionShareOrdersMapper.selectOrderByCondition(settlementCode, offset, size);
  3777 + if (CollectionUtils.isEmpty(periodOrders) || periodOrders.get(0) == null) {
  3778 + break;
3786 } 3779 }
3787 - orderList.add(b);  
3788 - });  
3789 - sendSettlementMq(unionShareSettlement,orderList,null,isFirst);  
3790 - isFirst = false;  
3791 - orderList.clear(); 3780 + periodOrders.forEach(o->{
  3781 + UnionShareOrdersBo b = new UnionShareOrdersBo();
  3782 + BeanUtils.copyProperties(o,b);
  3783 + if (b.getActivityId()>0) {
  3784 + b.setActivityType(2);
  3785 + }
  3786 + orderList.add(b);
  3787 + });
  3788 + sendSettlementMq(unionShareSettlement,orderList,null,isFirst);
  3789 + isFirst = false;
  3790 + orderList.clear();
  3791 + }
3792 } 3792 }
  3793 +
3793 //查询活动额外返的返利单 3794 //查询活动额外返的返利单
3794 List<Integer> ids = unionShareOrdersMapper.selectIdForActivity(settlementCode); 3795 List<Integer> ids = unionShareOrdersMapper.selectIdForActivity(settlementCode);
3795 List<UnionShareOrdersActivityBo> activityBos = new ArrayList<>(); 3796 List<UnionShareOrdersActivityBo> activityBos = new ArrayList<>();
3796 if(CollectionUtils.isNotEmpty(ids)){ 3797 if(CollectionUtils.isNotEmpty(ids)){
3797 - page = count % size > 0 ? (count / size) + 1 : count / size;  
3798 - for (int i = 0; i < page; i++) { 3798 + count = ids.size();
  3799 + int pageA = count % size > 0 ? (count / size) + 1 : count / size;
  3800 + for (int i = 0; i < pageA; i++) {
3799 int startIndex = i * size ; 3801 int startIndex = i * size ;
3800 int endIndex=startIndex+size-1; 3802 int endIndex=startIndex+size-1;
3801 List<UnionShareOrdersActivityLogs> activities = unionShareOrdersActivityLogsMapper.selectByOrderIds(ids.subList(startIndex,endIndex<count?endIndex:count-1)); 3803 List<UnionShareOrdersActivityLogs> activities = unionShareOrdersActivityLogsMapper.selectByOrderIds(ids.subList(startIndex,endIndex<count?endIndex:count-1));