瀏覽代碼

双十一活动

zouxuan 2 年之前
父節點
當前提交
9f2abb0506

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupActivityDao.java

@@ -85,6 +85,8 @@ public interface VipGroupActivityDao extends BaseDAO<Integer, VipGroupActivity>
 	*/
     List<DoubleEleven2021ActivityDto> countOrganActivityStatis(@Param("organIdList") List<Integer> organIdList);
 
+    List<DoubleEleven2021ActivityDto> countOrgan2022ActivityStatis(@Param("organIdList") List<Integer> organIdList);
+
     /**
     * @description: 双十一活动统计
      * @param

+ 17 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupActivityServiceImpl.java

@@ -31,6 +31,7 @@ import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
@@ -292,7 +293,9 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 	@Override
 	public List<DoubleEleven2021Dto> organDoubleEleven2022Statis(OrganDoubleEleven2021StatisDto queryInfo) {
 		List<DoubleEleven2021Dto> doubleEleven2022Dtos = vipGroupActivityDao.countOrganDoubleEleven2022Statis(queryInfo.getOrganId());
-		return this.sumDoubleEleven(doubleEleven2022Dtos,queryInfo);
+		return this.sumDoubleEleven(doubleEleven2022Dtos,queryInfo,
+				vipGroupActivityDao::countOrgan2022ActivityStatis,
+				null);
 	}
 
 	@Override
@@ -313,20 +316,29 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 	@Override
     public List<DoubleEleven2021Dto> organDoubleEleven2021Statis(OrganDoubleEleven2021StatisDto statisDto) {
 		List<DoubleEleven2021Dto> doubleEleven2021Dtos = vipGroupActivityDao.countOrganDoubleEleven2021Statis(statisDto.getOrganId());
-		return this.sumDoubleEleven(doubleEleven2021Dtos,statisDto);
+		return this.sumDoubleEleven(doubleEleven2021Dtos,statisDto,
+				vipGroupActivityDao::countOrganActivityStatis,
+				vipGroupActivityDao::countOrganGiveMemberNum);
     }
 
-	private List<DoubleEleven2021Dto> sumDoubleEleven(List<DoubleEleven2021Dto> doubleEleven2021Dtos,OrganDoubleEleven2021StatisDto statisDto){
+	private List<DoubleEleven2021Dto> sumDoubleEleven(List<DoubleEleven2021Dto> doubleEleven2021Dtos,
+													  OrganDoubleEleven2021StatisDto statisDto,
+													  Function<List<Integer>,List<DoubleEleven2021ActivityDto>> funOne,
+													  Function<List<Integer>,List<Map<Long,Long>>> funTwo){
 		if(!CollectionUtils.isEmpty(doubleEleven2021Dtos)){
 			String order = statisDto.getOrder();
 			String sort = statisDto.getSort();
 			List<Integer> organIdList = doubleEleven2021Dtos.stream().map(e -> e.getOrganId()).collect(Collectors.toList());
-			List<DoubleEleven2021ActivityDto> activityDtoList = vipGroupActivityDao.countOrganActivityStatis(organIdList);
+
+			List<DoubleEleven2021ActivityDto> activityDtoList = funOne.apply(organIdList);;
 			Map<Integer, List<DoubleEleven2021ActivityDto>> collect = new HashMap<>();
 			if(activityDtoList != null && activityDtoList.size() > 0){
 				collect = activityDtoList.stream().collect(Collectors.groupingBy(DoubleEleven2021ActivityDto::getOrganId));
 			}
-			Map<Long, Long> maps = MapUtil.convertIntegerMap(vipGroupActivityDao.countOrganGiveMemberNum(organIdList));
+			Map<Long, Long> maps = new HashMap<>();
+			if(funTwo != null){
+				maps = MapUtil.convertIntegerMap(funTwo.apply(organIdList));
+			}
 			for (DoubleEleven2021Dto doubleEleven2021Dto : doubleEleven2021Dtos) {
 				if(doubleEleven2021Dto.getTotalBuyAmount().compareTo(ZERO) > 0){
 					doubleEleven2021Dto.setAvgBuyAmount(

+ 13 - 0
mec-biz/src/main/resources/config/mybatis/VipGroupActivityMapper.xml

@@ -458,6 +458,19 @@
 		</foreach>
 		GROUP BY spo.organ_id_,aum.activity_id_,aum.user_id_)c GROUP BY c.organ_id_,c.type_
 	</select>
+	<select id="countOrgan2022ActivityStatis" resultMap="DoubleEleven2021ActivityDto">
+		SELECT SUM(c.buy_amount_) buy_amount_,SUM(c.buy_num_) buy_num_,c.type_,c.organ_id_ FROM (
+		SELECT SUM(aum.actual_price_) buy_amount_,COUNT(DISTINCT aum.user_id_) buy_num_,vga.code_ type_,spo.organ_id_
+		FROM student_payment_order spo
+		LEFT JOIN activity_user_mapper aum ON spo.id_ = aum.payment_order_id_ AND spo.user_id_ = aum.user_id_
+		LEFT JOIN vip_group_activity vga ON vga.id_ = aum.activity_id_
+		WHERE spo.group_type_ = 'ACTIVITY' AND spo.type_ = 'SMALL_CLASS_TO_BUY' AND spo.status_ = 'SUCCESS' AND spo.memo_ = '2022双十一活动购买'
+		AND spo.organ_id_ IN
+		<foreach collection="organIdList" open="(" close=")" item="organId" separator=",">
+			#{organId}
+		</foreach>
+		GROUP BY spo.organ_id_,aum.activity_id_,aum.user_id_)c GROUP BY c.organ_id_,c.type_
+	</select>
 	<select id="countOrganDoubleEleven2021Statis" resultMap="DoubleEleven2021Dto">
 		SELECT SUM(spo.expect_amount_) total_buy_amount_,COUNT(DISTINCT spo.user_id_) total_buy_num_,o.name_ organ_name_,o.id_ organ_id_
 		FROM organization o