admin
2018-12-26 f4b0bb5dfda8f21409b9eb0b2ee6e436c87475e3
Merge remote-tracking branch 'origin/master'

Conflicts:
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
1个文件已删除
11个文件已修改
565 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 280 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/Constant.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/order/CommonOrderVO.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/certificate/开发证书.p12 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/druid.properties 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/TBImgTest.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/TaoKeTest.java 44 ●●●●● 补丁 | 查看 | 原始文档 | 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, Long 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, "用户未登录"));
@@ -63,7 +70,7 @@
        }
        
        if (page == null || page < 1) {
            page = 1L;
            page = 1;
        }
        
        if (state !=null && state == 0) {
@@ -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;
@@ -114,8 +121,8 @@
                    totalInvite = countOrder.get("totalInvite").intValue();
                }    
                
                todayTotal = commonOrderService.countOrder(uid, 1);
                todayMoney = commonOrderService.countOrderMoney(uid, 1);
                todayTotal = commonOrderService.countOrder(uid, type, 1);
                todayMoney = commonOrderService.countOrderMoney(uid, type , 1);
            }
        
            if (todayMoney == null) {
@@ -259,13 +266,13 @@
    }
    
    /**
     * ç»Ÿè®¡ä»Šæ—¥è®¢å•æ”¶å…¥ ä»¥åŠè®¢å•数量
     * ç»Ÿè®¡å¥–金
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "countToday", method = RequestMethod.POST)
    public void countToday(AcceptData acceptData, Long uid, PrintWriter out) {
    @RequestMapping(value = "countBonus", method = RequestMethod.POST)
    public void countBonus(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
        
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
@@ -273,23 +280,25 @@
        }
        
        try {
            long count = commonOrderService.countOrder(uid, 1);
            BigDecimal money = commonOrderService.countOrderMoney(uid, 1);
            if (money == null) {
                money = new BigDecimal(0);
            }
            
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("money", money);
            // åˆ†äº«ç»Ÿè®¡
            BigDecimal sharemoney = commonOrderService.countOrderMoney(uid,2, dateType);
            data.put("shareCount", commonOrderService.countOrder(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", inviteMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("showTiCheng", hongBaoService.getTotalTiChengCount(uid) > 0);
            out.print(JsonUtil.loadTrueResult(data));
            
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "获取信息失败"));
            e.printStackTrace();
        }
    }
    
    
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -20,9 +20,11 @@
     * @param uid
     * @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("orderState") Integer orderState, @Param("orderNo") String orderNo,
            @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("day") Integer day);
    /**
     * ç»Ÿè®¡ç”¨æˆ·è®¢å• å¹¶è®¢å•号分组
@@ -33,7 +35,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("orderState") Integer orderState, @Param("orderNo") String orderNo,
            @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("day") Integer day);
    /**
     * æ ¹æ®è®¢å•号、订单类型查询商品
@@ -53,37 +56,32 @@
    Map<String, BigDecimal> countOrderByHongBaoType(@Param("uid") Long uid, @Param("day") Integer day);
    /**
     * æ€»è®¢å•
     *
     * @param uid
     * @return
     */
    long countOrder(@Param("uid") Long uid, @Param("isToday") Integer isToday);
    /**
     * æ€»è®¢å•
     *
     * @param uid
     * @return
     */
    BigDecimal countOrderMoney(@Param("uid") Long uid, @Param("isToday") Integer isToday);
    /**
     * æ˜¨æ—¥æ€»è®¢å•-根据红包类型 è‡ªè´­ é‚€è¯· åˆ†äº«
     * 
     * @param uid
     * @return
     */
    Map<String, BigDecimal> countByUidAndOrderState(@Param("uid") Long uid, @Param("type") Integer type,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * æ ¹æ®è®¢å•号和订单类型查询数量
     * å¥–金订单数量
     * 
     * @param orderNO
     * @param orderType
     * @param uid
     * @return
     */
    long countBonusOrder(@Param("uid") Long uid, @Param("type") Integer type, @Param("day") Integer day);
    /**
     * å¥–金统计
     *
     * @param uid
     * @return
     */
    BigDecimal countBonusOrderMoney(@Param("uid") Long uid, @Param("type") Integer type, @Param("day") Integer day);
    int countByOrderNOAndOrderType(@Param("orderNO") String orderNO, @Param("orderType") int orderType);
}
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -71,7 +71,7 @@
    </resultMap>
    <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_create_time,co_update_time
    <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,cog_create_time,cog_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
@@ -79,11 +79,16 @@
        <include refid="Base_Column_List" />
        from yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="countByOrderNOAndOrderType" resultType="java.lang.Integer">
        select
        count(co_id) from yeshi_ec_common_order where co_order_no=#{orderNO}
        and co_source_type=#{orderType}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.order.CommonOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_common_order
        (co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_create_time,co_update_time)
        (co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,cog_create_time,cog_update_time)
        values
        (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{sourcePosition,jdbcType=VARCHAR},#{commonOrderGoods.id,jdbcType=BIGINT},#{count,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{estimate,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{thirdCreateTime,jdbcType=TIMESTAMP},#{settleTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
@@ -105,8 +110,8 @@
            <if test="settlement != null">co_settlement,</if>
            <if test="thirdCreateTime != null">co_third_create_time,</if>
            <if test="settleTime != null">co_settle_time,</if>
            <if test="createTime != null">co_create_time,</if>
            <if test="updateTime != null">co_update_time,</if>
            <if test="createTime != null">cog_create_time,</if>
            <if test="updateTime != null">cog_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -142,8 +147,8 @@
        #{payment,jdbcType=DECIMAL},co_settlement =
        #{settlement,jdbcType=DECIMAL},co_third_create_time =
        #{thirdCreateTime,jdbcType=TIMESTAMP},co_settle_time =
        #{settleTime,jdbcType=TIMESTAMP},co_create_time =
        #{createTime,jdbcType=TIMESTAMP},co_update_time =
        #{settleTime,jdbcType=TIMESTAMP},cog_create_time =
        #{createTime,jdbcType=TIMESTAMP},cog_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where co_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder">
@@ -165,8 +170,8 @@
            <if test="thirdCreateTime != null">co_third_create_time=#{thirdCreateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="settleTime != null">co_settle_time=#{settleTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">co_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">co_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">cog_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">cog_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where co_id = #{id,jdbcType=BIGINT}
    </update>
@@ -181,8 +186,14 @@
        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)
@@ -196,22 +207,39 @@
        <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>
        GROUP BY tc.`co_order_no`
        <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}
        LIMIT ${start},${count}
    </select>
    <select id="countByOrderNOAndOrderType" resultType="java.lang.Integer">
        select count(co_id) from yeshi_ec_common_order where co_order_no=#{orderNO} and co_source_type=#{orderType}
    </select>
    <select id="countGroupOrderNoByUid" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0)
@@ -220,8 +248,14 @@
        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)
@@ -232,6 +266,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>
@@ -240,6 +285,20 @@
        </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>
    </select>
@@ -249,7 +308,7 @@
        totalSettlement,COALESCE(SUM(tc.`co_count`),0)AS
        totalCount,tc.`co_source_type`,tc.`co_order_no`,tg.*
        FROM yeshi_ec_common_order_goods tg
        LEFT JOIN yeshi_ec_common_order tc ON tc.`co_order_goods_id` = tg.`co_id`
        LEFT JOIN yeshi_ec_common_order tc ON tc.`co_order_goods_id` = tg.`cog_id`
        WHERE
        <foreach collection="list" item="item" separator=" OR ">
            (tc.`co_source_type` = #{item.sourceType,jdbcType=INTEGER} AND
@@ -311,36 +370,6 @@
        )A
    </select>
    <select id="countOrder" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0)
        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 1=1
        <if test="uid != null">
            AND th.`hb_uid` = ${uid}
        </if>
        <if test="isToday == 1">
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
    </select>
    <select id="countOrderMoney" resultType="java.lang.Long">
        SELECT IFNULL(SUM(th.`hb_money`),0)AS totalmoney 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 <![CDATA[tc.`co_state` <> 4]]>
        <if test="isToday == 1">
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
        GROUP BY tc.`co_order_no`,tc.`co_source_type`
    </select>
    <select id="countByUidAndOrderState" resultType="java.util.HashMap">
        SELECT SUM(valid)AS totalValid, SUM(proces)AS totalProces
        ,SUM(Invalid)AS totalInvite
@@ -353,8 +382,14 @@
        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 th.hb_type = #{type}
        <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="startTime != null">
            AND <![CDATA[tc.co_create_time >= #{startTime}]]>
@@ -374,8 +409,14 @@
        th.`hb_pid` = tr.`ho_hongbao_id` )
        WHERE th.`hb_uid` = #{uid} AND
        tc.`co_state` =3
        <if test="type != null">
            AND th.hb_type = #{type}
        <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="startTime != null">
            AND <![CDATA[tc.co_create_time >= #{startTime}]]>
@@ -395,8 +436,14 @@
        th.`hb_pid` = tr.`ho_hongbao_id` )
        WHERE th.`hb_uid`= #{uid} AND
        tc.`co_state` = 4
        <if test="type != null">
            AND th.hb_type = #{type}
        <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="startTime != null">
            AND <![CDATA[tc.co_create_time >= #{startTime}]]>
@@ -407,4 +454,123 @@
        )A
    </select>
    <select id="countBonusOrder" resultType="java.lang.Long">
        SELECT COALESCE(COUNT(DISTINCT
        tc.`co_order_no`,tc.`co_source_type`),0) 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 1=1
        <if test="uid != null">
            AND th.`hb_uid` = ${uid}
        </if>
        <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 PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
        </if>
    </select>
    <select id="countBonusOrderMoney" resultType="java.math.BigDecimal">
        SELECT COALESCE(SUM(th.`hb_money`),0)AS totalmoney 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 <![CDATA[tc.`co_state` <> 4]]>
        <if test="uid != null">
            AND th.`hb_uid` = ${uid}
        </if>
        <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 PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
        </if>
    </select>
    <select id="listBonusOrder" resultMap="ResultMap">
        SELECT COALESCE(SUM(th.`hb_money`),0)AS totalMoney,tc.*,th.hb_state AS
        hongBaoState, th.hb_type AS hongBaoType,
        th.hb_get_time AS accountTime,th.hb_get_time AS accountTime,th.hb_pre_get_time AS
        preAccountTime
        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}
        <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="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>
        <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}
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -131,6 +131,7 @@
                orderId = hb.getOrderId();
            int count = commonOrderMapper.countByOrderNOAndOrderType(orderId, Constant.SOURCE_TYPE_TAOBAO);
            // å·²ç»æ’入订单
            if (count > 0)
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,24 +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 (Long page, Long uid, Integer state, Integer type,
            String orderNo, String startTime, String endTime) throws CommonOrderException {
    public List<CommonOrderVO> getOrderByUid (Integer page, Long uid, Integer state, Integer type,
            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);
                state, type, orderState, orderNo, startTime, endTime, dateType);
        
        // è®¢å•信息为空
        if (listOrder == null || listOrder.size() == 0) {
@@ -99,6 +102,35 @@
        if (listGoods ==null || listGoods.size() == 0) {
            return listOrder; 
        }
        // æ•°æ®åŠ å·¥é‡æ–°ç»„ç»‡
        listDataFactory(listOrder, listGoods);
        return listOrder;
    }
    @Override
    public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) {
        return commonOrderMapper.countOrderByHongBaoType(uid, day);
    }
    @Override
    public long countOrder(Long uid,Integer type, Integer day) {
        return commonOrderMapper.countBonusOrder(uid, type, day);
    }
    @Override
    public BigDecimal countOrderMoney(Long uid, Integer type, Integer day) {
        return commonOrderMapper.countBonusOrderMoney(uid, type, day);
    }
    @Override
    public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime,String endTime) {
        return commonOrderMapper.countByUidAndOrderState(uid, type,  startTime, endTime);
    }
    public void listDataFactory (List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods ) {
        
        /* ç»„合商品信息  */
        for (CommonOrderVO commonOrder: listGoods) {
@@ -221,13 +253,18 @@
                order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
            }
            
            String hongBaoDate = "";
            String hongBaoState_Str = "";
            String hongbaoInfoFontColor = "#E5005C";
            /* çº¢åŒ…状态 è½¬æ¢ */
            String stateContent = "";
            Integer orderHongBaoState = null;
            Integer hongBaoState = order.getHongBaoState();
            if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
                orderHongBaoState = 1;
                stateContent = "未到账";
                hongBaoState_Str = "预估";
                hongbaoInfoFontColor = "#888888";
@@ -238,6 +275,7 @@
                }
                
            } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
                orderHongBaoState = 3;
                stateContent = "已到账";
                
                Date accountTime = order.getAccountTime();
@@ -247,18 +285,21 @@
                
            } else if (HongBaoV2.STATE_BUFENSHIXIAO == hongBaoState) {
                stateContent = "部分失效";    
                orderHongBaoState = 3;
                Date accountTime = order.getAccountTime();
                if (accountTime != null) {
                    hongBaoDate = "到账时间" + formatday.format(accountTime);
                }
                
            } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
                orderHongBaoState = 4;
                stateContent = "已失效";    
                hongBaoDate = "  ";
            }
            order.setHongBaoState(orderHongBaoState);
            order.setAccountState(stateContent);
            order.setHongBaoDate(hongBaoDate);
            if ("奖金".equals(hongbaoInfo) && hongBaoState_Str.trim().length() > 0) {
                hongbaoInfo = hongBaoState_Str + hongbaoInfo;
            }
@@ -270,32 +311,7 @@
            hongBaoMap.put("content", hongbaoInfo + " Â¥" + hongBao);
            hongBaoMap.put("fontColor", hongbaoInfoFontColor);
            order.setHongBaoInfo(hongBaoMap);
        }
        
        return listOrder;
    }
    @Override
    public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) {
        return commonOrderMapper.countOrderByHongBaoType(uid, day);
    }
    @Override
    public long countOrder(Long uid, Integer isToday) {
        return commonOrderMapper.countOrder(uid, isToday);
    }
    @Override
    public BigDecimal countOrderMoney(Long uid, Integer isToday) {
        return commonOrderMapper.countOrderMoney(uid, isToday);
    }
    @Override
    public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime,String endTime) {
        return commonOrderMapper.countByUidAndOrderState(uid, type,  startTime, endTime);
    }
}
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;
    
    /**
     * ç§»åŠ¨æ®µè®¢å•åˆ—è¡¨
@@ -61,8 +61,8 @@
     * @param type åˆ°è´¦çŠ¶æ€
     * @return
     */
    public List<CommonOrderVO> getOrderByUid(Long page, Long uid, Integer state, Integer type,
            String orderNo, String startTime, String endTime) throws CommonOrderException;
    public List<CommonOrderVO> getOrderByUid(Integer page, Long uid, Integer state, Integer type,
            Integer orderState, String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException;
    /**
     * ç»Ÿè®¡è®¢å•-根据红包类型 è‡ªè´­ é‚€è¯· åˆ†äº«
@@ -77,14 +77,14 @@
     * @param uid
     * @return
     */
    public long countOrder(Long uid, Integer isToday);
    public long countOrder(Long uid, Integer type, Integer isToday);
    
    /**
     * ç»Ÿè®¡è®¢å•
     * @param uid
     * @return
     */
    public BigDecimal countOrderMoney(Long uid, Integer isToday);
    public BigDecimal countOrderMoney(Long uid, Integer type,  Integer isToday);
    /**
     * æ ¹æ®æ¡ä»¶ç»Ÿè®¡
fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -12,7 +12,6 @@
public class Constant {
    public static boolean IS_TASK = false;
    // å¤–网环境
    public static boolean IS_OUTNET = false;
@@ -74,6 +73,10 @@
    public static final String MYLIKE = "mylike";
    public static final String MYDYNAMIC = "mydynamic";
    // æ¥æº
    public static final int SOURCE_TYPE_TAOBAO = 1;
    public static final int SOURCE_TYPE_JD = 2;
    public static WXGZConfig wxGZConfig;
    // çŸ­ä¿¡éªŒè¯ç é…ç½®
fanli/src/main/java/com/yeshi/fanli/vo/order/CommonOrderVO.java
@@ -34,9 +34,11 @@
     private Integer hongBaoType;
    // è®¢å•总预估奖金
     private BigDecimal hongBao;
     // çº¢åŒ…状态
     @Expose
    private Integer hongBaoState;
    // åˆ°è´¦æ—¶é—´
    @Expose
    private String hongBaoDate;
fanli/src/main/resource/certificate/¿ª·¢Ö¤Êé.p12
Binary files differ
fanli/src/main/resource/druid.properties
@@ -27,7 +27,7 @@
#druid.password=Yeshi2016@
#外网本地测试
#druid.url=jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ec_quan_test
#druid.url=jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ec_quan
#druid.username=root
#druid.password=Yeshi2016@
fanli/src/test/java/org/fanli/TBImgTest.java
@@ -1,43 +1,21 @@
package org.fanli;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.exception.HttpException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.util.FileUtil;
import com.yeshi.fanli.util.ImageUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.entity.common.ImageInfo;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
@Ignore
public class TBImgTest {
    @Test
    public void test1() {
        try {
            InputStream img = ImageUtil.drawGoodsShareImg(
                    HttpUtil.downLoadImg(
                            "https://wwc.alicdn.com/avatar/getAvatar.do?userId=1889722423&width=160&height=160&type=sns"),
                    HttpUtil.downLoadImg(
                            "https://wwc.alicdn.com/avatar/getAvatar.do?userId=1889722423&width=160&height=160&type=sns"),
                    TaoKeApiUtil.searchGoodsDetail(559888327092L));
            try {
                FileUtil.saveAsFile(img, "D:/test.png");
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
        }
        List<ImageInfo> list = TaoBaoUtil.getTBDetailImageWithSize(565204406588L);
        for (ImageInfo info : list)
            System.out.println(info.getPicture());
    }
}
fanli/src/test/java/org/fanli/TaoKeTest.java
@@ -1,15 +1,27 @@
package org.fanli;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
import com.yeshi.fanli.util.BeanUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@Ignore
//@Ignore
public class TaoKeTest {
    @Test
@@ -35,6 +47,34 @@
    @Test
    public void test3() {
        System.out.println("测试合并222");
        TaoBaoGoodsUpdateService taoBaoGoodsUpdateService = BeanUtil.getBean(TaoBaoGoodsUpdateService.class);
        try {
            taoBaoGoodsUpdateService.updateTaoBaoGoods(TaoKeApiUtil.searchGoodsDetail(571566226590L));
        } catch (TaobaoGoodsUpdateException e) {
            e.printStackTrace();
        } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
        }
    }
    @Test
    public void test4() {
        TaoBaoOrderService taoBaoOrderService = BeanUtil.getBean(TaoBaoOrderService.class);
        try {
            List<TaoBaoOrder> list = TaoBaoOrderUtil.parseOrder(
                    new FileInputStream(new File("C:/Users/Administrator/Desktop/淘宝订单/2018.1.10-2018-03-12 (2).xls")));
            for (int i = 0; i < list.size(); i++) {
//                if (TimeUtil.convertToTimeTemp(list.get(i).getCreateTime(), "yyyy-MM-dd HH:mm:ss") > 1522339200000l) {
//                    list.remove(i);
//                    i--;
//                }
            }
            taoBaoOrderService.addTaoBaoOrderList(list);
            System.out.println(list);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}