Browse Source

增加双十一接口

周箭河 5 years ago
parent
commit
68e0459c74
19 changed files with 301 additions and 50 deletions
  1. 16 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SporadicChargeInfoDao.java
  2. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java
  3. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java
  4. 20 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LuckStatisDto.java
  5. 29 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrderStatisDto.java
  6. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java
  7. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SporadicChargeTypeEnum.java
  8. 21 3
      mec-biz/src/main/java/com/ym/mec/biz/service/SporadicChargeInfoService.java
  9. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  10. 7 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java
  11. 7 18
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  12. 10 0
      mec-biz/src/main/resources/config/mybatis/SporadicChargeInfo.xml
  13. 16 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  14. 9 0
      mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml
  15. 47 0
      mec-student/src/main/java/com/ym/mec/student/controller/ActivityController.java
  16. 1 1
      mec-web/src/main/java/com/ym/mec/web/config/ResourceServerConfig.java
  17. 3 21
      mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java
  18. 6 0
      mec-web/src/main/java/com/ym/mec/web/controller/SporadicChargeInfoController.java
  19. 84 0
      mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SporadicChargeInfoDao.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 package com.ym.mec.biz.dal.dao;
 
 
+import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
@@ -10,4 +11,19 @@ public interface SporadicChargeInfoDao extends BaseDAO<Integer, SporadicChargeIn
     SporadicChargeInfo findInfoById(@Param("id") Integer id);
     SporadicChargeInfo findInfoById(@Param("id") Integer id);
 
 
     SporadicChargeInfo findByOrganIdAndType(@Param("organId") Integer organId, @Param("chargeType") Integer chargeType);
     SporadicChargeInfo findByOrganIdAndType(@Param("organId") Integer organId, @Param("chargeType") Integer chargeType);
+
+    /**
+     * 根据分部和类型获取活动信息
+     * @param organId
+     * @param chargeType
+     * @return
+     */
+    List<SporadicChargeInfo> getOrganActiveInfo(@Param("organId") Integer organId, @Param("chargeType") Integer chargeType);
+
+    /**
+     * 获取所有的活动分部
+     * @param type
+     * @return
+     */
+    List<Organization> getActiveOrgans(@Param("type") Integer type);
 }
 }

+ 10 - 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.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.GroupType;
@@ -311,8 +312,17 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
 
 
     /**
     /**
      * 搜索用户
      * 搜索用户
+     *
      * @param search
      * @param search
      * @return
      * @return
      */
      */
     List<BasicUserDto> getUsers(@Param("search") String search);
     List<BasicUserDto> getUsers(@Param("search") String search);
+
+    /**
+     * 获取2020双十一活动统计
+     *
+     * @return
+     */
+    List<OrderStatisDto> doubleEleven2020Statis(@Param("organs") List<Organization> organs);
+
 }
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java

@@ -355,4 +355,10 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
     List<StudentRegistration> getMusicGroupStu4Teacher(@Param("musicGroupId") String musicGroupId, @Param("teacherId") Integer teacherId);
     List<StudentRegistration> getMusicGroupStu4Teacher(@Param("musicGroupId") String musicGroupId, @Param("teacherId") Integer teacherId);
 
 
     StudentRegistration getStudentRegister(@Param("musicGroupId") String musicGroupId, @Param("studentId") Integer studentId);
     StudentRegistration getStudentRegister(@Param("musicGroupId") String musicGroupId, @Param("studentId") Integer studentId);
+
+    /**
+     * 获取分部乐团在读学生数
+     * @return
+     */
+    List<OrderStatisDto> getOrganNormalStudent();
 }
 }

+ 20 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LuckStatisDto.java

@@ -5,8 +5,10 @@ import java.util.List;
 
 
 public class LuckStatisDto {
 public class LuckStatisDto {
     private List<OrderStatisDto> orderStatisDtoList;
     private List<OrderStatisDto> orderStatisDtoList;
-    private Integer totalNum;
-    private BigDecimal totalMoney;
+    private Integer totalEstimatedNums = 0;
+    private Integer totalNum = 0;
+    private BigDecimal totalMoney = BigDecimal.ZERO;
+    private BigDecimal scale = BigDecimal.ZERO;
 
 
     public List<OrderStatisDto> getOrderStatisDtoList() {
     public List<OrderStatisDto> getOrderStatisDtoList() {
         return orderStatisDtoList;
         return orderStatisDtoList;
@@ -31,4 +33,20 @@ public class LuckStatisDto {
     public void setTotalMoney(BigDecimal totalMoney) {
     public void setTotalMoney(BigDecimal totalMoney) {
         this.totalMoney = totalMoney;
         this.totalMoney = totalMoney;
     }
     }
+
+    public Integer getTotalEstimatedNums() {
+        return totalEstimatedNums;
+    }
+
+    public void setTotalEstimatedNums(Integer totalEstimatedNums) {
+        this.totalEstimatedNums = totalEstimatedNums;
+    }
+
+    public BigDecimal getScale() {
+        return scale;
+    }
+
+    public void setScale(BigDecimal scale) {
+        this.scale = scale;
+    }
 }
 }

+ 29 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrderStatisDto.java

@@ -3,9 +3,20 @@ package com.ym.mec.biz.dal.dto;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 
 
 public class OrderStatisDto {
 public class OrderStatisDto {
+    private Integer organId;
     private String organName;
     private String organName;
-    private Integer nums;
-    private BigDecimal money;
+    private Integer estimatedNums = 0;
+    private Integer nums = 0;
+    private BigDecimal scale = BigDecimal.ZERO;
+    private BigDecimal money = BigDecimal.ZERO;
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
 
 
     public String getOrganName() {
     public String getOrganName() {
         return organName;
         return organName;
@@ -30,4 +41,20 @@ public class OrderStatisDto {
     public void setMoney(BigDecimal money) {
     public void setMoney(BigDecimal money) {
         this.money = money;
         this.money = money;
     }
     }
+
+    public Integer getEstimatedNums() {
+        return estimatedNums;
+    }
+
+    public void setEstimatedNums(Integer estimatedNums) {
+        this.estimatedNums = estimatedNums;
+    }
+
+    public BigDecimal getScale() {
+        return scale;
+    }
+
+    public void setScale(BigDecimal scale) {
+        this.scale = scale;
+    }
 }
 }

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java

@@ -15,6 +15,7 @@ public enum OrderTypeEnum implements BaseEnum<String, OrderTypeEnum> {
 	PRACTICE_GROUP_RENEW("PRACTICE_GROUP_RENEW", "网管课续费"),
 	PRACTICE_GROUP_RENEW("PRACTICE_GROUP_RENEW", "网管课续费"),
 	COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
 	COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
 	LUCK("LUCK", "福袋活动"),
 	LUCK("LUCK", "福袋活动"),
+	DOUBLE_ELEVEN2020("DOUBLE_ELEVEN2020","2020双十一活动"),
 	TENANT_RECHARGE("TENANT_RECHARGE","租户充值"),
 	TENANT_RECHARGE("TENANT_RECHARGE","租户充值"),
 	GOODS_SELL("GOODS_SELL","商品销售"),
 	GOODS_SELL("GOODS_SELL","商品销售"),
 	OUTORDER("OUTORDER", "外部订单"),
 	OUTORDER("OUTORDER", "外部订单"),

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SporadicChargeTypeEnum.java

@@ -13,7 +13,8 @@ public enum SporadicChargeTypeEnum implements BaseEnum<Integer, SporadicChargeTy
     VIP_BUY(8,"VIP课购买"),
     VIP_BUY(8,"VIP课购买"),
     RECHARGE(9,"账户充值"),
     RECHARGE(9,"账户充值"),
     MUSIC_UPKEEP(10,"乐保服务"),
     MUSIC_UPKEEP(10,"乐保服务"),
-    OTHER(11,"其他");
+    OTHER(11,"其他"),
+    DOUBLE_ELEVEN2020(12,"2020双十一活动");
 
 
     private Integer code;
     private Integer code;
 
 

+ 21 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/SporadicChargeInfoService.java

@@ -1,21 +1,27 @@
 package com.ym.mec.biz.service;
 package com.ym.mec.biz.service;
 
 
+import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.page.SporadicChargeInfoQueryInfo;
 import com.ym.mec.biz.dal.page.SporadicChargeInfoQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 
 public interface SporadicChargeInfoService extends BaseService<Integer, SporadicChargeInfo> {
 public interface SporadicChargeInfoService extends BaseService<Integer, SporadicChargeInfo> {
 
 
     /**
     /**
      * 零星支付订单
      * 零星支付订单
+     *
      * @param order
      * @param order
      */
      */
     Boolean renewForCallback(StudentPaymentOrder order);
     Boolean renewForCallback(StudentPaymentOrder order);
 
 
     /**
     /**
      * 分页查询
      * 分页查询
+     *
      * @param queryInfo
      * @param queryInfo
      * @return
      * @return
      */
      */
@@ -23,15 +29,17 @@ public interface SporadicChargeInfoService extends BaseService<Integer, Sporadic
 
 
     /**
     /**
      * 单查询
      * 单查询
+     *
      * @param id
      * @param id
      * @return
      * @return
      */
      */
     SporadicChargeInfo getDetail(Integer id);
     SporadicChargeInfo getDetail(Integer id);
 
 
-    SporadicChargeInfo findByOrganIdAndType(Integer organId,Integer type);
+    SporadicChargeInfo findByOrganIdAndType(Integer organId, Integer type);
 
 
     /**
     /**
      * 开启/关闭缴费
      * 开启/关闭缴费
+     *
      * @param sporadicId
      * @param sporadicId
      * @param openFlag
      * @param openFlag
      */
      */
@@ -39,18 +47,28 @@ public interface SporadicChargeInfoService extends BaseService<Integer, Sporadic
 
 
     /**
     /**
      * 删除
      * 删除
+     *
      * @param id
      * @param id
      */
      */
     void del(Integer id);
     void del(Integer id);
 
 
     /**
     /**
+     * @param id:
+     * @return com.ym.mec.biz.dal.entity.SporadicChargeInfo
      * @describe 获取详情
      * @describe 获取详情
      * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
      * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
      * @author zouxuan
      * @author zouxuan
      * @date 2020/9/10
      * @date 2020/9/10
      * @time 15:20
      * @time 15:20
-     * @param id:
-     * @return com.ym.mec.biz.dal.entity.SporadicChargeInfo
      */
      */
     SporadicChargeInfo findDetail(Integer id, Integer userId);
     SporadicChargeInfo findDetail(Integer id, Integer userId);
+
+    /**
+     * 获取分部活动信息
+     *
+     * @param organId
+     * @param type
+     * @return
+     */
+    List<SporadicChargeInfo> getOrganActiveInfo(Integer organId, Integer type);
 }
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -288,6 +288,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (chargeInfo == null) {
         if (chargeInfo == null) {
             throw new BizException("支付项不存在");
             throw new BizException("支付项不存在");
         }
         }
+        if(chargeInfo.getOpenFlag().equals(1)){
+            throw new BizException("项目已关闭");
+        }
         BigDecimal amount = chargeInfo.getAmount();
         BigDecimal amount = chargeInfo.getAmount();
         if (chargeInfo.getDiscountAmount() != null && chargeInfo.getDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
         if (chargeInfo.getDiscountAmount() != null && chargeInfo.getDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
             amount = amount.subtract(chargeInfo.getDiscountAmount());
             amount = amount.subtract(chargeInfo.getDiscountAmount());
@@ -297,6 +300,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         }
 
 
         OrderTypeEnum type = OrderTypeEnum.SPORADIC;
         OrderTypeEnum type = OrderTypeEnum.SPORADIC;
+        if(chargeInfo.getChargeType().equals(SporadicChargeTypeEnum.DOUBLE_ELEVEN2020)){
+            type = OrderTypeEnum.DOUBLE_ELEVEN2020;
+        }
 
 
         Integer userId = sporadicPayDto.getUserId();
         Integer userId = sporadicPayDto.getUserId();
         String orderNo = idGeneratorService.generatorId("payment") + "";
         String orderNo = idGeneratorService.generatorId("payment") + "";

+ 7 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java

@@ -84,8 +84,8 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
             }
             }
 
 
             //福袋活动,增加课程余额
             //福袋活动,增加课程余额
-            if (info.getChargeType().getCode() == 6) {
-                sysUserCashAccountService.appendCourseBalance(userId, studentPaymentOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.SPORADIC, "活动");
+            if (info.getChargeType().getCode() == 6 || info.getChargeType().getCode() == 12) {
+                sysUserCashAccountService.appendCourseBalance(userId, studentPaymentOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.SPORADIC, "双11活动");
             } else if (info.getChargeType().getCode() == 9) { //零星收费账户充值
             } else if (info.getChargeType().getCode() == 9) { //零星收费账户充值
                 sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.RECHARGE, "零星收费账户充值", studentPaymentOrder.getTransNo());
                 sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.RECHARGE, "零星收费账户充值", studentPaymentOrder.getTransNo());
             } else if (info.getOrganId().equals(42) && info.getChargeType().equals(SporadicChargeTypeEnum.LEVEL)) {
             } else if (info.getOrganId().equals(42) && info.getChargeType().equals(SporadicChargeTypeEnum.LEVEL)) {
@@ -242,4 +242,9 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
         }
         }
         return chargeInfo;
         return chargeInfo;
     }
     }
+
+    @Override
+    public List<SporadicChargeInfo> getOrganActiveInfo(Integer organId, Integer type) {
+        return sporadicChargeInfoDao.getOrganActiveInfo(organId, type);
+    }
 }
 }

+ 7 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -234,13 +234,18 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         }
         order.setPaymentBusinessChannel(rpMap.get("channelType"));
         order.setPaymentBusinessChannel(rpMap.get("channelType"));
 
 
+        callOrderCallBack(order);
+    }
+
+    //调用相应业务回调接口
+    private void callOrderCallBack(StudentPaymentOrder order) throws Exception {
         if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
         if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
             studentRegistrationService.updateApplyOrder(order);
             studentRegistrationService.updateApplyOrder(order);
         } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
         } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
             vipGroupService.orderCallback(order);
             vipGroupService.orderCallback(order);
         } else if (order.getType().equals(OrderTypeEnum.RENEW)) {
         } else if (order.getType().equals(OrderTypeEnum.RENEW)) {
             musicGroupService.renewForCallback(order);
             musicGroupService.renewForCallback(order);
-        } else if (order.getType().equals(OrderTypeEnum.SPORADIC) || order.getType().equals(OrderTypeEnum.LUCK)) {
+        } else if (order.getType().equals(OrderTypeEnum.SPORADIC) || order.getType().equals(OrderTypeEnum.LUCK) || order.getType().equals(OrderTypeEnum.DOUBLE_ELEVEN2020)) {
             sporadicChargeInfoService.renewForCallback(order);
             sporadicChargeInfoService.renewForCallback(order);
         } else if (order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_BUY) || order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_RENEW)) {
         } else if (order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_BUY) || order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_RENEW)) {
             practiceGroupService.orderCallback(order);
             practiceGroupService.orderCallback(order);
@@ -273,23 +278,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             try {
             try {
                 order.setStatus(DealStatusEnum.FAILED);
                 order.setStatus(DealStatusEnum.FAILED);
                 order.setMemo("超时未支付关闭");
                 order.setMemo("超时未支付关闭");
-                if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
-                    studentRegistrationService.updateApplyOrder(order);
-                } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
-                    vipGroupService.orderCallback(order);
-                } else if (order.getType().equals(OrderTypeEnum.RENEW)) {
-                    musicGroupService.renewForCallback(order);
-                } else if (order.getType().equals(OrderTypeEnum.SPORADIC) || order.getType().equals(OrderTypeEnum.LUCK)) {
-                    sporadicChargeInfoService.renewForCallback(order);
-                } else if (order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_BUY) || order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_RENEW)) {
-                    practiceGroupService.orderCallback(order);
-                } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
-                    studentRepairService.orderCallback(order);
-                } else if (order.getType().equals(OrderTypeEnum.GOODS_SELL)) {
-                    studentRepairService.goodsSellOrderCallback(order);
-                } else if (order.getType().equals(OrderTypeEnum.SUBJECT_CHANGE)) {
-                    subjectChangeService.orderCallback(order);
-                }
+                callOrderCallBack(order);
             } catch (Exception e) {
             } catch (Exception e) {
                 e.printStackTrace();
                 e.printStackTrace();
                 continue;
                 continue;

+ 10 - 0
mec-biz/src/main/resources/config/mybatis/SporadicChargeInfo.xml

@@ -132,4 +132,14 @@
 	<select id="findByOrganIdAndType" resultMap="SporadicChargeInfo">
 	<select id="findByOrganIdAndType" resultMap="SporadicChargeInfo">
 		SELECT * FROM sporadic_charge_info where organ_id_=#{organId} AND charge_type_=#{chargeType} AND del_flag_=0
 		SELECT * FROM sporadic_charge_info where organ_id_=#{organId} AND charge_type_=#{chargeType} AND del_flag_=0
 	</select>
 	</select>
+    <select id="getOrganActiveInfo" resultMap="SporadicChargeInfo">
+		SELECT * FROM sporadic_charge_info where organ_id_=#{organId} AND charge_type_=#{chargeType} AND del_flag_=0
+	</select>
+
+    <select id="getActiveOrgans" resultMap="com.ym.mec.biz.dal.dao.OrganizationDao.Organization">
+		SELECT o.* FROM sporadic_charge_info sci
+		LEFT JOIN organization o ON o.id_ =sci.organ_id_
+		WHERE sci.charge_type_ = #{type} AND sci.del_flag_=0
+		GROUP BY o.id_
+	</select>
 </mapper>
 </mapper>

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

@@ -557,8 +557,11 @@
     </sql>
     </sql>
 
 
     <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
     <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
+        <result property="organId" column="organId"/>
         <result property="organName" column="organName"/>
         <result property="organName" column="organName"/>
+        <result property="estimatedNums" column="estimatedNums"/>
         <result property="nums" column="nums"/>
         <result property="nums" column="nums"/>
+        <result property="scale" column="scale"/>
         <result property="money" column="money"/>
         <result property="money" column="money"/>
     </resultMap>
     </resultMap>
     <select id="getLuckStatis" resultMap="luckStatis">
     <select id="getLuckStatis" resultMap="luckStatis">
@@ -720,4 +723,17 @@
         WHERE id_ = #{id} FOR
         WHERE id_ = #{id} FOR
         UPDATE
         UPDATE
     </select>
     </select>
+
+    <select id="doubleEleven2020Statis" resultMap="luckStatis">
+        SELECT o.id_ organId, o.name_ organName, SUM(spo.actual_amount_) money, COUNT(DISTINCT spo.user_id_) nums
+        FROM student_payment_order spo
+        LEFT JOIN organization o ON o.id_ = spo.organ_id_
+        WHERE spo.type_ = 'DOUBLE_ELEVEN2020'
+        AND spo.status_ = 'SUCCESS'
+        AND spo.organ_id_ IN
+        <foreach collection="organs" item="organ" open="(" close=")" separator=",">
+            #{organ.id}
+        </foreach>
+        GROUP BY spo.organ_id_
+    </select>
 </mapper>
 </mapper>

+ 9 - 0
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -651,4 +651,13 @@
         SELECT * FROM student_registration WHERE music_group_id_ = #{musicGroupId} AND user_id_ = #{studentId}
         SELECT * FROM student_registration WHERE music_group_id_ = #{musicGroupId} AND user_id_ = #{studentId}
         ORDER BY id_ DESC LIMIT 1
         ORDER BY id_ DESC LIMIT 1
     </select>
     </select>
+
+    <!-- 获取分部乐团在读人数 -->
+    <select id="getOrganNormalStudent" resultMap="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.luckStatis">
+        SELECT mg.organ_id_ organId, COUNT(DISTINCT sr.user_id_) estimatedNums
+        FROM student_registration sr
+                 LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
+        WHERE sr.music_group_status_ = 'NORMAL'
+        GROUP BY mg.organ_id_
+    </select>
 </mapper>
 </mapper>

+ 47 - 0
mec-student/src/main/java/com/ym/mec/student/controller/ActivityController.java

@@ -0,0 +1,47 @@
+package com.ym.mec.student.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
+import com.ym.mec.biz.service.SporadicChargeInfoService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Comparator;
+import java.util.List;
+
+@RequestMapping("activity")
+@Api(tags = "活动")
+@RestController
+public class ActivityController extends BaseController {
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private SporadicChargeInfoService sporadicChargeInfoService;
+
+    @ApiOperation(value = "分部双11活动信息")
+    @GetMapping("/doubleEleven2020")
+    public HttpResponseResult<List<SporadicChargeInfo>> doubleEleven2020() throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null || sysUser.getId() == null) {
+            return failed("请先登录");
+        }
+        if (sysUser.getOrganId() == null) {
+            return failed("用户信息有误,没有分部信息");
+        }
+        Integer organId = sysUser.getOrganId();
+
+        List<SporadicChargeInfo> activeInfos = sporadicChargeInfoService.getOrganActiveInfo(organId, 12);
+        activeInfos.sort(Comparator.comparing(SporadicChargeInfo::getAmount).reversed());
+        if (activeInfos.size() <= 0) {
+            return failed("分部活动不存在");
+        }
+        return succeed(activeInfos);
+    }
+}

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/config/ResourceServerConfig.java

@@ -34,7 +34,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 				.antMatchers("/task/**")
 				.antMatchers("/task/**")
 				.hasIpAddress("0.0.0.0/0")
 				.hasIpAddress("0.0.0.0/0")
 				.antMatchers("/v2/api-docs", "/classGroup/highClassGroups", "/code/*", "/api/*", "/appVersionInfo/queryByPlatform", "/eduDegree/*",
 				.antMatchers("/v2/api-docs", "/classGroup/highClassGroups", "/code/*", "/api/*", "/appVersionInfo/queryByPlatform", "/eduDegree/*",
-						"/uploadFile", "/eduContracts/queryProduceContract").permitAll().anyRequest().authenticated().and().httpBasic();
+						"/uploadFile", "/eduContracts/queryProduceContract","/activity/doubleEleven2020Statis").permitAll().anyRequest().authenticated().and().httpBasic();
 	}
 	}
 
 
 	@Override
 	@Override

+ 3 - 21
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -902,27 +902,9 @@ public class ExportController extends BaseController {
                 row.setMusicalFee(BigDecimal.ZERO);
                 row.setMusicalFee(BigDecimal.ZERO);
                 row.setTeachingFee(BigDecimal.ZERO);
                 row.setTeachingFee(BigDecimal.ZERO);
                 if (row.getChargeType() != null) {
                 if (row.getChargeType() != null) {
-
-                    if (row.getChargeType().equals(1)) {
-                        row.setSporadicType("考级");
-                    } else if (row.getChargeType().equals(2)) {
-                        row.setSporadicType("声部更改");
-                    } else if (row.getChargeType().equals(3)) {
-                        row.setSporadicType("乐器更换");
-                    } else if (row.getChargeType().equals(4)) {
-                        row.setSporadicType("配件销售");
-                    } else if (row.getChargeType().equals(5)) {
-                        row.setSporadicType("维修费");
-                    } else if (row.getChargeType().equals(6)) {
-                        row.setSporadicType("福袋活动");
-                    } else if (row.getChargeType().equals(7)) {
-                        row.setSporadicType("上门费");
-                    } else if (row.getChargeType().equals(9)) {
-                        row.setSporadicType("账户充值");
-                    } else if (row.getChargeType().equals(10)) {
-                        row.setSporadicType("乐保服务");
-                    } else if (row.getChargeType().equals(11)) {
-                        row.setSporadicType("其他");
+                    for (SporadicChargeTypeEnum chargeType : SporadicChargeTypeEnum.values()) {
+                        if (!chargeType.getCode().equals(row.getChargeType())) continue;
+                        row.setSporadicType(chargeType.getMsg());
                     }
                     }
                 }
                 }
                 School userSchool = musicGroupDao.findUserSchool(row.getUserId());
                 School userSchool = musicGroupDao.findUserSchool(row.getUserId());

+ 6 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SporadicChargeInfoController.java

@@ -94,6 +94,12 @@ public class SporadicChargeInfoController extends BaseController {
 				return failed("分部活动已存在,请勿重复创建");
 				return failed("分部活动已存在,请勿重复创建");
 			}
 			}
 		}
 		}
+		if (sporadicChargeInfo.getChargeType().equals(SporadicChargeTypeEnum.DOUBLE_ELEVEN2020)) {
+			List<SporadicChargeInfo> organActiveInfo = sporadicChargeInfoService.getOrganActiveInfo(sporadicChargeInfo.getOrganId(), sporadicChargeInfo.getChargeType().getCode());
+			if (organActiveInfo.size() >= 2) {
+				return failed("分部活动已存在,请勿重复创建");
+			}
+		}
 		return succeed(sporadicChargeInfoService.insert(sporadicChargeInfo));
 		return succeed(sporadicChargeInfoService.insert(sporadicChargeInfo));
 	}
 	}
 
 

+ 84 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

@@ -0,0 +1,84 @@
+package com.ym.mec.web.controller.education;
+
+
+import com.ym.mec.biz.dal.dao.SporadicChargeInfoDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dto.LuckStatisDto;
+import com.ym.mec.biz.dal.dto.OrderStatisDto;
+import com.ym.mec.biz.dal.entity.Organization;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@RequestMapping("activity")
+@Api(tags = "活动")
+@RestController
+public class ActivityController extends BaseController {
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+    @Autowired
+    private SporadicChargeInfoDao sporadicChargeInfoDao;
+    @Autowired
+    private StudentRegistrationDao studentRegistrationDao;
+
+    @ApiOperation(value = "分部双11活动统计")
+    @GetMapping("/doubleEleven2020Statis")
+    public HttpResponseResult<LuckStatisDto> doubleEleven2020Statis() {
+        //获取所有参与分部
+        List<Organization> organs = sporadicChargeInfoDao.getActiveOrgans(12);
+        //获取所有分部参与的订单
+        List<OrderStatisDto> orders = studentPaymentOrderDao.doubleEleven2020Statis(organs);
+        Set<Integer> orderOrganIds = orders.stream().map(OrderStatisDto::getOrganId).collect(Collectors.toSet());
+        //获取所有分部预计的人数
+        List<OrderStatisDto> organNormalStudents = studentRegistrationDao.getOrganNormalStudent();
+
+        for (Organization organ : organs) {
+            if (orderOrganIds == null || !orderOrganIds.contains(organ.getId())) {
+                OrderStatisDto orderStatisDto = new OrderStatisDto();
+                orderStatisDto.setOrganId(organ.getId());
+                orderStatisDto.setOrganName(organ.getName());
+                orders.add(orderStatisDto);
+            }
+        }
+        BigDecimal totalMoney = BigDecimal.ZERO;
+        Integer totalEstimatedNums = 0;
+        Integer totalNum = 0;
+        for (OrderStatisDto order : orders) {
+            for (OrderStatisDto organNormalStudent : organNormalStudents) {
+                if (order.getOrganId().equals(organNormalStudent.getOrganId())) {
+                    order.setEstimatedNums(organNormalStudent.getEstimatedNums());
+                    break;
+                }
+            }
+            if (order.getEstimatedNums() > 0) {
+                order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(order.getEstimatedNums()), 2, BigDecimal.ROUND_HALF_UP));
+            }
+            totalEstimatedNums += order.getEstimatedNums();
+            totalNum += order.getNums();
+            totalMoney = totalMoney.add(order.getMoney());
+        }
+        orders.sort(Comparator.comparing(OrderStatisDto::getMoney).reversed());
+
+        LuckStatisDto luckStatisDto = new LuckStatisDto();
+        luckStatisDto.setOrderStatisDtoList(orders);
+        luckStatisDto.setTotalEstimatedNums(totalEstimatedNums);
+        luckStatisDto.setTotalNum(totalNum);
+        luckStatisDto.setTotalMoney(totalMoney);
+        if (luckStatisDto.getTotalEstimatedNums() > 0) {
+            luckStatisDto.setScale(new BigDecimal(totalNum).multiply(new BigDecimal(100)).divide(new BigDecimal(totalEstimatedNums), 2, BigDecimal.ROUND_HALF_UP));
+        }
+        return succeed(luckStatisDto);
+    }
+}