...
|
...
|
@@ -251,22 +251,23 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
@Override
|
|
|
public PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO){
|
|
|
logger.info("queryUnionShareOrders param is {}", reqBO);
|
|
|
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
|
|
|
Integer uid=null;
|
|
|
if(bo.getUnionType()!=null || bo.getUnionName()!=null ){
|
|
|
uid=queryUid(bo);
|
|
|
if(null==uid){
|
|
|
if(StringUtils.isNotBlank(reqBO.getUnionType())){
|
|
|
setUid(reqBO);
|
|
|
if (reqBO.getPromoteUid() ==null) {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isBlank(reqBO.getOrderCode())) {
|
|
|
reqBO.setOrderCode(null);
|
|
|
}
|
|
|
//查询总数
|
|
|
int count = unionShareOrdersMapper.selectCountBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode());
|
|
|
int count = unionShareOrdersMapper.selectCountBySearchCodition(reqBO);
|
|
|
logger.info("unionShareOrdersMapper.selectCountByBySearchCodition: size is {}", count);
|
|
|
if (count < 1) {
|
|
|
return null;
|
|
|
}
|
|
|
List<UnionShareOrders> ordersDOList=this.unionShareOrdersMapper.selectListBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode(), reqBO.getStart(), reqBO.getSize());
|
|
|
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRspBO(ordersDOList);
|
|
|
List<UnionShareOrders> ordersDOList=this.unionShareOrdersMapper.selectListBySearchCodition(reqBO);
|
|
|
List<UnionShareOrderRspBO> unionOrderRspBOList = getUnionShareOrderRspList(ordersDOList,reqBO);
|
|
|
PageUnionShareOrderRspBO pageUnionOrderRspBO = new PageUnionShareOrderRspBO();
|
|
|
pageUnionOrderRspBO.setList(unionOrderRspBOList);
|
|
|
pageUnionOrderRspBO.setTotal(count);
|
...
|
...
|
@@ -275,43 +276,47 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return pageUnionOrderRspBO;
|
|
|
}
|
|
|
|
|
|
private Integer queryUid(UnionShareOrderSearchBo bo){
|
|
|
Long unionType=null==bo.getUnionName()?bo.getUnionType():mktMarketingUrlDAO.selectUnionTypeByNameAndUnionType(bo.getUnionName(),bo.getUnionType());
|
|
|
if(null==unionType){
|
|
|
return null;
|
|
|
private List<UnionShareOrderRspBO> getUnionShareOrderRspList(List<UnionShareOrders> ordersDOList,UnionShareOrderSearchReqBO reqBO) {
|
|
|
List<UnionShareOrderRspBO> rsplist = new ArrayList<>();
|
|
|
if (CollectionUtils.isEmpty(ordersDOList)) {
|
|
|
return rsplist;
|
|
|
}
|
|
|
return this.unionShareUserMapper.selectUidByUnionType(unionType);
|
|
|
}
|
|
|
private UnionShareOrderSearchBo initUnionShareOrderSearchBo(UnionShareOrderSearchReqBO reqBO){
|
|
|
UnionShareOrderSearchBo bo=new UnionShareOrderSearchBo();
|
|
|
bo.setBeginTime(StringUtils.isNumeric(reqBO.getBeginTime()) ? Integer.parseInt(reqBO.getBeginTime()):0);
|
|
|
bo.setEndTime(StringUtils.isNumeric(reqBO.getEndTime()) ? Integer.parseInt(reqBO.getEndTime()):0);
|
|
|
bo.setOrderCode(StringUtils.isBlank(reqBO.getOrderCode()) ? null : reqBO.getOrderCode());
|
|
|
bo.setUnionType(StringUtils.isBlank(reqBO.getUnionId()) ? null :Long.valueOf( reqBO.getUnionId()));
|
|
|
bo.setUnionName(StringUtils.isBlank(reqBO.getUnionType()) ? null : reqBO.getUnionType());
|
|
|
bo.setIdList(reqBO.getIdsList());
|
|
|
return bo;
|
|
|
Set<Integer> uidSet;
|
|
|
if (reqBO.getPromoteUid() == null) {
|
|
|
uidSet = ordersDOList.stream().map(o -> o.getPromoteUid()).collect(Collectors.toSet());
|
|
|
} else {
|
|
|
uidSet = new HashSet<Integer>(){{add(reqBO.getPromoteUid());}};
|
|
|
}
|
|
|
Map<Integer, UnionShareUser> userMap = unionShareUserMapper.selectByUids(uidSet);
|
|
|
ordersDOList.forEach(o->{
|
|
|
UnionShareOrderRspBO rspBO = new UnionShareOrderRspBO();
|
|
|
BeanUtils.copyProperties(o,rspBO);
|
|
|
rspBO.setAmount(o.getOrderAmount());
|
|
|
rspBO.setOrderAmount(o.getLastOrderAmount());
|
|
|
rspBO.setOrderStatus(ShareOrdersStatusEnum.getDescByCode(o.getStatus()));
|
|
|
rspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(o.getOrderTime()) * Long.valueOf(1000), "yyyy-MM-dd HH:mm:ss"));
|
|
|
if (userMap.containsKey(o.getPromoteUid())) {
|
|
|
rspBO.setUnionType(userMap.get(o.getPromoteUid()).getUnionType());
|
|
|
}
|
|
|
rsplist.add(rspBO);
|
|
|
});
|
|
|
return rsplist;
|
|
|
}
|
|
|
|
|
|
private UnionShareOrderRspBO initShareUnionOrderRspBO(String unionType,MktMarketingUrl mktMarketingUrl,UnionShareOrders orders){
|
|
|
UnionShareOrderRspBO orderRspBO=new UnionShareOrderRspBO();
|
|
|
orderRspBO.setOrderAmount(orders.getLastOrderAmount());
|
|
|
orderRspBO.setAmount(orders.getAmount());
|
|
|
orderRspBO.setOrderStatus(ShareOrdersStatusEnum.getDescByCode(orders.getStatus()));
|
|
|
orderRspBO.setIsNew(orders.getIsNew());
|
|
|
orderRspBO.setUid(orders.getPromoteUid());
|
|
|
orderRspBO.setOrderUid(orders.getOrderUid());
|
|
|
orderRspBO.setOrderCode(orders.getOrderCode());
|
|
|
orderRspBO.setId(orders.getId());
|
|
|
orderRspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(orders.getOrderTime()) * Long.valueOf(1000), "yyyy-MM-dd HH:mm:ss"));
|
|
|
orderRspBO.setUnionId(unionType);
|
|
|
if(null!=mktMarketingUrl){
|
|
|
orderRspBO.setUnionType(mktMarketingUrl.getName());
|
|
|
orderRspBO.setChannelType(mktMarketingUrl.getChannelType());
|
|
|
private void setUid(UnionShareOrderSearchReqBO reqBO){
|
|
|
Integer uid=this.unionShareUserMapper.selectUidByUnionType(reqBO.getUnionType());
|
|
|
if (uid == null) {
|
|
|
reqBO.setPromoteUid(null);
|
|
|
return;
|
|
|
}
|
|
|
if (reqBO.getPromoteUid() != null && reqBO.getPromoteUid() != uid.intValue()) {
|
|
|
reqBO.setPromoteUid(null);
|
|
|
return;
|
|
|
}
|
|
|
return orderRspBO;
|
|
|
reqBO.setPromoteUid(uid);
|
|
|
}
|
|
|
|
|
|
|
|
|
private Set<Integer> getUids(List<UnionShareOrders> ordersDOList){
|
|
|
Set<Integer> uids=new HashSet<>(ordersDOList.size());
|
|
|
for(UnionShareOrders order:ordersDOList){
|
...
|
...
|
@@ -320,23 +325,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return uids;
|
|
|
}
|
|
|
|
|
|
private List<UnionShareOrderRspBO> queryUnionShareOrderRspBO(List<UnionShareOrders> ordersDOList){
|
|
|
List<UnionShareOrderRspBO> unionOrderRspBOList = new ArrayList<>(ordersDOList.size());
|
|
|
Map<Integer,UnionShareUser> userMap=unionShareUserMapper.selectByUids(getUids(ordersDOList));
|
|
|
Map<Long,MktMarketingUrl> mktMarketMap=listMktMarketingUrls(ordersDOList,userMap);
|
|
|
for (UnionShareOrders userOrders : ordersDOList) {
|
|
|
UnionShareUser unionShareUser = userMap.get(userOrders.getPromoteUid());
|
|
|
if (unionShareUser == null) {
|
|
|
continue;
|
|
|
}
|
|
|
String unionType= unionShareUser.getUnionType();
|
|
|
MktMarketingUrl mktMarketingUrl = isLong(unionType)?mktMarketMap.get(Long.valueOf(unionType)):null;
|
|
|
UnionShareOrderRspBO bo=initShareUnionOrderRspBO(unionType,mktMarketingUrl,userOrders);
|
|
|
unionOrderRspBOList.add(bo);
|
|
|
}
|
|
|
return unionOrderRspBOList;
|
|
|
}
|
|
|
|
|
|
private Map<Long,MktMarketingUrl> listMktMarketingUrls(List<UnionShareOrders> ordersDOList, Map<Integer,UnionShareUser> userMap){
|
|
|
List<String> unionTypes=new ArrayList<>();
|
|
|
for (UnionShareOrders userOrders : ordersDOList) {
|
...
|
...
|
@@ -2218,7 +2206,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
public List<? extends Object> batchExport(String confStr) {
|
|
|
try {
|
|
|
UnionShareOrderSearchReqBO request = JSONObject.parseObject(confStr, UnionShareOrderSearchReqBO.class);
|
|
|
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRspBOForExport(request);
|
|
|
request.setSize(1000);
|
|
|
List<UnionShareOrders> ordersDOList;
|
|
|
if (request.getIds() != null) {
|
|
|
List<String> ids = Arrays.asList(request.getIds().split(","));
|
|
|
logger.info("batchExport.ids is {},req is {}",ids,request);
|
|
|
ordersDOList = unionShareOrdersMapper.selectListByIds(ids);
|
|
|
} else {
|
|
|
logger.info("batchExport.req is {}",request);
|
|
|
ordersDOList = this.unionShareOrdersMapper.selectListBySearchCodition(request);
|
|
|
}
|
|
|
|
|
|
List<UnionShareOrderRspBO> unionOrderRspBOList = getUnionShareOrderRspList(ordersDOList,request);
|
|
|
if (CollectionUtils.isEmpty(unionOrderRspBOList)) {
|
|
|
throw new ServiceException(400, "没有要导出的数据");
|
|
|
}
|
...
|
...
|
@@ -2231,24 +2230,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
throw new ServiceException(e.getCode(), e.getErrorMessage());
|
|
|
}
|
|
|
}
|
|
|
private List<UnionShareOrderRspBO> queryUnionShareOrderRspBOForExport(UnionShareOrderSearchReqBO reqBO){
|
|
|
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
|
|
|
List<UnionShareOrders> ordersDOList=null;
|
|
|
if(bo.getIdList()!=null&&!bo.getIdList().isEmpty()){
|
|
|
ordersDOList= this.unionShareOrdersMapper.selectListByIds(bo.getIdList());
|
|
|
}else{
|
|
|
Integer uid=null;
|
|
|
if(bo.getUnionType()!=null || bo.getUnionName()!=null){
|
|
|
uid=queryUid(bo);
|
|
|
if(null==uid){
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
ordersDOList=this.unionShareOrdersMapper.selectAllListByUids(bo.getBeginTime(), bo.getEndTime(), uid, bo.getOrderCode());
|
|
|
}
|
|
|
return ordersDOList.isEmpty()?null: queryUnionShareOrderRspBO(ordersDOList);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public UnionShareStatisticsRspBO getStatisticsInfo(UnionShareOrderReqBO bo) {
|
|
|
logger.info("getStatisticsInfo enter,req is {}",bo);
|
...
|
...
|
|