yujian
2018-12-26 f0f94a69b05dd6049e1b3dff2ef3f7a9ac8332fb
订单接口优化
5个文件已修改
388 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java 115 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 174 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java
@@ -21,6 +21,7 @@
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.account.UserUtil;
@@ -38,24 +39,30 @@
    
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private HongBaoService hongBaoService;
    /**
     * 订单列表
     * @param acceptData
     * @param page
     * @param uid
     * @param state  状态:1-未到账 3-已到账 4-已失效
     * @param state  状态:1-未到账 2-已到账 3-已失效
     * @param type   类型:1-返利订单 2-分享订单 3-邀请订单
     * @param orderNo 订单号
     * @param orderState   1有效订单 2 维权订单  3失效订单
     * @param orderNo 订单号
     * @param startTime  起始时间
     * @param endTime   结束时间
     * @param slotTime 时间段:1-最近三天 2-最近七天 3最近半月 4本月 5近三月  6近半年
     * @param dateType   1-今日 2-昨天 3-本月 4-上个月  |
     * @param needCount
     * @param out
     */
    @RequestMapping(value = "getorder", method = RequestMethod.POST)
    public void getOrder(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type, String orderNo,
            String startTime, String endTime, Integer slotTime, boolean needCount, PrintWriter out) {
    public void getOrder(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
            Integer orderState,String orderNo, String startTime, String endTime, Integer slotTime,
            boolean needCount, Integer dateType, PrintWriter out) {
        
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
@@ -86,11 +93,11 @@
        
        try {
            long count = 0;
            List<CommonOrderVO> list = commonOrderService.getOrderByUid(page, uid, state, type, orderNo,
                    startTime, endTime);
            List<CommonOrderVO> list = commonOrderService.getOrderByUid(page, uid, state, type, orderState, orderNo,
                    startTime, endTime, dateType);
            
            if (list != null && list.size() > 0) {
                count = commonOrderService.countGroupOrderNoByUid(uid,  state, type, orderNo, startTime, endTime);
                count = commonOrderService.countGroupOrderNoByUid(uid,  state, type, orderState, orderNo, startTime, endTime, dateType);
            }
            
            int totalValid = 0;
@@ -276,11 +283,15 @@
            
            JSONObject data = new JSONObject();
            // 分享统计
            BigDecimal sharemoney = commonOrderService.countOrderMoney(uid,2, dateType);
            data.put("shareCount", commonOrderService.countOrder(uid, 2, dateType));
            data.put("sharemoney", commonOrderService.countOrderMoney(uid,2, dateType));
            data.put("sharemoney", sharemoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
            // 邀请统计
            BigDecimal inviteMoney = commonOrderService.countOrderMoney(uid,3, dateType);
            data.put("inviteCount", commonOrderService.countOrder(uid, 3, dateType));
            data.put("inviteMoney", commonOrderService.countOrderMoney(uid,3, dateType));
            data.put("inviteMoney", inviteMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("showTiCheng", hongBaoService.getTotalTiChengCount(uid) > 0);
            
            out.print(JsonUtil.loadTrueResult(data));
            
@@ -288,94 +299,8 @@
            out.print(JsonUtil.loadFalseResult(1, "获取信息失败"));
            e.printStackTrace();
        }
    }
    
    /**
     * 奖金订单
     * @param acceptData
     * @param page
     * @param uid
     * @param dateType   1-今日 2-昨天 3-本月 4-上个月  |
     * @param type     订单类型:1-返利订单 2-分享订单 3-邀请订单
     * @param out
     */
    @RequestMapping(value = "getbonusorder", method = RequestMethod.POST)
    public void getBonusOrder(AcceptData acceptData, Integer page, Long uid, Integer dateType,
            Integer type, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (type == null || dateType == null ) {
            out.print(JsonUtil.loadFalseResult(1, "传递参数缺失"));
            return;
        }
        if (page == null || page < 1) {
            page = 1;
        }
        try {
            long count = 0;
            List<CommonOrderVO> list = commonOrderService.listBonusOrder(page, uid,  type, dateType);
            if (list != null && list.size() > 0) {
                count = commonOrderService.countOrder(uid, type, dateType);
            }
            int totalValid = 0;
            int totalProces = 0;
            int totalInvite = 0;
            long todayTotal = 0;
            BigDecimal todayMoney = null;
            // 需要统计信息
            if (page == 1) {
                Map<String, BigDecimal> countOrder = commonOrderService.countBonusOrderByState(uid, type, dateType);
                if (countOrder.get("totalValid") != null) {
                    totalValid = countOrder.get("totalValid").intValue();
                }
                if (countOrder.get("totalProces") != null) {
                    totalProces = countOrder.get("totalProces").intValue();
                }
                if (countOrder.get("totalInvite") != null) {
                    totalInvite = countOrder.get("totalInvite").intValue();
                }
                todayTotal = commonOrderService.countOrder(uid, type, 1);
                todayMoney = commonOrderService.countOrderMoney(uid, type , 1);
            }
            if (todayMoney == null) {
                todayMoney = new BigDecimal(0);
            }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", JsonUtil.getApiCommonGson().toJson(list));
            data.put("todayTotal", todayTotal);
            data.put("todayMoney", todayMoney);
            data.put("totalValid", totalValid); // 有效数量
            data.put("totalProces", totalProces); // 维权数量
            data.put("totalInvite", totalInvite); // 失效数量
            out.print(JsonUtil.loadTrueResult(data));
        } catch(CommonOrderException e){
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "查询失败"));
            e.printStackTrace();
        }
    }
    
    /**
     * 时间转换
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -20,8 +20,9 @@
     * @return
     */
    List<CommonOrderVO> listGroupOrderNoByUid(@Param("start") long start, @Param("count") int count, 
        @Param("uid") Long uid,@Param("state") Integer state, @Param("type") Integer type,
        @Param("orderNo")String orderNo, @Param("startTime")String startTime, @Param("endTime")String endTime);
        @Param("uid") Long uid,@Param("state") Integer state, @Param("type") Integer type,
         @Param("orderState") Integer orderState, @Param("orderNo")String orderNo,
         @Param("startTime")String startTime, @Param("endTime")String endTime,@Param("day")Integer day);
    
    
    /**
@@ -32,8 +33,8 @@
     * @return
     */
    long countGroupOrderNoByUid(@Param("uid") Long uid, @Param("state") Integer state, 
        @Param("type") Integer type, @Param("orderNo")String orderNo,
        @Param("startTime")String startTime, @Param("endTime")String endTime);
        @Param("type") Integer type,@Param("orderState")Integer orderState,@Param("orderNo")String orderNo,
        @Param("startTime")String startTime, @Param("endTime")String endTime,@Param("day")Integer day);
    
    /**
     * 根据订单号、订单类型查询商品
@@ -70,21 +71,5 @@
     * @return
     */
    BigDecimal countBonusOrderMoney(@Param("uid")Long uid, @Param("type") Integer type, @Param("day")Integer day);
    /**
     * 奖金订单列表
     * @param uid
     * @return
     */
    List<CommonOrderVO> listBonusOrder(@Param("start") long start, @Param("count") int count,
            @Param("uid")Long uid, @Param("type") Integer type, @Param("day")Integer day);
    /**
     * 统计订单 根据订单状态
     * @param uid
     * @return
     */
    Map<String, BigDecimal> countBonusOrderByState(@Param("uid") Long uid, @Param("type") Integer type,
            @Param("day")Integer day);
}
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -137,8 +137,14 @@
        LEFT JOIN  yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id`
           LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR  th.`hb_pid` = tr.`ho_hongbao_id` )
    WHERE th.`hb_uid` = #{uid}
        <if test="state != null">
            AND th.hb_state = #{state}
        <if test="state != null and state == 1">  <!-- 未到账 -->
            AND (th.hb_state = 1 or th.hb_state = 2)
        </if>
        <if test="state != null and state == 2"> <!-- 已到账 -->
            AND th.hb_state = 3
        </if>
        <if test="state != null and state == 3">  <!-- 红包已失效 -->
            AND th.hb_state =4
        </if>
        <if test="type != null and type == 1"> <!-- 自购订单 -->
            AND (th.hb_type =1 or th.hb_type =2)
@@ -152,12 +158,33 @@
        <if test="orderNo != null">
            AND tc.co_order_no = #{orderNo}
        </if>
        <if test="orderState != null and orderState ==  1">
            AND (tc.co_state = 1 or tc.co_state = 2) <!-- 有效订单 -->
        </if>
        <if test="orderState != null and orderState ==  2">
            AND tc.co_state = 3 <!-- 维权订单 -->
        </if>
        <if test="orderState != null and orderState ==  3">
            AND tc.co_state = 4 <!-- 失效订单 -->
        </if>
        <if test="startTime != null">
            AND <![CDATA[tc.co_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null">
            AND <![CDATA[tc.co_create_time < #{endTime}]]>
        </if>
        <if test ="day != null and day == 1"> <!-- 今天 -->
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">  <!-- 昨天 -->
             AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
        </if>
        <if test="day != null and day == 3">  <!-- 本月 -->
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">  <!-- 上月 -->
             AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
        </if>
    GROUP BY tc.`co_order_no`,tc.co_source_type
    ORDER BY tc.co_create_time DESC
    LIMIT ${start},${count}
@@ -168,8 +195,14 @@
        LEFT JOIN  yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id`
           LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR  th.`hb_pid` = tr.`ho_hongbao_id` )
    WHERE  th.`hb_uid` = #{uid}
        <if test="state != null">
            AND th.hb_state = #{state}
        <if test="state != null and state == 1">  <!-- 未到账 -->
            AND (th.hb_state = 1 or th.hb_state = 2)
        </if>
        <if test="state != null and state == 2">  <!-- 已到账 -->
            AND th.hb_state = 3
        </if>
        <if test="state != null and state == 3"> <!-- 红包已失效 -->
            AND th.hb_state =4
        </if>
        <if test="type != null and type == 1"> <!-- 自购订单 -->
            AND (th.hb_type =1 or th.hb_type =2)
@@ -180,6 +213,17 @@
        <if test="type != null and type == 3"> <!-- 邀请订单 -->
            AND  (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
        </if>
        <if test="orderState != null and orderState = 1">
            AND (tc.co_state = 1 or tc.co_state = 2) <!-- 有效订单 -->
        </if>
        <if test="orderState != null and orderState = 2">
            AND tc.co_state = 3 <!-- 维权订单 -->
        </if>
        <if test="orderState != null and orderState = 3">
            AND tc.co_state = 4 <!-- 失效订单 -->
        </if>
        <if test="orderNo != null">
            AND tc.co_order_no = #{orderNo}
        </if>
@@ -189,6 +233,18 @@
        <if test="endTime != null">
            AND <![CDATA[tc.co_create_time < #{endTime}]]>
        </if>
        <if test ="day != null and day == 1"> <!-- 今天 -->
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">  <!-- 昨天 -->
             AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
        </if>
        <if test="day != null and day == 3">  <!-- 本月 -->
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">  <!-- 上月 -->
             AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
        </if>
  </select>
  
   <select id="listByOrderNoAndType" resultMap="ResultMap"  parameterType="java.util.List">
@@ -332,6 +388,7 @@
        <if test="type != null and type == 3"> <!-- 邀请订单 -->
            AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
        </if>
        <if test ="day != null and day == 1"> <!-- 今天 -->
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
@@ -339,10 +396,10 @@
             AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
        </if>
        <if test="day != null and day == 3">  <!-- 本月 -->
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m')
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">  <!-- 上月 -->
             AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
             AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
        </if>
  </select>
@@ -370,10 +427,10 @@
             AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
        </if>
        <if test="day != null and day == 3">  <!-- 本月 -->
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m')
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">  <!-- 上月 -->
             AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
             AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
        </if>
  </select>
  
@@ -393,6 +450,15 @@
        <if test="type != null and type == 3"> <!-- 邀请订单 -->
            AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
        </if>
        <if test="orderState != null and orderState == 1">
            AND (tc.co_state = 1 or tc.co_state = 2) <!-- 有效订单 -->
        </if>
        <if test="orderState != null and orderState == 2">
            AND tc.co_state = 3 <!-- 维权订单 -->
        </if>
        <if test="orderState != null and orderState == 3">
            AND tc.co_state = 4 <!-- 失效订单 -->
        </if>
        <if test ="day != null and day == 1"> <!-- 今天 -->
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
@@ -400,100 +466,14 @@
             AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
        </if>
        <if test="day != null and day == 3">  <!-- 本月 -->
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m')
             AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">  <!-- 上月 -->
             AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
             AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
        </if>
    GROUP BY tc.`co_order_no`,tc.co_source_type
    ORDER BY tc.co_create_time DESC
    LIMIT ${start},${count}
  </select>
  <select id="countBonusOrderByState" resultType="java.util.HashMap">
      SELECT SUM(valid)AS totalValid, SUM(proces)AS totalProces ,SUM(Invalid)AS totalInvite
      FROM (SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS valid,0 AS proces,0 AS  Invalid
          FROM yeshi_ec_common_order tc
            LEFT JOIN  yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id`
               LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR  th.`hb_pid` = tr.`ho_hongbao_id` )
        WHERE th.`hb_uid` = #{uid} AND (tc.`co_state` = 1 OR tc.`co_state` = 2)
            <if test="type != null and type == 1"> <!-- 自购订单 -->
                AND (th.hb_type =1 or th.hb_type =2)
            </if>
            <if test="type != null and type == 2"> <!-- 分享订单 -->
                AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22)
            </if>
            <if test="type != null and type == 3"> <!-- 邀请订单 -->
                AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
            </if>
            <if test ="day != null and day == 1"> <!-- 今天 -->
                AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
            </if>
            <if test="day != null and day == 2">  <!-- 昨天 -->
                 AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
            </if>
            <if test="day != null and day == 3">  <!-- 本月 -->
                 AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m')
            </if>
            <if test="day != null and day == 4">  <!-- 上月 -->
                 AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
            </if>
        UNION
        SELECT 0 AS valid,IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS proces,0 AS Invalid
        FROM yeshi_ec_common_order tc
            LEFT JOIN  yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id`
               LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR  th.`hb_pid` = tr.`ho_hongbao_id` )
        WHERE th.`hb_uid` = #{uid} AND  tc.`co_state` =3
            <if test="type != null and type == 1"> <!-- 自购订单 -->
                AND (th.hb_type =1 or th.hb_type =2)
            </if>
            <if test="type != null and type == 2"> <!-- 分享订单 -->
                AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22)
            </if>
            <if test="type != null and type == 3"> <!-- 邀请订单 -->
                AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
            </if>
            <if test ="day != null and day == 1"> <!-- 今天 -->
                AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
            </if>
            <if test="day != null and day == 2">  <!-- 昨天 -->
                 AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
            </if>
            <if test="day != null and day == 3">  <!-- 本月 -->
                 AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m')
            </if>
            <if test="day != null and day == 4">  <!-- 上月 -->
                 AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
            </if>
        UNION
        SELECT 0 AS valid,0 AS proces,IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS Invalid
        FROM yeshi_ec_common_order tc
            LEFT JOIN  yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id`
               LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR  th.`hb_pid` = tr.`ho_hongbao_id` )
        WHERE th.`hb_uid`= #{uid} AND tc.`co_state` = 4
            <if test="type != null and type == 1"> <!-- 自购订单 -->
                AND (th.hb_type =1 or th.hb_type =2)
            </if>
            <if test="type != null and type == 2"> <!-- 分享订单 -->
                AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22)
            </if>
            <if test="type != null and type == 3"> <!-- 邀请订单 -->
                AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
            </if>
            <if test ="day != null and day == 1"> <!-- 今天 -->
                AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
            </if>
            <if test="day != null and day == 2">  <!-- 昨天 -->
                 AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
            </if>
            <if test="day != null and day == 3">  <!-- 本月 -->
                 AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m')
            </if>
            <if test="day != null and day == 4">  <!-- 上月 -->
                 AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
            </if>
        )A
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -4,9 +4,9 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import javax.annotation.Resource;
@@ -68,51 +68,27 @@
    
    @Override
    public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, 
            Integer type, String orderNo, String startTime,String endTime) throws CommonOrderException{
        return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderNo, startTime, endTime);
            Integer type,Integer orderState, String orderNo, String startTime,String endTime,
            Integer dateType) throws CommonOrderException{
        return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderState,
                orderNo, startTime, endTime, dateType);
    }
    
    @Override
    public long countGroupOrderNoByUid(Long uid,Integer state, Integer type, String orderNo,
            String startTime,String endTime) throws CommonOrderException{
        return commonOrderMapper.countGroupOrderNoByUid(uid, state, type, orderNo, startTime, endTime);
    public long countGroupOrderNoByUid(Long uid,Integer state, Integer type, Integer orderState,
            String orderNo,    String startTime,String endTime, Integer dateType) throws CommonOrderException{
        return commonOrderMapper.countGroupOrderNoByUid(uid, state, type, orderState, orderNo,
                startTime, endTime, dateType);
    }
    
    @Override
    public List<CommonOrderVO> getOrderByUid (Integer page, Long uid, Integer state, Integer type,
            String orderNo, String startTime, String endTime) throws CommonOrderException {
            Integer orderState, String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException {
        
        int pageSize = Constant.PAGE_SIZE;
        
        List<CommonOrderVO> listOrder = listGroupOrderNoByUid((page - 1) * pageSize, pageSize, uid, 
                state, type, orderNo, startTime, endTime);
        // 订单信息为空
        if (listOrder == null || listOrder.size() == 0) {
            listOrder = new ArrayList<CommonOrderVO>();
            return listOrder;
        }
        // 商品信息
        List<CommonOrderVO> listGoods = commonOrderMapper.listByOrderNoAndType(listOrder);
        // 订单商品为空
        if (listGoods ==null || listGoods.size() == 0) {
            return listOrder;
        }
        // 数据加工重新组织
        listDataFactory(listOrder, listGoods);
        return listOrder;
    }
    @Override
    public List<CommonOrderVO> listBonusOrder (Integer page, Long uid, Integer type,Integer day) throws CommonOrderException {
        int pageSize = Constant.PAGE_SIZE;
        List<CommonOrderVO> listOrder = commonOrderMapper.listBonusOrder((page - 1) * pageSize, pageSize, uid, type, day);
                state, type, orderState, orderNo, startTime, endTime, dateType);
        
        // 订单信息为空
        if (listOrder == null || listOrder.size() == 0) {
@@ -152,11 +128,6 @@
    @Override
    public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime,String endTime) {
        return commonOrderMapper.countByUidAndOrderState(uid, type,  startTime, endTime);
    }
    @Override
    public Map<String, BigDecimal> countBonusOrderByState(Long uid,Integer type, Integer day) {
        return commonOrderMapper.countBonusOrderByState(uid, type, day);
    }
    
    public void listDataFactory (List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods ) {
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java
@@ -36,8 +36,8 @@
     * @return
     * @throws CommonOrderException
     */
    public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, Integer type,
            String orderNo, String startTime, String endTime) throws CommonOrderException;
    public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state,
            Integer type,Integer orderState,String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException;
    /**
     * 统计查询
@@ -50,8 +50,8 @@
     * @return
     * @throws CommonOrderException
     */
    long countGroupOrderNoByUid(Long uid, Integer state, Integer type, String orderNo, String startTime, String endTime)
            throws CommonOrderException;
    long countGroupOrderNoByUid(Long uid, Integer state, Integer type,Integer orderState,
            String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException;
    
    /**
     * 移动段订单列表
@@ -62,7 +62,7 @@
     * @return
     */
    public List<CommonOrderVO> getOrderByUid(Integer page, Long uid, Integer state, Integer type,
            String orderNo, String startTime, String endTime) throws CommonOrderException;
            Integer orderState, String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException;
    /**
     * 统计订单-根据红包类型 自购 邀请 分享
@@ -95,18 +95,5 @@
     * @return
     */
    public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime);
    /**
     * 奖金列表统计
     * @param page
     * @param uid
     * @param type
     * @param day
     * @return
     * @throws CommonOrderException
     */
    public List<CommonOrderVO> listBonusOrder(Integer page, Long uid, Integer type, Integer day) throws CommonOrderException;
    public Map<String, BigDecimal> countBonusOrderByState(Long uid, Integer type, Integer day);
}