Эх сурвалжийг харах

渠道商角色,经销商列表,显示经销商的盲票库存、线下销量、线上销量、用户数等统计数据

guanglong 3 жил өмнө
parent
commit
0ba7ce96da

+ 49 - 0
mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/ChannelController.java

@@ -3,8 +3,12 @@ package com.qs.mp.web.controller.api.channel;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qs.mp.admin.domain.vo.TicketCntVO;
+import com.qs.mp.admin.service.ITicketService;
 import com.qs.mp.channel.domain.Channel;
 import com.qs.mp.channel.domain.Channel;
 import com.qs.mp.channel.domain.ChannelCommission;
 import com.qs.mp.channel.domain.ChannelCommission;
+import com.qs.mp.channel.domain.ChannelOrderDetail;
+import com.qs.mp.channel.domain.ChannelUserRel;
 import com.qs.mp.channel.domain.param.ChannelParam;
 import com.qs.mp.channel.domain.param.ChannelParam;
 import com.qs.mp.channel.domain.param.SiteQueryParam;
 import com.qs.mp.channel.domain.param.SiteQueryParam;
 import com.qs.mp.channel.domain.param.VerifyParam;
 import com.qs.mp.channel.domain.param.VerifyParam;
@@ -36,6 +40,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
@@ -70,6 +75,9 @@ public class ChannelController extends BaseApiController {
 
 
     @Autowired
     @Autowired
     private ISysUserService userService;
     private ISysUserService userService;
+    
+	@Autowired
+	private ITicketService ticketService;
 
 
 	@Autowired
 	@Autowired
 	private MapperFacade mapperFacade;
 	private MapperFacade mapperFacade;
@@ -341,6 +349,47 @@ public class ChannelController extends BaseApiController {
 				queryWrapper.eq("t1.certify_status", siteParam.getCertifyStatus());
 				queryWrapper.eq("t1.certify_status", siteParam.getCertifyStatus());
 			}
 			}
 			list = channelService.selectChannelVoList(queryWrapper);
 			list = channelService.selectChannelVoList(queryWrapper);
+			
+			List<Long> channelIds = new ArrayList<Long>();
+			if(null != list && list.size() > 0) {
+				for(ChannelVO channelVO : list) {
+					if(null != channelVO && null != channelVO.getChannelId()
+							&& StringUtils.isNotBlank(channelVO.getChannelNo())) {
+						channelIds.add(channelVO.getChannelId());
+	 				}
+				}
+			}
+			List<TicketCntVO>  cntList = new ArrayList<TicketCntVO>();
+			if(null != channelIds && channelIds.size() > 0) {
+				QueryWrapper<ChannelOrderDetail> ticketCntQueryWrapper = new QueryWrapper<ChannelOrderDetail>();
+				ticketCntQueryWrapper.in("t1.channel_id", channelIds);
+				cntList = ticketService.listTicketCnt(ticketCntQueryWrapper);
+			}
+			
+			if(null != list && list.size() > 0) {
+				for(ChannelVO channelVO : list) {
+					if(null != channelVO && null != channelVO.getChannelId()
+							&& StringUtils.isNotBlank(channelVO.getChannelNo())) {
+						// int siteCnt = channelService.getChannelSiteCnt(channelVO.getChannelNo());
+						LambdaQueryWrapper<ChannelUserRel> userCntQueryWrapper = new LambdaQueryWrapper<ChannelUserRel>();
+						userCntQueryWrapper.eq(ChannelUserRel::getChannelId, channelVO.getChannelId());
+						int userCnt = channelUserRelService.count(userCntQueryWrapper);
+						channelVO.setUserCnt(userCnt);
+						// 统计盲票库存, 销量
+						if(null != cntList && cntList.size() > 0) {
+							List<TicketCntVO> voList =  cntList.stream().filter(item  -> item.getChannelId().equals(channelVO.getChannelId()))
+					                .collect(Collectors.toList());
+							if(null != voList && voList.size() > 0) {
+								TicketCntVO ticketCnt =  voList.get(0);
+								channelVO.setOffLineQtyCnt(null != ticketCnt?ticketCnt.getOffLineQtyCnt():0);
+								channelVO.setOffLineSaleCnt(null != ticketCnt?ticketCnt.getOffLineSaleCnt():0);
+								channelVO.setOnLineSaleCnt(null != ticketCnt?ticketCnt.getOnLineSaleCnt():0);
+							}
+						}
+	 				}
+				}
+			}
+			
 		}
 		}
 		return getDataTable(list);
 		return getDataTable(list);
 	}
 	}