瀏覽代碼

Merge remote-tracking branch 'origin/master'

周箭河 5 年之前
父節點
當前提交
dbd1e1576a

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

@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -33,6 +34,17 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
                                               @Param("status") String status);
 
     /**
+     * @describe 统计学员剩余课时的课程费用
+     * @author Joburgess
+     * @date 2019/12/3
+     * @param vipGroupId:
+     * @param userId:
+     * @return java.math.BigDecimal
+     */
+    BigDecimal sumSurplusCourseFee(@Param("vipGroupId") String vipGroupId,
+                                   @Param("userId") Integer userId);
+
+    /**
      * @Author: Joburgess
      * @Date: 2019/10/3
      * 根据学生vip课获取非失败缴费订单

+ 11 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1201,7 +1201,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
 			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode());
 			if(Objects.isNull(studentPaymentOrder)){
-				result.put("suplusCourseFee",new BigDecimal(0));
+				BigDecimal surplusCourseFee = studentPaymentOrderDao.sumSurplusCourseFee(vipGroupId.toString(), studentId);
+				if(Objects.isNull(surplusCourseFee)){
+					result.put("suplusCourseFee",new BigDecimal(0));
+				}else{
+					result.put("suplusCourseFee",surplusCourseFee);
+				}
 			}else{
 				result.put("suplusCourseFee",studentPaymentOrder.getActualAmount());
 			}
@@ -1209,7 +1214,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
 		if(Objects.isNull(classGroup)){
-			throw new BizException("找到对应班级");
+			throw new BizException("找到对应班级");
 		}
 		BigDecimal bigDecimal = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
 		result.put("suplusCourseFee",Objects.isNull(bigDecimal)?new BigDecimal(0):bigDecimal);
@@ -1618,6 +1623,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				courseScheduleStudentPayment.setClassGroupId(vipGroupCourseSchedule.getClassGroupId());
 				courseScheduleStudentPayment.setCourseScheduleId(vipGroupCourseSchedule.getId());
 				courseScheduleStudentPayment.setUserId(studentId);
+				//通过课程余额兑换的课程不会产生实际费用
 				courseScheduleStudentPayment.setExpectPrice(new BigDecimal(0));
 				courseScheduleStudentPayment.setCreateTime(now);
 				courseScheduleStudentPayment.setUpdateTime(now);
@@ -1720,7 +1726,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                         vipGroup.setStatus(VipGroupStatusEnum.NOT_START);
                     }
                     if(vipGroup.getRegistrationStartTime().before(now)&&vipGroup.getCoursesExpireDate().after(now)){
-                        vipGroup.setStatus(VipGroupStatusEnum.APPLYING);
+                        if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
+							vipGroup.setStatus(VipGroupStatusEnum.APPLYING);
+						}
                     }
                     if(vipGroup.getCoursesExpireDate().before(now)&&vipGroup.getCourseStartDate().after(now)){
                         vipGroup.setStatus(VipGroupStatusEnum.APPLYING_END);

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

@@ -215,6 +215,17 @@
             </if>
             AND spo.type_ = 'SMALL_CLASS_TO_BUY'
     </select>
+    <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
+        SELECT
+            SUM(cssp.expect_price_)
+        FROM
+            course_schedule_student_payment cssp
+            LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
+        WHERE
+            cssp.user_id_ = #{userId}
+            AND cssp.music_group_id_ = #{vipGroupId}
+            AND cs.status_='NOT_START'
+    </select>
     <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
         SELECT
           spo.*

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -743,7 +743,7 @@
         FROM
           vip_group
         WHERE
-          payment_expire_date_ &lt; NOW( )
+          payment_expire_date_ &lt; DATE_FORMAT(NOW( ),'%Y-%m-%d')
           AND status_ =1
     </select>