瀏覽代碼

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

yonge 4 年之前
父節點
當前提交
06ea71219e

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

@@ -237,4 +237,16 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      * @return
      */
     MusicGroupPaymentCalender getMusicGroupRegCalender(@Param("musicGroupId") String musicGroupId);
+
+    /**
+     * @describe 获取学员在乐团的缴费状态
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/11/4
+     * @time 15:43
+     * @param userId:
+     * @param musicGroupId:
+     * @return java.util.Map<java.lang.String,java.lang.String>
+     */
+    Map<String, String> queryUserPaymentStatus(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
 }

+ 10 - 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;
 
+import com.ym.mec.biz.dal.dto.OrganMaxAmountDto;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.common.dal.BaseDAO;
@@ -14,6 +15,7 @@ public interface SporadicChargeInfoDao extends BaseDAO<Integer, SporadicChargeIn
 
     /**
      * 根据分部和类型获取活动信息
+     *
      * @param organId
      * @param chargeType
      * @return
@@ -22,8 +24,16 @@ public interface SporadicChargeInfoDao extends BaseDAO<Integer, SporadicChargeIn
 
     /**
      * 获取所有的活动分部
+     *
      * @param type
      * @return
      */
     List<Organization> getActiveOrgans(@Param("type") Integer type);
+
+    /**
+     * 获取活动分部的最大缴费金额
+     * @param type
+     * @return
+     */
+    List<OrganMaxAmountDto> getActiveOrgansMaxAmount(@Param("type") Integer type);
 }

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LuckStatisDto.java

@@ -20,7 +20,10 @@ public class LuckStatisDto {
     @ApiModelProperty(value = "总金额",required = true)
     private BigDecimal totalMoney = BigDecimal.ZERO;
 
-    @ApiModelProperty(value = "总转化率",required = true)
+    @ApiModelProperty(value = "总目标金额",required = true)
+    private BigDecimal totalMaxAmount= BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "总完成度",required = true)
     private BigDecimal scale = BigDecimal.ZERO;
 
     public List<OrderStatisDto> getOrderStatisDtoList() {
@@ -70,4 +73,12 @@ public class LuckStatisDto {
     public void setTotalTimes(Integer totalTimes) {
         this.totalTimes = totalTimes;
     }
+
+    public BigDecimal getTotalMaxAmount() {
+        return totalMaxAmount;
+    }
+
+    public void setTotalMaxAmount(BigDecimal totalMaxAmount) {
+        this.totalMaxAmount = totalMaxAmount;
+    }
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrderStatisDto.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.dal.dto;
 
+import io.swagger.annotations.ApiModelProperty;
+
 import java.math.BigDecimal;
 
 public class OrderStatisDto {
@@ -10,6 +12,8 @@ public class OrderStatisDto {
     private Integer times = 0;
     private BigDecimal scale = BigDecimal.ZERO;
     private BigDecimal money = BigDecimal.ZERO;
+    @ApiModelProperty(value = "目标金额", required = true)
+    private BigDecimal maxAmount = BigDecimal.ZERO;
 
     public Integer getOrganId() {
         return organId;
@@ -66,4 +70,12 @@ public class OrderStatisDto {
     public void setTimes(Integer times) {
         this.times = times;
     }
+
+    public BigDecimal getMaxAmount() {
+        return maxAmount;
+    }
+
+    public void setMaxAmount(BigDecimal maxAmount) {
+        this.maxAmount = maxAmount;
+    }
 }

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrganMaxAmountDto.java

@@ -0,0 +1,36 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.math.BigDecimal;
+
+public class OrganMaxAmountDto {
+    //分部id
+    private Integer id;
+
+    private String name;
+
+    private BigDecimal maxAmount;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public BigDecimal getMaxAmount() {
+        return maxAmount;
+    }
+
+    public void setMaxAmount(BigDecimal maxAmount) {
+        this.maxAmount = maxAmount;
+    }
+}

+ 11 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -305,11 +305,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             if (chargeInfo.getOpenMaxTerm().equals(YesOrNoEnum.YES) && chargeInfo.getMaxAmount().compareTo(chargeInfo.getPaidAmount()) <= 0) {
                 throw new Exception("活动人数暂时已满,请稍后再试");
             }
-            chargeInfo.setPaidAmount(chargeInfo.getPaidAmount().add(chargeInfo.getAmount()));
-            chargeInfo.setUpdateTime(new Date());
-            int update = sporadicChargeInfoDao.update(chargeInfo);
-            if (update <= 0) {
-                throw new BizException("活动火爆,请稍后再试");
+            List<SporadicChargeInfo> activeInfos = sporadicChargeInfoDao.getOrganActiveInfo(chargeInfo.getOrganId(), 12);
+            for (SporadicChargeInfo activeInfo : activeInfos) {
+                activeInfo.setPaidAmount(activeInfo.getPaidAmount().add(chargeInfo.getAmount()));
+                activeInfo.setUpdateTime(new Date());
+                int update = sporadicChargeInfoDao.update(activeInfo);
+                if (update <= 0) {
+                    throw new BizException("活动火爆,请稍后再试");
+                }
             }
         }
 
@@ -1123,7 +1126,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     public List<MusicCardDto> queryUserMusicGroups(Integer userId) {
         List<MusicCardDto> musicCardDtos = musicGroupDao.queryUserMusicGroups(userId);
         Set<String> musicGroupIds = musicCardDtos.stream().map(MusicCardDto::getMusicGroupId).collect(Collectors.toSet());
-        Map<String, String> paymentStatus = MapUtil.convertMybatisMap(musicGroupStudentFeeDao.queryUserPaymentStatus(userId, StringUtils.join(musicGroupIds, ",")));
+//        Map<String, String> paymentStatus = MapUtil.convertMybatisMap(musicGroupStudentFeeDao.queryUserPaymentStatus(userId, StringUtils.join(musicGroupIds, ",")));
+        Map<String, String> paymentStatus = musicGroupPaymentCalenderDao.queryUserPaymentStatus(userId, StringUtils.join(musicGroupIds, ","));
         // 获取学员在该乐团续费状态
         musicCardDtos.forEach(e -> {
             e.setPaymentStatus(paymentStatus.get(e.getMusicGroupId()));
@@ -1740,7 +1744,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
             studentPaymentRouteOrderService.addRouteOrder(orderNo,organId, balance);
-            Map<String, String> notifyMap = new HashMap<>();
+            Map<String, String> notifyMap = new HashMap<>(4);
             notifyMap.put("tradeState", "1");
             notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
             notifyMap.put("channelType", "");

+ 8 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java

@@ -149,11 +149,14 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
         }
         if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
             if (info.getMaxAmount() != null && info.getPaidAmount().compareTo(BigDecimal.ZERO) > 0) {
-                info.setPaidAmount(info.getPaidAmount().subtract(studentPaymentOrder.getActualAmount()));
-                info.setUpdateTime(new Date());
-                int update = sporadicChargeInfoDao.update(info);
-                if (update <= 0) {
-                    throw new BizException("已收金额更新失败,请重试");
+                List<SporadicChargeInfo> activeInfos = sporadicChargeInfoDao.getOrganActiveInfo(info.getOrganId(), 12);
+                for (SporadicChargeInfo activeInfo : activeInfos) {
+                    activeInfo.setPaidAmount(activeInfo.getPaidAmount().subtract(info.getAmount()));
+                    activeInfo.setUpdateTime(new Date());
+                    int update = sporadicChargeInfoDao.update(activeInfo);
+                    if (update <= 0) {
+                        throw new BizException("已收金额更新失败,请重试");
+                    }
                 }
             }
             if (info.getOrganId().equals(42) && info.getChargeType().equals(SporadicChargeTypeEnum.LEVEL)) {

+ 13 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -45,11 +45,13 @@
             keyColumn="id_" keyProperty="id">
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
-        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_)
+        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
+        payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_)
         VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
-        #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{paymentAmount},#{batchNo},#{auditMemo})
+        #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        #{paymentAmount},#{batchNo},#{auditMemo},#{operator})
     </insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
@@ -57,13 +59,13 @@
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
         actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_amount_,
-        payment_type_,batch_no_,audit_memo_)
+        payment_type_,batch_no_,audit_memo_,operator_)
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
         (#{item.musicGroupId},#{item.musicGroupOrganizationCourseSettingId},#{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.rejectReason},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
         #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentAmount},#{item.paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{item.batchNo},#{item.auditMemo})
+        #{item.batchNo},#{item.auditMemo},#{item.operator})
         </foreach>
     </insert>
 
@@ -462,4 +464,11 @@
         AND pay_user_type_='STUDENT'
         AND status_='OPEN'
     </select>
+    <select id="queryUserPaymentStatus" resultType="java.util.Map">
+        SELECT mgpc.music_group_id_ 'key',CASE WHEN COUNT(DISTINCT mgpcd.id_) > 0 THEN 'NON_PAYMENT' ELSE 'PAID_COMPLETED' END 'value'
+        FROM music_group_payment_calender mgpc
+        LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
+        WHERE FIND_IN_SET(mgpc.music_group_id_,#{musicGroupId}) AND mgpcd.user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT'
+        GROUP BY mgpc.music_group_id_
+    </select>
 </mapper>

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

@@ -185,4 +185,13 @@
           AND sci.del_flag_ = 0
         GROUP BY o.id_
     </select>
+
+    <select id="getActiveOrgansMaxAmount" resultType="com.ym.mec.biz.dal.dto.OrganMaxAmountDto">
+        SELECT o.id_ id,o.name_ name ,(SUM(sci.max_amount_)/COUNT(*)) maxAmount
+        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>

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -236,7 +236,7 @@ public class MusicGroupController extends BaseController {
             throw new BizException("缴费项不存在该学员,请联系教务老师");
         }
         if(calenderDetail.getPaymentStatus() == PaymentStatus.PAID_COMPLETED){
-            throw new BizException("当前缴费项已缴费");
+            throw new BizException("您已缴费请勿重复支付");
         }else if(calenderDetail.getPaymentStatus() == PaymentStatus.PROCESSING){
             throw new BizException("当前缴费项存在待处理的订单,请稍候尝试");
         }

+ 20 - 7
mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

@@ -6,6 +6,7 @@ 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.dto.OrganMaxAmountDto;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -43,6 +44,8 @@ public class ActivityController extends BaseController {
         Set<Integer> orderOrganIds = orders.stream().map(OrderStatisDto::getOrganId).collect(Collectors.toSet());
         //获取所有分部预计的人数
         List<OrderStatisDto> organNormalStudents = studentRegistrationDao.getOrganNormalStudent();
+        //获取分部的目标金额
+        List<OrganMaxAmountDto> maxAmount4Organs = sporadicChargeInfoDao.getActiveOrgansMaxAmount(12);
 
         for (Organization organ : organs) {
             if (!orderOrganIds.contains(organ.getId())) {
@@ -56,7 +59,15 @@ public class ActivityController extends BaseController {
         Integer totalEstimatedNums = 0;
         Integer totalNum = 0;
         Integer totalTimes = 0;
+        BigDecimal totalMaxAmount = BigDecimal.ZERO;
         for (OrderStatisDto order : orders) {
+            for (OrganMaxAmountDto maxAmount4Organ : maxAmount4Organs) {
+                if (order.getOrganId().equals(maxAmount4Organ.getId())) {
+                    order.setMaxAmount(maxAmount4Organ.getMaxAmount() == null ? BigDecimal.ZERO.setScale(2) : maxAmount4Organ.getMaxAmount().setScale(2));
+                    break;
+                }
+            }
+
             for (OrderStatisDto organNormalStudent : organNormalStudents) {
                 if (order.getOrganId().equals(organNormalStudent.getOrganId())) {
                     order.setEstimatedNums(organNormalStudent.getEstimatedNums());
@@ -67,10 +78,11 @@ public class ActivityController extends BaseController {
             totalNum += order.getNums();
             totalTimes += order.getTimes();
             totalMoney = totalMoney.add(order.getMoney());
-            if (order.getEstimatedNums() <= 0) {
-                order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP));
-            }else {
-                order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(order.getEstimatedNums()), 2, BigDecimal.ROUND_HALF_UP));
+            totalMaxAmount = totalMaxAmount.add(order.getMaxAmount());
+            if (order.getMaxAmount().compareTo(BigDecimal.ZERO) <= 0) {
+                order.setScale(new BigDecimal("100.00"));
+            } else {
+                order.setScale(order.getMoney().multiply(new BigDecimal(100)).divide(order.getMaxAmount(), 2, BigDecimal.ROUND_HALF_UP));
             }
         }
         orders.sort(Comparator.comparing(OrderStatisDto::getMoney).reversed());
@@ -81,10 +93,11 @@ public class ActivityController extends BaseController {
         luckStatisDto.setTotalNum(totalNum);
         luckStatisDto.setTotalTimes(totalTimes);
         luckStatisDto.setTotalMoney(totalMoney);
-        if (luckStatisDto.getTotalEstimatedNums() <= 0) {
-            totalEstimatedNums = 1;
+        luckStatisDto.setTotalMaxAmount(totalMaxAmount);
+        if (luckStatisDto.getTotalMaxAmount().compareTo(BigDecimal.ZERO) <= 0) {
+            totalMaxAmount = BigDecimal.ONE;
         }
-        luckStatisDto.setScale(new BigDecimal(totalNum).multiply(new BigDecimal(100)).divide(new BigDecimal(totalEstimatedNums), 2, BigDecimal.ROUND_HALF_UP));
+        luckStatisDto.setScale(totalMoney.multiply(new BigDecimal(100)).divide(totalMaxAmount, 2, BigDecimal.ROUND_HALF_UP));
         return succeed(luckStatisDto);
     }
 }