Browse Source

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

zouxuan 5 years ago
parent
commit
74a78afe18

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentFeeDao.java

@@ -25,6 +25,13 @@ public interface MusicGroupStudentFeeDao extends BaseDAO<Long, MusicGroupStudent
 	 * @return
 	 */
 	int deleteByUserIdAndMusicGroupId(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
+	
+	/**
+	 * 删除缴费记录
+	 * @param musicGroupId
+	 * @return
+	 */
+	int deleteByMusicGroupId(String musicGroupId);
 
 	/**
 	 * @describe 根据学生编号和乐团编号更新旷课次数

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentApplyRefundsDao.java

@@ -29,5 +29,18 @@ public interface StudentApplyRefundsDao extends BaseDAO<Long, StudentApplyRefund
      */
     List<StudentApplyRefunds> findByGroupAndType(@Param("groupId") String groupId,
                                                  @Param("groupType") String groupType);
+
+    /**
+     * @describe 获取用户退课中的申请
+     * @author Joburgess
+     * @date 2019/12/9
+     * @param groupId: 乐团或vip课编号
+     * @param groupType: 乐团类型
+     * @param userId: 用户编号
+     * @return java.util.List<com.ym.mec.biz.dal.entity.StudentApplyRefunds>
+     */
+    List<StudentApplyRefunds> findByGroupAndUser(@Param("groupId") String groupId,
+                                                 @Param("groupType") String groupType,
+                                                 @Param("userId") Integer userId);
 	
 }

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

@@ -35,6 +35,9 @@ public class HighClassGroupDto extends ClassGroup {
 	@ApiModelProperty(value = "排课次数", required = true)
 	private Integer courseTimes;
 
+	@ApiModelProperty(value = "是否跳过节假日 true-跳过 false-不跳过", required = true)
+	private Boolean isHoliday;
+
 	public Integer getUserId() {
 		return userId;
 	}
@@ -95,4 +98,12 @@ public class HighClassGroupDto extends ClassGroup {
 	public void setTeacherName(String teacherName) {
 		this.teacherName = teacherName;
 	}
+
+	public Boolean getHoliday() {
+		return isHoliday;
+	}
+
+	public void setHoliday(Boolean holiday) {
+		isHoliday = holiday;
+	}
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ClassGroupStudentMapper.java

@@ -7,6 +7,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 
+import java.util.Date;
+
 /**
  * 对应数据库表(class_group_student_mapper):
  */
@@ -38,6 +40,16 @@ public class ClassGroupStudentMapper {
 
 	private String userName;
 
+	private Date updateTime;
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
 	public String getUserName() {
 		return userName;
 	}

+ 15 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1131,7 +1131,11 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
                 courseSchedule.setType(classGroup4MixDto.getCourseType());
                 courseSchedule.setGroupType(GroupType.MUSIC);
-                courseSchedule.setName(subjectNames + "-" + CourseSchedule.CourseScheduleType.SINGLE.getMsg());
+                if(classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MIX)){
+                    courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
+                }else{
+                    courseSchedule.setName(subjectNames + "-" + CourseSchedule.CourseScheduleType.SINGLE.getMsg());
+                }
                 courseSchedule.setTeacherId(teacherId);
                 courseSchedule.setActualTeacherId(teacherId);
                 courseScheduleDao.insert(courseSchedule);
@@ -1328,7 +1332,11 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
                 courseSchedule.setMusicGroupId(classGroup.getMusicGroupId());
                 courseSchedule.setType(classGroup4MixDto.getCourseType());
-                courseSchedule.setName(subjectNames + "-" + classGroup4MixDto.getCourseType().getMsg());
+                if(classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MIX)){
+                    courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
+                }else{
+                    courseSchedule.setName(subjectNames + "-" + classGroup4MixDto.getCourseType().getMsg());
+                }
                 courseSchedule.setGroupType(GroupType.MUSIC);
                 courseSchedule.setTeacherId(teacherId);
                 courseSchedule.setActualTeacherId(teacherId);
@@ -1548,7 +1556,11 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 courseSchedule.setType(classGroup4MixDto.getCourseType());
                 courseSchedule.setGroupType(GroupType.MUSIC);
                 courseSchedule.setMusicGroupId(classGroup.getMusicGroupId());
-                courseSchedule.setName(subjectNames + "-" + classGroup4MixDto.getCourseType().getMsg());
+                if(classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MIX)){
+                    courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
+                }else{
+                    courseSchedule.setName(subjectNames + "-" + classGroup4MixDto.getCourseType().getMsg());
+                }
                 courseSchedule.setTeacherId(teacherId);
                 courseSchedule.setActualTeacherId(teacherId);
 

+ 20 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -609,13 +609,17 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.SUCCESS);
 
 			if (studentPaymentOrder == null) {
-				throw new BizException("缴费订单不存在");
-			}
+				MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanService.findSubjectPlan(musicGroupId, subjectId);
+				if (musicGroupSubjectPlan != null) {
+					depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
+				}
+			} else {
 
-			List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
-			for (StudentPaymentOrderDetail detail : orderDetailList) {
-				if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
-					depositFee = detail.getPrice().doubleValue();
+				List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
+				for (StudentPaymentOrderDetail detail : orderDetailList) {
+					if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
+						depositFee = detail.getPrice().doubleValue();
+					}
 				}
 			}
 		}
@@ -697,13 +701,17 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.WAIT_PAY);
 
 			if (studentPaymentOrder == null) {
-				throw new BizException("缴费订单不存在");
-			}
+				MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanService.findSubjectPlan(musicGroupId, subjectId);
+				if (musicGroupSubjectPlan != null) {
+					depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
+				}
+			} else {
 
-			List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
-			for (StudentPaymentOrderDetail detail : orderDetailList) {
-				if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
-					depositFee = detail.getPrice().doubleValue();
+				List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
+				for (StudentPaymentOrderDetail detail : orderDetailList) {
+					if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
+						depositFee = detail.getPrice().doubleValue();
+					}
 				}
 			}
 		}

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

@@ -882,6 +882,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (studentPaymentOrders != null && studentPaymentOrders.size() > 0) {
             throw new BizException("缴费存在交易中的数据,不能取消乐团");
         }
+        
+        //删除续费记录
+        musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId);
 
         // 查询已缴费信息
         studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(musicGroupId, OrderTypeEnum.APPLY, DealStatusEnum.SUCCESS);

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -697,7 +697,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
 
         if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
-            studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
+            if(studentRegistration.getTemporaryCourseFee() != null){
+                studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
+            }
             studentRegistration.setPaymentStatus(PaymentStatusEnum.YES);
             studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.NORMAL);
             studentRegistrationDao.update(studentRegistration);

+ 17 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -176,6 +176,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		CourseSchedule firstCourseSchedule = vipGroup.getCourseSchedules().stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
 		//获取最后一节课
 		CourseSchedule latestCourseSchedule = vipGroup.getCourseSchedules().stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
+
+		if(firstCourseSchedule.getStartClassTime().before(now)){
+			throw new BizException("开课时间不能小于当前时间");
+		}
+
 		//判断课程安排是否超出范围
 		if(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime())){
 			if(latestCourseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
@@ -560,10 +565,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 					StudentApplyRefunds studentApplyRefund = studentApplyRefunds.get(0);
 					if(data.getStudentStatus()==0&&studentApplyRefund.getStatus().equals(StudentApplyRefundsStatus.ING)){
 						data.setStudentStatus(2);
-						data.setRefundDate(studentApplyRefund.getUpdateTime());
-					}
-					if(data.getStudentStatus()==0){
-						data.setRefundDate(studentApplyRefund.getUpdateTime());
 					}
 				}
 			});
@@ -1182,9 +1183,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("指定的课程不存在");
 		}
 		if(vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)){
-			throw new BizException("不能已进行的课程进行此操作");
+			throw new BizException("不能对已停止的课程进行此操作");
 		}
-		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
+
+        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), GroupType.VIP.getCode(), studentId);
+		if(!CollectionUtils.isEmpty(studentApplyRefunds)){
+		    throw new BizException("此学生存在退课申请,请到系统日志中查看");
+        }
+
+        ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
 
 		ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
 				studentId);
@@ -1305,6 +1312,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(studentPaymentOrder.getClassGroupId(),
 						studentPaymentOrder.getUserId());
 
+				if(Objects.isNull(classStudentMapperByUserIdAndClassGroupId)){
+				    throw new BizException("此学员不在指定班级上");
+                }
+
 				classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
 				classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
 

+ 4 - 2
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -13,6 +13,7 @@
         <result column="class_group_id_" property="classGroupId"/>
         <result column="user_id_" property="userId"/>
         <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
         <result column="username_" property="userName"/>
         <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
@@ -30,8 +31,8 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ClassGroupStudentMapper" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
-        INSERT INTO class_group_student_mapper (id_,group_type_,music_group_id_,class_group_id_,user_id_,status_,create_time_)
-        VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},#{userId},#{status},now())
+        INSERT INTO class_group_student_mapper (id_,group_type_,music_group_id_,class_group_id_,user_id_,status_,create_time_,update_time_)
+        VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},#{userId},#{status},now(),now())
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -50,6 +51,7 @@
             <if test="groupType != null">
                 group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+            update_time_ = now(),
         </set>
         WHERE id_ = #{id}
     </update>

+ 5 - 8
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -1498,15 +1498,12 @@
     </delete>
     
     <select id="queryUnsignedStudentList" resultMap="StudentAttendance">
-        SELECT a.*,cg.current_class_times_,sa.id_ FROM (SELECT cssp.user_id_,cs.actual_teacher_id_ teacher_id_,
-        cs.id_ course_schedule_id_,cs.class_group_id_,cs.music_group_id_,cs.group_type_
+        SELECT cssp.user_id_,cs.actual_teacher_id_ teacher_id_,
+        cs.id_ course_schedule_id_,cs.class_group_id_,cs.music_group_id_,cs.group_type_,cg.current_class_times_
         FROM course_schedule_student_payment cssp
-        LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
-        WHERE CONCAT(cs.class_date_,' ',cs.end_class_time_) &lt;= now() AND cssp.actual_price_ IS NOT NULL) a
-        LEFT JOIN class_group cg ON a.class_group_id_ = cg.id_
-        LEFT JOIN student_attendance sa ON sa.user_id_ = a.user_id_ AND a.teacher_id_ = sa.teacher_id_
-        AND sa.class_group_id_ = a.class_group_id_ AND sa.course_schedule_id_ = a.course_schedule_id_
-        WHERE sa.id_ IS NULL
+        LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_ LEFT JOIN class_group cg ON cg.id_=cs.class_group_id_
+        LEFT JOIN student_attendance sa ON sa.course_schedule_id_= cssp.course_schedule_id_
+        WHERE CONCAT(cs.class_date_,' ',cs.end_class_time_) <= now() AND sa.id_ IS NULL
     </select>
     <select id="getNextCourseSchedule" resultMap="CourseSchedule">
         SELECT

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentFeeMapper.xml

@@ -103,6 +103,10 @@
     <delete id="deleteByUserIdAndMusicGroupId" parameterType="map">
 		DELETE FROM music_group_student_fee_ WHERE user_id_ = #{userId} and music_group_id_ = #{musicGroupId}
 	</delete>
+	
+    <delete id="deleteByMusicGroupId" parameterType="map">
+		DELETE FROM music_group_student_fee_ WHERE music_group_id_ = #{musicGroupId}
+	</delete>
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="MusicGroupStudentFee" parameterType="map">

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

@@ -144,7 +144,7 @@
             sar.update_time_
         FROM
             student_payment_order spo
-            LEFT JOIN student_apply_refunds sar ON spo.user_id_
+            LEFT JOIN student_apply_refunds sar ON spo.user_id_=sar.user_id_
             AND spo.id_ = sar.orig_payment_order_id_
         WHERE
             spo.music_group_id_ = #{groupId}
@@ -155,4 +155,20 @@
             spo.update_time_ DESC
 
     </select>
+    <select id="findByGroupAndUser" resultMap="StudentApplyRefunds">
+        SELECT
+            sar.*
+        FROM
+            student_apply_refunds sar
+            LEFT JOIN student_payment_order spo ON spo.user_id_=sar.user_id_
+            AND spo.id_ = sar.orig_payment_order_id_
+        WHERE
+            spo.music_group_id_ = #{groupId}
+            AND spo.group_type_ = #{groupType}
+            AND spo.user_id_ = #{userId}
+            AND spo.status_ = 'SUCCESS'
+            AND sar.status_ = 'ING'
+        ORDER BY
+            spo.update_time_ DESC
+    </select>
 </mapper>

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

@@ -474,6 +474,7 @@
         <result column="current_class_times_" property="currentClassTimes"/>
         <result column="course_balance_" property="courseSalary"/>
         <result column="create_time_" property="applyDate"/>
+        <result column="update_time_" property="refundDate"/>
         <result column="student_status_" property="studentStatus"/>
     </resultMap>
 
@@ -486,6 +487,7 @@
             cg.current_class_times_,
             suaa.course_balance_,
             cgsm.create_time_,
+            cgsm.update_time_,
             CASE cgsm.status_ WHEN 'QUIT' THEN 1 ELSE 0 END student_status_
         FROM
             class_group cg

+ 129 - 129
mec-util/src/main/java/com/ym/mec/util/money/MoneyUtil.java

@@ -1,131 +1,131 @@
 package com.ym.mec.util.money;
 
-public class MoneyUtil {  
-    /** 大写数字 */  
-    private static final String[] NUMBERS = { "零", "壹", "贰", "叁", "肆", "伍",  
-            "陆", "柒", "捌", "玖" };  
-  
-    /** 整数部分的单位 */  
-    private static final String[] IUNIT = { "元", "拾", "佰", "仟", "万", "拾", "佰",  
-            "仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟" };  
-  
-    /** 小数部分的单位 */  
-    private static final String[] DUNIT = { "角", "分", "厘" };  
-  
-    /** 
-     * 得到大写金额。 
-     */  
-    public static String toChinese(String str) {  
-        str = str.replaceAll(",", "");// 去掉","  
-        String integerStr;// 整数部分数字  
-        String decimalStr;// 小数部分数字  
-        // 初始化:分离整数部分和小数部分  
-        if (str.indexOf(".") > 0) {  
-            integerStr = str.substring(0, str.indexOf("."));  
-            decimalStr = str.substring(str.indexOf(".") + 1);  
-        } else if (str.indexOf(".") == 0) {  
-            integerStr = "";  
-            decimalStr = str.substring(1);  
-        } else {  
-            integerStr = str;  
-            decimalStr = "";  
-        }  
-        // integerStr去掉首0,不必去掉decimalStr的尾0(超出部分舍去)  
-        if (!integerStr.equals("")) {  
-            integerStr = Long.toString(Long.parseLong(integerStr));  
-            if (integerStr.equals("0")) {  
-                integerStr = "";  
-            }  
-        }  
-        // overflow超出处理能力,直接返回  
-        if (integerStr.length() > IUNIT.length) {  
-            System.out.println(str + ":超出处理能力");  
-            return str;  
-        }  
-  
-        int[] integers = toArray(integerStr);// 整数部分数字  
-        boolean isMust5 = isMust5(integerStr);// 设置万单位  
-        int[] decimals = toArray(decimalStr);// 小数部分数字  
-        return getChineseInteger(integers, isMust5)  
-                + getChineseDecimal(decimals);  
-    }  
-  
-    /** 
-     * 整数部分和小数部分转换为数组,从高位至低位 
-     */  
-    private static int[] toArray(String number) {  
-        int[] array = new int[number.length()];  
-        for (int i = 0; i < number.length(); i++) {  
-            array[i] = Integer.parseInt(number.substring(i, i + 1));  
-        }  
-        return array;  
-    }  
-  
-    /** 
-     * 得到中文金额的整数部分。 
-     */
-    private static String getChineseInteger(int[] integers, boolean isMust5) {  
-        StringBuffer chineseInteger = new StringBuffer("");  
-        int length = integers.length;  
-        for (int i = 0; i < length; i++) {  
-            // 0出现在关键位置:1234(万)5678(亿)9012(万)3456(元)  
-            // 特殊情况:10(拾元、壹拾元、壹拾万元、拾万元)  
-            String key = "";  
-            if (integers[i] == 0) {  
-                if ((length - i) == 13)// 万(亿)(必填)  
-                    key = IUNIT[4];  
-                else if ((length - i) == 9)// 亿(必填)  
-                    key = IUNIT[8];  
-                else if ((length - i) == 5 && isMust5)// 万(不必填)  
-                    key = IUNIT[4];  
-                else if ((length - i) == 1)// 元(必填)  
-                    key = IUNIT[0];  
-                // 0遇非0时补零,不包含最后一位  
-                if ((length - i) > 1 && integers[i + 1] != 0)  
-                    key += NUMBERS[0];  
-            }  
-            chineseInteger.append(integers[i] == 0 ? key  
-                    : (NUMBERS[integers[i]] + IUNIT[length - i - 1]));  
-        }  
-        return chineseInteger.toString();  
-    }  
-  
-    /** 
-     * 得到中文金额的小数部分。 
-     */  
-    private static String getChineseDecimal(int[] decimals) {  
-        StringBuffer chineseDecimal = new StringBuffer("");  
-        for (int i = 0; i < decimals.length; i++) {  
-            // 舍去3位小数之后的  
-            if (i == 3)  
-                break;  
-            chineseDecimal.append(decimals[i] == 0 ? ""  
-                    : (NUMBERS[decimals[i]] + DUNIT[i]));  
-        }  
-        return chineseDecimal.toString();  
-    }  
-  
-    /** 
-     * 判断第5位数字的单位"万"是否应加。 
-     */  
-    private static boolean isMust5(String integerStr) {  
-        int length = integerStr.length();  
-        if (length > 4) {  
-            String subInteger = "";  
-            if (length > 8) {  
-                // 取得从低位数,第5到第8位的字串  
-                subInteger = integerStr.substring(length - 8, length - 4);  
-            } else {  
-                subInteger = integerStr.substring(0, length - 4);  
-            }  
-            return Integer.parseInt(subInteger) > 0;  
-        } else {  
-            return false;  
-        }  
-    }  
-  
-    public static void main(String[] args) {  
-        System.out.println(MoneyUtil.toChinese("500100001.23"));  
-    }  
-  
-}  
+import com.ym.mec.util.exception.UtilException;
+
+public class MoneyUtil {
+	/** 大写数字 */
+	private static final String[] NUMBERS = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
+
+	/** 整数部分的单位 */
+	private static final String[] IUNIT = { "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟" };
+
+	/** 小数部分的单位 */
+	private static final String[] DUNIT = { "角", "分", "厘" };
+
+	/** 
+	 * 得到大写金额。 
+	 */
+	public static String toChinese(String str) {
+		str = str.replaceAll(",", "");// 去掉","
+		String integerStr;// 整数部分数字
+		String decimalStr;// 小数部分数字
+		// 初始化:分离整数部分和小数部分
+		if (str.indexOf(".") > 0) {
+			integerStr = str.substring(0, str.indexOf("."));
+			decimalStr = str.substring(str.indexOf(".") + 1);
+		} else if (str.indexOf(".") == 0) {
+			integerStr = "";
+			decimalStr = str.substring(1);
+		} else {
+			integerStr = str;
+			decimalStr = "";
+		}
+		// integerStr去掉首0,不必去掉decimalStr的尾0(超出部分舍去)
+		if (!integerStr.equals("")) {
+			integerStr = Long.toString(Long.parseLong(integerStr));
+			if (integerStr.equals("0")) {
+				integerStr = "";
+			}
+		}
+		// overflow超出处理能力,直接返回
+		if (integerStr.length() > IUNIT.length) {
+			throw new UtilException(str + ":超出处理能力");
+		}
+
+		int[] integers = toArray(integerStr);// 整数部分数字
+		boolean isMust5 = isMust5(integerStr);// 设置万单位
+		int[] decimals = toArray(decimalStr);// 小数部分数字
+		return getChineseInteger(integers, isMust5) + getChineseDecimal(decimals);
+	}
+
+	/** 
+	 * 整数部分和小数部分转换为数组,从高位至低位 
+	 */
+	private static int[] toArray(String number) {
+		int[] array = new int[number.length()];
+		for (int i = 0; i < number.length(); i++) {
+			array[i] = Integer.parseInt(number.substring(i, i + 1));
+		}
+		return array;
+	}
+
+	/** 
+	 * 得到中文金额的整数部分。 
+	 */
+	private static String getChineseInteger(int[] integers, boolean isMust5) {
+		StringBuffer chineseInteger = new StringBuffer("");
+		int length = integers.length;
+		if(length == 0){
+			return "零元";
+		}
+		for (int i = 0; i < length; i++) {
+			// 0出现在关键位置:1234(万)5678(亿)9012(万)3456(元)
+			// 特殊情况:10(拾元、壹拾元、壹拾万元、拾万元)
+			String key = "";
+			if (integers[i] == 0) {
+				if ((length - i) == 13)// 万(亿)(必填)
+					key = IUNIT[4];
+				else if ((length - i) == 9)// 亿(必填)
+					key = IUNIT[8];
+				else if ((length - i) == 5 && isMust5)// 万(不必填)
+					key = IUNIT[4];
+				else if ((length - i) == 1)// 元(必填)
+					key = IUNIT[0];
+				// 0遇非0时补零,不包含最后一位
+				if ((length - i) > 1 && integers[i + 1] != 0)
+					key += NUMBERS[0];
+			}
+			chineseInteger.append(integers[i] == 0 ? key : (NUMBERS[integers[i]] + IUNIT[length - i - 1]));
+		}
+		return chineseInteger.toString();
+	}
+
+	/** 
+	 * 得到中文金额的小数部分。 
+	 */
+	private static String getChineseDecimal(int[] decimals) {
+		StringBuffer chineseDecimal = new StringBuffer("");
+		for (int i = 0; i < decimals.length; i++) {
+			// 舍去3位小数之后的
+			if (i == 3)
+				break;
+			chineseDecimal.append(decimals[i] == 0 ? "" : (NUMBERS[decimals[i]] + DUNIT[i]));
+		}
+		return chineseDecimal.toString();
+	}
+
+	/** 
+	 * 判断第5位数字的单位"万"是否应加。 
+	 */
+	private static boolean isMust5(String integerStr) {
+		int length = integerStr.length();
+		if (length > 4) {
+			String subInteger = "";
+			if (length > 8) {
+				// 取得从低位数,第5到第8位的字串
+				subInteger = integerStr.substring(length - 8, length - 4);
+			} else {
+				subInteger = integerStr.substring(0, length - 4);
+			}
+			return Integer.parseInt(subInteger) > 0;
+		} else {
+			return false;
+		}
+	}
+
+	public static void main(String[] args) {
+		double d = 0d;
+		System.out.println(MoneyUtil.toChinese(d + ""));
+	}
+
+}

+ 2 - 3
mec-web/src/main/java/com/ym/mec/web/WebApplication.java

@@ -1,6 +1,5 @@
 package com.ym.mec.web;
 
-import com.spring4all.swagger.EnableSwagger2Doc;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -10,11 +9,11 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.web.client.RestTemplate;
 
+import com.spring4all.swagger.EnableSwagger2Doc;
+
 @SpringBootApplication
 @EnableDiscoveryClient
 @EnableFeignClients("com.ym.mec")