Kaynağa Gözat

Merge remote-tracking branch 'origin/dev' into dev

cup 3 yıl önce
ebeveyn
işleme
8694f2a3a6

+ 10 - 50
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/SaleSiteMgrController.java

@@ -68,13 +68,13 @@ public class SaleSiteMgrController extends BaseApiController {
 
 	@Autowired
 	private IChannelOrderService channelOrderService;
-	
+
 	@Autowired
 	private IUserTicketOrderService userTicketOrderService;
 
 	@Autowired
 	private ISysUserService userService;
-	
+
 	@Autowired
 	private ITicketService ticketService;
 
@@ -102,30 +102,8 @@ public class SaleSiteMgrController extends BaseApiController {
 		queryWrapper.eq(null != channel && null != channel.getProvinceId(), "t1.province_id", channel.getProvinceId());
 		queryWrapper.eq(null != channel && null != channel.getCityId(), "t1.city_id", channel.getCityId());
 		queryWrapper.eq(null != channel && null != channel.getAreaId(), "t1.area_id", channel.getAreaId());
-		queryWrapper.orderByDesc("t1.channel_id");
-		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>  qtyCntList = new ArrayList<TicketCntVO>();
-		List<TicketCntVO>  saleCntList = new ArrayList<TicketCntVO>();
-		if(null != channelIds && channelIds.size() > 0) {
-			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);
-		}
-		
+		list = channelService.selectSaleSiteList(queryWrapper);
+
 		if(null != list && list.size() > 0) {
 			for(ChannelVO channelVO : list) {
 				if(null != channelVO && null != channelVO.getChannelId()
@@ -139,30 +117,12 @@ public class SaleSiteMgrController extends BaseApiController {
 					//SysUser sysUser = userService.selectUserById(channelVO.getUserId());
 					// channelVO.setSysUser(sysUser);
 					channelVO.setParentsName(getParentsName(channelVO.getChannelNo()));
-					// 统计盲票库存, 销量
-					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 ticketSaleCnt =  voList.get(0);
-							channelVO.setOffLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOffLineSaleCnt():0);
-							channelVO.setOnLineSaleCnt(null != ticketSaleCnt?ticketSaleCnt.getOnLineSaleCnt():0);
-						}
-					}
  				}
 			}
 		}
 		return getDataTable(list);
 	}
-	
+
 	// 获取上级渠道迭代
 	private String getParentsName(String channelNo) {
 		if(StringUtils.isNotBlank(channelNo)) {
@@ -388,26 +348,26 @@ public class SaleSiteMgrController extends BaseApiController {
 		}
 	    // 查询经销商销售额、佣金收入、订单数等
 	    ChannelOperDataVO channelOperDataVO = channelService.getChannelTotalOperData(channelVO.getChannelNo());
-		
+
 		// 盲票销售张数
 		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);
 	}
 

+ 17 - 0
mp-admin/src/main/java/com/qs/mp/web/controller/api/user/UserMineController.java

@@ -35,6 +35,7 @@ import io.swagger.annotations.ApiResponses;
 import lombok.AllArgsConstructor;
 import ma.glasnost.orika.MapperFacade;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -108,6 +109,22 @@ public class UserMineController extends BaseApiController {
     return getDataTable(userCouponVOList);
   }
 
+  /**
+   * 优惠券详情
+   */
+  @PostMapping("/coupon/detail")
+  @ApiOperation(value = "优惠券详情", notes = "获取我的优惠券详情")
+  public AjaxResult getCouponInfo(@RequestBody UserCoupon param) {
+    Long userId = SecurityUtils.getLoginUser().getUserId();
+    List<UserCouponVO> userCouponVOList = userCouponService.listUserCouponVO(new QueryWrapper<UserCoupon>()
+        .eq("t1.id", param.getId())
+        .eq("t1.user_id", userId));
+    if (!CollectionUtils.isEmpty(userCouponVOList)) {
+      return AjaxResult.success(userCouponVOList.get(0));
+    }
+    return AjaxResult.error("优惠券不存在");
+  }
+
   /**
    * 我的盲豆
    */

+ 10 - 10
mp-service/src/main/java/com/qs/mp/channel/mapper/ChannelMapper.java

@@ -21,29 +21,29 @@ public interface ChannelMapper extends BaseMapper<Channel> {
 
 	/**
 	 * 获取我的下级渠道列表信息,支持翻页
-	 * 
-	 * @param channel
+	 *
+	 * @param wrapper
 	 * @return
 	 */
 	public List<ChannelVO> selectChannelVoList(@Param(Constants.WRAPPER) Wrapper<Channel> wrapper);
-	
+
 	/**
-	 * 根据ID查询渠道VO
+	 * 查询经销商列表
 	 *
-	 * @param userId
+	 * @param wrapper
 	 * @return
 	 */
-	public ChannelVO getChannelVoById(@Param("channelId") Long channelId);
-	
-	
+	public List<ChannelVO> selectSaleSiteList(@Param(Constants.WRAPPER) Wrapper<Channel> wrapper);
+
+
     /**
      * 查询渠道及其子渠道经销商总数
      * @param channelNo
      * @return
      */
     int getChannelSiteCnt(@Param("channelNo") String channelNo);
-    
-	
+
+
     /**
      * 统计新增的经销商数
      * @param wrapper

+ 12 - 4
mp-service/src/main/java/com/qs/mp/channel/service/IChannelService.java

@@ -43,13 +43,21 @@ public interface IChannelService extends IService<Channel> {
 
 
 	/**
-	 * 获取我的下级渠道、经销商列表信息,支持翻页
+	 * 获取我的下级渠道信息,支持翻页
 	 *
-	 * @param channel
+	 * @param queryWrapper
 	 * @return
 	 */
 	public List<ChannelVO> selectChannelVoList(Wrapper<Channel> queryWrapper);
 
+	/**
+	 * 获取经销商列表信息,支持翻页
+	 *
+	 * @param queryWrapper
+	 * @return
+	 */
+	public List<ChannelVO> selectSaleSiteList(Wrapper<Channel> queryWrapper);
+
 	/**
 	 * 根据用户ID查询渠道
 	 *
@@ -85,8 +93,8 @@ public interface IChannelService extends IService<Channel> {
 	 * 根据channelNo统计全部的经营数据
 	 */
 	public ChannelOperDataVO getChannelTotalOperData(String channelNo);
-	
-	
+
+
    /**
     * 统计新增的经销商数
     * @param wrapper

+ 15 - 4
mp-service/src/main/java/com/qs/mp/channel/service/impl/ChannelServiceImpl.java

@@ -2,6 +2,7 @@ package com.qs.mp.channel.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qs.mp.admin.domain.vo.IndexVO;
 import com.qs.mp.channel.domain.Channel;
@@ -24,6 +25,7 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 /**
  * <p>
@@ -122,6 +124,11 @@ public class ChannelServiceImpl extends ServiceImpl<ChannelMapper, Channel> impl
     return getBaseMapper().selectChannelVoList(queryWrapper);
   }
 
+  @Override
+  public List<ChannelVO> selectSaleSiteList(Wrapper<Channel> queryWrapper) {
+    return getBaseMapper().selectSaleSiteList(queryWrapper);
+  }
+
   @Override
   public Channel getChannelByUserId(Long userId) {
     return getBaseMapper().selectOne(
@@ -135,7 +142,11 @@ public class ChannelServiceImpl extends ServiceImpl<ChannelMapper, Channel> impl
 
   @Override
   public ChannelVO getChannelVoById(Long channelId) {
-    return getBaseMapper().getChannelVoById(channelId);
+    List<ChannelVO> channelVOList = getBaseMapper().selectChannelVoList(new QueryWrapper<Channel>().eq("t1.channel_id", channelId));
+    if (CollectionUtils.isEmpty(channelVOList)) {
+      return null;
+    }
+    return channelVOList.get(0);
   }
 
   @Override
@@ -164,11 +175,11 @@ public class ChannelServiceImpl extends ServiceImpl<ChannelMapper, Channel> impl
     // channelOperData.setNewUserCnt(newUserCnt);
     return channelOperData;
   }
-  
-  
+
+
   @Override
   public List<IndexVO> selectIndexSiteIncreaseList(Wrapper<Channel> wrapper) {
 	 return getBaseMapper().selectIndexSiteIncreaseList(wrapper);
   }
-  
+
 }

+ 35 - 0
mp-service/src/main/java/com/qs/mp/mq/impl/PulsarConsumerImpl.java

@@ -1,19 +1,28 @@
 package com.qs.mp.mq.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.qs.mp.admin.domain.Ticket;
 import com.qs.mp.admin.domain.TicketAwards;
 import com.qs.mp.admin.domain.TicketBox;
+import com.qs.mp.admin.domain.TicketPackage;
 import com.qs.mp.admin.service.ITicketBoxSerialService;
 import com.qs.mp.admin.service.ITicketBoxService;
+import com.qs.mp.admin.service.ITicketPackageService;
+import com.qs.mp.admin.service.ITicketService;
 import com.qs.mp.common.enums.CommStatusEnum;
 import com.qs.mp.common.enums.MqTopicType;
 import com.qs.mp.common.enums.TicketBoxStatusEnum;
+import com.qs.mp.common.enums.TicketPkgSaleStatusEnum;
 import com.qs.mp.common.enums.TicketTypeEnum;
 import com.qs.mp.common.enums.UserTicketOrderStatusEnum;
 import com.qs.mp.common.pulsar.PulsarConsumer;
 import com.qs.mp.common.utils.LogUtil;
 import com.qs.mp.user.domain.UserTicketOrder;
+import com.qs.mp.user.domain.UserTicketOrderItem;
+import com.qs.mp.user.service.IUserTicketOrderItemService;
 import com.qs.mp.user.service.IUserTicketOrderService;
+import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +46,15 @@ public class PulsarConsumerImpl implements PulsarConsumer {
   @Autowired
   private IUserTicketOrderService userTicketOrderService;
 
+  @Autowired
+  private IUserTicketOrderItemService userTicketOrderItemService;
+
+  @Autowired
+  private ITicketPackageService ticketPackageService;
+
+  @Autowired
+  private ITicketService ticketService;
+
   @Override
   @Async("threadPoolTaskExecutor")
   public void wsConsumer(String topicType, String mqData) {
@@ -62,6 +80,23 @@ public class PulsarConsumerImpl implements PulsarConsumer {
               .eq(TicketBox::getBoxId, ticketBox.getBoxId()));
     }
 
+
+    // 更新票组销售数量,此处只做累计,允许并发容错
+    List<UserTicketOrderItem> ticketOrderItemList = userTicketOrderItemService.list(new LambdaQueryWrapper<UserTicketOrderItem>()
+        .eq(UserTicketOrderItem::getOrderId, orderId));
+    for (UserTicketOrderItem orderItem : ticketOrderItemList) {
+      Ticket ticket = ticketService.getById(orderItem.getTicketId());
+      TicketPackage ticketPackage = ticketPackageService.getById(ticket.getPkgId());
+      ticketPackageService.update(new LambdaUpdateWrapper<TicketPackage>()
+          .set(TicketPkgSaleStatusEnum.WAIT_SALE == ticketPackage.getSaleStatus(),
+              TicketPackage::getSaleStatus, TicketPkgSaleStatusEnum.ON_SALE)
+          .set(TicketPkgSaleStatusEnum.ON_SALE == ticketPackage.getSaleStatus()
+                  && ticketPackage.getSaleQty() + 1 >= ticketPackage.getPkgUnit(),
+              TicketPackage::getSaleStatus, TicketPkgSaleStatusEnum.SALE_OUT)
+          .set(TicketPackage::getSaleQty, ticketPackage.getSaleQty() + 1)
+          .eq(TicketPackage::getPkgId, ticketPackage.getPkgId()));
+    }
+
     if (ticketOrder.getCommStatus() != CommStatusEnum.NO) {
       LogUtil.warn(logger, "收到盲票支付成功消息,订单结佣状态不是未结佣,忽略消息。orderId=" + orderId);
       return;

+ 0 - 8
mp-service/src/main/java/com/qs/mp/user/service/impl/UserTicketOrderServiceImpl.java

@@ -400,14 +400,6 @@ public class UserTicketOrderServiceImpl extends
               .eq(Ticket::getTicketId, ticket.getTicketId()));
       Assert.isTrue(rtn, "支付回调用户购票订单处理,更新盲票状态失败,ticketId:" + ticket.getTicketId());
 
-      // 更新票组销售数量,此处只做累计,允许并发容错
-      TicketPackage ticketPackage = ticketPackageService.getById(ticket.getPkgId());
-      ticketPackageService.update(new LambdaUpdateWrapper<TicketPackage>()
-          .set(TicketPkgSaleStatusEnum.WAIT_SALE == ticketPackage.getSaleStatus(), TicketPackage::getSaleStatus, TicketPkgSaleStatusEnum.ON_SALE)
-          .set(TicketPkgSaleStatusEnum.ON_SALE == ticketPackage.getSaleStatus() && ticketPackage.getSaleQty()+1 >= ticketPackage.getPkgUnit(), TicketPackage::getSaleStatus, TicketPkgSaleStatusEnum.SALE_OUT)
-          .set(TicketPackage::getSaleQty, ticketPackage.getSaleQty() + 1)
-          .eq(TicketPackage::getPkgId, ticketPackage.getPkgId()));
-
     }
 
     // 更新订单状态为已完成

+ 22 - 9
mp-service/src/main/resources/mapper/channel/ChannelMapper.xml

@@ -56,18 +56,31 @@
 		and (t1.channel_no like concat(#{channelNo}, '.%') or t1.channel_no = #{channelNo})
     </select>
 
-     <!-- 查询渠道信息 -->
-    <select id="getChannelVoById" resultType="com.qs.mp.channel.domain.vo.ChannelVO">
-		select t1.* , t2.name parentName
-		from mp_channel t1
-		left join mp_channel t2 on t1.parent_id = t2.channel_id
-		where t1.channel_id = #{channelId}
+     <!-- 查询经销商列表信息 -->
+    <select id="selectSaleSiteList" resultType="com.qs.mp.channel.domain.vo.ChannelVO">
+      select t1.channel_id as channelId, t1.channel_no, t1.name, t1.parent_id, t1.level, t1.site_type, t1.site_name, t1.comm_rate as commRate, t1.province, t1.province_id, t1.city, t1.city_id, t1.area, t1.area_id, t1.address, t1.contact, t1.mobile, t1.user_id, t1.certify_status, t1.verify_status, t1.status, t1.created_time, t1.updated_time , t2.offLineQtyCnt, t2.offLineSaleCnt, t4.saleQty-t2.offLineSaleCnt as onLineSaleCnt, t3.userCnt
+      from mp_channel t1
+             left join (
+        select channel_id, SUM(  b.pkg_unit - b.sale_qty ) AS offLineQtyCnt,
+               SUM(  b.sale_qty  ) AS offLineSaleCnt
+        from mp_channel_order_detail a
+               left join mp_ticket_package b on a.pkg_id=b.pkg_id
+        group by a.channel_id) t2 on t1.channel_id = t2.channel_id
+             left join (
+        select channel_id, count(*) AS userCnt
+        from mp_channel_user_rel
+        group by channel_id) t3 on t1.channel_id = t3.channel_id
+             left join (
+        select channel_id, count(*) AS saleQty
+        from mp_channel_commission
+        group by channel_id) t4 on t1.channel_id = t4.channel_id
+        ${ew.customSqlSegment}
 	</select>
-	
-	
+
+
 	<!-- 统计新增经销商数列表 -->
     <select id="selectIndexSiteIncreaseList" resultType="com.qs.mp.admin.domain.vo.IndexVO">
-		select 
+		select
           DATE_FORMAT(t1.created_time, '%Y%m%d') AS time,
           COUNT(t1.channel_id) AS newSiteCnt
 	     from `mp_channel` t1