...
|
...
|
@@ -108,27 +108,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
@Override
|
|
|
public PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO){
|
|
|
logger.info("queryUnionShareOrders param is {}", reqBO);
|
|
|
/*
|
|
|
* 由于不能连表查所以解决方案有二:
|
|
|
* 1.牺牲内存,临时数据先查出存到内存中(比如这里 uids),缺点是数据太多的话内存放不下
|
|
|
* 2.数据库添加冗余外表字段(比如A表连接B表查,可把B表中用的字段在A表也添加上去,缺点是业务复杂度提高)
|
|
|
*
|
|
|
*/
|
|
|
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
|
|
|
List<Integer> uids=null;
|
|
|
if(bo.getUnionType()!=null || bo.getUnionName()!=null || bo.getChannelType()!=null){
|
|
|
uids=queryUids(bo);
|
|
|
if(null==uids){
|
|
|
Integer uid=null;
|
|
|
if(bo.getUnionType()!=null || bo.getUnionName()!=null ){
|
|
|
uid=queryUid(bo);
|
|
|
if(null==uid){
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
//查询总数
|
|
|
int count = unionShareOrdersMapper.selectCountByUids(bo.getBeginTime(), bo.getEndTime(), uids,bo.getOrderCode());
|
|
|
logger.info("unionShareOrdersMapper.selectCountByUids: size is {}", count);
|
|
|
int count = unionShareOrdersMapper.selectCountBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode());
|
|
|
logger.info("unionShareOrdersMapper.selectCountByBySearchCodition: size is {}", count);
|
|
|
if (count < 1) {
|
|
|
return null;
|
|
|
}
|
|
|
Map<String,UnionShareOrders> ordersDOMap=this.unionShareOrdersMapper.selectListByUids(bo.getBeginTime(), bo.getEndTime(), uids,bo.getOrderCode(), reqBO.getStart(), reqBO.getSize());
|
|
|
Map<String,UnionShareOrders> ordersDOMap=this.unionShareOrdersMapper.selectListBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode(), reqBO.getStart(), reqBO.getSize());
|
|
|
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRsp(ordersDOMap);
|
|
|
PageUnionShareOrderRspBO pageUnionOrderRspBO = new PageUnionShareOrderRspBO();
|
|
|
pageUnionOrderRspBO.setList(unionOrderRspBOList);
|
...
|
...
|
@@ -138,17 +132,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return pageUnionOrderRspBO;
|
|
|
}
|
|
|
|
|
|
private List<Integer> queryUids(UnionShareOrderSearchBo bo){
|
|
|
List<Integer> uids=null;
|
|
|
List<Long> unionTypes=mktMarketingUrlDAO.selectUnionTypes(bo.getUnionType(), bo.getUnionName(), bo.getChannelType());
|
|
|
if(unionTypes.isEmpty()){
|
|
|
private Integer queryUid(UnionShareOrderSearchBo bo){
|
|
|
Integer uid=null;
|
|
|
Long unionType=mktMarketingUrlDAO.selectUnionTypeByNameAndUnionType(bo.getUnionName(),bo.getUnionType());
|
|
|
if(null==unionType){
|
|
|
return null;
|
|
|
}
|
|
|
uids=this.unionShareUserMapper.selectUids(unionTypes);
|
|
|
if(uids.isEmpty()){
|
|
|
return null;
|
|
|
}
|
|
|
return uids;
|
|
|
uid=this.unionShareUserMapper.selectUidByUnionType(unionType);
|
|
|
return uid;
|
|
|
}
|
|
|
private UnionShareOrderSearchBo initUnionShareOrderSearchBo(UnionShareOrderSearchReqBO reqBO){
|
|
|
UnionShareOrderSearchBo bo=new UnionShareOrderSearchBo();
|
...
|
...
|
@@ -157,7 +148,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
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.setChannelType(StringUtils.isBlank(reqBO.getChannelType())?null:reqBO.getChannelType());
|
|
|
bo.setIdList(reqBO.getIdsList());
|
|
|
return bo;
|
|
|
}
|
...
|
...
|
@@ -199,14 +189,17 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
private Map<String, ShareUserOrderDatailBO> initUserShareOrderDatails( Map<String,UnionShareOrders> ordersDOMap){
|
|
|
Map<String, ShareUserOrderDatailBO> userOrderDatailBOMap = new HashMap<>(ordersDOMap.size());
|
|
|
Map<Integer,UnionShareUser> userMap=unionShareUserMapper.selectByUids(getUids(ordersDOMap));
|
|
|
Map<Long,MktMarketingUrl> mktMarketMap=listMktMarketingUrls(ordersDOMap,userMap);
|
|
|
for (UnionShareOrders userOrders : ordersDOMap.values()) {
|
|
|
String unionType=userMap.get(userOrders.getPromoteUid()).getUnionType();
|
|
|
ShareUserOrderDatailBO userOrderDatailBO = new ShareUserOrderDatailBO();
|
|
|
userOrderDatailBO.setUnionType(unionType);
|
|
|
MktMarketingUrl mktMarketingUrl = redisValueCache.get("yh:union:uniontype:" + unionType, MktMarketingUrl.class);
|
|
|
if (mktMarketingUrl == null &&isLong(unionType)) {
|
|
|
mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(unionType));
|
|
|
redisValueCache.set("yh:union:uniontype:" + unionType, mktMarketingUrl, 1, TimeUnit.HOURS);
|
|
|
if (mktMarketingUrl == null && isLong(unionType)) {
|
|
|
mktMarketingUrl = mktMarketMap.get(Long.valueOf(unionType));
|
|
|
if(null!=mktMarketingUrl){
|
|
|
redisValueCache.set("yh:union:uniontype:" + unionType, mktMarketingUrl, 1, TimeUnit.HOURS);
|
|
|
}
|
|
|
}
|
|
|
if (mktMarketingUrl != null) {
|
|
|
userOrderDatailBO.setUnionName(mktMarketingUrl.getName());
|
...
|
...
|
@@ -218,6 +211,17 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return userOrderDatailBOMap;
|
|
|
}
|
|
|
|
|
|
private Map<Long,MktMarketingUrl> listMktMarketingUrls(Map<String,UnionShareOrders> ordersDOMap, Map<Integer,UnionShareUser> userMap){
|
|
|
List<String> unionTypes=new ArrayList<>();
|
|
|
for (UnionShareOrders userOrders : ordersDOMap.values()) {
|
|
|
String unionType=userMap.get(userOrders.getPromoteUid()).getUnionType();
|
|
|
if(StringUtils.isNotBlank(unionType)){
|
|
|
unionTypes.add(unionType);
|
|
|
}
|
|
|
}
|
|
|
return unionTypes.isEmpty()?new HashMap<>():this.mktMarketingUrlDAO.selectByUnionTypes(unionTypes);
|
|
|
}
|
|
|
|
|
|
private boolean isLong(String value){
|
|
|
boolean flag=true;
|
|
|
try {
|
...
|
...
|
@@ -773,14 +777,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
if(bo.getIdList()!=null&&!bo.getIdList().isEmpty()){
|
|
|
ordersDOMap= this.unionShareOrdersMapper.selectListByIds(bo.getIdList());
|
|
|
}else{
|
|
|
List<Integer> uids=null;
|
|
|
if(bo.getUnionType()!=null || bo.getUnionName()!=null || bo.getChannelType()!=null){
|
|
|
uids=queryUids(bo);
|
|
|
if(null==uids){
|
|
|
Integer uid=null;
|
|
|
if(bo.getUnionType()!=null || bo.getUnionName()!=null){
|
|
|
uid=queryUid(bo);
|
|
|
if(null==uid){
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
ordersDOMap=this.unionShareOrdersMapper.selectAllListByUids(bo.getBeginTime(), bo.getEndTime(), uids, bo.getOrderCode());
|
|
|
ordersDOMap=this.unionShareOrdersMapper.selectAllListByUids(bo.getBeginTime(), bo.getEndTime(), uid, bo.getOrderCode());
|
|
|
}
|
|
|
return ordersDOMap.isEmpty()?null:queryUnionShareOrderRsp(ordersDOMap);
|
|
|
}
|
...
|
...
|
|