Browse Source

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
yonge 5 years ago
parent
commit
99ecc326c8

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

@@ -256,4 +256,12 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
     StudentPaymentOrder getOrderMoneyAmount(Map<String, Object> params);
 
     List<StudentPaymentOrder> queryPageOrder(Map<String, Object> params);
+
+    /**
+     * 统计收款金额
+     *
+     * @param merNo
+     * @return
+     */
+    BigDecimal sumPerAccountAmount(@Param("merNo") String merNo, @Param("firstDate") Date firstDate);
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysAccountDao.java

@@ -22,6 +22,7 @@ public interface SysAccountDao extends BaseDAO<Integer, SysAccount> {
 
     /**
      * 获取一个支付
+     *
      * @param company
      * @param channel
      * @param type
@@ -29,4 +30,11 @@ public interface SysAccountDao extends BaseDAO<Integer, SysAccount> {
      * @return
      */
     SysAccount getOneAccount(@Param("company") String company, @Param("channel") String channel, @Param("type") String type, @Param("amount") BigDecimal amount);
+
+    /**
+     * 获取所有私有账户
+     * @param channel
+     * @return
+     */
+    List<SysAccount> getPerAccount(@Param("channel") String channel);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherClassHeadInfo.java

@@ -32,6 +32,9 @@ public class TeacherClassHeadInfo {
     @ApiModelProperty(value = "当前课次",required = false)
     private Integer currentClassTimes;
 
+    @ApiModelProperty(value = "声部信息",required = false)
+    private String subjectNames;
+
     public Integer getTotalClassTimes() {
         return totalClassTimes;
     }
@@ -95,4 +98,12 @@ public class TeacherClassHeadInfo {
     public void setTeachingTeacher(String teachingTeacher) {
         this.teachingTeacher = teachingTeacher;
     }
+
+    public String getSubjectNames() {
+        return subjectNames;
+    }
+
+    public void setSubjectNames(String subjectNames) {
+        this.subjectNames = subjectNames;
+    }
 }

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

@@ -40,6 +40,7 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     PUSH_TEACHER_COURSE_COLLIDE("PUSH_TEACHER_COURSE_COLLIDE", "课程冲突"),
     PAY_PRACTICE_BUY_SUCCESS("PAY_PRACTICE_BUY_SUCCESS", "网管课购买成功"),
     PRACTICE_COMPLETED_STUDY_REPORT("PRACTICE_COMPLETED_STUDY_REPORT", "网管课完成学习报告"),
+    FREE_PRACTICE_APPLY_PUSH("FREE_PRACTICE_APPLY_PUSH", "免费陪练课预约推送"),
     STUDENT_PUSH_NAMES_ACHIEVE("STUDENT_PUSH_NAMES_ACHIEVE", "点名完成"),
     SCHEDULE_CHANGE("SCHEDULE_CHANGE", "课表变动"),
     STUDENT_SMS_TEACHING_SCHOOL_CHANGE("STUDENT_SMS_TEACHING_SCHOOL_CHANGE", "教学点变动"),

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java

@@ -84,7 +84,7 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @param isJumpHoliday 是否跳过节假日
 	 * @return
 	 */
-	boolean batchAddCourseSchedule(Integer classGroupId, int coursesTimes, Date startDate, Date endDate, List<CourseTimeDto> teachingArrangementList,
+	boolean batchAddCourseSchedule(Integer classGroupId, int coursesTimes, Date startDate, Date groupEndDate, Date groupStartDate, List<CourseTimeDto> teachingArrangementList,
 			TeachModeEnum teachMode, CourseScheduleType type, Integer schoolId, boolean isJumpHoliday);
 	
 	/**

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysAccountService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysArea;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -29,4 +30,12 @@ public interface SysAccountService extends BaseService<Integer, SysAccount> {
      */
     SysAccount getOneAccount(String company, String channel, String type,  BigDecimal amount);
 
+
+    /**
+     * 获取私有账户
+     * @param channel
+     * @return
+     */
+    SysAccount getPerAccount(@Param("channel") String channel,SysAccount account);
+
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1069,10 +1069,15 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             throw new BizException("未找到该班级");
         }
 
+        String subjectNames = subjectDao.findNames(classGroup.getSubjectIdList());
+
         TeacherClassHeadInfo teacherClassHeadInfo = new TeacherClassHeadInfo();
         teacherClassHeadInfo.setStudentNum(classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId()));
         teacherClassHeadInfo.setCurrentClassTimes(courseScheduleDao.countCurrentTimes(classGroup.getId(),new Date()));
         teacherClassHeadInfo.setTotalClassTimes(courseScheduleDao.countClassGroupCourses(classGroup.getId()));
+        if(subjectNames != null && !subjectNames.isEmpty()){
+            teacherClassHeadInfo.setSubjectNames(subjectNames);
+        }
         ClassGroupTeacherMapper bishopTeacher = classGroupTeacherMapperDao.findByClassGroupAndRole(classGroupId, TeachTypeEnum.BISHOP);
         if (Objects.nonNull(bishopTeacher)) {
             teacherClassHeadInfo.setBishopTeacherId(bishopTeacher.getId());

+ 12 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -256,7 +256,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
     @Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean batchAddCourseSchedule(Integer classGroupId, int coursesTimes, Date startDate, Date endDate, List<CourseTimeDto> teachingArrangementList,
+	public boolean batchAddCourseSchedule(Integer classGroupId, int coursesTimes, Date startDate, Date groupEndDate, Date groupStartDate, List<CourseTimeDto> teachingArrangementList,
 			TeachModeEnum teachMode, CourseScheduleType type, Integer schoolId, boolean isJumpHoliday) {
 		ClassGroup classGroup = classGroupService.get(classGroupId);
 		if (classGroup == null) {
@@ -451,9 +451,14 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 					}
 					
 					// 判断课程时间是否超过排课结束时间
-					if (endDate != null) {
-						if (calendar.getTime().after(endDate)) {
-							throw new BizException("排课时间超出排课截止日期({})", endDate);
+					if(groupStartDate != null){
+						if(groupStartDate.after(calendar.getTime())){
+							throw new BizException("调整时间不得早于开课时间({})",groupStartDate);
+						}
+					}
+					if (groupEndDate != null) {
+						if (calendar.getTime().after(groupEndDate)) {
+							throw new BizException("排课时间超出排课截止日期({})", groupEndDate);
 						}
 					}
 					
@@ -644,16 +649,18 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		courseHomeworkService.delHomwworkByCourseScheduleId(courseScheduleIds);
 
 		Date endDate = null;
+		Date startDate = null;
 		if (batchInsertCoursesDto.getType() == CourseScheduleType.PRACTICE) {
 			PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(musicGroupId));
 			if (practiceGroup == null) {
 				throw new BizException("找不到课程组[{}]信息", musicGroupId);
 			}
 			endDate = practiceGroup.getCoursesExpireDate();
+			startDate = practiceGroup.getCoursesStartDate();
 		}
 
 		// 批量加课
-		batchAddCourseSchedule(classGroupId, batchInsertCoursesDto.getCourseScheduleIdList().size(), batchInsertCoursesDto.getStartDate(), endDate,
+		batchAddCourseSchedule(classGroupId, batchInsertCoursesDto.getCourseScheduleIdList().size(), batchInsertCoursesDto.getStartDate(), endDate, startDate,
 				batchInsertCoursesDto.getTeachingArrangementList(), batchInsertCoursesDto.getTeachMode(), batchInsertCoursesDto.getType(),
 				batchInsertCoursesDto.getSchoolId(), batchInsertCoursesDto.getIsJumpHoliday());
 		return true;

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

@@ -282,11 +282,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         OrderTypeEnum type = OrderTypeEnum.SPORADIC;
-        String receiver = null;
-        if (chargeInfo.getChargeType().equals("6")) {
-            type = OrderTypeEnum.LUCK;
-            receiver = "PER";
-        }
+        String receiver = "PER";
 
         Integer userId = sporadicPayDto.getUserId();
         String orderNo = idGeneratorService.generatorId("payment") + "";
@@ -325,7 +321,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setOrganId(chargeInfo.getOrganId());
-        studentPaymentOrder.setRoutingOrganId(42);
+        studentPaymentOrder.setRoutingOrganId(chargeInfo.getOrganId());
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrderService.update(studentPaymentOrder);
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
@@ -363,7 +359,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         Map<String, BigDecimal> routingFee = (Map<String, BigDecimal>) payMap.get("routingFee");
         studentPaymentOrder.setOrganId(chargeInfo.getOrganId());
-        studentPaymentOrder.setRoutingOrganId(42);
+        studentPaymentOrder.setRoutingOrganId(chargeInfo.getOrganId());
         studentPaymentOrder.setComAmount(routingFee.get("COM"));
         studentPaymentOrder.setPerAmount(routingFee.get("PER"));
         studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));

+ 16 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -118,7 +118,7 @@ public class PayServiceImpl implements PayService {
                 routingList.put("routingFee", account.getRoutingFee().subtract((account.getRoutingFee().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP))); //分佣金额
                 tempRoutingList.add(routingList);
             }
-            if(accounts.size() ==1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())){
+            if (accounts.size() == 1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())) {
                 tempRoutingList = null;
             }
 
@@ -134,8 +134,8 @@ public class PayServiceImpl implements PayService {
         unionPay.put("orderNo", orderNo);
         unionPay.put("type", type);
         unionPay.put("payMap", payMap);
-        unionPay.put("routingFee",routingFee);
-        unionPay.put("routingMerNos",routingMerNos);
+        unionPay.put("routingFee", routingFee);
+        unionPay.put("routingMerNos", routingMerNos);
         return unionPay;
     }
 
@@ -151,7 +151,7 @@ public class PayServiceImpl implements PayService {
 
         //支付通道决策
         Map unionPay = new HashMap();
-        Map<String, BigDecimal> routingFee = getRoutingFee(company, amount, fee, organId,receiver);
+        Map<String, BigDecimal> routingFee = getRoutingFee(company, amount, fee, organId, receiver);
         List<SysAccount> accounts = getRoutingAccount(routingFee, company);
         SysAccount routingAccount = accounts.get(0);
 
@@ -165,7 +165,7 @@ public class PayServiceImpl implements PayService {
                 routingList.put("routingFee", account.getRoutingFee().subtract((account.getRoutingFee().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP))); //分佣金额
                 tempRoutingList.add(routingList);
             }
-            if(accounts.size() ==1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())){
+            if (accounts.size() == 1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())) {
                 tempRoutingList = null;
             }
 
@@ -181,8 +181,8 @@ public class PayServiceImpl implements PayService {
         unionPay.put("orderNo", orderNo);
         unionPay.put("type", type);
         unionPay.put("payMap", payMap);
-        unionPay.put("routingFee",routingFee);
-        unionPay.put("routingMerNos",routingMerNos);
+        unionPay.put("routingFee", routingFee);
+        unionPay.put("routingMerNos", routingMerNos);
         return unionPay;
     }
 
@@ -249,6 +249,13 @@ public class PayServiceImpl implements PayService {
             if (account.getType().equals("COM")) {
                 account.setRoutingFee(routingFee.get("COM"));
             } else {
+                SysAccount perAccount = sysAccountService.getPerAccount(channel, account);
+                if (perAccount != null) {
+                    account.setRoutingMerNo(perAccount.getRoutingMerNo());
+                    if (!account.getCompany().equals("daya")) {
+                        account.setMerNo(perAccount.getRoutingMerNo());
+                    }
+                }
                 account.setRoutingFee(routingFee.get("PER"));
             }
         }
@@ -312,7 +319,7 @@ public class PayServiceImpl implements PayService {
     }
 
 
-    private Map<String, BigDecimal> getRoutingFee(String company, BigDecimal amount, Map<String, BigDecimal> fee, Integer organId,String receiver) {
+    private Map<String, BigDecimal> getRoutingFee(String company, BigDecimal amount, Map<String, BigDecimal> fee, Integer organId, String receiver) {
         Map<String, BigDecimal> routingFee = new HashMap<>(2);
         routingFee.put("COM", BigDecimal.ZERO);
         routingFee.put("PER", BigDecimal.ZERO);
@@ -321,7 +328,7 @@ public class PayServiceImpl implements PayService {
             return routingFee;
         }
 
-        if(receiver != null){
+        if (receiver != null) {
             routingFee.put(receiver, amount);
             return routingFee;
         }

+ 6 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -3033,6 +3033,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             if(order.getStatus().equals(DealStatusEnum.FAILED)&&Objects.nonNull(order.getBalancePaymentAmount())&&order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO)>0){
                 sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
             }
+            if(order.getStatus().equals(DealStatusEnum.SUCCESS)){
+                sysUserCashAccountService.updateBalance(order.getUserId(), order.getExpectAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "重复支付,退还余额");
+                order.setMemo("重复支付,进入余额");
+            }
             studentPaymentOrderDao.update(order);
             return;
         }
@@ -3097,10 +3101,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         PracticeGroup practiceGroup = practiceGroupDao.get(Long.valueOf(order.getMusicGroupId()));
         if(practiceGroup.getGroupStatus().equals(GroupStatusEnum.CANCEL)){
             order.setVersion(order.getVersion()+1);
-            order.setMemo("支付成功,在重新支付时,用户选择取消");
+            order.setMemo("支付成功,在重新支付时,用户选择取消,金额进入账户");
             studentPaymentOrderDao.update(order);
 
-            sysUserCashAccountService.updateBalance(order.getUserId(), order.getActualAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "支付成功,用户取消,退还余额");
+            sysUserCashAccountService.updateBalance(order.getUserId(), order.getExpectAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "支付成功,用户取消,退还余额");
 
             return;
         }

+ 30 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysAccountServiceImpl.java

@@ -1,16 +1,19 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 import com.ym.mec.biz.dal.dao.SysAccountDao;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysArea;
 import com.ym.mec.biz.service.SysAccountService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.date.DateUtil;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -18,6 +21,8 @@ public class SysAccountServiceImpl extends BaseServiceImpl<Integer, SysAccount>
 
     @Autowired
     private SysAccountDao sysAccountDao;
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
 
     @Override
     public BaseDAO<Integer, SysAccount> getDAO() {
@@ -31,7 +36,31 @@ public class SysAccountServiceImpl extends BaseServiceImpl<Integer, SysAccount>
 
     @Override
     public SysAccount getOneAccount(String company, String channel, String type, BigDecimal amount) {
-        return sysAccountDao.getOneAccount(company,channel,type,amount);
+        return sysAccountDao.getOneAccount(company, channel, type, amount);
+    }
+
+    @Override
+    public SysAccount getPerAccount(String channel, SysAccount account) {
+        BigDecimal maxReceive = new BigDecimal("75000");
+        Date nowDate = new Date();
+        Date firstDayOfMonth = DateUtil.getFirstDayOfMonth(nowDate);
+
+        BigDecimal amount = studentPaymentOrderDao.sumPerAccountAmount(account.getRoutingMerNo(),firstDayOfMonth);
+
+        if (amount == null || amount.compareTo(maxReceive) < 0) {
+            return account;
+        }
+
+        SysAccount newAccount = null;
+        List<SysAccount> perAccounts = sysAccountDao.getPerAccount(channel);
+        for (SysAccount perAccount : perAccounts) {
+            amount = studentPaymentOrderDao.sumPerAccountAmount(perAccount.getRoutingMerNo(),firstDayOfMonth);
+            if (amount == null || amount.compareTo(maxReceive) < 0) {
+                newAccount = perAccount;
+                break;
+            }
+        }
+        return newAccount;
     }
 
 }

+ 67 - 32
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -83,16 +83,19 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
         INSERT INTO student_payment_order
-        (id_, group_type_, user_id_,organ_id_,routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_, per_amount_,
+        (id_, group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
+         per_amount_,
          balance_payment_amount_, remit_fee_, trans_no_,
          status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
          payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_)
         VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-                #{userId},#{organId},#{routingOrganId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                #{userId}, #{organId}, #{routingOrganId},
+                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
                 #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
                 #{remitFee}, #{transNo},
                 #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
-                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo}, #{musicGroupId},
+                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
+                #{musicGroupId},
                 #{classGroupId})
     </insert>
 
@@ -251,15 +254,13 @@
                               #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </select>
     <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
-        SELECT
-        spo.*
-        FROM
-        student_payment_order spo
-        WHERE spo.user_id_=#{userId}
-        AND spo.music_group_id_=#{musicGroupId}
-        AND spo.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-        AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-        and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        SELECT spo.*
+        FROM student_payment_order spo
+        WHERE spo.user_id_ = #{userId}
+          AND spo.music_group_id_ = #{musicGroupId}
+          AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </select>
     <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
         SELECT
@@ -347,9 +348,11 @@
     </select>
 
     <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order
+        SELECT *
+        FROM student_payment_order
         WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-        AND payment_channel_ = #{paymentChannel} LIMIT 100
+          AND payment_channel_ = #{paymentChannel}
+        LIMIT 100
     </select>
 
     <!-- 查询支付中超时订单 -->
@@ -382,7 +385,7 @@
         FROM student_payment_order
         WHERE group_type_ = #{groupType}
           AND music_group_id_ = #{musicGroupId}
-          AND status_='SUCCESS'
+          AND status_ = 'SUCCESS'
     </select>
     <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
         SELECT *
@@ -416,7 +419,13 @@
     </select>
 
     <select id="findFixOrder" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order where status_ ='SUCCESS' AND type_='APPLY' AND actual_amount_> 0 and mer_nos_ IS NULL LIMIT 100
+        SELECT *
+        FROM student_payment_order
+        where status_ = 'SUCCESS'
+          AND type_ = 'APPLY'
+          AND actual_amount_ > 0
+          and mer_nos_ IS NULL
+        LIMIT 100
     </select>
 
 
@@ -439,7 +448,8 @@
 
     <!-- 分页查询 -->
     <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
-        SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_ detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
+        SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
+        detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
         o.name_ organ_name,sci.charge_type_,g.id_ goods_id, g.name_ goods_name FROM student_payment_order spo
         LEFT JOIN sys_user u on spo.user_id_ = u.id_
         LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
@@ -500,22 +510,37 @@
         <result property="money" column="money"/>
     </resultMap>
     <select id="getLuckStatis" resultMap="luckStatis">
-        SELECT o.name_ organName, SUM(spo.actual_amount_) money ,COUNT(spo.id_) nums FROM student_payment_order spo LEFT JOIN organization o ON o.id_=spo.organ_id_
-        WHERE spo.type_='LUCK' AND spo.status_='SUCCESS' GROUP BY spo.organ_id_ ORDER BY nums DESC;
+        SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
+        FROM student_payment_order spo
+                 LEFT JOIN organization o ON o.id_ = spo.organ_id_
+        WHERE spo.type_ = 'LUCK'
+          AND spo.status_ = 'SUCCESS'
+        GROUP BY spo.organ_id_
+        ORDER BY nums DESC;
     </select>
-    
+
     <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
-    	select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
-    	where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' )  AND status_ = 'SUCCESS'
-   		<if test="organId != null">
-   			and FIND_IN_SET(organ_id_,#{organId})
-   		</if>
-  	</select>
+        select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
+        where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
+        status_ = 'SUCCESS'
+        <if test="organId != null">
+            and FIND_IN_SET(organ_id_,#{organId})
+        </if>
+    </select>
     <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
-      select count(*) from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP' and status_='SUCCESS'
+        select count(*)
+        from student_payment_order
+        where user_id_ = #{userId}
+          and music_group_id_ = #{vipGroupId}
+          and group_type_ = 'VIP'
+          and status_ = 'SUCCESS'
     </select>
     <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
-      select * from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP'
+        select *
+        from student_payment_order
+        where user_id_ = #{userId}
+          and music_group_id_ = #{vipGroupId}
+          and group_type_ = 'VIP'
     </select>
     <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
         select * from student_payment_order
@@ -543,9 +568,19 @@
     <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
         SELECT * FROM student_payment_order
         WHERE music_group_id_=#{groupId}
-            and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-            <if test="status!=null">
-                and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-            </if>
+        and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        <if test="status!=null">
+            and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        </if>
+    </select>
+
+    <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
+        SELECT SUM(per_amount_)
+        FROM student_payment_order
+        WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
+          AND create_time_ >= #{firstDate}
+          AND create_time_ <= NOW()
+          AND FIND_IN_SET(#{merNo}, mer_nos_)
+        ]]>
     </select>
 </mapper>

+ 7 - 0
mec-biz/src/main/resources/config/mybatis/SysAccountMapper.xml

@@ -161,4 +161,11 @@
             <![CDATA[AND max_receipt_ < has_receipt_+ #{amount}]]>
         </if>
     </select>
+
+    <select id="getPerAccount" resultMap="SysAccount">
+        SELECT * FROM sys_account WHERE status_=1 AND type_='PER'
+        <if test="channel != null">
+            AND channel_ = #{channel}
+        </if>
+    </select>
 </mapper>

+ 32 - 0
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -209,6 +209,38 @@ public class PracticeGroupController extends BaseController {
         return practiceGroupService.repay(sysUser.getId(),groupId,useBalancePayment);
     }
 
+    @ApiOperation("免费陪练课定点推送")
+    @GetMapping(value = "/freePush")
+    public HttpResponseResult freePush(Integer userId, String pushType){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+
+        String pushUrl = baseApiUrl + "/#/auditionbanner/id";
+
+//        String smsUrl = baseApiUrl + "/#/transfer?url=" + baseApiUrl + "/#/auditionbanner/id";
+//
+//        SysUser student = sysUserFeignService.queryUserById(userId);
+
+        if(pushType.equals("ALL")||pushType.equals("JIGUANG")){
+            Map<Integer, String> userMap = new HashMap<>();
+            userMap.put(userId, userId.toString());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.FREE_PRACTICE_APPLY_PUSH,
+                    userMap, null, 0, "5?" + pushUrl, "STUDENT");
+        }
+
+//        if(pushType.equals("ALL")||pushType.equals("SMS")){
+//            Map<Integer, String> userPhoneMap = new HashMap<>();
+//            userPhoneMap.put(userId, student.getPhone());
+//            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.FREE_PRACTICE_APPLY_PUSH,
+//                    userPhoneMap, null, 0, null, "STUDENT", HttpUtil.getSortUrl(smsUrl));
+//        }
+
+        return succeed();
+    }
+
     @ApiOperation("陪练课完成报告推送")
     @GetMapping(value = "/reportPush")
     public HttpResponseResult reportPush(Integer userId, String pushType){

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java

@@ -313,7 +313,7 @@ public class CourseScheduleController extends BaseController {
     		batchInsertCoursesDto.setClassGroupId(classGroupList.get(0).getId());
     	}
 		scheduleService.batchAddCourseSchedule(batchInsertCoursesDto.getClassGroupId(), batchInsertCoursesDto.getCoursesTimes(),
-				batchInsertCoursesDto.getStartDate(), null, batchInsertCoursesDto.getTeachingArrangementList(), batchInsertCoursesDto.getTeachMode(),
+				batchInsertCoursesDto.getStartDate(), null,null, batchInsertCoursesDto.getTeachingArrangementList(), batchInsertCoursesDto.getTeachMode(),
 				batchInsertCoursesDto.getType(), batchInsertCoursesDto.getSchoolId(), batchInsertCoursesDto.getIsJumpHoliday());
         return succeed();
     }