admin
2019-12-13 a3e7322a0aa6b5b13a84bc76923d0c6b68b13276
订单修改
7个文件已修改
729 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 516 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/manger/HongBaoV2AddManager.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeOrderApiUtil.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java
@@ -17,6 +17,7 @@
import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.config.AppHomeFloatImg;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
@@ -30,13 +31,16 @@
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserActiveLogService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.homemodule.FloatImgDetailVO;
import net.sf.json.JSONObject;
@@ -80,6 +84,12 @@
    @Resource
    private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private RedisManager redisManager;
    /**
     * s 首页配置信息
@@ -167,7 +177,8 @@
        for (int i = 0; i < listAD.size(); i++) {
            FloatAD floatAD = listAD.get(i);
            FloatADTypeEnum typeEnum = floatAD.getTypeEnum();
            if (typeEnum == FloatADTypeEnum.newUserRedPack && !userTaoLiJinNewbiesService.verifyHasReward(uid, acceptData.getDevice())) {
            if (typeEnum == FloatADTypeEnum.newUserRedPack
                    && !userTaoLiJinNewbiesService.verifyHasReward(uid, acceptData.getDevice())) {
                listAD.remove(i);
                i--;
                continue;
@@ -478,9 +489,30 @@
     */
    @RequestMapping(value = "getElemeLink")
    public void getElemeLink(AcceptData acceptData, Long uid, String callback, PrintWriter out) {
        UserExtraTaoBaoInfo userInfoExtra = userExtraTaoBaoInfoService.getByUid(uid);
        if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getRelationId())) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "请绑定淘宝")));
            return;
        }
        String elmeLink = redisManager.getCommonString("elme-link-" + uid);
        if (StringUtil.isNullOrEmpty(elmeLink)) {
            elmeLink = TaoKeApiUtil.officialActivityConvert(TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3],
                    "1571715733668", userInfoExtra.getRelationId());
            if (!StringUtil.isNullOrEmpty(elmeLink)) {
                redisManager.cacheCommonString("elme-link-" + uid, elmeLink, 60 * 60);// 缓存1个小时
            }
        }
        JSONObject data = new JSONObject();
        data.put("hongBao", configService.get("eleme_hongbao_link").replace("{用户ID}", uid + ""));
        data.put("goods", configService.get("eleme_goods_link").replace("{用户ID}", uid + ""));
        // data.put("hongBao",
        // configService.get("eleme_hongbao_link").replace("{用户ID}", uid + ""));
        // data.put("goods",
        // configService.get("eleme_goods_link").replace("{用户ID}", uid + ""));
        data.put("hongBao", elmeLink);
        data.put("goods", elmeLink);
        ClientTBPid clientTBPid1 = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_ELEME_PID,
                null, TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3]);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -361,7 +361,8 @@
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥"+ TaoBaoUtil.getGoodsHongBaoMoney(goods, hongBaoManageService.getVIPShareRate()));
            goodsDetail.getMoneyInfo().setShareMoney(
                    "¥" + TaoBaoUtil.getGoodsHongBaoMoney(goods, hongBaoManageService.getVIPShareRate()));
        }
        if (TaoBaoUtil.isYUShou(goods)) {
@@ -519,8 +520,10 @@
            RewardCouponVO rewardCoupon = new RewardCouponVO();
            rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
            JSONObject params1 = new JSONObject();
            if (!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.get("special_guide_reward_coupon_link"));
            else
                params1.put("url", configService.get("vip_link"));
            rewardCoupon
                    .setMaxMoney("¥" + TaoBaoUtil.getGoodsHongBaoMoney(goods, hongBaoManageService.getVIPFanLiRate()));
            if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
@@ -615,7 +618,8 @@
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥"+ JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPShareRate()));
            goodsDetail.getMoneyInfo()
                    .setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPShareRate()));
        }
        // 附加信息
@@ -654,7 +658,10 @@
        rewardCoupon.setMaxMoneyPlus(maxMoneyPlus);
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion()))
        params1.put("url", configService.get("special_guide_reward_coupon_link"));
        else
            params1.put("url", configService.get("vip_link"));
        rewardCoupon.setMaxMoney("¥" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPFanLiRate()));
        if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
@@ -807,7 +814,8 @@
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥"+ PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPShareRate()));
            goodsDetail.getMoneyInfo().setShareMoney(
                    "¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPShareRate()));
        }
        // 附加信息
@@ -815,7 +823,10 @@
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion()))
        params1.put("url", configService.get("special_guide_reward_coupon_link"));
        else
            params1.put("url", configService.get("vip_link"));
        rewardCoupon
                .setMaxMoney("¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPFanLiRate()));
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -24,6 +24,7 @@
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <association property="userInfo" column="co_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT" />
@@ -56,6 +57,7 @@
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <association property="userInfo" column="co_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT" />
@@ -97,23 +99,16 @@
        <result column="userId" property="userId" jdbcType="VARCHAR" />
        <result column="userName" property="userName" jdbcType="VARCHAR" />
        <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" />
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_uid" property="userId" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <association property="userInfo" column="co_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
        <association property="commonOrderGoods" column="co_order_goods_id"
            resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap" />
    </resultMap>
    <resultMap id="ThreeResultMap" type="com.yeshi.fanli.vo.order.CommonOrderVO">
        <id column="co_id" property="id" jdbcType="BIGINT" />
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR" />
@@ -151,30 +146,25 @@
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <association property="userInfo" column="co_uid"
            select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey" />
        <association property="commonOrderGoods" column="co_order_goods_id"
            select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey" />
    </resultMap>
    <resultMap id="OrderCountMap" type="com.yeshi.fanli.vo.order.OrderCountVO" >
        <result column="self" property="self" jdbcType="BIGINT" />
        <result column="shared" property="shared" jdbcType="BIGINT" />
        <result column="invite" property="invite" jdbcType="BIGINT" />
    </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_state_whole_order,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time,co_trade_id,co_state_desc
    <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_state_whole_order,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time,co_trade_id,co_state_desc,co_urank
    </sql>
    <sql id="Order_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,
        co_order_goods_id,co_count,co_state,co_state_whole_order,
        co_estimate,co_eIncome,co_payment,co_settlement, co_third_create_time,
        MAX(co_settle_time) AS co_settle_time, co_order_by, co_create_time,
        co_update_time,co_state_desc
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
@@ -198,68 +188,42 @@
        yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and
        co_order_no=#{orderNo}
    </select>
    <select id="selectBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT *
        FROM
        yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and
        co_trade_id=#{tradeId} limit 1
        FROM yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType}
        and co_trade_id=#{tradeId} limit 1
    </select>
    <select id="listBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT *
        FROM
    <select id="listBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT * FROM
        yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and
        co_trade_id=#{tradeId}
    </select>
    <select id="listBySourceTypeAndTradeIdList" resultMap="BaseResultMap">
        SELECT *
        FROM
        yeshi_ec_common_order co WHERE
        SELECT * FROM yeshi_ec_common_order co WHERE
        co.co_source_type=#{sourceType}
        <if test="tradeIdList!=null">
            <foreach collection="tradeIdList" item="tradeId" open=" and ("
                close=")" separator=" or ">
                co.co_trade_id=#{tradeId}
            </foreach>
                close=")" separator=" or ">co.co_trade_id=#{tradeId}</foreach>
        </if>
    </select>
    <select id="listBySourceTypeAndStateAndThirdCrateTime"
        resultMap="BaseResultMap">
        SELECT *
        FROM
        yeshi_ec_common_order co WHERE
        SELECT * FROM yeshi_ec_common_order co WHERE
        co.co_source_type=#{sourceType}
        <if test="state!=null">
            and co_state=#{state}
        <if test="state!=null">and co_state=#{state}</if>
        <if test="minTime!=null">and
            UNIX_TIMESTAMP(co_third_create_time)*1000&gt;=#{minTime}</if>
        <if test="maxTime!=null">and #{maxTime}&gt;
            UNIX_TIMESTAMP(co_third_create_time)*1000
        </if>
        <if test="minTime!=null">
            and UNIX_TIMESTAMP(co_third_create_time)*1000>=#{minTime}
        </if>
        <if test="maxTime!=null">
            and #{maxTime}> UNIX_TIMESTAMP(co_third_create_time)*1000
        </if>
        order by co_id desc
        limit #{start},#{count}
        order by co_id desc limit #{start},#{count}
    </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_state_whole_order,co_order_by,co_trade_id,co_state_desc)
        (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_state_whole_order,co_order_by,co_trade_id,co_state_desc,co_urank)
        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},#{stateWholeOrder,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{tradeId,jdbcType=VARCHAR},#{stateDesc,jdbcType=VARCHAR})
        (#{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},#{stateWholeOrder,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{tradeId,jdbcType=VARCHAR},#{stateDesc,jdbcType=VARCHAR},#{urank,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder"
        useGeneratedKeys="true" keyProperty="id">
@@ -285,6 +249,7 @@
            <if test="updateTime != null">co_update_time,</if>
            <if test="tradeId != null">co_trade_id,</if>
            <if test="stateDesc != null">co_state_desc,</if>
            <if test="urank != null">co_urank,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -307,7 +272,8 @@
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR},</if>
            <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR}</if>
            <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="urank != null">#{urank,jdbcType=INTEGER}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update
@@ -330,7 +296,8 @@
        #{createTime,jdbcType=TIMESTAMP},co_update_time =
        #{updateTime,jdbcType=TIMESTAMP} ,co_trade_id
        =#{tradeId,jdbcType=VARCHAR},co_state_desc
        =#{stateDesc,jdbcType=VARCHAR} where co_id = #{id,jdbcType=BIGINT}
        =#{stateDesc,jdbcType=VARCHAR} ,co_urank =#{urank,jdbcType=INTEGER}
        where co_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder">
        update yeshi_ec_common_order
@@ -359,6 +326,7 @@
            <if test="id !=null">co_id =#{id,jdbcType=BIGINT},</if>
            <if test="tradeId !=null">co_trade_id =#{tradeId,jdbcType=VARCHAR},</if>
            <if test="stateDesc !=null">co_state_desc =#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="urank !=null">co_urank =#{urank,jdbcType=INTEGER},</if>
        </set>
        where co_id = #{id,jdbcType=BIGINT}
    </update>
@@ -396,33 +364,43 @@
        </if>
        <if test="day == 3 or day == 10">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),    DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <if test="day == 6">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),    DATE_FORMAT(co.`co_third_create_time`, '%Y%m')) = 1
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_third_create_time`, '%Y%m')) = 1
        </if>
        <if test="day == 11"> <!-- 近3个月产生 -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 3 MONTH) AND NOW()
        <if test="day == 11">
            <!-- 近3个月产生 -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 3
            MONTH) AND NOW()
        </if>
        <if test="day == 12"> <!-- 近半年产生  -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 6 MONTH) AND NOW()
        <if test="day == 12">
            <!-- 近半年产生 -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 6
            MONTH) AND NOW()
        </if>
    </sql>
    <sql id="SELECT_PARAM_HONGBAO_TYPE">
        <if test="type != null and type == 1"> <!-- 自购订单 -->
        <if test="type != null and type == 1">
            <!-- 自购订单 -->
            AND (v2.hb_type =1 or v2.hb_type =2)
        </if>
        <if test="type != null and type == 2"> <!-- 分享订单 -->
        <if test="type != null and type == 2">
            <!-- 分享订单 -->
            AND v2.`hb_type` = 20
        </if>
        <if test="type != null and type == 3"> <!-- 邀请订单 -->
            AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR v2.`hb_type` = 21 OR v2.`hb_type` = 22)
        <if test="type != null and type == 3">
            <!-- 邀请订单 -->
            AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
            v2.`hb_type` = 21 OR v2.`hb_type` = 22)
        </if>
    </sql>
    <sql id="SELECT_PARAM_HONGBAO_STATE">
@@ -442,26 +420,26 @@
    <sql id="Hongbao_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_type,hb_state,hb_pre_get_time,hb_get_time,hb_version,
        IF(v2.`hb_state` = 4, 0, v2.hb_money)AS hb_money
    </sql>
    <select id="listUserOrder" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS
        hongBaoState, hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
        <include refid="Order_Column_List" />
        FROM yeshi_ec_hongbao_order ho
        LEFT JOIN (SELECT
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <if test="type == 2 and day == 5"> <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5"> <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <!-- 红包类型 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
@@ -475,26 +453,27 @@
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countUserOrder" resultType="java.lang.Long">
        <!-- 统计用户订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE" /> <!-- 红包类型 -->
        <if test="type == 2 and day == 5"> <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5"> <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
@@ -507,7 +486,6 @@
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="listOrderGoodsInfo" resultMap="ResultMap"
@@ -525,8 +503,6 @@
        </foreach>
        GROUP BY tc.`co_order_no`,tc.`co_order_goods_id`
    </select>
    <select id="countHistoryOrder" resultType="java.util.HashMap">
        <!-- 统计历史订单数量 -->
        SELECT SUM(A.self)AS totalSelf,SUM(A.shared)AS
@@ -560,11 +536,7 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX
        UNION ALL
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL
        <!-- 分享订单 -->
        SELECT 0 AS self,IFNULL(COUNT(ho_id),0) AS shared,0 AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
@@ -593,11 +565,7 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ
        UNION ALL
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL
        <!-- 邀请订单 -->
        SELECT 0 AS self,0 AS shared,IFNULL(COUNT(ho_id),0) AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
@@ -627,64 +595,64 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A
    </select>
    <sql id="OrderCountQuery">
        WHERE co.`co_state_whole_order`<![CDATA[<>]]>3
        <if test="day == 1"> <!-- 今天 -->
    <sql id="OrderCountQuery">WHERE
        co.`co_state_whole_order`<![CDATA[<>]]>3
        <if test="day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day == 2"> <!-- 昨天 -->
        <if test="day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day == 3"> <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
        <if test="day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4"> <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        <if test="day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),
            '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="source != null and source != 0">AND co.co_source_type = #{source}</if>
    </sql>
    <select id="getOrderCount" resultMap="OrderCountMap">
        SELECT sum(self) as self,sum(shared) as shared,sum(invite) as invite from
        (
            SELECT IFNULL(COUNT(co_order_no),0)AS self,0 AS shared,0 AS invite FROM
                (SELECT co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`= ${uid} AND v.`hb_type` = 1)v2
                LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)
                LEFT JOIN yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id`
                <include refid="OrderCountQuery"></include>
                GROUP BY co.`co_order_no`,co.`co_source_type`)A
            UNION ALL
            SELECT 0 AS self,IFNULL(COUNT(co_order_no),0)AS shared,0 AS invite FROM
                (SELECT co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`= ${uid} AND v.`hb_type` = 20)v2
                LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)
                LEFT JOIN yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id`
                <include refid="OrderCountQuery"></include>
                GROUP BY co.`co_order_no`,co.`co_source_type`)A
            UNION ALL
            SELECT 0 AS self,0 AS shared,IFNULL(COUNT(co_order_no),0)AS invite FROM
                (SELECT co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v
                     WHERE v.`hb_uid`= ${uid}
                     AND (v.`hb_type` = 5 OR v.`hb_type` = 6 OR v.`hb_type` = 7 OR v.`hb_type` = 21 OR v.`hb_type` = 22))v2
                LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)
                LEFT JOIN yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id`
                <include refid="OrderCountQuery"></include>
                GROUP BY co.`co_order_no`,co.`co_source_type`)A
        )B
        SELECT sum(self) as self,sum(shared) as shared,sum(invite) as invite
        from ( SELECT IFNULL(COUNT(co_order_no),0)AS self,0 AS shared,0 AS
        invite FROM (SELECT co.`co_order_no` FROM (SELECT * FROM
        yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`= ${uid} AND v.`hb_type` = 1)v2
        LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` =
        IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid) LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery" />
        GROUP BY co.`co_order_no`,co.`co_source_type`)A UNION ALL SELECT 0 AS
        self,IFNULL(COUNT(co_order_no),0)AS shared,0 AS invite FROM (SELECT
        co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
        v.`hb_uid`= ${uid} AND v.`hb_type` = 20)v2 LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS
        NULL,v2.hb_id,v2.hb_pid) LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery" />
        GROUP BY co.`co_order_no`,co.`co_source_type`)A UNION ALL SELECT 0 AS
        self,0 AS shared,IFNULL(COUNT(co_order_no),0)AS invite FROM (SELECT
        co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
        v.`hb_uid`= ${uid} AND (v.`hb_type` = 5 OR v.`hb_type` = 6 OR
        v.`hb_type` = 7 OR v.`hb_type` = 21 OR v.`hb_type` = 22))v2 LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS
        NULL,v2.hb_id,v2.hb_pid) LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery" />
        GROUP BY co.`co_order_no`,co.`co_source_type`)A )B
    </select>
    <select id="countUserOrderToApp" resultType="Long">
            <!-- 有效订单 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM
            (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho
              LEFT JOIN
               ( SELECT * FROM yeshi_ec_hongbao_v2 v2
                 WHERE v2.`hb_uid`=${uid}
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.`ho_id` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM
        yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
                    <include refid="SELECT_PARAM_HONGBAO_TYPE" />
                    <if test="state != null and state == 1">
                        <!-- 未到账 -->
@@ -701,71 +669,51 @@
                ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
            LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
            WHERE hb.hb_id IS NOT NULL <![CDATA[AND co.`co_state` <> 3]]>
            <if test="stateOrder == 1"> <!-- 有效订单 -->
        <if test="stateOrder == 1">
            <!-- 有效订单 -->
                AND (co.`co_state_whole_order` =1 OR co.`co_state_whole_order` = 2)
            </if>
            <if test="stateOrder == 2"> <!-- 维权订单 -->
        <if test="stateOrder == 2">
            <!-- 维权订单 -->
                AND co.`co_state` = 3
            </if>
            <if test="stateOrder == 3"> <!-- 失效订单 -->
        <if test="stateOrder == 3">
            <!-- 失效订单 -->
                AND co.`co_state_whole_order` = 3
            </if>
            <!-- 订单时间 -->
            <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
            <!-- 订单来源 -->
            <if test="source != null">AND co.co_source_type = #{source}</if>
            GROUP BY co.`co_order_no`, co.`co_source_type`
            )A
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <!--
    <select id="countByUidAndOrderState" resultType="java.util.HashMap">
        SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS
        totalProces,SUM(A.Invalid)AS totalInvite FROM (
        有效订单
        SELECT IFNULL(COUNT(ho_id),0) AS valid,0 AS proces,0 AS Invalid FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL <![CDATA[AND co.`co_state` <> 3]]>
        AND (co.`co_state_whole_order` =1 OR co.`co_state_whole_order` = 2)
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        订单来源
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX
        UNION ALL
        维权订单
        SELECT 0 AS valid,IFNULL(COUNT(ho_id),0) AS proces,0 AS Invalid FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL AND co.`co_state` = 3
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        订单来源
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ
        UNION ALL
        失效订单
        SELECT 0 AS valid,0 AS proces,IFNULL(COUNT(ho_id),0) AS Invalid FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL AND co.`co_state_whole_order` = 3
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        订单来源
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A
    </select> -->
    <!-- <select id="countByUidAndOrderState" resultType="java.util.HashMap">
        SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS totalProces,SUM(A.Invalid)AS
        totalInvite FROM ( 有效订单 SELECT IFNULL(COUNT(ho_id),0) AS valid,0 AS proces,0
        AS Invalid FROM (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN
        ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include
        refid="SELECT_PARAM_HONGBAO_TYPE" /> ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL <![CDATA[AND co.`co_state` <> 3]]> AND (co.`co_state_whole_order`
        =1 OR co.`co_state_whole_order` = 2) <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL 维权订单 SELECT 0
        AS valid,IFNULL(COUNT(ho_id),0) AS proces,0 AS Invalid FROM (SELECT ho.`ho_id`
        FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL AND co.`co_state` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL 失效订单 SELECT 0
        AS valid,0 AS proces,IFNULL(COUNT(ho_id),0) AS Invalid FROM (SELECT ho.`ho_id`
        FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL AND co.`co_state_whole_order` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A </select> -->
    <select id="countBonusOrderNumber" resultType="java.lang.Long">
        <!-- 奖金统计:订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.`ho_id` FROM
@@ -811,7 +759,8 @@
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <if test="day != null and day == 4">AND co.`co_state` = 2</if> <!-- 上月 :统计已收货 -->
        <if test="day != null and day == 4">AND co.`co_state` = 2</if>
        <!-- 上月 :统计已收货 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
@@ -883,20 +832,17 @@
        userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
        totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
        hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">
            LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
        <if test="listShopId != null">LEFT JOIN yeshi_ec_common_order_goods g ON
            co.`co_order_goods_id`=g.`cog_id`
        </if>
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
@@ -911,39 +857,33 @@
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and (" separator=" or " close=")">
                co.`co_order_goods_id` =#{goodsId}
            </foreach>
            <foreach collection="listGoodsId" item="goodsId" open=" and ("
                separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}</foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and (" separator=" or " close=")">
                g.`cog_shop_id` =#{shopId}
            </foreach>
            <foreach collection="listShopId" item="shopId" open=" and ("
                separator=" or " close=")">g.`cog_shop_id` =#{shopId}</foreach>
        </if>
        <if test="minTime != null"> <!-- 高风险订单 -->
            AND co.`co_third_create_time`>#{minTime} AND <![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        <if test="minTime != null">
            <!-- 高风险订单 -->
            AND co.`co_third_create_time`&gt;#{minTime} AND<![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
        JOIN yeshi_ec_user u ON u.id = A.hb_uid
    </select>
    <select id="listQueryWithNoChild" resultMap="ThreeResultMap">
        SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS
        userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
        totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
        hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON hb.hb_id=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co    ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        )hb ON hb.hb_id=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
@@ -959,8 +899,6 @@
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
        JOIN yeshi_ec_user u ON u.id = A.hb_uid
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
@@ -970,8 +908,8 @@
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">
            LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
        <if test="listShopId != null">LEFT JOIN yeshi_ec_common_order_goods g ON
            co.`co_order_goods_id`=g.`cog_id`
        </if>
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
@@ -987,22 +925,18 @@
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and (" separator=" or " close=")">
                co.`co_order_goods_id` =#{goodsId}
            </foreach>
            <foreach collection="listGoodsId" item="goodsId" open=" and ("
                separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}</foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and (" separator=" or " close=")">
                g.`cog_shop_id` =#{shopId}
            </foreach>
            <foreach collection="listShopId" item="shopId" open=" and ("
                separator=" or " close=")">g.`cog_shop_id` =#{shopId}</foreach>
        </if>
        <if test="minTime != null"> <!-- 高风险订单 -->
            AND co.`co_third_create_time`>#{minTime} AND <![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        <if test="minTime != null">
            <!-- 高风险订单 -->
            AND co.`co_third_create_time`&gt;#{minTime} AND<![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
    </select>
    <select id="countQueryWithNoChild" resultType="java.lang.Long">
        SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
@@ -1010,10 +944,8 @@
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON hb.hb_id=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        )hb ON hb.hb_id=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
@@ -1027,10 +959,6 @@
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
    </select>
    <select id="getCouponHongbaoByOrderNo" resultMap="ResultMap">
        SELECT COALESCE(SUM(IF(hb.hb_type=1,hb.`hb_money`,0)),0)AS totalMoney,
        COALESCE(SUM(IF(hb.hb_type=10,hb.`hb_money`,0)),0)AS couponMoney,
@@ -1064,76 +992,72 @@
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type`
    </select>
    <select id="getByOrderNo" resultMap="BaseResultMap">
        SELECT * FROM
        yeshi_ec_common_order co
        WHERE co_uid = #{uid} AND co_order_no=#{orderNo}
    <select id="getByOrderNo" resultMap="BaseResultMap">SELECT * FROM
        yeshi_ec_common_order co WHERE co_uid = #{uid} AND
        co_order_no=#{orderNo}
    </select>
    <select id="listByUid" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co
        WHERE co_uid = #{uid}
        SELECT * FROM yeshi_ec_common_order co WHERE co_uid = #{uid}
        <if test="stateList!=null">
            <foreach collection="stateList" separator=" or " open="and ("
                item="state" close=")">
                co_state=#{state}
            </foreach>
                item="state" close=")">co_state=#{state}</foreach>
        </if>
        limit #{start},#{count}
    </select>
    <select id="firstValidOrderByUid"  resultMap="ResultMap">
        SELECT co.*,v2.`hb_get_time` AS accountTime FROM yeshi_ec_hongbao_order ho
        LEFT JOIN yeshi_ec_hongbao_v2 v2 ON IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE v2.hb_id IS NOT NULL AND v2.`hb_uid` = #{uid} AND v2.`hb_state` = 3
            <if test="typeHB == 1"> <!-- 自购订单 -->
        SELECT co.*,v2.`hb_get_time` AS accountTime FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON
        IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE v2.hb_id
        IS NOT NULL AND v2.`hb_uid` = #{uid} AND v2.`hb_state` = 3
        <if test="typeHB == 1">
            <!-- 自购订单 -->
                AND (v2.hb_type =1 or v2.hb_type =2)  
            </if>
            <if test="typeHB == 2"> <!-- 分享订单 -->
        <if test="typeHB == 2">
            <!-- 分享订单 -->
                AND v2.`hb_type` = 20  
            </if>
            <if test="typeHB == 3">  <!-- 邀请订单 -->
        <if test="typeHB == 3">
            <!-- 邀请订单 -->
                AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
                v2.`hb_type` = 21 OR v2.`hb_type` = 22)
            </if>
            <if test="typeDate == 3"> <!-- 本月 -->
                AND DATE_FORMAT(co.`co_create_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
        <if test="typeDate == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
            </if>
            <if test="typeDate == 4"> <!-- 上月 -->
                AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(co.`co_create_time`, '%Y%m')) = 1
        <if test="typeDate == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),
            '%Y%m'),DATE_FORMAT(co.`co_create_time`, '%Y%m')) = 1
            </if>
        ORDER BY co.`co_id`
        LIMIT 1
        ORDER BY co.`co_id` LIMIT 1
    </select>
  <select id="getFirstShareOrderByUid"  resultMap="BaseResultMap">
    SELECT co.* FROM yeshi_ec_hongbao_order ho
    LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id = ho.`ho_hongbao_id`
    LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
    WHERE v2.`hb_uid` = #{uid} AND v2.`hb_type` = 20
    ORDER BY co.`co_third_create_time`
    LIMIT 1
    <select id="getFirstShareOrderByUid" resultMap="BaseResultMap">SELECT co.* FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id
        = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_uid` = #{uid} AND
        v2.`hb_type` = 20 ORDER BY co.`co_third_create_time` LIMIT 1
  </select>
  <select id="getTotalRewardMoneyByOrderNoAndSourceType" resultType="BigDecimal">
    SELECT SUM(hb_money) FROM(SELECT v2.`hb_money` FROM yeshi_ec_hongbao_order ho
        LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id = ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE v2.`hb_type` = 20 AND v2.`hb_state` = 3
              AND co.`co_order_no` = #{orderNo} AND co.`co_source_type`= #{sourceType})A
    <select id="getTotalRewardMoneyByOrderNoAndSourceType"
        resultType="BigDecimal">SELECT SUM(hb_money) FROM(SELECT v2.`hb_money` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id
        = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_type` = 20 AND v2.`hb_state`
        = 3 AND co.`co_order_no` = #{orderNo} AND co.`co_source_type`=
        #{sourceType})A
  </select>
 <select id="count24HValidOrderByUid" resultType="Long">
     SELECT IFNULL(COUNT(A.co_order_no),0) FROM (SELECT co.`co_order_no` FROM yeshi_ec_hongbao_order ho
    LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id = ho.`ho_hongbao_id`
    LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
    WHERE v2.`hb_type` = 1 AND co.`co_state_whole_order`<![CDATA[<>]]> 3 AND co.`co_uid` = #{uid}
         AND co.co_third_create_time <![CDATA[>]]> #{minTime}
         AND co.`co_third_create_time` <![CDATA[<=]]> DATE_SUB(NOW(), INTERVAL 1 DAY)
    GROUP BY co.`co_order_no`,co.`co_source_type`)A
    <select id="count24HValidOrderByUid" resultType="Long">SELECT
        IFNULL(COUNT(A.co_order_no),0) FROM (SELECT co.`co_order_no` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id
        = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_type` = 1 AND
        co.`co_state_whole_order`<![CDATA[<>]]>
        3 AND co.`co_uid` = #{uid} AND co.co_third_create_time <![CDATA[>]]>
        #{minTime} AND co.`co_third_create_time` <![CDATA[<=]]>
        DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY
        co.`co_order_no`,co.`co_source_type`)A
 </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -52,6 +52,7 @@
import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
@@ -121,6 +122,9 @@
    @Resource
    private UserVIPInfoService userVIPInfoService;
    @Resource
    private UserInfoService userInfoService;
    // 奖励订单图片
    public final static String PIC_REWARD = "http://img.flqapp.com/resource/order/order_state_reward.png";
@@ -203,7 +207,6 @@
        
        return listOrder;
    }
    /**
     * 订单信息加工
@@ -556,14 +559,14 @@
                if (sourceType == null) {
                    couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData);
                } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
                    couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType,
                            listRecordTB, uid, vip, acceptData);
                    couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip,
                            acceptData);
                } else if (sourceType == Constant.SOURCE_TYPE_JD) {
                    couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType,
                            listRecordJD, uid, vip, acceptData);
                    couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip,
                            acceptData);
                } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
                    couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType,
                            listRecordPDD, uid, vip, acceptData);
                    couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip,
                            acceptData);
                }
            }
@@ -576,7 +579,6 @@
        }
    }
    
    /**
     * 订单: 免单标识 奖励标识
     * 
@@ -586,8 +588,8 @@
     * @param list
     * @param signList
     */
    private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon,    Integer hongBaoState,
            Integer hongBaoType, List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception{
    private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType,
            List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception {
        // 是否免单商品
        boolean freeOrder = false;
@@ -804,7 +806,6 @@
        rewardMap.put("jump", jump);
        order.setRewardDetail(rewardMap);
    }
    
    @Override
    public Map<String, BigDecimal> countHistoryOrder(Long uid, Integer day, Integer source) {
@@ -1093,6 +1094,16 @@
        if (oldCommonOrder == null)// 新增
        {
            commonOrder.setCreateTime(new Date());
            // 查询是否为vip
            boolean isVIP = userVIPInfoService.isVIP(commonOrder.getUserInfo().getId());
            if (isVIP)
                commonOrder.setUrank(100);// VIP订单
            else {
                UserInfo user = userInfoService.selectAvailableByPrimaryKey(commonOrder.getUserInfo().getId());
                if (user != null)
                    commonOrder.setUrank(user.getRank());
            }
            commonOrderMapper.insertSelective(commonOrder);
            // 插入映射,保证交易ID的完整性
            commonOrderTradeIdMapMapper.insertSelective(new CommonOrderTradeIdMap(commonOrder.getId(),
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -24,6 +24,8 @@
import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
import com.google.gson.Gson;
import com.opensymphony.xwork2.util.Element;
import com.sun.org.apache.xml.internal.serializer.ElemDesc;
import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
@@ -51,6 +53,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.exception.elme.ElmeOrderException;
import com.yeshi.fanli.exception.money.OrderMoneySettleException;
import com.yeshi.fanli.exception.money.UserMoneyDetailException;
import com.yeshi.fanli.exception.order.CommonOrderException;
@@ -202,6 +205,7 @@
        Iterator<String> its = orders.keySet().iterator();
        Map<String, List<TaoBaoOrder>> fanliOrderMap = new HashMap<>();
        Map<String, List<TaoBaoOrder>> shareOrderMap = new HashMap<>();
        Map<String, List<TaoBaoOrder>> elmeOrderMap = new HashMap<>();
        while (its.hasNext()) {
            String orderId = its.next();
@@ -209,7 +213,12 @@
                List<TaoBaoOrder> list = orders.get(orderId);
                String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
                        list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
                if ("饿了么".equalsIgnoreCase(list.get(0).getOrderType())) {
                    // 处理饿了么订单
                    elmeOrderMap.put(orderId, list);
                }
                else {
                if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId())
                        || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 设置渠道ID当做会员运营ID的位置ID
                    fanliOrderMap.put(orderId, list);
@@ -232,11 +241,52 @@
                }
            }
        }
        }
        // 处理返利订单
        processShopingFanliOrder(fanliOrderMap);
        // 处理分享赚订单
        processShareGoodsOrder(shareOrderMap);
        // 处理饿了么订单
        processElemeOrder(elmeOrderMap);
    }
    private ElmeOrder createElmeOrder(TaoBaoOrder taoBaoOrder) {
        ElmeOrder elmeOrder = new ElmeOrder();
        elmeOrder.setChannelId("");
        elmeOrder.setCreateTime(new Date());
        elmeOrder
                .setOrderDate(new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")));
        elmeOrder.setOrderId(taoBaoOrder.getOrderId());
        elmeOrder.setPayMoney(taoBaoOrder.getPayment());
        elmeOrder.setRid(taoBaoOrder.getRelationId());
        if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单结算"))
            elmeOrder.setIsSettle(true);
        else
            elmeOrder.setIsSettle(false);
        elmeOrder.setTrackPid(
                String.format("mm_124933865_%s_%s", taoBaoOrder.getSourceMediaId(), taoBaoOrder.getAdPositionId()));
        if (!StringUtil.isNullOrEmpty(taoBaoOrder.getRelationId())) {
            UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByRelationId(taoBaoOrder.getRelationId());
            if (extraInfo != null)
                elmeOrder.setUid(extraInfo.getUser().getId());
        }
        return elmeOrder;
    }
    private void processElemeOrder(Map<String, List<TaoBaoOrder>> orders) {
        for (Iterator<String> its = orders.keySet().iterator(); its.hasNext();) {
            String orderId = its.next();
            List<TaoBaoOrder> orderList = orders.get(orderId);
            for (TaoBaoOrder taoBaoOrder : orderList) {
                ElmeOrder elmeOrder = createElmeOrder(taoBaoOrder);
                try {
                    elmeOrderService.addOrder(elmeOrder);
                } catch (ElmeOrderException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/manger/HongBaoV2AddManager.java
@@ -28,7 +28,6 @@
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.exception.order.HongBaoException;
import com.yeshi.fanli.exception.user.UserAccountException;
import com.yeshi.fanli.exception.user.UserInfoException;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
@@ -78,32 +77,6 @@
    @Resource
    private UserVIPInfoService userVIPInfoService;
    // 保存红包
    public void saveHongBao1(CommonOrder commonOrder, int commonOrderType) throws HongBaoException, UserInfoException {
        // 查询上2级的信息
        long uid = commonOrder.getUserInfo().getId();
        UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
        if (user == null)
            throw new UserInfoException(1, "用户不存在");
        UserInfo lastUser = threeSaleSerivce.getBoss(uid);
        UserInfo superLastUser = null;
        if (lastUser != null) {
            lastUser = userInfoService.selectAvailableByPrimaryKey(lastUser.getId());
            if (lastUser != null)
                superLastUser = threeSaleSerivce.getBoss(lastUser.getId());
            if (superLastUser != null)
                superLastUser = userInfoService.selectAvailableByPrimaryKey(superLastUser.getId());
        }
        if (commonOrderType == CommonOrder.ORDER_TYPE_ZIGOU) {
            // 保存红包信息
        } else if (commonOrderType == CommonOrder.ORDER_TYPE_SHARE) {
        }
    }
    /**
     * 添加红包信息
     * 
@@ -123,7 +96,6 @@
            boolean hasAdd = false;
            boolean hasUpdate = false;
            Set<Integer> stateSet = new HashSet<>();// 订单状态Set
            boolean isVIP = userVIPInfoService.isVIP(commonOrderList.get(0).getUserInfo().getId());
            for (CommonOrder commonOrder : commonOrderList) {
                stateSet.add(commonOrder.getState());
                goodsCount += commonOrder.getCount();
@@ -131,7 +103,7 @@
                    throw new HongBaoException(1, "订单信息不完整");
                HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
                if (hongBaoOrder == null) {
                    saveHongBao(commonOrder, type, isVIP, notificationMap);
                    saveHongBao(commonOrder, type, notificationMap);
                    hasAdd = true;
                } else {
                    boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
@@ -458,8 +430,10 @@
    }
    @Transactional(rollbackFor = Exception.class)
    private void saveHongBao(CommonOrder commonOrder, int type, boolean vip, Map<Integer, HongBaoOrder> notificationMap)
    private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
            throws HongBaoException, UserAccountException {
        boolean vip = commonOrder.getUrank() != null && commonOrder.getUrank() == 100;
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService
                    .getRate(new OrderHongBaoRateParams(0, type, false, vip, commonOrder.getThirdCreateTime()));
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeOrderApiUtil.java
@@ -31,7 +31,6 @@
    public static int TK_STATUS_SUCCESS = 14;
    public static int TK_STATUS_INVALID = 13;
    private static TaoBaoPunishOrder parsePunishOrder(JSONObject data) {
        TaoBaoPunishOrder order = new TaoBaoPunishOrder();
        order.setPunishStatus(data.optString("punish_status"));
@@ -209,8 +208,7 @@
        JSONObject data = JSONObject.fromObject(response);
        try {
            JSONObject rootData=data.optJSONObject("tbk_order_details_get_response").optJSONObject("data");
            array =rootData .optJSONObject("results")
                    .optJSONArray("publisher_order_dto");
            array = rootData.optJSONObject("results").optJSONArray("publisher_order_dto");
            dto.setHasPre(    rootData.optBoolean("has_pre"));
            dto.setPositionIndex(rootData.optString("position_index"));
            dto.setHasNext(rootData.optBoolean("has_next"));
@@ -260,11 +258,14 @@
                        taoBaoOrder.setPayment(new BigDecimal(item.optString("alipay_total_price")));
                    else
                        taoBaoOrder.setPayment(new BigDecimal(0));
                    if (StringUtil.isNullOrEmpty(item.optString("item_price")))
                        taoBaoOrder.setPrice(new BigDecimal(0));
                    else
                    taoBaoOrder.setPrice(new BigDecimal(item.optString("item_price")));
                    if (!StringUtil.isNullOrEmpty(item.optString("pay_price")))
                        taoBaoOrder.setSettlement(new BigDecimal(item.optString("pay_price")));
                    else
                        taoBaoOrder.setSettlement(new BigDecimal(0));
                        taoBaoOrder.setSettlement(taoBaoOrder.getPayment());
                    taoBaoOrder.setSettlementTime(item.optString("tk_earning_time"));
                    taoBaoOrder.setShop(item.optString("seller_shop_title"));
                    taoBaoOrder.setSourceMediaId(item.optString("site_id"));
@@ -412,6 +413,14 @@
        return getTaoBaoOrderList(startTime, endTime, queryType, 3);
    }
    /**
     * 淘宝渠道订单
     *
     * @param startTime
     * @param endTime
     * @param queryType
     * @return
     */
    public static List<TaoBaoOrder> getTaoBaoRelationOrderList(long startTime, long endTime, int queryType) {
        return getTaoBaoOrderList(startTime, endTime, queryType, 2);
    }
@@ -419,7 +428,6 @@
    public static List<TaoBaoOrder> getTaoBaoCommonOrderList(long startTime, long endTime, int queryType) {
        return getTaoBaoOrderList(startTime, endTime, queryType, 1);
    }
    
    public static List<TaoBaoOrder> getTaoBaoOrderList(long startTime, long endTime, int queryType,int orderScene) {
        List<TaoBaoOrder> orderList = new ArrayList<>();
@@ -438,10 +446,10 @@
                    TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"),null, queryType, orderScene);
            if (dto != null)
                orderList.addAll(dto.getOrderList());
            while(dto.isHasNext())
            {
            while (dto.isHasNext()) {
                dto=queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"),
                        TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"),dto.getPositionIndex(), queryType, orderScene);
                        TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), dto.getPositionIndex(), queryType,
                        orderScene);
                if (dto != null)
                    orderList.addAll(dto.getOrderList());
            }
@@ -449,8 +457,19 @@
        return orderList;
    }
    
    private static TaoBaoOrderResultDTO queryNewOrder(String startTime, String endTime,String positionIndex, int queryType, int orderScene) {
    /**
     * 淘宝订单查询
     *
     * @param startTime
     * @param endTime
     * @param positionIndex
     * @param queryType
     *            1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询
     * @param orderScene
     * @return
     */
    private static TaoBaoOrderResultDTO queryNewOrder(String startTime, String endTime, String positionIndex,
            int queryType, int orderScene) {
        Map<String, String> params = new HashMap<>();
        params.put("query_type", queryType + "");
        params.put("page_size", "100");