admin
2019-01-03 b3007afcb9b8ca4302497a2c1c3e0d990b10a388
新版订单与返利
15个文件已修改
1个文件已添加
717 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/InviteGetMoneyController.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoWeiQuanOrderMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/order/CommonOrder.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2Mapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 109 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/HongBaoOrderMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoManageServiceImpl.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java 123 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 111 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 161 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/HongBaoManageService.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/CommonOrderGoodsFactory.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoOrderUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/InviteGetMoneyController.java
@@ -14,12 +14,16 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.admin.InviteGetMoney;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.system.System;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.exception.NotExistObjectException;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.user.QrCodeService;
import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
import com.yeshi.fanli.service.inter.user.UserRankingsService;
@@ -59,6 +63,12 @@
    @Resource
    private UserRankingsService userRankingsService;
    @Resource
    private ConfigService configService;
    @Resource
    private SwiperPictureService swiperPictureService;
    @RequestMapping(value = "/inviteGetMoney", method = RequestMethod.POST)
    public void everyDayTaskList(AcceptData acceptData, int pageIndex, PrintWriter out, String uid)
            throws NotExistObjectException {
@@ -83,10 +93,11 @@
        List<InviteGetMoney> inviteGetMoneyList = userRankingsService.getRank(0, 5);
        JSONObject data = new JSONObject();
        com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
        data.put("pageEntity", JsonUtil.getSimpleGsonWithDate().toJson(pageEntity));
        data.put("everyDayTaskList", new JSONArray());
        data.put("inviteGetMoneyList", JsonUtil.getSimpleGsonWithDate().toJson(inviteGetMoneyList));
        data.put("inviteGetMoneyList",
                JSONArray.fromObject(JsonUtil.getSimpleGsonWithDate().toJson(inviteGetMoneyList)));
        if (uid.equals("0") || uid == null) {
            data.put("myTeam", "---");
            data.put("moneyToday", "---");
@@ -129,7 +140,26 @@
        data.put("activityRules", valueBr);
        data.put("inviteList", String.format("http://%s/%s/client/share/friends_new.html",
                Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
        out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
        try {
            List<SwiperPicture> pictureList = swiperPictureService.getByBannerCard("invite_top_banner");
            if (pictureList != null && pictureList.size() > 0) {
                SwiperPicture picture = pictureList.get(0);
                com.alibaba.fastjson.JSONObject pictureJson = new com.alibaba.fastjson.JSONObject();
                pictureJson.put("src", picture.getSrc());
                pictureJson.put("jumpDetail", picture.getJumpDetail());
                pictureJson.put("params", picture.getParams());
                data.put("topBanner", pictureJson);
            }
        } catch (SwiperPictureException e) {
            e.printStackTrace();
        }
        com.alibaba.fastjson.JSONObject root = new com.alibaba.fastjson.JSONObject();
        root.put("code", 0);
        root.put("data", data);
        out.print(JsonUtil.loadTrue(0, root, "成功"));
    }
    /**
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -81,7 +81,20 @@
     */
    BigDecimal countBonusOrderMoney(@Param("uid") Long uid, @Param("type") Integer type, @Param("day") Integer day);
    
    int countByOrderNOAndOrderType(@Param("orderNO") String orderNO, @Param("orderType") int orderType);
    /**
     * 根据订单号与订单排序值获取详情
     *
     * @param orderNo
     *            -订单号
     * @param orderBy
     *            -订单排序值
     * @param orderType
     *            -订单类型
     * @return
     */
    CommonOrder selectByOrderNoAndOrderTypeAndOrderBy(@Param("orderNo") String orderNo,
            @Param("orderType") int orderType, @Param("orderBy") int orderBy);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoWeiQuanOrderMapper.java
@@ -27,4 +27,7 @@
    // 按订单号和维权状态查询
    List<TaoBaoWeiQuanOrder> selectListByOrderIdAndState(@Param("orderId") String orderId,
            @Param("state") String state);
}
fanli/src/main/java/com/yeshi/fanli/entity/order/CommonOrder.java
@@ -31,7 +31,6 @@
    public final static String TYPE_INVITE = "http://ec-1255749512.file.myqcloud.com/resource/order/icon_invite.png";
    public final static String TYPE_SHARE = "http://ec-1255749512.file.myqcloud.com/resource/order/icon_share.png";
    
    @Column(name = "co_id")
    private Long id;
@@ -90,6 +89,9 @@
    // 收货时间-结算时间
    @Column(name = "co_settle_time")
    private Date settleTime;
    @Column(name = "co_order_by")
    private Integer orderBy;// 子订单的排序值
    // 创建时间
    @Column(name = "co_create_time")
@@ -219,6 +221,14 @@
        this.settleTime = settleTime;
    }
    public Integer getOrderBy() {
        return orderBy;
    }
    public void setOrderBy(Integer orderBy) {
        this.orderBy = orderBy;
    }
    public Date getCreateTime() {
        return createTime;
    }
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2Mapper.xml
@@ -22,7 +22,7 @@
        </association>
        <association property="parent" column="hb_pid"
            javaType="com.yeshi.fanli.entity.push.PushGoods">
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
            <id column="hb_pid" property="id" jdbcType="BIGINT" />
        </association>
@@ -46,7 +46,6 @@
    </select>
    
    
    List<HongBaoV2> listChildrenById(Long id);
    
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}</delete>
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -17,6 +17,7 @@
        <result column="co_third_create_time" property="thirdCreateTime"
            jdbcType="TIMESTAMP" />
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
@@ -46,6 +47,7 @@
        <result column="co_third_create_time" property="thirdCreateTime"
            jdbcType="TIMESTAMP" />
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
@@ -71,7 +73,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,co_order_by,co_create_time,co_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
@@ -84,8 +86,18 @@
        count(co_id) from yeshi_ec_common_order where co_order_no=#{orderNO}
        and co_source_type=#{orderType}
    </select>
    <select id="selectByOrderNoAndOrderTypeAndOrderBy" resultMap="BaseResultMap">
        select
        * from yeshi_ec_common_order where co_order_no=#{orderNo}
        and
        co_source_type=#{orderType} and co_order_by=#{orderBy}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}</delete>
        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)
@@ -110,6 +122,7 @@
            <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="orderBy != null">co_order_by,</if>
            <if test="createTime != null">co_create_time,</if>
            <if test="updateTime != null">co_update_time,</if>
        </trim>
@@ -129,6 +142,7 @@
            <if test="settlement != null">#{settlement,jdbcType=DECIMAL},</if>
            <if test="thirdCreateTime != null">#{thirdCreateTime,jdbcType=TIMESTAMP},</if>
            <if test="settleTime != null">#{settleTime,jdbcType=TIMESTAMP},</if>
            <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
@@ -147,7 +161,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 =
        #{settleTime,jdbcType=TIMESTAMP},co_order_by =
        #{orderBy,jdbcType=INTEGER},co_create_time =
        #{createTime,jdbcType=TIMESTAMP},co_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where co_id = #{id,jdbcType=BIGINT}
    </update>
@@ -170,6 +185,7 @@
            <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="orderBy != null">co_order_by=#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">co_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">co_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
@@ -179,11 +195,14 @@
    <select id="listGroupOrderNoByUid" 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
        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
        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 state == 1">  <!-- 未到账 -->
@@ -237,15 +256,18 @@
            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
        ORDER BY tc.co_create_time
        DESC
        LIMIT ${start},${count}
    </select>
    <select id="countGroupOrderNoByUid" 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
        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 state == 1">  <!-- 未到账 -->
@@ -307,8 +329,10 @@
        SELECT COALESCE(SUM(tc.`co_settlement`),0)AS
        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.`cog_id`
        FROM
        yeshi_ec_common_order_goods tg
        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
@@ -323,12 +347,15 @@
        SELECT IFNULL(COUNT(DISTINCT
        tc.`co_order_no`,tc.`co_source_type`),0) AS self,0 AS shared,0 AS
        invite 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_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`
        JOIN yeshi_ec_hongbao_v2 th ON
        tr.`ho_hongbao_id` = th.`hb_id`
        WHERE
        th.`hb_uid` = ${uid}
        AND (th.`hb_type` = 1 OR th.`hb_type` = 2)
        AND
        (th.`hb_type` = 1 OR th.`hb_type` = 2)
        <if test="day != null and day == 1">
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
@@ -340,12 +367,15 @@
        SELECT 0 AS self, IFNULL(COUNT(DISTINCT
        tc.`co_order_no`,tc.`co_source_type`),0) AS shared,0 AS invite 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_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
        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 (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22)
        AND (th.`hb_type` = 20 OR th.`hb_type` = 21
        OR th.`hb_type` = 22)
        <if test="day != null and day == 1">
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
@@ -356,11 +386,14 @@
        SELECT 0 AS self,0 AS shared,IFNULL(COUNT(DISTINCT
        tc.`co_order_no`,tc.`co_source_type`),0) AS invite 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
        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 (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
        AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR
        th.`hb_type` = 7)
        <if test="day != null and day == 1">
            AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
        </if>
@@ -377,8 +410,10 @@
        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
        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)
@@ -418,8 +453,10 @@
        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
        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
@@ -458,8 +495,10 @@
        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
        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
@@ -535,8 +574,10 @@
    <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
        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">
@@ -570,11 +611,14 @@
    <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
        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
        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"> <!-- 自购订单 -->
@@ -610,7 +654,8 @@
            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
        ORDER BY tc.co_create_time
        DESC
        LIMIT ${start},${count}
    </select>
fanli/src/main/java/com/yeshi/fanli/mapping/order/HongBaoOrderMapper.xml
@@ -11,7 +11,7 @@
            <id column="ho_hongbao_id" property="id" jdbcType="BIGINT" />
        </association>
        <association property="commonOrderGoods" column="ho_order_id"
        <association property="commonOrder" column="ho_order_id"
            javaType="com.yeshi.fanli.entity.order.CommonOrder">
            <id column="ho_order_id" property="id" jdbcType="BIGINT" />
        </association>
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoManageServiceImpl.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.impl.hongbao;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -116,8 +117,7 @@
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return null;
        return new BigDecimal(0);
    }
    @Override
@@ -135,7 +135,55 @@
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return null;
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getFirstShareRate(int urank) {
        String key = "share_21_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getFirstShareRate(int urank, long time) {
        String key = "share_21_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getSecondShareRate(int urank) {
        String key = "share_22_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getSecondShareRate(int urank, long time) {
        String key = "share_22_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -20,6 +20,7 @@
import com.yeshi.fanli.dao.mybatis.order.OrderItemMapper;
import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -27,6 +28,7 @@
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.exception.HongBaoException;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
@@ -70,6 +72,9 @@
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
    @Override
    public int insert(HongBaoV2 record) {
@@ -141,7 +146,6 @@
            if (hb.getOrder() != null) {
                orderId = hb.getOrder().getOrderId();
                // 查询同一订单号的非子红包
            } else
                orderId = hb.getOrderId();
@@ -189,9 +193,15 @@
                if (list.size() <= 0)
                    return;
                List<TaoBaoOrder> orderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
                if (orderList == null || orderList.size() < list.size()) {
                    System.out.println("红包数与订单数不对应");
                    return;
                }
                // 加入排序值
                for (int i = 0; i < orderList.size(); i++) {
                    orderList.get(i).setOrderBy(i + 1);
                }
                // 按照auctionId,payMoney排序
@@ -237,6 +247,11 @@
                    commonOrder.setCreateTime(new Date(list.get(i).getCreatetime()));
                    // TODO 维权判断
                    List<TaoBaoWeiQuanOrder> weiQuanList = taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(orderId,
                            "维权成功");
                    if (weiQuanList != null && weiQuanList.size() > 0)
                        commonOrder.setState(CommonOrder.STATE_WQ);
                    commonOrderMapper.insertSelective(commonOrder);
                    // 插入红包
@@ -287,21 +302,30 @@
            throw new HongBaoException(1, "订单信息不完整");
        HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
        if (hongBaoOrder == null) {
            saveHongBao(commonOrder, type);
        } else {
            updateHongBao(hongBaoOrder, commonOrder, type);
        }
    }
    @Transactional
    private void updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type) throws HongBaoException {
        System.out.println(commonOrder.getOrderNo());
        HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoOrder.getHongBaoV2().getId());
        if (oldHongBao == null)
            throw new HongBaoException(10, "红包对象不存在");
        // 已经失效或者已经领取的红包不做处理
        if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
            return;
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
            HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
            hongBao.setUpdateTime(new Date());
            // 更改状态与资金
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUFENSHIXIAO);
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
@@ -311,24 +335,27 @@
                hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            }
            hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
            // 获取子红包
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBaoOrder.getId());
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
            if (children != null)
                for (HongBaoV2 child : children) {
                    HongBaoV2 childUpdate = new HongBaoV2(child.getId());
                    childUpdate.setState(hongBao.getState());
                    childUpdate.setUpdateTime(new Date());
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_YIJI) {
                    if (child.getType() == HongBaoV2.TYPE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                    } else if (child.getType() == HongBaoV2.TYPE_ERJI) {
                    } else if (child.getType() == HongBaoV2.TYPE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                    }
                    // 以实际收入为准计算预估收益
                    if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), rate.divide(new BigDecimal(100))));
@@ -346,36 +373,65 @@
                }
        } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
            // TODO 分享赚的二级更新
            // 分享赚
            BigDecimal shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setCreateTime(new Date());
            hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);
            hongBao.setVersion(2);
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
            HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
            hongBao.setUpdateTime(new Date());
            // 更改状态与资金
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUFENSHIXIAO);
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100))));
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(commonOrder.getSettleTime());
                calendar.add(Calendar.MONTH, 1);
                hongBao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            }
            UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
            hongBao.setUrank(user.getRank());
            hongBaoV2Mapper.insertSelective(hongBao);
            // 插入红包与订单映射
            HongBaoOrder hongBaoOrder = new HongBaoOrder();
            hongBaoOrder.setCommonOrder(commonOrder);
            hongBaoOrder.setCreateTime(new Date());
            hongBaoOrder.setHongBaoV2(hongBao);
            hongBaoOrderMapper.insertSelective(hongBaoOrder);
            hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
            // 获取子红包
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
            if (children != null)
                for (HongBaoV2 child : children) {
                    HongBaoV2 childUpdate = new HongBaoV2(child.getId());
                    // 统一设置状态
                    childUpdate.setState(hongBao.getState());
                    childUpdate.setUpdateTime(new Date());
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstShareRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                    } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondShareRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                    }
                    // 以实际收入为准计算预估收益
                    if (CommonOrder.STATE_JS == commonOrder.getState()) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), rate.divide(new BigDecimal(100))));
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        childUpdate.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    } else if (CommonOrder.STATE_FK == commonOrder.getState()) {
                        if (commonOrder.getOrderNo().equalsIgnoreCase("314134177659155087"))
                            System.out.println("");
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), rate.divide(new BigDecimal(100))));
                    }
                    hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
                }
        } else
            throw new HongBaoException(2, "type错误");
    }
@@ -385,11 +441,12 @@
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setUserInfo(commonOrder.getUserInfo());
            hongBao.setCreateTime(new Date());
            hongBao.setType(HongBaoV2.TYPE_ZIGOU);
            hongBao.setVersion(2);
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUFENSHIXIAO);
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
@@ -419,7 +476,11 @@
                // 插入一级子红包
                BigDecimal firstRate = hongBaoManageService
                        .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                    return;
                HongBaoV2 firstHongbao = new HongBaoV2();
                firstHongbao.setUserInfo(boss);
                firstHongbao.setUrank(boss.getRank());
                firstHongbao.setParent(hongBao);
                firstHongbao.setCreateTime(new Date());
                firstHongbao.setType(HongBaoV2.TYPE_YIJI);
@@ -446,7 +507,11 @@
                if (boss != null) {// 二级BOSS存在
                    BigDecimal secondRate = hongBaoManageService
                            .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                    if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                        return;
                    HongBaoV2 secondHongbao = new HongBaoV2();
                    secondHongbao.setUserInfo(boss);
                    secondHongbao.setUrank(boss.getRank());
                    secondHongbao.setParent(hongBao);
                    secondHongbao.setCreateTime(new Date());
                    secondHongbao.setType(HongBaoV2.TYPE_ERJI);
@@ -467,6 +532,7 @@
                    }
                    hongBaoV2Mapper.insertSelective(secondHongbao);
                }
            }
        } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
@@ -480,7 +546,7 @@
            hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);
            hongBao.setVersion(2);
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUFENSHIXIAO);
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
@@ -495,6 +561,7 @@
            }
            UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
            hongBao.setUrank(user.getRank());
            hongBao.setUserInfo(user);
            hongBaoV2Mapper.insertSelective(hongBao);
            // 插入红包与订单映射
            HongBaoOrder hongBaoOrder = new HongBaoOrder();
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -3,6 +3,7 @@
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -12,20 +13,28 @@
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory;
import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.order.CommonOrderGoodsVO;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@Service
public class CommonOrderServiceImpl implements CommonOrderService {
@@ -35,6 +44,9 @@
    
    @Resource
    private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
    @Resource
    private CommonOrderGoodsMapper commonOrderGoodsMapper;
    
    @Override
    public int insert(CommonOrder record) {
@@ -67,28 +79,28 @@
    }
    
    @Override
    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{
        return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderState,
                orderNo, startTime, endTime, dateType);
    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 {
        return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderState, orderNo, startTime,
                endTime, dateType);
    }
    
    @Override
    public long countGroupOrderNoByUid(Long uid,Integer state, Integer type, Integer orderState,
    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, 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,
            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, orderState, orderNo, startTime, endTime, dateType);
        List<CommonOrderVO> listOrder = listGroupOrderNoByUid((page - 1) * pageSize, pageSize, uid, state, type,
                orderState, orderNo, startTime, endTime, dateType);
        
        // 订单信息为空
        if (listOrder == null || listOrder.size() == 0) {
@@ -109,7 +121,6 @@
        return listOrder;
    }
    
    @Override
    public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) {
        return commonOrderMapper.countOrderByHongBaoType(uid, day);
@@ -126,8 +137,8 @@
    }
    
    @Override
    public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime,
            String endTime, Integer day) {
    public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime,
            Integer day) {
        return commonOrderMapper.countByUidAndOrderState(uid, type,  startTime, endTime, day);
    }
    
@@ -171,7 +182,6 @@
                        commonGoodsVO.setTitle(null);
                        commonGoodsVO.setGoodsTitle(titleMap);
                    }
                    
                    commonGoodsVO.setActualCount(commonOrder.getTotalCount() + "件");
                    String settlement = commonOrder.getTotalSettlement().setScale(2, BigDecimal.ROUND_DOWN).toString();
@@ -230,8 +240,8 @@
                orderStateContent = "已维权";
                
                /* 订单维权 判断是否全部维权  */
                List<TaoBaoWeiQuanOrder> listWQ =
                        taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
                List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
                        .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
                
                boolean isPart = false;// 默认失效
                
@@ -281,7 +291,6 @@
                order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
            }
            
            String hongBaoDate = null;
            String hongBaoState_Str = "";
            String hongbaoInfoFontColor = "#E5005C";
@@ -300,7 +309,6 @@
                if (preAccountTime != null) {
                    hongBaoDate = "预计到账时间:" + formatday.format(preAccountTime);
                }
                
            } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
                orderHongBaoState = 3;
@@ -348,8 +356,59 @@
    @Override
    public List<CommonOrder> listBySourceTypeAndOrderId(int sourceType, String orderId) {
        
        return null;
    }
    @Transactional
    @Override
    public CommonOrder addTaoBaoOrder(TaoBaoOrder taoBaoOrder, Long uid) throws CommonOrderException {
        CommonOrder commonOrder = commonOrderMapper.selectByOrderNoAndOrderTypeAndOrderBy(taoBaoOrder.getOrderId(),
                Constant.SOURCE_TYPE_TAOBAO, taoBaoOrder.getOrderBy());
        if (commonOrder == null)// 新增
        {
            commonOrder = TaoBaoOrderUtil.convert(taoBaoOrder);
            CommonOrderGoods goods = new CommonOrderGoods();
            goods.setGoodsId(taoBaoOrder.getAuctionId() + "");
            goods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
            // 商品是否已经插入
            List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper
                    .listByGoodsIdAndGoodsType(goods.getGoodsId(), goods.getGoodsType());
            if (commonGoodsList.size() <= 0)// 不存在就插入商品
            {
                TaoBaoGoodsBrief taoBaoGoods = null;
                try {
                    taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(taoBaoOrder.getAuctionId());
                } catch (TaobaoGoodsDownException e) {
                    e.printStackTrace();
                }
                if (taoBaoGoods != null) {
                    goods = CommonOrderGoodsFactory.create(taoBaoGoods);
                }
                goods.setCreateTime(new Date());
                goods.setUpdateTime(new Date());
                commonOrderGoodsMapper.insertSelective(goods);
            } else
                goods.setId(commonGoodsList.get(commonGoodsList.size() - 1).getId());
            commonOrder.setCommonOrderGoods(goods);
            commonOrder.setUserInfo(new UserInfo(uid));
            commonOrder.setCreateTime(new Date());
            commonOrderMapper.insertSelective(commonOrder);
            return commonOrder;
        } else {// 修改
            // 已经结算或者已经失效的订单不处理
            if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_SX)
                return commonOrder;
            CommonOrder newCommonOrder = TaoBaoOrderUtil.convert(taoBaoOrder);
            CommonOrder updateCommonOrder = new CommonOrder(commonOrder.getId());
            updateCommonOrder.seteIncome(newCommonOrder.geteIncome());
            updateCommonOrder.setEstimate(newCommonOrder.getEstimate());
            updateCommonOrder.setPayment(newCommonOrder.getPayment());
            updateCommonOrder.setSettlement(newCommonOrder.getSettlement());
            updateCommonOrder.setSettleTime(newCommonOrder.getSettleTime());
            updateCommonOrder.setState(newCommonOrder.getState());
            updateCommonOrder.setUpdateTime(new Date());
            commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder);
            return commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId());
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -31,11 +31,13 @@
import com.yeshi.fanli.entity.bus.user.AccountDetails;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.HongBaoExtra;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.MoneyRecord;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.OrderItem;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.taobao.PidOrder;
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
@@ -47,10 +49,13 @@
import com.yeshi.fanli.exception.OrderItemException;
import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
import com.yeshi.fanli.exception.money.UserMoneyDetailException;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.service.inter.order.OrderItemServcie;
import com.yeshi.fanli.service.inter.order.OrderProcessService;
@@ -158,7 +163,8 @@
        // 分离出返利订单与分享赚订单
        Iterator<String> its = orders.keySet().iterator();
        Map<String, List<TaoBaoOrder>> fanliOrderMap = new HashMap<>();
        Map<String, List<PidOrder>> shareOrderMap = new HashMap<>();
        Map<String, List<PidOrder>> sharePidOrderMap = new HashMap<>();
        Map<String, List<TaoBaoOrder>> shareOrderMap = new HashMap<>();
        while (its.hasNext()) {
            String orderId = its.next();
            if (orders.get(orderId) != null && orders.get(orderId).size() > 0) {
@@ -167,11 +173,12 @@
                        list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
                PidUser pidUser = pidUserMapper.selectByPid(pid);
                if (pidUser != null && pidUser.getType() == PidUser.TYPE_SHARE_GOODS) {// 商品分享订单
                    List<PidOrder> pidOrderList = new ArrayList<>();
                    for (TaoBaoOrder order : list) {
                        pidOrderList.add(TaoBaoOrderUtil.convertToPidOrder(order));
                    }
                    shareOrderMap.put(orderId, pidOrderList);
//                    List<PidOrder> pidOrderList = new ArrayList<>();
//                    for (TaoBaoOrder order : list) {
//                        pidOrderList.add(TaoBaoOrderUtil.convertToPidOrder(order));
//                    }
//                    sharePidOrderMap.put(orderId, pidOrderList);
                    shareOrderMap.put(orderId, list);
                } else {// 普通返利订单
                    fanliOrderMap.put(orderId, list);
                }
@@ -224,14 +231,16 @@
    public void processShopingFanliOrder(Map<String, List<TaoBaoOrder>> orders) {
        // 查询在Order中是否存在该订单号
        Iterator<String> its = orders.keySet().iterator();
        String tempOrderId="";
        while (its.hasNext()) {
            try {
                String orderId = its.next();
                tempOrderId=orderId;
                // 处理红包与子红包
                // if (isRedisLockOrder(orderId))
                // continue;
                // redisLockOrder(orderId);
                processShopingFanliOrder(orderId, orders.get(orderId));
                processShopingFanliOrderNew(orderId, orders.get(orderId));
                // redisUnlockOrder(orderId);
                // 出错了就不处理该订单了,需要定期检查
@@ -243,15 +252,27 @@
            } catch (OrderItemException e2) {
                e2.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
                try {
                    LogHelper.errorDetailInfo(e, null, tempOrderId);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    @Transactional
    @Override
    public void processShareGoodsOrder(Map<String, List<PidOrder>> orders) {
        pidOrderService.addPidOrderFromTaoBao(orders);
    public void processShareGoodsOrder(Map<String, List<TaoBaoOrder>> orders) {
        // pidOrderService.addPidOrderFromTaoBao(orders);
        if (orders != null) {
            Iterator<String> its = orders.keySet().iterator();
            while (its.hasNext()) {
                String orderId = its.next();
                processShareGoodsOrderNew(orderId, orders.get(orderId));
            }
        }
    }
    /**
@@ -664,8 +685,6 @@
            }
        }
        
        /**
         * 处理一级二级分享赚(属于邀请赚类型)
         */
@@ -699,8 +718,6 @@
                    drawBackOrders.add(hb.getOrderId());
            }
        }
        
        // 邀请赚到账
        if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
@@ -776,8 +793,6 @@
            }
        }
        /**
         * 分享赚到账
         */
@@ -820,4 +835,118 @@
    }
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Transactional
    @Override
    public void processShopingFanliOrderNew(String orderId, List<TaoBaoOrder> orderList)
            throws HongBaoException, OrderItemException {
        List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
        if (orderList != null && orderList.size() > 0) {
            String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
                    orderList.get(0).getSourceMediaId(), orderList.get(0).getAdPositionId());
            Order oldOrder = orderMapper.selectOrderByOrderId(orderId);
            // 原来不存在订单
            Long uid = null;
            if (oldOrder == null) {
                PidUser pidUser = pidUserMapper.selectByPid(pid);
                if (pidUser != null) {
                    uid = pidUser.getUid();
                    // 插入到Order中
                    // 添加到订单中去
                    Order order = new Order();
                    order.setBeizhu("PID返利订单");
                    order.setCreatetime(System.currentTimeMillis());
                    order.setOrderId(orderId);
                    order.setOrderType(1);
                    order.setState(Order.STATE_YIZHIFU);
                    order.setUserInfo(new UserInfo(uid));
                    order.setVersion(2);
                    // 加入到订单表
                    orderMapper.insertSelective(order);
                    oldOrder = order;
                }
            } else {
                uid = oldOrder.getUserInfo().getId();
            }
            // 尚未找到和PID对应的用户
            if (uid == null)
                return;
            // 计算订单总额度
            Order updateOrder = new Order();
            updateOrder.setId(oldOrder.getId());
            BigDecimal money = new BigDecimal(0);
            for (TaoBaoOrder o : orderList) {
                if (o.getOrderState().equalsIgnoreCase("订单结算"))
                    money = money.add(o.getSettlement());
                else {
                    money = money.add(o.getPayment());
                }
            }
            updateOrder.setMoney(money);
            String thirdState = null;
            for (TaoBaoOrder o : orderList)
                if (!o.getOrderState().equalsIgnoreCase("订单失效")) {
                    thirdState = o.getOrderState();
                    break;
                }
            updateOrder.setThirdState(thirdState);
            updateOrder.setThirdCreateTime(
                    new Date(TimeUtil.convertToTimeTemp(orderList.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss")));
            orderMapper.updateByPrimaryKeySelective(updateOrder);
            // 用第一个子订单锁定用户
            for (TaoBaoOrder taoBaoOrder : orderList) {
                try {
                    CommonOrder commonOrder = commonOrderService.addTaoBaoOrder(taoBaoOrder, uid);
                    hongBaoV2Service.addHongBao(commonOrder, HongBaoV2.TYPE_ZIGOU);
                } catch (CommonOrderException e) {
                    e.printStackTrace();
                } catch (HongBaoException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    @Override
    public void processShareGoodsOrderNew(String orderId, List<TaoBaoOrder> orderList) {
        List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
        if (orderList != null && orderList.size() > 0) {
            String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
                    orderList.get(0).getSourceMediaId(), orderList.get(0).getAdPositionId());
            // 原来不存在订单
            Long uid = null;
            PidUser pidUser = pidUserMapper.selectByPid(pid);
            if (pidUser != null)
                uid = pidUser.getUid();
            // 尚未找到和PID对应的用户
            if (uid == null)
                return;
            // 用第一个子订单锁定用户
            for (TaoBaoOrder taoBaoOrder : orderList) {
                try {
                    CommonOrder commonOrder = commonOrderService.addTaoBaoOrder(taoBaoOrder, uid);
                    hongBaoV2Service.addHongBao(commonOrder, HongBaoV2.TYPE_SHARE_GOODS);
                } catch (CommonOrderException e) {
                    e.printStackTrace();
                } catch (HongBaoException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/HongBaoManageService.java
@@ -65,18 +65,48 @@
    public BigDecimal getFirstInviteRate(int urank, long time);
    /**
     * 获取第一级的邀请赚比例
     * 获取第二级的邀请赚比例
     * 
     * @return
     */
    public BigDecimal getSecondInviteRate(int urank);
    /**
     * 获取第一级的邀请赚比例
     * 获取第二级的邀请赚比例
     * 
     * @param time
     * @return
     */
    public BigDecimal getSecondInviteRate(int urank, long time);
    /**
     * 获取第一级的分享赚比例
     *
     * @return
     */
    public BigDecimal getFirstShareRate(int urank);
    /**
     * 获取第一级的分享赚比例
     *
     * @param time
     * @return
     */
    public BigDecimal getFirstShareRate(int urank, long time);
    /**
     * 获取第二级的分享赚比例
     *
     * @return
     */
    public BigDecimal getSecondShareRate(int urank);
    /**
     * 获取第二级的分享赚比例
     *
     * @param time
     * @return
     */
    public BigDecimal getSecondShareRate(int urank, long time);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java
@@ -5,6 +5,7 @@
import java.util.Map;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@@ -117,4 +118,13 @@
     */
    public List<CommonOrder> listBySourceTypeAndOrderId(int sourceType, String orderId);
    /**
     * 缓存普通订单
     *
     * @param taoBaoOrder
     * @param uid
     * @return
     */
    public CommonOrder addTaoBaoOrder(TaoBaoOrder taoBaoOrder, Long uid) throws CommonOrderException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java
@@ -37,7 +37,20 @@
    /**
     * 处理分享商品订单
     */
    public void processShareGoodsOrder(Map<String, List<PidOrder>> orders);
    public void processShareGoodsOrder(Map<String, List<TaoBaoOrder>> orders);
    public void processShopingFanliOrderNew(String orderId, List<TaoBaoOrder> orderList)
            throws HongBaoException, OrderItemException;
    /**
     * 处理分享商品订单
     */
    public void processShareGoodsOrderNew(String orderId, List<TaoBaoOrder> orderList);
    /**
     * 处理返利
fanli/src/main/java/com/yeshi/fanli/util/factory/CommonOrderGoodsFactory.java
New file
@@ -0,0 +1,27 @@
package com.yeshi.fanli.util.factory;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.util.Constant;
public class CommonOrderGoodsFactory {
    public static CommonOrderGoods create(TaoBaoGoodsBrief goods) {
        if (goods == null)
            return null;
        CommonOrderGoods orderGoods = new CommonOrderGoods();
        orderGoods.setGoodsId(goods.getAuctionId() + "");
        orderGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
        orderGoods.setPicture(goods.getPictUrl());
        orderGoods.setPrice(goods.getZkPrice());
        orderGoods.setShopId(goods.getSellerId());
        orderGoods.setShopName(goods.getShopTitle());
        if (goods.getUserType() == 0)
            orderGoods.setShopType(CommonOrderGoods.TYPE_TAOBAO);
        else
            orderGoods.setShopType(CommonOrderGoods.TYPE_TMALL);
        orderGoods.setTitle(goods.getTitle());
        return orderGoods;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoOrderUtil.java
@@ -887,7 +887,7 @@
        } else if ("订单结算".equalsIgnoreCase(taoBaoOrder.getOrderState())) {
            state = CommonOrder.STATE_JS;
        }
        commonOrder.setOrderBy(taoBaoOrder.getOrderBy());
        commonOrder.setState(state);
        commonOrder.setThirdCreateTime(
                new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")));