...
|
...
|
@@ -695,7 +695,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
logger.info("joinInviteActivity end.newUids error.uids is {}.",uids);
|
|
|
return;
|
|
|
}
|
|
|
// Set<Integer> newUids = uids;//TODO 测试环境绕过
|
|
|
// Set<Integer> newUids = uids;// 测试环境绕过
|
|
|
//过滤udid有过记录的用户
|
|
|
Set<String> udids=appYohoCpsNewUids.stream().map(u->u.getUdid()).collect(Collectors.toSet());
|
|
|
Set<String> existUdids=unionShareYohoNewUidMapper.selectByUdids(udids);
|
...
|
...
|
@@ -3504,6 +3504,69 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return totalAmount;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int sendSettlementMqToErp(String settlementCode,int uid) {
|
|
|
mqLog.info("sendSettlementMqToErp start,send mq {} to erp,uid is {},settlementCode is {}", SETTLEMENT_TOPIC, uid, settlementCode);
|
|
|
UnionShareSettlement unionShareSettlement=unionShareSettlementMapper.selectByCode(settlementCode);
|
|
|
if (unionShareSettlement == null||unionShareSettlement.getPromoteUid()!=uid) {
|
|
|
return 0;
|
|
|
}
|
|
|
int count = unionShareOrdersMapper.selectOrderNumByCondition(settlementCode);
|
|
|
if (count < 1) {
|
|
|
return -1;
|
|
|
}
|
|
|
Set<String> orderCodes = new HashSet<>();
|
|
|
List<UnionShareOrdersBo> orderList = new ArrayList<>();//该提现对应的订单
|
|
|
int size = 1000;
|
|
|
int page = count % size > 0 ? (count / size) + 1 : count / size;
|
|
|
for (int i = 0; i < page; i++) {
|
|
|
int offset = i * size ;
|
|
|
List<UnionShareOrders> periodOrders = unionShareOrdersMapper.selectOrderByCondition(settlementCode, offset, size);
|
|
|
if (CollectionUtils.isEmpty(periodOrders) || periodOrders.get(0) == null) {
|
|
|
break;
|
|
|
}
|
|
|
periodOrders.forEach(o->{
|
|
|
UnionShareOrdersBo b = new UnionShareOrdersBo();
|
|
|
BeanUtils.copyProperties(o,b);
|
|
|
if (b.getActivityId()>0) {
|
|
|
b.setActivityType(2);
|
|
|
}
|
|
|
orderList.add(b);
|
|
|
orderCodes.add(b.getOrderCode());
|
|
|
});
|
|
|
}
|
|
|
//查询活动额外返的返利单
|
|
|
List<Integer> ids = unionShareOrdersMapper.selectIdForActivity(settlementCode);
|
|
|
List<UnionShareOrdersActivityBo> activityBos = new ArrayList<>();
|
|
|
if(CollectionUtils.isNotEmpty(ids)){
|
|
|
List<UnionShareOrdersActivityLogs> activities = unionShareOrdersActivityLogsMapper.selectByOrderIds(ids);
|
|
|
activities.forEach(a->{
|
|
|
UnionShareOrdersActivityBo bo = new UnionShareOrdersActivityBo();
|
|
|
BeanUtils.copyProperties(a,bo);
|
|
|
bo.setId(a.getOrderId());
|
|
|
activityBos.add(bo);
|
|
|
});
|
|
|
}
|
|
|
if (CollectionUtils.isEmpty(orderList)&&CollectionUtils.isEmpty(activityBos)) {
|
|
|
//不该查不到订单
|
|
|
settlementLog.warn("sendSettlementMqToErp end,uid is {},settlementCode is {},totalAmount is {},can not find orders and activity.",uid,settlementCode,unionShareSettlement.getSettlementAmount());
|
|
|
throw new ServiceException(ServiceError.UNION_SETTLEMENT_CANNOT_FIND_ORDER_ERROR);
|
|
|
}
|
|
|
//清缓存
|
|
|
clearShareOrderRedis(uid);
|
|
|
|
|
|
// 发送取现mq给erp SETTLEMENT_TOPIC
|
|
|
ShareSettlementBo bo = new ShareSettlementBo();
|
|
|
BeanUtils.copyProperties(unionShareSettlement,bo);
|
|
|
bo.setOrderCodes(orderCodes);
|
|
|
bo.setOrderList(orderList);
|
|
|
bo.setActivities(activityBos);
|
|
|
mqLog.info("sendSettlementMqToErp,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, JsonUtil.objectToJSON(bo));
|
|
|
yhProducer.send(SETTLEMENT_TOPIC, bo);
|
|
|
settlementLog.info("sendSettlementMqToErp,send mq {} to erp success,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
//扣税金额计算,保留两位小数,多余位舍弃
|
|
|
private BigDecimal getTaxAmount(BigDecimal amount) {
|
|
|
// 假设佣金为X
|
...
|
...
|
|