Browse Source

1.双11统计

yuanliang 1 year ago
parent
commit
af7b728954

+ 251 - 0
mec-application/src/main/java/com/ym/mec/web/controller/open/OpenDouble11StaticsController.java

@@ -0,0 +1,251 @@
+package com.ym.mec.web.controller.open;
+
+import com.alibaba.fastjson.JSON;
+import com.alipay.api.domain.BizActionComsumedAmountDTO;
+import com.microsvc.toolkit.common.response.template.R;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.entity.Organization;
+import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.wrapper.Double11StaticWrapper;
+import com.ym.mec.biz.service.OrganizationService;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.util.collection.MapUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * @author 袁亮
+ * @apiNote 2023双11销售统计
+ */
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("${app-config.url.web:}/open/double11Statics")
+@Api(tags = "2023双11统计")
+public class OpenDouble11StaticsController extends BaseController {
+
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+
+    @Autowired
+    private OrganizationService organizationService;
+
+    @Autowired
+    private SysConfigService sysConfigService;
+
+
+    @ApiOperation(value = "2023双11销售统计", notes = "2023双11销售统计")
+    @PostMapping("/saleStatics")
+    public R<Double11StaticWrapper.SaleStatics> saleStatics() {
+        Double11StaticWrapper.SaleStaticsQuery query = new Double11StaticWrapper.SaleStaticsQuery();
+
+        SysConfig config = sysConfigService.findByParamName("2023_double_eleven_active_config");
+        Double11StaticWrapper.SaleStaticConfigParam configParam =
+                JSON.parseObject(config.getParanValue(), Double11StaticWrapper.SaleStaticConfigParam.class);
+
+        Double11StaticWrapper.SaleStatics result = new Double11StaticWrapper.SaleStatics();
+        // 1V1
+        query.setSaleStaticsType(1);
+        setQueryParam(query, configParam);
+        Double11StaticWrapper.SaleAmountAndUser s1v1 = studentPaymentOrderDao.saleStatics(query);
+        result.setTotalSale1V1(s1v1.getSaleAmount());
+        result.setTotalUser1V1PurchaseNumber(s1v1.getUserPurchaseNumber());
+
+        // 1v12
+        query.setSaleStaticsType(2);
+        setQueryParam(query, configParam);
+        Double11StaticWrapper.SaleAmountAndUser s1v2 = studentPaymentOrderDao.saleStatics(query);
+        result.setTotalSale1V2(s1v2.getSaleAmount());
+        result.setTotalUser1V2PurchaseNumber(s1v2.getUserPurchaseNumber());
+
+        // 乐理直播
+        query.setSaleStaticsType(3);
+        setQueryParam(query, configParam);
+        Double11StaticWrapper.SaleAmountAndUser theory = studentPaymentOrderDao.saleStatics(query);
+        result.setTotalSaleTheory(theory.getSaleAmount());
+        result.setTotalUserTheoryPurchaseNumber(theory.getUserPurchaseNumber());
+
+        // 云教练
+        query.setSaleStaticsType(4);
+        setQueryParam(query, configParam);
+        Double11StaticWrapper.SaleAmountAndUser cloudTeacher = studentPaymentOrderDao.saleStatics(query);
+        result.setTotalSaleCloudTeacher(cloudTeacher.getSaleAmount());
+        result.setTotalUserCloudTeacherPurchaseNumber(cloudTeacher.getUserPurchaseNumber());
+
+        // 乐器
+        query.setSaleStaticsType(5);
+        setQueryParam(query, configParam);
+        Double11StaticWrapper.SaleAmountAndUser good = studentPaymentOrderDao.musicalSaleStatics(query);
+        result.setTotalSaleMusical(good.getSaleAmount());
+        result.setTotalUserMusicalPurchaseNumber(good.getUserPurchaseNumber());
+
+        // 保价卡
+        query.setSaleStaticsType(6);
+        setQueryParam(query, configParam);
+        Double11StaticWrapper.SaleAmountAndUser sporadic = studentPaymentOrderDao.saleStatics(query);
+        result.setTotalSaleMaintenance(sporadic.getSaleAmount());
+        result.setTotalUserMaintenancePurchaseNumber(sporadic.getUserPurchaseNumber());
+
+        BigDecimal totalAmount = result.getTotalSale1V1()
+                .add(result.getTotalSale1V2())
+                .add(result.getTotalSaleMaintenance())
+                .add(result.getTotalSaleMusical())
+                .add(result.getTotalSaleTheory())
+                .add(result.getTotalSaleCloudTeacher());
+        result.setTotalSaleAmount(totalAmount);
+        return R.from(result);
+    }
+
+    @ApiOperation(value = "2023双11销售统计详情", notes = "2023双11销售统计详情")
+    @GetMapping("/saleStaticsDetail")
+    public R<List<Double11StaticWrapper.SaleAmountAndUser>> saleStaticsDetail(Double11StaticWrapper.SaleStaticsQuery query) {
+
+
+        SysConfig config = sysConfigService.findByParamName("2023_double_eleven_active_config");
+        Double11StaticWrapper.SaleStaticConfigParam configParam =
+                JSON.parseObject(config.getParanValue(), Double11StaticWrapper.SaleStaticConfigParam.class);
+        setQueryParam(query, configParam);
+
+
+        List<Organization> allOrgans = organizationService.findAllOrgans(query.getTenantId());
+        Map<Integer, String> orgIdNameMap = allOrgans.stream()
+                .collect(Collectors.toMap(Organization::getId, Organization::getName));
+        List<Double11StaticWrapper.SaleAmountAndUser> result = studentPaymentOrderDao.saleStaticsByOrgId(query);
+        result.forEach(next -> next.setOrganName(orgIdNameMap.getOrDefault(next.getOrganId(), "")));
+
+        String orderBy = Optional.ofNullable(query.getOrderBy()).orElse("saleAmount");
+        int asc = Optional.ofNullable(query.getAsc()).orElse(0);
+        if ("saleAmount".equals(orderBy)) {
+            result.sort((o1, o2) -> {
+                if (0 == asc) {
+                    return o1.getSaleAmount().compareTo(o2.getSaleAmount());
+                } else {
+                    return o2.getSaleAmount().compareTo(o1.getSaleAmount());
+                }
+            });
+        } else if ("userCount".equals(orderBy)) {
+            result.sort((o1, o2) -> {
+                if (0 == asc) {
+                    return o1.getUserPurchaseNumber().compareTo(o2.getUserPurchaseNumber());
+                } else {
+                    return o2.getUserPurchaseNumber().compareTo(o1.getUserPurchaseNumber());
+                }
+            });
+        }
+
+        Double11StaticWrapper.SaleAmountAndUser total = new Double11StaticWrapper.SaleAmountAndUser();
+        total.setOrganName("总部");
+        double acAmount = result.stream().map(Double11StaticWrapper.SaleAmountAndUser::getActualAmount)
+                .mapToDouble(BigDecimal::doubleValue).sum();
+        total.setActualAmount(new BigDecimal(acAmount));
+        double baAmount = result.stream().map(Double11StaticWrapper.SaleAmountAndUser::getBalancePaymentAmount)
+                .mapToDouble(BigDecimal::doubleValue).sum();
+        total.setBalancePaymentAmount(new BigDecimal(baAmount));
+        int totalUser = result.stream().map(Double11StaticWrapper.SaleAmountAndUser::getUserPurchaseNumber)
+                .mapToInt(Integer::intValue).sum();
+        total.setUserPurchaseNumber(totalUser);
+
+        result.add(0, total);
+        return R.from(result);
+    }
+
+    @ApiOperation(value = "2023双11销售统计详情", notes = "2023双11销售统计详情")
+    @GetMapping("/queryStudentPaymentOrder")
+    public R<PageInfo<Double11StaticWrapper.SaleStaticsStudent>> queryStudentPaymentOrder(Double11StaticWrapper.SaleStaticsStudentQuery query) {
+        Double11StaticWrapper.SaleStaticsQuery temp = new Double11StaticWrapper.SaleStaticsQuery();
+        SysConfig config = sysConfigService.findByParamName("2023_double_eleven_active_config");
+        Double11StaticWrapper.SaleStaticConfigParam configParam =
+                JSON.parseObject(config.getParanValue(), Double11StaticWrapper.SaleStaticConfigParam.class);
+        setQueryParam(temp, configParam);
+        Map<String, Object> tempMap = new HashMap<>();
+        MapUtil.populateMap(tempMap, temp);
+
+        query.setOrderBy("t.pay_time_");
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, query);
+        params.putAll(tempMap);
+        PageInfo<Double11StaticWrapper.SaleStaticsStudent> pageInfo = new PageInfo<>(query.getPage(), query.getRows());
+        List<Double11StaticWrapper.SaleStaticsStudent> dataList = new ArrayList<>();
+        Integer count = studentPaymentOrderDao.queryPaymentStudentCount(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = studentPaymentOrderDao.queryPaymentStudentByPage(params);
+        }
+        pageInfo.setRows(dataList);
+        return R.from(pageInfo);
+    }
+
+    private void setQueryParam(Double11StaticWrapper.SaleStaticsQuery query,
+                               Double11StaticWrapper.SaleStaticConfigParam configParam) {
+
+        Integer saleStaticsType = query.getSaleStaticsType();
+        query.setGroupType(null);
+        query.setType(null);
+        query.setActivityId(null);
+        query.setGoodId(null);
+        query.setMusicGroupId(null);
+        query.setTenantId(Optional.ofNullable(configParam.getTenantId()).orElse(1));
+
+        if (saleStaticsType == 1) {
+            // 1V1
+            query.setGroupType(GroupType.VIP);
+            query.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
+            query.setActivityId(configParam.getV1());
+        } else if (saleStaticsType == 2) {
+            // 乐理
+            query.setGroupType(GroupType.LIVE);
+            query.setType(OrderTypeEnum.LIVE_BUY);
+            query.setActivityId(configParam.getV2());
+        } else if (saleStaticsType == 3) {
+            // 乐理
+            query.setGroupType(GroupType.LIVE);
+            query.setType(OrderTypeEnum.LIVE_BUY);
+            query.setActivityId(configParam.getTheoryLive());
+        } else if (saleStaticsType == 4) {
+            // 云教练
+            query.setGroupType(GroupType.MEMBER);
+            query.setType(OrderTypeEnum.MEMBER);
+            query.setActivityId(configParam.getCloudTeacher());
+        } else if (saleStaticsType == 5) {
+            // 乐器销售
+            Map<String, Long> musical = configParam.getMusical();
+            if (musical != null) {
+                Collection<String> values = musical.values().stream().map(String::valueOf).collect(Collectors.toList());
+                query.setGoodId(String.join(",", values));
+            }
+            query.setStartPayTime(Optional.ofNullable(configParam.getStartPayTime()).orElse(new SimpleDateFormat(
+                    "yyyy-MM-dd HH:mm:ss").parse("2023-11-11 00:00:00", new ParsePosition(0))));
+            query.setEndPayTime(Optional.ofNullable(configParam.getEndPayTime()).orElse(new SimpleDateFormat(
+                    "yyyy-MM-dd HH:mm:ss").parse("2023-11-11 23:59:59", new ParsePosition(0))));
+        } else if (saleStaticsType == 6) {
+            // 保价卡销售
+            query.setGroupType(GroupType.SPORADIC);
+            query.setType(OrderTypeEnum.SPORADIC);
+            query.setMusicGroupId(configParam.getSporadic());
+        }
+    }
+
+}

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dao;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.microsvc.toolkit.common.response.template.R;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
@@ -9,6 +10,7 @@ import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.vo.StudentPaymentOrderVo;
+import com.ym.mec.biz.dal.wrapper.Double11StaticWrapper;
 import com.ym.mec.common.dal.BaseDAO;
 
 import org.apache.ibatis.annotations.Param;
@@ -466,4 +468,14 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
     List<BaseMapDto<Long, BigDecimal>> groupSellOrder(Map<String, Object> params);
 
     List<StudentPaymentOrder> queryVipQuitOrder(@Param("vipGroupId") Long vipGroupId, @Param("orderTypeEnum") OrderTypeEnum orderTypeEnum, @Param("success") DealStatusEnum success);
+
+    Double11StaticWrapper.SaleAmountAndUser saleStatics(@Param("param") Double11StaticWrapper.SaleStaticsQuery query);
+
+    Double11StaticWrapper.SaleAmountAndUser musicalSaleStatics(@Param("param") Double11StaticWrapper.SaleStaticsQuery query);
+
+    List<Double11StaticWrapper.SaleAmountAndUser> saleStaticsByOrgId(@Param("param") Double11StaticWrapper.SaleStaticsQuery query);
+
+    List<Double11StaticWrapper.SaleStaticsStudent> queryPaymentStudentByPage(Map<String, Object> params);
+
+    Integer queryPaymentStudentCount(@Param("param") Map<String, Object> params);
 }

+ 220 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/Double11StaticWrapper.java

@@ -0,0 +1,220 @@
+package com.ym.mec.biz.dal.wrapper;
+
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Map;
+import java.util.Optional;
+
+@Data
+public class Double11StaticWrapper {
+
+    @ApiModel("2023销售统计查询参数")
+    @Data
+    public static class SaleStaticsQuery {
+
+        @ApiModelProperty("分部")
+        private Long organId;
+
+        @ApiModelProperty("统计类型,0:汇总,1:1V1,2:1v2,3:乐理,4:云教练,5:乐器销售,6:报价卡")
+        @NotNull
+        private Integer saleStaticsType = 0;
+
+        @ApiModelProperty("排序字段,saleAmount:销售金额,userCount:人数")
+        @Pattern(regexp = "saleAmount|userCount", message = "不支持的类型")
+        private String orderBy;
+
+        @ApiModelProperty("1:升序 0:降序")
+        private Integer asc = 0;
+
+        @ApiModelProperty(hidden = true)
+        private Integer tenantId;
+
+        @ApiModelProperty(hidden = true)
+        private GroupType groupType;
+
+        @ApiModelProperty(hidden = true)
+        private OrderTypeEnum type;
+
+        @ApiModelProperty(hidden = true)
+        private String activityId;
+
+        @ApiModelProperty(hidden = true)
+        private String musicGroupId;
+
+        @ApiModelProperty(hidden = true)
+        private String goodId;
+
+        @ApiModelProperty(hidden = true)
+        private Date startPayTime;
+
+        @ApiModelProperty(hidden = true)
+        private Date endPayTime;
+
+    }
+
+    @ApiModel("分部学生购买")
+    @Data
+    public static class SaleStaticsStudentQuery implements QueryInfo {
+
+        @ApiModelProperty("分部")
+        private Long organId;
+
+        @ApiModelProperty("学生姓名")
+        private String userName;
+
+        @ApiModelProperty("统计类型,1:1V1,2:1v2,3:乐理,4:云教练,5:乐器销售,6:报价卡")
+        private Integer saleType = 1;
+
+        @ApiModelProperty("默认为时间")
+        private String orderBy;
+
+        @ApiModelProperty("1:升序,0:降序")
+        private Integer asc = 0;
+
+        @ApiModelProperty(hidden = true)
+        private Long tenantId;
+
+        @ApiModelProperty(hidden = true)
+        private GroupType groupType;
+
+        @ApiModelProperty(hidden = true)
+        private OrderTypeEnum type;
+
+        @ApiModelProperty(hidden = true)
+        private String activityId;
+
+        @ApiModelProperty(hidden = true)
+        private String musicGroupId;
+
+        @ApiModelProperty(hidden = true)
+        private String goodId;
+    }
+
+    @Data
+    public static class SaleStaticsStudent {
+
+        @ApiModelProperty("分部")
+        private Long organId;
+
+        private String organName;
+
+        private String userName;
+
+        private String phone;
+
+        private Date payTime;
+
+        private BigDecimal payAmount;
+
+    }
+
+
+    @ApiModel(value = "销售额")
+    @Data
+    public static class SaleStatics {
+
+        @ApiModelProperty("总销售额")
+        private BigDecimal totalSaleAmount;
+
+        @ApiModelProperty("1V1销售额")
+        private BigDecimal totalSale1V1;
+
+        @ApiModelProperty("1V1销售购买人数")
+        private Integer totalUser1V1PurchaseNumber;
+
+        @ApiModelProperty("1V2销售额")
+        private BigDecimal totalSale1V2;
+
+        @ApiModelProperty("1V2销售购买人数")
+        private Integer totalUser1V2PurchaseNumber;
+
+        @ApiModelProperty("乐理销售额")
+        private BigDecimal totalSaleTheory;
+
+        @ApiModelProperty("乐理销售购买人数")
+        private Integer totalUserTheoryPurchaseNumber;
+
+        @ApiModelProperty("云教练销售额")
+        private BigDecimal totalSaleCloudTeacher;
+
+        @ApiModelProperty("云教练销售购买人数")
+        private Integer totalUserCloudTeacherPurchaseNumber;
+
+        @ApiModelProperty("乐器销售额")
+        private BigDecimal totalSaleMusical;
+
+        @ApiModelProperty("乐器销售购买人数")
+        private Integer totalUserMusicalPurchaseNumber;
+
+        @ApiModelProperty("保价卡销售额")
+        private BigDecimal totalSaleMaintenance;
+
+        @ApiModelProperty("保价卡销售购买人数")
+        private Integer totalUserMaintenancePurchaseNumber;
+
+        @ApiModelProperty("分部ID")
+        private Long orgId;
+
+        @ApiModelProperty("分部名称")
+        private Long orgName;
+
+    }
+
+    @ApiModel("分部统计详情")
+    @Data
+    public static class SaleAmountAndUser {
+
+        @ApiModelProperty("分部")
+        private Integer organId;
+
+        @ApiModelProperty("分部")
+        private String organName;
+
+        @ApiModelProperty("总销售额")
+        private BigDecimal saleAmount;
+
+        @ApiModelProperty("购买人数")
+        private Integer userPurchaseNumber;
+
+        @ApiModelProperty(hidden = true)
+        private BigDecimal actualAmount;
+
+        @ApiModelProperty(hidden = true)
+        private BigDecimal balancePaymentAmount;
+
+        public BigDecimal getSaleAmount() {
+            BigDecimal a = Optional.ofNullable(actualAmount).orElse(new BigDecimal(0));
+            BigDecimal b = Optional.ofNullable(balancePaymentAmount).orElse(new BigDecimal(0));
+            return (a.add(b));
+        }
+    }
+
+    @Data
+    public static class SaleStaticConfigParam {
+        // {"1v1":680,"1v2":"930","theoryLive":"778,776,775","cloudTeacher":"11160","musical":{"flute":10,
+        // "clarinet":"9","altoSaxophone":"8","trumpet":"7","trombone":"6","upperTuba":"5"},"sporadic":680}
+        private String v1;
+        private String v2;
+        private String theoryLive;
+        private String cloudTeacher;
+        // 保价卡
+        private String sporadic;
+
+        private Map<String,Long> musical;
+
+        private Integer tenantId;
+
+        private Date startPayTime;
+
+        private Date endPayTime;
+    }
+}

+ 136 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -1238,5 +1238,141 @@
         AND spo.status_ = 'SUCCESS'  AND spo.class_group_id_ = cgsm.class_group_id_ and spo.music_group_id_ = cgsm.music_group_id_
     </select>
 
+    <select id="saleStatics" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
+        SELECT
+        SUM(actual_amount_) AS 'actualAmount'
+        , SUM(balance_payment_amount_) AS 'balancePaymentAmount'
+        , COUNT(distinct user_id_) AS 'userPurchaseNumber'
+        FROM student_payment_order
+        <where>
+            status_ = 'SUCCESS'
+            <if test="param.tenantId != null">
+                AND tenant_id_ =#{param.tenantId}
+            </if>
+            <if test="param.groupType != null">
+                AND group_type_ =#{param.groupType}
+            </if>
+            <if test="param.type != null">
+                AND type_ =#{param.type}
+            </if>
+            <if test="param.activityId != null">
+                AND find_in_set(activity_id_,#{param.activityId})
+            </if>
+            <if test="param.musicGroupId != null">
+                AND find_in_set(music_group_id_,#{param.musicGroupId})
+            </if>
+        </where>
+    </select>
+
+    <select id="musicalSaleStatics" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
+        SELECT
+        SUM(t.actual_amount_) AS 'actualAmount'
+        , SUM(t.balance_payment_amount_) AS 'balancePaymentAmount'
+        , COUNT(distinct t.user_id_) AS 'userPurchaseNumber'
+        FROM student_payment_order t
+        LEFT join sell_order so on t.order_no_ = so.order_no_
+        <where>
+            t.status_ = 'SUCCESS'
+            AND t.tenant_id_ = #{param.tenantId}
+            AND find_in_set(so.goods_id_,#{param.goodId})
+            AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
+        </where>
+    </select>
+
+    <select id="saleStaticsByOrgId" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
+        SELECT
+        organ_id_ AS organId
+        , SUM(actual_amount_) AS 'actualAmount'
+        , SUM(balance_payment_amount_) AS 'balancePaymentAmount'
+        , COUNT(distinct user_id_) AS 'userPurchaseNumber'
+        FROM student_payment_order
+        <where>
+            status_ = 'SUCCESS'
+            <if test="param.tenantId != null">
+                AND tenant_id_ =#{param.tenantId}
+            </if>
+            <if test="param.groupType!= null">
+                AND group_type_ =#{param.groupType}
+            </if>
+            <if test="param.type!= null">
+                AND type_ =#{param.type}
+            </if>
+            <if test="param.activityId != null">
+                AND find_in_set(activity_id_,#{param.activityId})
+            </if>
+            <if test="param.musicGroupId != null">
+                AND find_in_set(music_group_id_,#{param.musicGroupId})
+            </if>
+        </where>
+        GROUP BY organ_id_
+    </select>
+
+    <select id="queryPaymentStudentByPage" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleStaticsStudent">
+        select t.user_id_ as userId
+        , t.organ_id_ as organId
+        , su.username_ as userName
+        , su.phone_ as phone
+        , t.pay_time_ as payTime
+        , (t.actual_amount_ + t.balance_payment_amount_) as payAmount
+        from student_payment_order t
+        left join sys_user su on t.user_id_ = su.id_
+        <where>
+            t.status_='SUCCESS'
+            <if test="tenantId != null">
+                AND t.tenant_id_ =#{tenantId}
+            </if>
+            <if test="organId != null">
+                t.organ_id_ = #{organId}
+            </if>
+            <if test="userName != null and userName.trim() !=''">
+                su.username_ like concat('%',#{userName},'%')
+            </if>
+            <if test="groupType != null">
+                AND group_type_ =#{groupType}
+            </if>
+            <if test="type != null">
+                AND type_ =#{type}
+            </if>
+            <if test="activityId != null">
+                AND find_in_set(activity_id_,#{activityId})
+            </if>
+            <if test="musicGroupId != null">
+                AND find_in_set(music_group_id_,#{musicGroupId})
+            </if>
+        </where>
+        <if test=" orderBy != null and asc == 0">
+            order by #{orderBy} desc
+        </if>
+        <if test=" orderBy != null and asc == 1">
+            order by #{orderBy} asc
+        </if>
+        <include refid="global.limit"/>
+    </select>
+
+    <select id="queryPaymentStudentCount" resultType="java.lang.Integer">
+        select count(1) from student_payment_order t
+        left join sys_user su on t.user_id_ = su.id_
+        <where>
+            t.status_='SUCCESS' and t.tenant_id_ = #{param.tenantId}
+            <if test="param.organId != null">
+                t.organ_id_ = #{param.organId}
+            </if>
+            <if test="param.userName != null and param.userName.trim() !=''">
+                su.username_ like concat('%',#{param.userName},'%')
+            </if>
+            <if test="param.groupType!= null">
+                AND group_type_ =#{param.groupType}
+            </if>
+            <if test="param.type!= null">
+                AND type_ =#{param.type}
+            </if>
+            <if test="param.activityId != null">
+                AND find_in_set(activity_id_,#{param.activityId})
+            </if>
+            <if test="param.musicGroupId != null">
+                AND find_in_set(music_group_id_,#{param.musicGroupId})
+            </if>
+        </where>
+    </select>
 
 </mapper>