Browse Source

Merge branch 'mp-server-test' into 'master'

Mp server test

See merge request quanshu/mp-server!353
zhong chunping 3 years ago
parent
commit
0332c59fe1
23 changed files with 522 additions and 200 deletions
  1. 0 4
      mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/ChannelMgrController.java
  2. 57 57
      mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/IndexMgrController.java
  3. 38 15
      mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/SaleSiteMgrController.java
  4. 43 10
      mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/ChannelController.java
  5. 64 4
      mp-admin/src/main/java/com/qs/mp/web/controller/api/user/UserTicketController.java
  6. 10 3
      mp-admin/src/main/java/com/qs/mp/web/controller/api/user/UserTicketOrderController.java
  7. 1 0
      mp-framework/src/main/java/com/qs/mp/framework/config/SecurityConfig.java
  8. 2 2
      mp-service/src/main/java/com/qs/mp/admin/mapper/TicketMapper.java
  9. 2 2
      mp-service/src/main/java/com/qs/mp/admin/service/ITicketService.java
  10. 4 4
      mp-service/src/main/java/com/qs/mp/admin/service/impl/TicketServiceImpl.java
  11. 1 3
      mp-service/src/main/java/com/qs/mp/channel/domain/vo/ChannelVO.java
  12. 32 0
      mp-service/src/main/java/com/qs/mp/user/domain/vo/TicketHitPrizeBarrageVO.java
  13. 1 1
      mp-service/src/main/java/com/qs/mp/user/domain/vo/TicketOrderSettleVO.java
  14. 33 0
      mp-service/src/main/java/com/qs/mp/user/domain/vo/UserCoupon4OrderVO.java
  15. 20 0
      mp-service/src/main/java/com/qs/mp/user/mapper/UserHitPrizeMapper.java
  16. 15 0
      mp-service/src/main/java/com/qs/mp/user/mapper/UserTicketOrderMapper.java
  17. 16 0
      mp-service/src/main/java/com/qs/mp/user/service/IUserHitPrizeService.java
  18. 16 0
      mp-service/src/main/java/com/qs/mp/user/service/IUserTicketOrderService.java
  19. 95 80
      mp-service/src/main/java/com/qs/mp/user/service/impl/UserHitPrizeServiceImpl.java
  20. 18 4
      mp-service/src/main/java/com/qs/mp/user/service/impl/UserTicketOrderServiceImpl.java
  21. 2 6
      mp-service/src/main/resources/mapper/admin/TicketMapper.xml
  22. 26 0
      mp-service/src/main/resources/mapper/user/UserHitPrizeMapper.xml
  23. 26 5
      mp-service/src/main/resources/mapper/user/UserTicketOrderMapper.xml

+ 0 - 4
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/ChannelMgrController.java

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qs.mp.channel.domain.Channel;
-import com.qs.mp.channel.domain.ChannelOrder;
 import com.qs.mp.channel.domain.param.ChannelParam;
 import com.qs.mp.channel.domain.vo.ChannelOperDataVO;
 import com.qs.mp.channel.domain.vo.ChannelVO;
@@ -18,7 +17,6 @@ import com.qs.mp.common.core.page.TableDataInfo;
 import com.qs.mp.common.enums.BusinessType;
 import com.qs.mp.common.enums.ChannelRoleEnum;
 import com.qs.mp.common.enums.ErrorCodeEnum;
-import com.qs.mp.system.domain.SysUser;
 import com.qs.mp.system.service.ISysUserService;
 import com.qs.mp.user.service.IUserTicketOrderService;
 import com.qs.mp.web.controller.common.BaseApiController;
@@ -28,13 +26,11 @@ import ma.glasnost.orika.MapperFacade;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Component;

+ 57 - 57
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/IndexMgrController.java

@@ -62,14 +62,14 @@ public class IndexMgrController extends BaseApiController {
 		queryWrapper.ge(null != queryParam && null != queryParam.getStartTime(), "t1.created_time", queryParam.getStartTime());
 		queryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "t1.created_time", queryParam.getEndTime());
 		queryWrapper.gt("t1.`status`", 0);
-		Long channelId = SecurityUtils.getLoginUser().getChannelId();
-		if(null != channelId && 0 != channelId) {
-			Channel channel = channelService.getById(channelId);
-			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
-				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
-						.or().eq("t2.channel_no", channel.getChannelNo()));
-			}
-		}
+//		Long channelId = SecurityUtils.getLoginUser().getChannelId();
+//		if(null != channelId && 0 != channelId) {
+//			Channel channel = channelService.getById(channelId);
+//			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
+//				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
+//						.or().eq("t2.channel_no", channel.getChannelNo()));
+//			}
+//		}
 	
 		list = userTicketOrderService.selectIndexPayAmtList(queryWrapper);
 		return  AjaxResult.success(getPayAmtList(list, queryParam));
@@ -185,14 +185,14 @@ public class IndexMgrController extends BaseApiController {
 		queryWrapper.ge(null != queryParam && null != queryParam.getStartTime(), "t1.created_time", queryParam.getStartTime());
 		queryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "t1.created_time", queryParam.getEndTime());
 		queryWrapper.gt("t1.`status`", 0);
-		Long channelId = SecurityUtils.getLoginUser().getChannelId();
-		if(null != channelId && 0 != channelId) {
-			Channel channel = channelService.getById(channelId);
-			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
-				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
-						.or().eq("t2.channel_no", channel.getChannelNo()));
-			}
-		}
+//		Long channelId = SecurityUtils.getLoginUser().getChannelId();
+//		if(null != channelId && 0 != channelId) {
+//			Channel channel = channelService.getById(channelId);
+//			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
+//				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
+//						.or().eq("t2.channel_no", channel.getChannelNo()));
+//			}
+//		}
 	
 		list = userTicketOrderService.selectIndexPayUserCntList(queryWrapper);
 		return  AjaxResult.success(getPayUserList(list, queryParam));
@@ -333,14 +333,14 @@ public class IndexMgrController extends BaseApiController {
 		queryWrapper.ge(null != queryParam && null != queryParam.getStartTime(), "t1.created_time", queryParam.getStartTime());
 		queryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "t1.created_time", queryParam.getEndTime());
 		queryWrapper.eq("t1.`level`", 0);
-		Long channelId = SecurityUtils.getLoginUser().getChannelId();
-		if(null != channelId && 0 != channelId) {
-			Channel channel = channelService.getById(channelId);
-			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
-				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
-						.or().eq("t2.channel_no", channel.getChannelNo()));
-			}
-		}
+//		Long channelId = SecurityUtils.getLoginUser().getChannelId();
+//		if(null != channelId && 0 != channelId) {
+//			Channel channel = channelService.getById(channelId);
+//			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
+//				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
+//						.or().eq("t2.channel_no", channel.getChannelNo()));
+//			}
+//		}
 	
 		list = channelService.selectIndexSiteIncreaseList(queryWrapper);
 		return  AjaxResult.success(getSiteIncreaseList(list, queryParam));
@@ -468,17 +468,17 @@ public class IndexMgrController extends BaseApiController {
 		siteQueryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "t1.created_time", queryParam.getEndTime());
 		siteQueryWrapper.eq("t1.`level`", 0);
 		
-		Long channelId = SecurityUtils.getLoginUser().getChannelId();
-		if(null != channelId && 0 != channelId) {
-			Channel channel = channelService.getById(channelId);
-			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
-				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
-						.or().eq("t2.channel_no", channel.getChannelNo()));
-				
-				siteQueryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
-						.or().eq("t2.channel_no", channel.getChannelNo()));
-			}
-		}
+//		Long channelId = SecurityUtils.getLoginUser().getChannelId();
+//		if(null != channelId && 0 != channelId) {
+//			Channel channel = channelService.getById(channelId);
+//			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
+//				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
+//						.or().eq("t2.channel_no", channel.getChannelNo()));
+//				
+//				siteQueryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
+//						.or().eq("t2.channel_no", channel.getChannelNo()));
+//			}
+//		}
 	
 		list = userTicketOrderService.selectIndexDailyInfoList(queryWrapper);
 	
@@ -562,19 +562,19 @@ public class IndexMgrController extends BaseApiController {
 		IndexQueryParam queryParam = getQueryParam(indeQueryParam);
 		List<IndexVO> list = new ArrayList<IndexVO>();
 		QueryWrapper<UserTicketOrder> queryWrapper = new QueryWrapper<>();
-		queryWrapper.ge(null != queryParam && null != queryParam.getStartTime(), "DATE_FORMAT(t1.created_time, '%Y-%m-%d')", queryParam.getStartTime());
-		queryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "DATE_FORMAT(t1.created_time, '%Y-%m-%d')", queryParam.getEndTime());
+		queryWrapper.ge(null != queryParam && null != queryParam.getStartTime(), "t1.created_time", queryParam.getStartTime());
+		queryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "t1.created_time", queryParam.getEndTime());
 		queryWrapper.gt("t1.`status`", 0);
 		
-		Long channelId = SecurityUtils.getLoginUser().getChannelId();
-		if(null != channelId && 0 != channelId) {
-			Channel channel = channelService.getById(channelId);
-			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
-				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
-						.or().eq("t2.channel_no", channel.getChannelNo()));
-				
-			}
-		}
+//		Long channelId = SecurityUtils.getLoginUser().getChannelId();
+//		if(null != channelId && 0 != channelId) {
+//			Channel channel = channelService.getById(channelId);
+//			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
+//				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
+//						.or().eq("t2.channel_no", channel.getChannelNo()));
+//				
+//			}
+//		}
 	
 		list = userTicketOrderService.selectIndexTicketBoxTop(queryWrapper);
 		List<Map<String,Object>> mapList = new ArrayList<>();
@@ -605,19 +605,19 @@ public class IndexMgrController extends BaseApiController {
 		IndexQueryParam queryParam = getQueryParam(indeQueryParam);
 		List<IndexVO> list = new ArrayList<IndexVO>();
 		QueryWrapper<UserTicketOrder> queryWrapper = new QueryWrapper<>();
-		queryWrapper.ge(null != queryParam && null != queryParam.getStartTime(), "DATE_FORMAT(t1.created_time, '%Y-%m-%d')", queryParam.getStartTime());
-		queryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "DATE_FORMAT(t1.created_time, '%Y-%m-%d')", queryParam.getEndTime());
+		queryWrapper.ge(null != queryParam && null != queryParam.getStartTime(), "t1.created_time", queryParam.getStartTime());
+		queryWrapper.le(null != queryParam && null != queryParam.getEndTime(), "t1.created_time", queryParam.getEndTime());
 		queryWrapper.gt("t1.`status`", 0);
 		
-		Long channelId = SecurityUtils.getLoginUser().getChannelId();
-		if(null != channelId && 0 != channelId) {
-			Channel channel = channelService.getById(channelId);
-			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
-				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
-						.or().eq("t2.channel_no", channel.getChannelNo()));
-				
-			}
-		}
+//		Long channelId = SecurityUtils.getLoginUser().getChannelId();
+//		if(null != channelId && 0 != channelId) {
+//			Channel channel = channelService.getById(channelId);
+//			if(null!=channel && StringUtils.isNotBlank(channel.getChannelNo())) {
+//				queryWrapper.and(wrapper -> wrapper.likeRight("t2.channel_no", channel.getChannelNo())
+//						.or().eq("t2.channel_no", channel.getChannelNo()));
+//				
+//			}
+//		}
 	
 		list = userTicketOrderService.selectIndexTicketSiteTop(queryWrapper);
 		List<Map<String,Object>> mapList = new ArrayList<>();

+ 38 - 15
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/SaleSiteMgrController.java

@@ -113,11 +113,17 @@ public class SaleSiteMgrController extends BaseApiController {
  				}
 			}
 		}
-		List<TicketCntVO>  cntList = new ArrayList<TicketCntVO>();
+		List<TicketCntVO>  qtyCntList = new ArrayList<TicketCntVO>();
+		List<TicketCntVO>  saleCntList = 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);
+			QueryWrapper<ChannelOrderDetail> ticketQtyCntQueryWrapper = new QueryWrapper<ChannelOrderDetail>();
+			ticketQtyCntQueryWrapper.in("t1.channel_id", channelIds);
+			qtyCntList = ticketService.listTicketQtyCnt(ticketQtyCntQueryWrapper);
+			
+	    	QueryWrapper<UserTicketOrder> ticketSaleCntQueryWrapper = new QueryWrapper<UserTicketOrder>();
+	    	ticketSaleCntQueryWrapper.in("t1.channel_id", channelIds);
+	    	ticketSaleCntQueryWrapper.eq("t1.`status`", 1);
+	    	saleCntList = userTicketOrderService.listTicketSaleCnt(ticketSaleCntQueryWrapper);
 		}
 		
 		if(null != list && list.size() > 0) {
@@ -134,14 +140,21 @@ public class SaleSiteMgrController extends BaseApiController {
 					// channelVO.setSysUser(sysUser);
 					channelVO.setParentsName(getParentsName(channelVO.getChannelNo()));
 					// 统计盲票库存, 销量
-					if(null != cntList && cntList.size() > 0) {
-						List<TicketCntVO> voList =  cntList.stream().filter(item  -> item.getChannelId().equals(channelVO.getChannelId()))
+					if(null != qtyCntList && qtyCntList.size() > 0) {
+						List<TicketCntVO> voList =  qtyCntList.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);
+							TicketCntVO ticketQtyCnt =  voList.get(0);
+							channelVO.setOffLineQtyCnt(null != ticketQtyCnt?ticketQtyCnt.getOffLineQtyCnt():0);
+						}
+					}
+					if(null != saleCntList && saleCntList.size() > 0) {
+						List<TicketCntVO> voList =  saleCntList.stream().filter(item  -> item.getChannelId().equals(channelVO.getChannelId()))
+				                .collect(Collectors.toList());
+						if(null != voList && voList.size() > 0) {
+							TicketCntVO ticketSaleCnt =  voList.get(0);
+							channelVO.setOffLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOffLineSaleCnt():0);
+							channelVO.setOnLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOnLineSaleCnt():0);
 						}
 					}
  				}
@@ -375,16 +388,26 @@ public class SaleSiteMgrController extends BaseApiController {
 		}
 	    // 查询经销商销售额、佣金收入、订单数等
 	    ChannelOperDataVO channelOperDataVO = channelService.getChannelTotalOperData(channelVO.getChannelNo());
-		// LambdaQueryWrapper<ChannelOrder> queryWrapper = new LambdaQueryWrapper<ChannelOrder>();
-		// queryWrapper.eq(ChannelOrder::getChannelId, channelId);
-//		int orderCnt = channelOrderService.count(queryWrapper);
-//		channelOperDataVO.setOrderCnt(orderCnt);
 		
 		// 盲票销售张数
 		int ticketSaleCnt = userTicketOrderService.getSaleSiteTotalTicketNumCnt(channelVO.getChannelId());
 		channelOperDataVO.setTicketSaleCnt(ticketSaleCnt);
-		
 	    channelVO.setOperData(channelOperDataVO);
+	    
+        if(null != channelVO && null != channelVO.getChannelId()) {
+	    	LambdaQueryWrapper<ChannelUserRel> userCntQueryWrapper = new LambdaQueryWrapper<ChannelUserRel>();
+			userCntQueryWrapper.eq(ChannelUserRel::getChannelId, channelVO.getChannelId());
+			int userCnt = channelUserRelService.count(userCntQueryWrapper);
+			channelVO.setUserCnt(userCnt);
+	    	
+	    	int ticketQtyCnt = ticketService.getTicketQtyCnt(channelVO.getChannelId());
+	    	channelVO.setOffLineQtyCnt(ticketQtyCnt);
+	    	
+	    	TicketCntVO ticketCnt = userTicketOrderService.getTicketSaleCnt(channelVO.getChannelId());
+			channelVO.setOffLineSaleCnt(null != ticketCnt?ticketCnt.getOffLineSaleCnt():0);
+			channelVO.setOnLineSaleCnt(null != ticketCnt?ticketCnt.getOnLineSaleCnt():0);
+	    }
+	    
 		return AjaxResult.success(channelVO);
 	}
 

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

@@ -27,6 +27,8 @@ import com.qs.mp.common.enums.ErrorCodeEnum;
 import com.qs.mp.common.exception.ServiceException;
 import com.qs.mp.common.utils.DateUtils;
 import com.qs.mp.system.service.ISysUserService;
+import com.qs.mp.user.domain.UserTicketOrder;
+import com.qs.mp.user.service.IUserTicketOrderService;
 import com.qs.mp.utils.SecurityUtils;
 import com.qs.mp.web.controller.common.BaseApiController;
 import io.swagger.annotations.Api;
@@ -76,6 +78,9 @@ public class ChannelController extends BaseApiController {
     @Autowired
     private ISysUserService userService;
     
+	@Autowired
+	private IUserTicketOrderService userTicketOrderService;
+    
 	@Autowired
 	private ITicketService ticketService;
 
@@ -359,11 +364,17 @@ public class ChannelController extends BaseApiController {
 	 				}
 				}
 			}
-			List<TicketCntVO>  cntList = new ArrayList<TicketCntVO>();
+			List<TicketCntVO>  qtyCntList = new ArrayList<TicketCntVO>();
+			List<TicketCntVO>  saleCntList = 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);
+				QueryWrapper<ChannelOrderDetail> ticketQtyCntQueryWrapper = new QueryWrapper<ChannelOrderDetail>();
+				ticketQtyCntQueryWrapper.in("t1.channel_id", channelIds);
+				qtyCntList = ticketService.listTicketQtyCnt(ticketQtyCntQueryWrapper);
+				
+		    	QueryWrapper<UserTicketOrder> ticketSaleCntQueryWrapper = new QueryWrapper<UserTicketOrder>();
+		    	ticketSaleCntQueryWrapper.in("t1.channel_id", channelIds);
+		    	ticketSaleCntQueryWrapper.eq("t1.`status`", 1);
+		    	saleCntList = userTicketOrderService.listTicketSaleCnt(ticketSaleCntQueryWrapper);
 			}
 			
 			if(null != list && list.size() > 0) {
@@ -376,14 +387,21 @@ public class ChannelController extends BaseApiController {
 						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()))
+						if(null != qtyCntList && qtyCntList.size() > 0) {
+							List<TicketCntVO> voList =  qtyCntList.stream().filter(item  -> item.getChannelId().equals(channelVO.getChannelId()))
+					                .collect(Collectors.toList());
+							if(null != voList && voList.size() > 0) {
+								TicketCntVO ticketQtyCnt =  voList.get(0);
+								channelVO.setOffLineQtyCnt(null != ticketQtyCnt?ticketQtyCnt.getOffLineQtyCnt():0);
+							}
+						}
+						if(null != saleCntList && saleCntList.size() > 0) {
+							List<TicketCntVO> voList =  saleCntList.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);
+								TicketCntVO ticketSaleCnt =  voList.get(0);
+								channelVO.setOffLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOffLineSaleCnt():0);
+								channelVO.setOnLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOnLineSaleCnt():0);
 							}
 						}
 	 				}
@@ -418,6 +436,21 @@ public class ChannelController extends BaseApiController {
 	    // 查询今日的销售额、佣金收入、新增用户数
 	    ChannelOperDataVO channelOperDataVO = channelService.getChannelOperData(channelVO.getChannelNo(), 1);
 	    channelVO.setOperData(channelOperDataVO);
+	    if(null != channelVO && null != channelVO.getChannelId()) {
+	    	
+	    	LambdaQueryWrapper<ChannelUserRel> userCntQueryWrapper = new LambdaQueryWrapper<ChannelUserRel>();
+			userCntQueryWrapper.eq(ChannelUserRel::getChannelId, channelVO.getChannelId());
+			int userCnt = channelUserRelService.count(userCntQueryWrapper);
+			channelVO.setUserCnt(userCnt);
+	    	
+	    	int ticketQtyCnt = ticketService.getTicketQtyCnt(channelVO.getChannelId());
+	    	channelVO.setOffLineQtyCnt(ticketQtyCnt);
+	    	
+	    	TicketCntVO ticketSaleCnt = userTicketOrderService.getTicketSaleCnt(channelVO.getChannelId());
+			channelVO.setOffLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOffLineSaleCnt():0);
+			channelVO.setOnLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOnLineSaleCnt():0);
+	    }
+	   
 		return AjaxResult.success(channelVO);
 	}
 

+ 64 - 4
mp-admin/src/main/java/com/qs/mp/web/controller/api/user/UserTicketController.java

@@ -3,6 +3,7 @@ package com.qs.mp.web.controller.api.user;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.qs.mp.admin.domain.Ticket;
 import com.qs.mp.admin.domain.TicketAwardsPrize;
 import com.qs.mp.admin.domain.TicketBox;
@@ -25,21 +26,26 @@ import com.qs.mp.common.enums.TicketPkgStatusEnum;
 import com.qs.mp.common.enums.TicketStatusEnum;
 import com.qs.mp.common.utils.LogUtil;
 import com.qs.mp.common.utils.StringUtils;
+import com.qs.mp.framework.security.handle.HostHolder;
+import com.qs.mp.user.domain.UserHitPrize;
 import com.qs.mp.user.domain.UserTicketOrderItem;
+import com.qs.mp.user.domain.vo.TicketHitPrizeBarrageVO;
 import com.qs.mp.user.service.IUserHitPrizeService;
 import com.qs.mp.user.service.IUserTicketOrderItemService;
 import com.qs.mp.utils.SecurityUtils;
 import com.qs.mp.web.controller.common.BaseApiController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
 import lombok.AllArgsConstructor;
 import ma.glasnost.orika.MapperFacade;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 @RestController
@@ -70,6 +76,10 @@ public class UserTicketController extends BaseApiController {
   @Autowired
   private MapperFacade mapperFacade;
 
+
+  @Autowired
+  private HostHolder hostHolder;
+
   /**
    * 盲票进货列表
    */
@@ -231,4 +241,54 @@ public class UserTicketController extends BaseApiController {
     return AjaxResult.success();
   }
 
+  @GetMapping("/ticket/hitPrizeBarrage")
+  @ApiOperation(value = "中奖弹幕", notes = "获取最近中奖的 20-22 条信息")
+  public AjaxResult hitPrizeBarrage() {
+
+    // 获取用户 id
+    Long userId = 0L;
+
+    if (hostHolder.getUser() != null) {
+      userId = SecurityUtils.getLoginUser().getUserId();
+    }
+
+    // 弹幕列表
+    List<TicketHitPrizeBarrageVO> listOne = new ArrayList<>();
+    List<TicketHitPrizeBarrageVO> listTwo = new ArrayList<>();
+
+    // 获取用户当天中奖的 2 条弹幕
+    if (userId != 0L) {
+      List<TicketHitPrizeBarrageVO> ticketHitPrizeBarrageVOList = userHitPrizeService.hitPrizeBarrageByUserId(userId);
+      if (CollectionUtils.isNotEmpty(ticketHitPrizeBarrageVOList)) {
+        for (int i = 0; i < ticketHitPrizeBarrageVOList.size(); i++) {
+          if (i % 2 == 0) {
+            listOne.add(ticketHitPrizeBarrageVOList.get(i));
+          }else {
+            listTwo.add(ticketHitPrizeBarrageVOList.get(i));
+          }
+        }
+      }
+    }
+    // 获取除该用户外,最近中奖的 20 条弹幕信息
+    List<TicketHitPrizeBarrageVO> ticketHitPrizeBarrageVOList = userHitPrizeService.hitPrizeBarrage(userId);
+
+    for (int i = 0; i < ticketHitPrizeBarrageVOList.size(); i++) {
+      if (i % 2 == 0) {
+        listOne.add(ticketHitPrizeBarrageVOList.get(i));
+      }else {
+        listTwo.add(ticketHitPrizeBarrageVOList.get(i));
+      }
+    }
+    Map<String,List<TicketHitPrizeBarrageVO>> ticketHitPrizeBarrageMap = new HashMap<>();
+    ticketHitPrizeBarrageMap.put("listOne",listOne);
+    ticketHitPrizeBarrageMap.put("listTwo",listTwo);
+
+    return AjaxResult.success(ticketHitPrizeBarrageMap);
+  }
+
+
+
+
+
+
 }

+ 10 - 3
mp-admin/src/main/java/com/qs/mp/web/controller/api/user/UserTicketOrderController.java

@@ -26,6 +26,7 @@ import com.qs.mp.system.service.ISysUserService;
 import com.qs.mp.user.domain.UserTicketOrder;
 import com.qs.mp.user.domain.param.TicketOrderParam;
 import com.qs.mp.user.domain.vo.TicketOrderSettleVO;
+import com.qs.mp.user.domain.vo.UserCoupon4OrderVO;
 import com.qs.mp.user.domain.vo.UserCouponVO;
 import com.qs.mp.user.domain.vo.UserShareVO;
 import com.qs.mp.user.service.IUserCouponService;
@@ -115,12 +116,18 @@ public class UserTicketOrderController extends BaseApiController {
     if (param.getAutoCoupon() == 1) {
       List<UserCouponVO> userCouponVOList = userCouponService.queryUserCouponList(userId, orderAmt, ticketBox);
       if (!CollectionUtils.isEmpty(userCouponVOList)) {
-        orderSettleVO.getCouponList().add(userCouponVOList.get(0));
+        // 只考虑使用单张券
+        orderSettleVO.getCouponList().add(mapperFacade.map(userCouponVOList.get(0), UserCoupon4OrderVO.class));
         discountAmt = userCouponVOList.get(0).getDiscount();
       }
     } else if (!CollectionUtils.isEmpty(param.getUserCouponIds())){
       // 查询指定券
-      orderSettleVO.setCouponList(userCouponService.listTicketOrderCouponByIds(param.getUserCouponIds()));
+      List<UserCouponVO> userCouponVOList = userCouponService.listTicketOrderCouponByIds(param.getUserCouponIds());
+      if (!CollectionUtils.isEmpty(userCouponVOList)) {
+        // 只考虑使用单张券
+        orderSettleVO.getCouponList().add(mapperFacade.map(userCouponVOList.get(0), UserCoupon4OrderVO.class));
+        discountAmt = userCouponVOList.get(0).getDiscount();
+      }
     }
 
     orderSettleVO.setOrderAmt(orderAmt);
@@ -196,7 +203,7 @@ public class UserTicketOrderController extends BaseApiController {
   }
 
   /**
-   * 取消订单
+   * 可用优惠券列表
    */
   @PostMapping("/order/coupon/list")
   @ApiOperation(value = "取消订单" , notes = "在订单列表页面取消")

+ 1 - 0
mp-framework/src/main/java/com/qs/mp/framework/config/SecurityConfig.java

@@ -112,6 +112,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                     "/api/v1/mp/wx/urlschema/generate",
                     "/api/v1/mp/wx/code/generate",
                     "/api/v1/mp/user/ticket/queryLuckyNum",
+                    "/api/v1/mp/user/ticket/hitPrizeBarrage",
                     "/api/v1/mp/user/mall/ticket/detail",
                     "/api/v1/mp/user/mall/ticket/list",
                     "/api/v1/mp/user/exchange/goods/list",

+ 2 - 2
mp-service/src/main/java/com/qs/mp/admin/mapper/TicketMapper.java

@@ -25,12 +25,12 @@ public interface TicketMapper extends BaseMapper<Ticket> {
    * @param channelId
    * @return
    */
-  TicketCntVO getTicketCnt(@Param("channelId") Long channelId);
+  int getTicketQtyCnt(@Param("channelId") Long channelId);
   
   /**
    * 查询统计数据
    * @param queryWrapper
    * @return
    */
-  List<TicketCntVO> listTicketCnt(@Param(Constants.WRAPPER) Wrapper<ChannelOrderDetail> queryWrapper);
+  List<TicketCntVO> listTicketQtyCnt(@Param(Constants.WRAPPER) Wrapper<ChannelOrderDetail> queryWrapper);
 }

+ 2 - 2
mp-service/src/main/java/com/qs/mp/admin/service/ITicketService.java

@@ -49,12 +49,12 @@ public interface ITicketService extends IService<Ticket> {
    * @param channelId
    * @return
    */
-  TicketCntVO getTicketCnt(Long channelId);
+  int getTicketQtyCnt(Long channelId);
   
   /**
    * 查询统计数据
    * @param queryWrapper
    * @return
    */
-  List<TicketCntVO> listTicketCnt(Wrapper<ChannelOrderDetail> queryWrapper);
+  List<TicketCntVO> listTicketQtyCnt(Wrapper<ChannelOrderDetail> queryWrapper);
 }

+ 4 - 4
mp-service/src/main/java/com/qs/mp/admin/service/impl/TicketServiceImpl.java

@@ -80,13 +80,13 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
 	}
 
 	@Override
-	public TicketCntVO getTicketCnt(Long channelId) {
-		return getBaseMapper().getTicketCnt(channelId);
+	public int getTicketQtyCnt(Long channelId) {
+		return getBaseMapper().getTicketQtyCnt(channelId);
 	}
 
 	@Override
-	public List<TicketCntVO> listTicketCnt(Wrapper<ChannelOrderDetail> queryWrapper) {
-		return getBaseMapper().listTicketCnt(queryWrapper);
+	public List<TicketCntVO> listTicketQtyCnt(Wrapper<ChannelOrderDetail> queryWrapper) {
+		return getBaseMapper().listTicketQtyCnt(queryWrapper);
 	}
 	
 }

+ 1 - 3
mp-service/src/main/java/com/qs/mp/channel/domain/vo/ChannelVO.java

@@ -1,8 +1,6 @@
 package com.qs.mp.channel.domain.vo;
 
 import com.qs.mp.channel.domain.Channel;
-import com.qs.mp.system.domain.SysUser;
-
 import lombok.Data;
 
 /**
@@ -12,7 +10,7 @@ import lombok.Data;
 @Data
 public class ChannelVO extends Channel {
   long siteCnt;   // 经销网点数
-  long userCnt;   // 经销用户数
+  long userCnt;   // 用户数
   
   String parentName; // 上级渠道名称
   

+ 32 - 0
mp-service/src/main/java/com/qs/mp/user/domain/vo/TicketHitPrizeBarrageVO.java

@@ -0,0 +1,32 @@
+package com.qs.mp.user.domain.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.qs.mp.user.domain.UserDeliverOrderItem;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * 盲票中奖弹幕 VO
+ *
+ * @author Cup
+ * @date 2022/4/13
+ */
+@ApiModel("盲票中奖弹幕 VO")
+@Data
+public class TicketHitPrizeBarrageVO {
+
+    @ApiModelProperty("用户名")
+    private String nickName;
+
+    @ApiModelProperty("用户头像")
+    private String avatar;
+
+    @ApiModelProperty("奖品信息")
+    private String prizeInfo;
+
+
+}

+ 1 - 1
mp-service/src/main/java/com/qs/mp/user/domain/vo/TicketOrderSettleVO.java

@@ -54,6 +54,6 @@ public class TicketOrderSettleVO {
   /**
    * 使用优惠券列表
    */
-  List<UserCouponVO> couponList = new ArrayList<>();
+  List<UserCoupon4OrderVO> couponList = new ArrayList<>();
 
 }

+ 33 - 0
mp-service/src/main/java/com/qs/mp/user/domain/vo/UserCoupon4OrderVO.java

@@ -0,0 +1,33 @@
+package com.qs.mp.user.domain.vo;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.qs.mp.common.enums.CouponDiscountTypeEnum;
+import com.qs.mp.common.enums.CouponTypeEnum;
+import com.qs.mp.common.enums.CouponUseAreaEnum;
+import com.qs.mp.user.domain.UserCoupon;
+import lombok.Data;
+
+/**
+ * @describe 盲票购买时的优惠券
+ * @auther zhongcp
+ * @create 2022-03-07 20:45:43
+ */
+@Data
+public class UserCoupon4OrderVO {
+  private String id;
+
+  private String title;
+
+  /**
+   * 图片
+   */
+  private String picUrl;
+
+  /**
+   * 优惠金额(比例)
+   */
+  private Integer discount;
+
+
+}

+ 20 - 0
mp-service/src/main/java/com/qs/mp/user/mapper/UserHitPrizeMapper.java

@@ -2,6 +2,11 @@ package com.qs.mp.user.mapper;
 
 import com.qs.mp.user.domain.UserHitPrize;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qs.mp.user.domain.vo.TicketHitPrizeBarrageVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * @auther quanshu
@@ -10,4 +15,19 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface UserHitPrizeMapper extends BaseMapper<UserHitPrize> {
 
+    /**
+     * 获取除该用户外的近 20 条中奖弹幕
+     *
+     * @param userId 用户 id
+     * @return
+     */
+    List<TicketHitPrizeBarrageVO> selectTicketHitPrizeBarrageNotByUserId(@Param("userId") Long userId);
+
+    /**
+     * 获取用户当天中奖的 2 条弹幕
+     *
+     * @param userId
+     * @return
+     */
+    List<TicketHitPrizeBarrageVO> selectTicketHitPrizeBarrageByUserId(@Param("userId") Long userId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
 }

+ 15 - 0
mp-service/src/main/java/com/qs/mp/user/mapper/UserTicketOrderMapper.java

@@ -1,6 +1,7 @@
 package com.qs.mp.user.mapper;
 
 import com.qs.mp.admin.domain.vo.IndexVO;
+import com.qs.mp.admin.domain.vo.TicketCntVO;
 import com.qs.mp.user.domain.UserDeliverOrder;
 import com.qs.mp.user.domain.UserTicketOrder;
 
@@ -68,4 +69,18 @@ public interface UserTicketOrderMapper extends BaseMapper<UserTicketOrder> {
 	   */
 	  int getSaleSiteTotalTicketNumCnt(@Param("channelId") Long channelId);
 	  
+	  /**
+	    * 统计经销商盲票销量,线下和线上
+	    * @param channelId
+	    * @return
+	    */
+	   TicketCntVO getTicketSaleCnt(@Param("channelId") Long channelId);
+	   
+	   /**
+	    * 查询统计经销商盲票销量数据,线下和线上
+	    * @param queryWrapper
+	    * @return
+	    */
+	   List<TicketCntVO> listTicketSaleCnt(@Param(Constants.WRAPPER) Wrapper<UserTicketOrder> queryWrapper);
+	  
 }

+ 16 - 0
mp-service/src/main/java/com/qs/mp/user/service/IUserHitPrizeService.java

@@ -5,6 +5,8 @@ import com.qs.mp.admin.domain.TicketAwardsPrize;
 import com.qs.mp.admin.domain.vo.TicketAwardsPrizeVO;
 import com.qs.mp.user.domain.UserHitPrize;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qs.mp.user.domain.vo.TicketHitPrizeBarrageVO;
+
 import java.util.List;
 
 /**
@@ -30,4 +32,18 @@ public interface IUserHitPrizeService extends IService<UserHitPrize> {
    * @return
    */
   void cashPrize(Ticket ticket, Long userId, String awardsId, String prizeId);
+
+  /**
+   * 获取除该用户外的近 20 条中奖弹幕
+   * @param userId  用户 id
+   * @return
+   */
+  List<TicketHitPrizeBarrageVO> hitPrizeBarrage(Long userId);
+
+  /**
+   * 获取用户当天中奖的 2 条弹幕
+   * @param userId  用户 id
+   * @return
+   */
+  List<TicketHitPrizeBarrageVO> hitPrizeBarrageByUserId(Long userId);
 }

+ 16 - 0
mp-service/src/main/java/com/qs/mp/user/service/IUserTicketOrderService.java

@@ -1,6 +1,8 @@
 package com.qs.mp.user.service;
 
 import com.qs.mp.admin.domain.vo.IndexVO;
+import com.qs.mp.admin.domain.vo.TicketCntVO;
+import com.qs.mp.channel.domain.ChannelOrderDetail;
 import com.qs.mp.pay.domain.PayOrder;
 import com.qs.mp.user.domain.UserDeliverOrder;
 import com.qs.mp.user.domain.UserTicketOrder;
@@ -112,5 +114,19 @@ public interface IUserTicketOrderService extends IService<UserTicketOrder> {
   * @return
    */
    int getSaleSiteTotalTicketNumCnt(Long channelId);
+   
+   /**
+    * 统计经销商盲票销量线下和线上
+    * @param channelId
+    * @return
+    */
+   TicketCntVO getTicketSaleCnt(Long channelId);
+   
+   /**
+    * 查询统计经销商盲票销量数据线下和线上
+    * @param queryWrapper
+    * @return
+    */
+   List<TicketCntVO> listTicketSaleCnt(Wrapper<UserTicketOrder> queryWrapper);
   
 }

+ 95 - 80
mp-service/src/main/java/com/qs/mp/user/service/impl/UserHitPrizeServiceImpl.java

@@ -28,6 +28,7 @@ import com.qs.mp.user.domain.UserCouponChannel;
 import com.qs.mp.user.domain.UserHitPrize;
 import com.qs.mp.user.domain.UserPrizeStorage;
 import com.qs.mp.user.domain.UserTicketOrderItem;
+import com.qs.mp.user.domain.vo.TicketHitPrizeBarrageVO;
 import com.qs.mp.user.mapper.UserHitPrizeMapper;
 import com.qs.mp.user.service.IUserCoinService;
 import com.qs.mp.user.service.IUserCouponChannelService;
@@ -36,9 +37,13 @@ import com.qs.mp.user.service.IUserHitPrizeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qs.mp.user.service.IUserPrizeStorageService;
 import com.qs.mp.user.service.IUserTicketOrderItemService;
+
+import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+
 import org.codehaus.janino.IClass.IField;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,102 +64,112 @@ import org.springframework.util.CollectionUtils;
 @Service
 public class UserHitPrizeServiceImpl extends ServiceImpl<UserHitPrizeMapper, UserHitPrize> implements IUserHitPrizeService {
 
-  protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
 
-  @Autowired
-  private IUserTicketOrderItemService userTicketOrderItemService;
+    @Autowired
+    private IUserTicketOrderItemService userTicketOrderItemService;
 
-  @Autowired
-  private ITicketAwardsPrizeService ticketAwardsPrizeService;
+    @Autowired
+    private ITicketAwardsPrizeService ticketAwardsPrizeService;
 
-  @Autowired
-  private IUserPrizeStorageService userPrizeStorageService;
+    @Autowired
+    private IUserPrizeStorageService userPrizeStorageService;
 
-  @Autowired
-  private IUserCoinService userCoinService;
+    @Autowired
+    private IUserCoinService userCoinService;
 
-  @Autowired
-  private ICouponService couponService;
+    @Autowired
+    private ICouponService couponService;
 
-  @Autowired
-  private ITicketAwardsService ticketAwardsService;
+    @Autowired
+    private ITicketAwardsService ticketAwardsService;
 
-  @Autowired
-  private ITicketService ticketService;
+    @Autowired
+    private ITicketService ticketService;
 
-  @Autowired
-  private BizIdGenerator bizIdGenerator;
+    @Autowired
+    private BizIdGenerator bizIdGenerator;
 
-  @Override
-  public List<TicketAwardsPrize> listPrize(Ticket ticket, Long userId) {
-    UserHitPrize userHitPrize = getOne(new LambdaQueryWrapper<UserHitPrize>().eq(UserHitPrize::getTicketId, ticket.getTicketId()));
-    UserTicketOrderItem orderItem = userTicketOrderItemService.queryFinishedOrderItem(userId, ticket.getTicketId());
-    if (null == orderItem) {
-      LogUtil.error(logger, "查询盲票的奖品信息,盲票订单不存在。ticketId:{0}, userId:{1}",
-          new Object[]{ticket.getTicketId(), userId});
-      throw new ServiceException("盲票订单不存在");
-    }
+    @Override
+    public List<TicketAwardsPrize> listPrize(Ticket ticket, Long userId) {
+        UserHitPrize userHitPrize = getOne(new LambdaQueryWrapper<UserHitPrize>().eq(UserHitPrize::getTicketId, ticket.getTicketId()));
+        UserTicketOrderItem orderItem = userTicketOrderItemService.queryFinishedOrderItem(userId, ticket.getTicketId());
+        if (null == orderItem) {
+            LogUtil.error(logger, "查询盲票的奖品信息,盲票订单不存在。ticketId:{0}, userId:{1}",
+                    new Object[]{ticket.getTicketId(), userId});
+            throw new ServiceException("盲票订单不存在");
+        }
 
-    if (null == userHitPrize) {
-      List<TicketDrawNumDTO> drawNumDTOList = JSONObject.parseArray(ticket.getDrawNum(), TicketDrawNumDTO.class);
-      for (TicketDrawNumDTO ticketDrawNumDTO : drawNumDTOList) {
-        if (ticketDrawNumDTO.getNum() == ticket.getPlainLuckyNum()) {
-          userHitPrize = new UserHitPrize();
-          userHitPrize.setId(bizIdGenerator.newIdWithUidSharding(String.valueOf(userId)));
-          userHitPrize.setUserId(userId);
-          userHitPrize.setOrderId(orderItem.getOrderId());
-          userHitPrize.setOrderItemId(orderItem.getItemId());
-          userHitPrize.setTicketId(ticket.getTicketId());
-          TicketAwards ticketAwards = ticketAwardsService.getOne(new LambdaQueryWrapper<TicketAwards>()
-              .eq(TicketAwards::getBoxId, ticket.getBoxId()).eq(TicketAwards::getName, ticketDrawNumDTO.getName()));
-          userHitPrize.setAwardsId(ticketAwards.getAwardsId());
-          // 奖品ID等用户选择后填入
+        if (null == userHitPrize) {
+            List<TicketDrawNumDTO> drawNumDTOList = JSONObject.parseArray(ticket.getDrawNum(), TicketDrawNumDTO.class);
+            for (TicketDrawNumDTO ticketDrawNumDTO : drawNumDTOList) {
+                if (ticketDrawNumDTO.getNum() == ticket.getPlainLuckyNum()) {
+                    userHitPrize = new UserHitPrize();
+                    userHitPrize.setId(bizIdGenerator.newIdWithUidSharding(String.valueOf(userId)));
+                    userHitPrize.setUserId(userId);
+                    userHitPrize.setOrderId(orderItem.getOrderId());
+                    userHitPrize.setOrderItemId(orderItem.getItemId());
+                    userHitPrize.setTicketId(ticket.getTicketId());
+                    TicketAwards ticketAwards = ticketAwardsService.getOne(new LambdaQueryWrapper<TicketAwards>()
+                            .eq(TicketAwards::getBoxId, ticket.getBoxId()).eq(TicketAwards::getName, ticketDrawNumDTO.getName()));
+                    userHitPrize.setAwardsId(ticketAwards.getAwardsId());
+                    // 奖品ID等用户选择后填入
 //          userHitPrize.setPrizeId();
-          save(userHitPrize);
+                    save(userHitPrize);
+                }
+            }
         }
-      }
-    }
-    List<TicketAwardsPrize> awardsPrizes = ticketAwardsPrizeService.list(new LambdaQueryWrapper<TicketAwardsPrize>()
-        .eq(TicketAwardsPrize::getAwardsId, userHitPrize.getAwardsId()).orderByDesc(TicketAwardsPrize::getRemainQty));
-    return awardsPrizes;
-  }
-
-  @Override
-  @Transactional
-  public void cashPrize(Ticket ticket, Long userId, String awardsId, String prizeId) {
-    // 更新奖品已兑奖数量
-    TicketAwardsPrize ticketAwardsPrize = ticketAwardsPrizeService.getById(prizeId);
-    if (ticketAwardsPrize.getRemainQty() <= 0) {
-      throw new ServiceException("奖品已兑完,请重新选择");
-    }
-    // 乐观锁
-    ticketAwardsPrizeService.update(new LambdaUpdateWrapper<TicketAwardsPrize>().set(TicketAwardsPrize::getCashedQty, ticketAwardsPrize.getCashedQty() + 1)
-        .set(TicketAwardsPrize::getRemainQty, ticketAwardsPrize.getRemainQty() - 1)
-        .eq(TicketAwardsPrize::getPrizeId, prizeId).eq(TicketAwardsPrize::getCashedQty, ticketAwardsPrize.getCashedQty()));
-
-    // 保存奖品到中奖记录中
-    UserHitPrize userHitPrize = getOne(new LambdaQueryWrapper<UserHitPrize>().eq(UserHitPrize::getTicketId, ticket.getTicketId()));
-    if (StringUtils.isNotBlank(userHitPrize.getPrizeId())) {
-      throw new ServiceException("盲票已兑奖");
-    }
-    userHitPrize.setPrizeId(prizeId);
-    updateById(userHitPrize);
-
-    // 放入仓库
-    if (ticketAwardsPrize.getPrizeType() == TicketPrizeTypeEnum.COIN) {
-      userCoinService.produce(userId, ticketAwardsPrize.getValue(), userHitPrize.getId());
-    } else if (ticketAwardsPrize.getPrizeType() == TicketPrizeTypeEnum.COUPON) {
-      couponService.distribute(ticket, userId, ticketAwardsPrize.getRefId());
-    } else {
-      userPrizeStorageService.takeInStorage(userId, ticketAwardsPrize, PrizeStorageInTypeEnum.TICKET_CASHED, userHitPrize.getId());
+        List<TicketAwardsPrize> awardsPrizes = ticketAwardsPrizeService.list(new LambdaQueryWrapper<TicketAwardsPrize>()
+                .eq(TicketAwardsPrize::getAwardsId, userHitPrize.getAwardsId()).orderByDesc(TicketAwardsPrize::getRemainQty));
+        return awardsPrizes;
     }
 
-    boolean rtn = ticketService.update(new LambdaUpdateWrapper<Ticket>().set(Ticket::getStatus, TicketStatusEnum.CASHED)
-        .eq(Ticket::getTicketId, ticket.getTicketId()).eq(Ticket::getStatus, TicketStatusEnum.ACTIVATED));
-    Assert.isTrue(rtn, "兑奖后更新盲票状态失败。ticketId:" + ticket.getTicketId());
-  }
+    @Override
+    @Transactional
+    public void cashPrize(Ticket ticket, Long userId, String awardsId, String prizeId) {
+        // 更新奖品已兑奖数量
+        TicketAwardsPrize ticketAwardsPrize = ticketAwardsPrizeService.getById(prizeId);
+        if (ticketAwardsPrize.getRemainQty() <= 0) {
+            throw new ServiceException("奖品已兑完,请重新选择");
+        }
+        // 乐观锁
+        ticketAwardsPrizeService.update(new LambdaUpdateWrapper<TicketAwardsPrize>().set(TicketAwardsPrize::getCashedQty, ticketAwardsPrize.getCashedQty() + 1)
+                .set(TicketAwardsPrize::getRemainQty, ticketAwardsPrize.getRemainQty() - 1)
+                .eq(TicketAwardsPrize::getPrizeId, prizeId).eq(TicketAwardsPrize::getCashedQty, ticketAwardsPrize.getCashedQty()));
+
+        // 保存奖品到中奖记录中
+        UserHitPrize userHitPrize = getOne(new LambdaQueryWrapper<UserHitPrize>().eq(UserHitPrize::getTicketId, ticket.getTicketId()));
+        if (StringUtils.isNotBlank(userHitPrize.getPrizeId())) {
+            throw new ServiceException("盲票已兑奖");
+        }
+        userHitPrize.setPrizeId(prizeId);
+        updateById(userHitPrize);
+
+        // 放入仓库
+        if (ticketAwardsPrize.getPrizeType() == TicketPrizeTypeEnum.COIN) {
+            userCoinService.produce(userId, ticketAwardsPrize.getValue(), userHitPrize.getId());
+        } else if (ticketAwardsPrize.getPrizeType() == TicketPrizeTypeEnum.COUPON) {
+            couponService.distribute(ticket, userId, ticketAwardsPrize.getRefId());
+        } else {
+            userPrizeStorageService.takeInStorage(userId, ticketAwardsPrize, PrizeStorageInTypeEnum.TICKET_CASHED, userHitPrize.getId());
+        }
 
+        boolean rtn = ticketService.update(new LambdaUpdateWrapper<Ticket>().set(Ticket::getStatus, TicketStatusEnum.CASHED)
+                .eq(Ticket::getTicketId, ticket.getTicketId()).eq(Ticket::getStatus, TicketStatusEnum.ACTIVATED));
+        Assert.isTrue(rtn, "兑奖后更新盲票状态失败。ticketId:" + ticket.getTicketId());
+    }
 
 
+    @Override
+    public List<TicketHitPrizeBarrageVO> hitPrizeBarrage(Long userId) {
+        return this.getBaseMapper().selectTicketHitPrizeBarrageNotByUserId(userId);
+    }
+
+    @Override
+    public List<TicketHitPrizeBarrageVO> hitPrizeBarrageByUserId(Long userId) {
+        LocalDateTime startTime = LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MIN);
+        LocalDateTime endTime = LocalDateTime.now().withNano(0);
+        return this.getBaseMapper().selectTicketHitPrizeBarrageByUserId(userId, startTime, endTime);
+    }
 
 }

+ 18 - 4
mp-service/src/main/java/com/qs/mp/user/service/impl/UserTicketOrderServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qs.mp.admin.domain.Ticket;
 import com.qs.mp.admin.domain.TicketBox;
 import com.qs.mp.admin.domain.vo.IndexVO;
+import com.qs.mp.admin.domain.vo.TicketCntVO;
 import com.qs.mp.admin.service.ITicketBoxService;
 import com.qs.mp.admin.service.ITicketService;
 import com.qs.mp.channel.domain.Channel;
@@ -41,6 +42,7 @@ import com.qs.mp.user.domain.UserDeliverOrder;
 import com.qs.mp.user.domain.UserTicketOrder;
 import com.qs.mp.user.domain.UserTicketOrderItem;
 import com.qs.mp.user.domain.vo.TicketOrderSettleVO;
+import com.qs.mp.user.domain.vo.UserCoupon4OrderVO;
 import com.qs.mp.user.domain.vo.UserCouponVO;
 import com.qs.mp.user.domain.vo.UserShareVO;
 import com.qs.mp.user.mapper.UserTicketOrderMapper;
@@ -249,9 +251,9 @@ public class UserTicketOrderServiceImpl extends
     return ticketOrder.getOrderId();
   }
 
-  private String verifyUserCoupon(List<UserCouponVO> userCouponVOList) {
+  private String verifyUserCoupon(List<UserCoupon4OrderVO> userCouponVOList) {
     StringBuilder sb = new StringBuilder();
-    for (UserCouponVO userCouponVO : userCouponVOList) {
+    for (UserCoupon4OrderVO userCouponVO : userCouponVOList) {
       UserCoupon userCoupon = userCouponService.getById(userCouponVO.getId());
       userCoupon.setVerifyTime(new Date());
       userCoupon.setStatus(UserCouponStatusEnum.USED);
@@ -476,7 +478,7 @@ public class UserTicketOrderServiceImpl extends
 	public List<IndexVO> selectIndexPayAmtList(Wrapper<UserTicketOrder> wrapper) {
 		return getBaseMapper().selectIndexPayAmtList(wrapper);
 	}
-	
+
 	@Override
 	public List<IndexVO> selectIndexPayUserCntList(Wrapper<UserTicketOrder> wrapper) {
 		return getBaseMapper().selectIndexPayUserCntList(wrapper);
@@ -501,9 +503,21 @@ public class UserTicketOrderServiceImpl extends
 	public int getChannelTotalTicketNumCnt(String channelNo) {
 		return getBaseMapper().getChannelTotalTicketNumCnt(channelNo);
 	}
-	
+
 	@Override
 	public int getSaleSiteTotalTicketNumCnt(Long channelId) {
 		return getBaseMapper().getSaleSiteTotalTicketNumCnt(channelId);
 	}
+
+	@Override
+	public TicketCntVO getTicketSaleCnt(Long channelId) {
+		return getBaseMapper().getTicketSaleCnt(channelId);
+	}
+
+	@Override
+	public List<TicketCntVO> listTicketSaleCnt(Wrapper<UserTicketOrder> queryWrapper) {
+		return getBaseMapper().listTicketSaleCnt(queryWrapper);
+	}
+	
+	
 }

+ 2 - 6
mp-service/src/main/resources/mapper/admin/TicketMapper.xml

@@ -44,10 +44,8 @@
 
     </select>
     
-    <select id="getTicketCnt" resultType="com.qs.mp.admin.domain.vo.TicketCntVO">
+    <select id="getTicketQtyCnt" resultType="integer">
        select
-		 SUM( CASE WHEN (t2.`status` != 1 and t3.type = 'online') THEN 1 ELSE 0 END ) AS onLineSaleCnt,
-		 SUM( CASE WHEN (t2.`status` != 1 and t3.type = 'offline') THEN 1 ELSE 0 END ) AS offLineSaleCnt,
 		 SUM( CASE WHEN (t2.`status` = 1 and t3.type = 'offline') THEN 1 ELSE 0 END ) AS offLineQtyCnt
 		from mp_channel_order_detail t1
 		left join mp_ticket t2 on t1.pkg_id = t2.pkg_id
@@ -55,11 +53,9 @@
 		where t1.channel_id = #{channelId};
     </select>
     
-     <select id="listTicketCnt" resultType="com.qs.mp.admin.domain.vo.TicketCntVO">
+     <select id="listTicketQtyCnt" resultType="com.qs.mp.admin.domain.vo.TicketCntVO">
        select
          t1.channel_id channelId,
-		 SUM( CASE WHEN (t2.`status` != 1 and t3.type = 'online') THEN 1 ELSE 0 END ) AS onLineSaleCnt,
-		 SUM( CASE WHEN (t2.`status` != 1 and t3.type = 'offline') THEN 1 ELSE 0 END ) AS offLineSaleCnt,
 		 SUM( CASE WHEN (t2.`status` = 1 and t3.type = 'offline') THEN 1 ELSE 0 END ) AS offLineQtyCnt
 		from mp_channel_order_detail t1
 		left join mp_ticket t2 on t1.pkg_id = t2.pkg_id

+ 26 - 0
mp-service/src/main/resources/mapper/user/UserHitPrizeMapper.xml

@@ -20,4 +20,30 @@
         id, user_id, order_id, order_item_id, ticket_id, awards_id, prize_id, created_time, updated_time
     </sql>
 
+    <select id="selectTicketHitPrizeBarrageNotByUserId"
+            resultType="com.qs.mp.user.domain.vo.TicketHitPrizeBarrageVO">
+        SELECT su.nick_name nickName,
+                su.avatar avatar,
+                mtap.title prizeInfo
+        FROM mp_user_hit_prize muhp
+                 LEFT JOIN mp_ticket_awards_prize mtap ON muhp.prize_id = mtap.prize_id
+                 LEFT JOIN sys_user su ON muhp.user_id = su.user_id
+        WHERE muhp.prize_id != ''
+        AND muhp.user_id != #{userId}
+        AND ((mtap.prize_type = 'coin' AND mtap.quantity >= 100) OR mtap.prize_type='goods')
+        ORDER BY muhp.created_time DESC
+        LIMIT 20
+    </select>
+
+    <select id="selectTicketHitPrizeBarrageByUserId" resultType="com.qs.mp.user.domain.vo.TicketHitPrizeBarrageVO">
+        SELECT su.nick_name,su.avatar,mtap.title
+        FROM mp_user_hit_prize muhp
+                 LEFT JOIN mp_ticket_awards_prize mtap ON muhp.prize_id = mtap.prize_id
+                 LEFT JOIN sys_user su ON muhp.user_id = su.user_id
+        WHERE muhp.prize_id != ''
+          AND muhp.user_id = #{userId}
+          AND muhp.created_time BETWEEN	#{startTime} AND #{endTime}
+        ORDER BY muhp.created_time DESC
+        LIMIT 2
+    </select>
 </mapper>

+ 26 - 5
mp-service/src/main/resources/mapper/user/UserTicketOrderMapper.xml

@@ -35,7 +35,6 @@
           DATE_FORMAT(t1.created_time, '%Y%m%d') AS time,
           SUM(t1.pay_amt) AS payAmt
 	     from `mp_user_ticket_order` t1
-	left join mp_channel t2 on t1.channel_id = t2.channel_id
 		${ew.customSqlSegment}
 		GROUP BY time
 	</select>
@@ -46,7 +45,6 @@
           DATE_FORMAT(t1.created_time, '%Y%m%d') AS time,
           COUNT(DISTINCT t1.user_id) AS payUserCnt
 	     from `mp_user_ticket_order` t1
-	left join mp_channel t2 on t1.channel_id = t2.channel_id
 		${ew.customSqlSegment}
 		GROUP BY time
 	</select>
@@ -59,7 +57,6 @@
           SUM(IFNULL(t1.ticket_num,0)) AS 'ticketNum',
           COUNT(DISTINCT t1.user_id) AS payUserCnt
 	     from `mp_user_ticket_order` t1
-	left join mp_channel t2 on t1.channel_id = t2.channel_id
 		${ew.customSqlSegment}
 		GROUP BY time
 	</select>
@@ -73,11 +70,11 @@
           t1.box_id,
           SUM(t1.pay_amt) AS pay_amt
 	     from `mp_user_ticket_order` t1
-	left join mp_channel t2 on t1.channel_id = t2.channel_id
 		${ew.customSqlSegment}
 		GROUP BY t1.box_id
 		ORDER BY pay_amt DESC limit 10 ) a
 		left join mp_ticket_box b on a.box_id = b.box_id
+		ORDER BY payAmt DESC 
 	</select>
 	
 	<!-- 统计经销商交易额TOP10 -->
@@ -88,11 +85,11 @@
           t1.channel_id,
           SUM(t1.pay_amt) AS pay_amt
 	     from `mp_user_ticket_order` t1
-	left join mp_channel t2 on t1.channel_id = t2.channel_id
 		${ew.customSqlSegment}
 		GROUP BY t1.channel_id
 		ORDER BY pay_amt DESC limit 10 ) a
 		left join mp_channel b on a.channel_id = b.channel_id
+		ORDER BY payAmt DESC 
 	</select>
 	
 	 <!-- 查询子渠道全部的盲票销量 -->
@@ -110,5 +107,29 @@
 		from mp_user_ticket_order t1
 		where t1.`status` = 1 and t1.channel_id = #{channelId}
 	</select>
+	
+	
+	<!-- 查询经销商的线下、线上盲票销量 -->
+    <select id="getTicketSaleCnt" resultType="com.qs.mp.admin.domain.vo.TicketCntVO">
+		 select
+		 SUM( CASE WHEN (t2.type = 'online') THEN IFNULL(t1.ticket_num,0) ELSE 0 END ) AS onLineSaleCnt,
+		 SUM( CASE WHEN (t2.type = 'offline') THEN IFNULL(t1.ticket_num,0) ELSE 0 END ) AS offLineSaleCnt
+		from mp_user_ticket_order t1
+		left join mp_ticket_box t2 on t1.box_id = t2.box_id
+		where t1.channel_id = #{channelId} and t1.`status` = 1
+	</select>
+	
+	
+	<!-- 查询经销商的线下、线上盲票销量 -->
+    <select id="listTicketSaleCnt" resultType="com.qs.mp.admin.domain.vo.TicketCntVO">
+		 select
+		 t1.channel_id,
+		 SUM( CASE WHEN (t2.type = 'online') THEN IFNULL(t1.ticket_num,0) ELSE 0 END ) AS onLineSaleCnt,
+		 SUM( CASE WHEN (t2.type = 'offline') THEN IFNULL(t1.ticket_num,0) ELSE 0 END ) AS offLineSaleCnt
+		from mp_user_ticket_order t1
+		left join mp_ticket_box t2 on t1.box_id = t2.box_id
+		${ew.customSqlSegment}
+		GROUP BY t1.channel_id
+	</select>
     
 </mapper>