yujian
2018-12-29 e55de244fa08ee10b08ee316ae1aa64d2e55efe8
订单接口代码修复
2个文件已修改
56 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/DateUtil.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java
@@ -73,23 +73,24 @@
            page = 1;
        }
        
        if (state !=null && state == 0) {
            state = null;
        if (state != null && state == 0) {
            state = null;// 所有状态
        }
        
        if (type != null && type == 0 ) {
            type = null; // 查询所有类型订单
            type = null; // 所有类型订单
        }
        
        try {
            if (slotTime != null) {
                SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                startTime = sd.format(new Date());
                endTime = convertDate(slotTime, startTime);
                 endTime= sd.format(new Date());
                 startTime = convertDate(slotTime, endTime);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        try {
            long count = 0;
@@ -140,9 +141,9 @@
            data.put("helpUrl", helpUrl);
            
            if (type != null && type == 1) {
                data.put("todayMoney", "今日预估返利总额 ¥" + todayMoney);
                data.put("todayMoney", "今日预估返利总额 ¥" + todayMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
            } else {
                data.put("todayMoney", "预估奖金总额 ¥" + todayMoney);
                data.put("todayMoney", "今日预估奖金总额 ¥" + todayMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
            }
            data.put("todayTotal", "共"+ todayTotal+ "笔");
            data.put("totalValid", totalValid); // 有效数量
@@ -315,32 +316,32 @@
     * @return
     * @throws Exception
     */
    public String convertDate (Integer slotTime, String startTime) throws Exception {
        String endTime = null;
    public String convertDate (Integer slotTime, String endTime) throws Exception {
        String startTime = null;
        
        switch (slotTime) {
            case 1: // 最近三天
                endTime = DateUtil.plusDay(3, startTime);
                startTime = DateUtil.reduceDay(3, endTime);
                break;
            case 2: // 最近七天
                endTime = DateUtil.plusDay(7, startTime);
                startTime = DateUtil.reduceDay(7, endTime);
                break;
            case 3: // 最近15天 (半月)
                endTime = DateUtil.plusDay(15, startTime);
                startTime = DateUtil.reduceDay(15, endTime);
                break;
            case 4: // 最近三十天 (本月)
                endTime = DateUtil.plusDay(30, startTime);
                startTime = DateUtil.reduceDay(30, endTime);
                break;
            case 5: // 最近九十天(近三月)
                endTime = DateUtil.plusDay(3*30, startTime);
                startTime = DateUtil.reduceDay(3*30, endTime);
                break;
            case 6: // 最近一百八十天(近半年)
                endTime = DateUtil.plusDay(6*30, startTime);
                startTime = DateUtil.reduceDay(6*30, endTime);
                break;
            default:
                break;
        }
        
        return endTime;
        return startTime;
    }
}
utils/src/main/java/org/yeshi/utils/DateUtil.java
@@ -97,7 +97,7 @@
     * 指定日期加上天数后的日期
     * 
     * @param num
     *            为增加的天数
     *            增加的天数
     * @param nowDate
     *            创建时间
     * @return
@@ -113,4 +113,25 @@
        
        return format.format(ca.getTime());
    }
    /**
     * 指定日期减去天数后的日期
     *
     * @param num
     *            减去的天数
     * @param nowDate
     *            创建时间
     * @return
     * @throws ParseException
     */
    public static String reduceDay(int num, String nowDate) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date currdate = format.parse(nowDate);
        Calendar ca = Calendar.getInstance();
        ca.setTime(currdate);
        ca.add(Calendar.DATE, -num); // 日期减 如果不够减会将月变动
        return format.format(ca.getTime());
    }
}