admin
2019-09-06 810c03ebbb309ee9447f7a3e073b914a216930f4
订单监控修改
2个文件已添加
9个文件已修改
4个文件已删除
1179 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/order/CommonOrderAddResultDTO.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 197 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/jd/JDOrderProcessServiceImpl.java 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDOrderProcessServiceImpl.java 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/jd/JDOrderProcessService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/pdd/PDDOrderProcessService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cmq/PlaceOrderCMQManager.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java
@@ -8,7 +8,9 @@
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Resource;
@@ -67,6 +69,7 @@
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
@Controller
@@ -104,16 +107,12 @@
    @Resource
    private InviteMaterialService inviteMaterialService;
    @Resource
    private DynamicInfoDao dynamicInfoDao;
    @Resource
    private JedisPool jedisPool;
    @RequestMapping(value = "testimg")
    public void testImg(HttpServletRequest request, PrintWriter out) {
@@ -478,9 +477,7 @@
            e.printStackTrace();
        }
    }
    /**
     * 插入邀请素材
     * 
@@ -490,42 +487,55 @@
    public void queryExistsAuctionId(PrintWriter out) {
        try {
            List<DynamicInfo> list = dynamicInfoDao.queryExistsAuctionId();
            for (DynamicInfo dynamicInfo: list) {
            for (DynamicInfo dynamicInfo : list) {
                List<GoodsPicture> imgs = dynamicInfo.getImgs();
                if (imgs == null || imgs.size() == 0) {
                    continue;
                }
                boolean update = false;
                for (GoodsPicture goodsPicture: imgs) {
                for (GoodsPicture goodsPicture : imgs) {
                    TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
                    if (goods == null) {
                        continue;
                    }
                    if (goods.getAuctionId() == null) {
                        update = true;
                        goods.setAuctionId(goods.getId());
                    }
                }
                if (update) {
                    dynamicInfo.setImgs(imgs);
                    dynamicInfoDao.updateGoodInfo(dynamicInfo);
                }
            }
            JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("操作成功"));
//            JsonUtil.printMode(out, null, JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(list)));
            // JsonUtil.printMode(out, null,
            // JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(list)));
        } catch (Exception e) {
            JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("操作失败"));
            e.printStackTrace();
        }
    }
    @RequestMapping(value = "getWaitingThreadsCount")
    public void getWaitingThreadsCount(PrintWriter out) {
        out.print(Constant.waitingThreadSet.size());
    }
    @RequestMapping(value = "getBinFaRedisKey")
    public void getPinFaRedisKey(PrintWriter out) {
        JSONArray array = new JSONArray();
        Jedis jedis = jedisPool.getResource();
        try {
            Set<String> sets = jedis.keys("rs-*");
            for (Iterator<String> its = sets.iterator(); its.hasNext();)
                array.add(its.next());
        } finally {
            jedisPool.returnResource(jedis);
        }
        out.println(array.toString());
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -256,17 +256,16 @@
     * @return
     */
    List<CommonOrder> listBySourceTypeAndTradeId(@Param("sourceType") int sourceType, @Param("tradeId") String tradeId);
    /**
     * 根据来源和交易ID获取订单列表
     *
     * @param sourceType
     * @param tradeIdList
     * @return
     */
    List<CommonOrder> listBySourceTypeAndTradeIdList(@Param("sourceType") int sourceType, @Param("tradeIdList") List<String> tradeIdList);
    List<CommonOrder> listBySourceTypeAndTradeIdList(@Param("sourceType") int sourceType,
            @Param("tradeIdList") List<String> tradeIdList);
    /**
     * 
@@ -281,13 +280,24 @@
    List<CommonOrder> listBySourceTypeAndStateAndThirdCrateTime(@Param("sourceType") int sourceType,
            @Param("state") Integer state, @Param("minTime") Long minTime, @Param("maxTime") Long maxTime,
            @Param("start") long start, @Param("count") int count);
    /**
     * 根据订单号查询
     *
     * @param orderNO
     * @return
     */
    List<CommonOrder> getByOrderNo(@Param("uid") Long uid, @Param("orderNo") String orderNo);
    /**
     * 根据用户ID查询
     * @param uid
     * @param stateList
     * @param start
     * @param count
     * @return
     */
    List<CommonOrder> listByUid(@Param("uid")Long uid,@Param("stateList") List<Integer> stateList,@Param("start") long start,@Param("count") int count);
}
fanli/src/main/java/com/yeshi/fanli/dto/order/CommonOrderAddResultDTO.java
New file
@@ -0,0 +1,38 @@
package com.yeshi.fanli.dto.order;
import com.yeshi.fanli.entity.order.CommonOrder;
public class CommonOrderAddResultDTO {
    public final static int TYPE_ADD = 1;
    public final static int TYPE_UPDATE = 2;
    public final static int TYPE_NOUPDATE = 3;
    private CommonOrder commonOrder;
    private int type;
    public CommonOrderAddResultDTO() {
    }
    public CommonOrderAddResultDTO(CommonOrder commonOrder, int type) {
        this.commonOrder = commonOrder;
        this.type = type;
    }
    public CommonOrder getCommonOrder() {
        return commonOrder;
    }
    public void setCommonOrder(CommonOrder commonOrder) {
        this.commonOrder = commonOrder;
    }
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -99,7 +99,7 @@
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <association property="userInfo" column="co_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
@@ -107,8 +107,8 @@
            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" />
@@ -145,14 +145,14 @@
        <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" />
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
         <association property="userInfo" column="co_uid"
           select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey"/>
         <association property="commonOrderGoods" column="co_order_goods_id"
           select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey"/>
        <association property="userInfo" column="co_uid"
            select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" />
        <association property="commonOrderGoods" column="co_order_goods_id"
            select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey" />
    </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
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
@@ -183,48 +183,54 @@
    <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
        co_trade_id=#{tradeId} limit 1
    </select>
    <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 *
    <select id="listBySourceTypeAndTradeIdList" resultMap="BaseResultMap">
        SELECT *
        FROM
        yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType}
        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 ">
            <foreach collection="tradeIdList" item="tradeId" open=" and ("
                close=")" separator=" or ">
                co.co_trade_id=#{tradeId}
            </foreach>
        </if>
    </select>
    <select id="listBySourceTypeAndStateAndThirdCrateTime" resultMap="BaseResultMap">SELECT *
    <select id="listBySourceTypeAndStateAndThirdCrateTime"
        resultMap="BaseResultMap">
        SELECT *
        FROM
        yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType}
        yeshi_ec_common_order co WHERE
        co.co_source_type=#{sourceType}
        <if test="state!=null">
            and co_state=#{state}
        </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
            and #{maxTime}> UNIX_TIMESTAMP(co_third_create_time)*1000
        </if>
        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}
@@ -413,7 +419,7 @@
        MAX(co_settle_time) AS co_settle_time, co_order_by, co_create_time,
        co_update_time
    </sql>
    <select id="listUserOrder" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS
@@ -437,11 +443,11 @@
        <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
@@ -462,7 +468,7 @@
        <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"
@@ -480,8 +486,8 @@
        </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
@@ -515,11 +521,11 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX
        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 *
@@ -527,7 +533,7 @@
        = 20 ) 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  and hb.hb_state!=4
        WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
@@ -548,11 +554,11 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ
        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 *
@@ -560,7 +566,8 @@
        (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
        v2.`hb_type` = 21 OR v2.`hb_type` = 22 ) ) hbp ON
        hbp.hb_pid=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE hbp.hb_id IS NOT NULL  and hbp.hb_state!=4
        co.`co_id`=ho.`ho_order_id` WHERE hbp.hb_id IS NOT NULL and
        hbp.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
@@ -581,11 +588,11 @@
        </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>
    <select id="countByUidAndOrderState" resultType="java.util.HashMap">
        SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS
        totalProces,SUM(A.Invalid)AS totalInvite FROM (
@@ -598,13 +605,13 @@
        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
        <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 *
@@ -614,12 +621,12 @@
        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
        <!-- 订单来源 -->
        <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 *
@@ -629,8 +636,8 @@
        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>
        <!-- 订单来源 -->
        <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">
@@ -679,7 +686,7 @@
        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="source != null">AND co.co_source_type = #{source}</if>
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <sql id="SELECT_HONGBAO_STATE">
@@ -750,14 +757,15 @@
        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`
        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" />
        <!-- 订单状态 -->
@@ -774,21 +782,23 @@
        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`
        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" />
        <!-- 订单状态 -->
@@ -805,8 +815,8 @@
        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
@@ -815,8 +825,8 @@
        <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`
         WHERE hb.hb_id IS NOT NULL
        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}]]>
@@ -830,8 +840,8 @@
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</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
@@ -840,8 +850,9 @@
        <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
        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}]]>
@@ -855,10 +866,10 @@
        <!-- 订单来源 -->
        <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,
@@ -884,16 +895,34 @@
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        )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_order_no = #{orderNo} AND  co.`co_source_type` = #{sourceType}
        WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo} AND
        co.`co_source_type` = #{sourceType}
        <if test="orderState != null">
            AND co.co_state = #{orderState}
            <!-- 已收货 -->
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type`
    </select>
    <select id="getByOrderNo" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co
        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}
        <if test="stateList!=null">
            <foreach collection="stateList" separator=" or " open="and ("
                item="state" close=")">
                co_state=#{state}
            </foreach>
        </if>
        limit #{start},#{count}
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/jd/JDOrderProcessServiceImpl.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -20,6 +20,7 @@
import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderTradeIdMapMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
@@ -728,8 +729,9 @@
    @Transactional
    @Override
    public List<CommonOrder> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid) throws CommonOrderException {
        List<CommonOrder> commonOrderList = new ArrayList<>();
    public List<CommonOrderAddResultDTO> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid)
            throws CommonOrderException {
        List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
        // 判断所有的订单状态
        int invalidCount = 0;
        for (TaoBaoOrder tb : taoBaoOrders) {
@@ -789,8 +791,9 @@
    @Transactional
    @Override
    public List<CommonOrder> addPDDOrder(List<PDDOrder> pddOrderList, Long uid) throws CommonOrderException {
        List<CommonOrder> commonOrderList = new ArrayList<>();
    public List<CommonOrderAddResultDTO> addPDDOrder(List<PDDOrder> pddOrderList, Long uid)
            throws CommonOrderException {
        List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
        // 判断所有的订单状态
        int invalidCount = 0;
        for (PDDOrder order : pddOrderList) {
@@ -838,8 +841,8 @@
    @Transactional
    @Override
    public List<CommonOrder> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException {
        List<CommonOrder> commonOrderList = new ArrayList<>();
    public List<CommonOrderAddResultDTO> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException {
        List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
        // 判断所有的订单状态
        int invalidCount = 0;
        for (JDOrderItem tb : jdOrder.getOrderItemList()) {
@@ -907,7 +910,7 @@
     * @param commonOrder
     */
    @Transactional
    private CommonOrder addCommonOrder(CommonOrder commonOrder) throws CommonOrderException {
    private CommonOrderAddResultDTO addCommonOrder(CommonOrder commonOrder) throws CommonOrderException {
        // 判断商品是否存在
        if (commonOrder == null)
            throw new CommonOrderException(1, "订单为空");
@@ -950,13 +953,13 @@
            // 插入映射,保证交易ID的完整性
            commonOrderTradeIdMapMapper.insertSelective(new CommonOrderTradeIdMap(commonOrder.getId(),
                    commonOrder.getTradeId(), new Date(), commonOrder.getSourceType()));
            return commonOrder;
            return new CommonOrderAddResultDTO(commonOrder, CommonOrderAddResultDTO.TYPE_ADD);
        } else {// 修改
            // 已经结算,已经失效,状态未改变的订单不处理
            if (oldCommonOrder.getState() == CommonOrder.STATE_JS || oldCommonOrder.getState() == CommonOrder.STATE_SX
                    || oldCommonOrder.getState() == CommonOrder.STATE_WQ
                    || (oldCommonOrder.getState().intValue() == commonOrder.getState())) {
                return oldCommonOrder;
                return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE);
            }
            // 交易ID一致才修改
            if (commonOrder.getTradeId() != null
@@ -972,9 +975,10 @@
                updateCommonOrder.setUpdateTime(new Date());
                updateCommonOrder.setTradeId(commonOrder.getTradeId());
                commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder);
                return commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId());
                return new CommonOrderAddResultDTO(commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId()),
                        CommonOrderAddResultDTO.TYPE_UPDATE);
            } else
                return oldCommonOrder;
                return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE);
        }
    }
@@ -1451,4 +1455,15 @@
        return commonOrderMapper.getByOrderNo(uid, orderNO);
    }
    @Override
    public CommonOrder selectLatestValidByUid(Long uid) {
        List<Integer> stateList = new ArrayList<>();
        stateList.add(CommonOrder.STATE_FK);
        stateList.add(CommonOrder.STATE_JS);
        List<CommonOrder> commonOrderList = commonOrderMapper.listByUid(uid, stateList, 0, 1);
        if (commonOrderList == null || commonOrderList.size() == 0)
            return null;
        return commonOrderList.get(0);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -26,6 +26,7 @@
import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.HongBao;
import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -49,10 +50,12 @@
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.jd.JDOrderService;
import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.service.inter.order.OrderProcessService;
import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
@@ -67,6 +70,7 @@
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
@@ -125,6 +129,43 @@
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private JDOrderService jdOrderService;
    @Resource
    private PDDOrderService pddOrderService;
    /**
     * 是否是分享订单
     *
     * @param order
     * @return
     */
    private boolean isShareOrder(TaoBaoOrder order) {
        List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
        String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(), order.getSourceMediaId(),
                order.getAdPositionId());
        if (!StringUtil.isNullOrEmpty(order.getSpecialId())
                || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 设置渠道ID当做会员运营ID的位置ID
            return false;
        } else if (!StringUtil.isNullOrEmpty(order.getRelationId())) {
            return true;
        } else {
            // 通过红包查询
            CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
                    order.getTradeId());
            if (commonOrder != null) {
                HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
                if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
                        && hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
                    return true;
                }
            }
            return false;
        }
    }
    @Override
    public synchronized void processOrder(Map<String, List<TaoBaoOrder>> orders) {
@@ -947,11 +988,21 @@
            orderMapper.updateByPrimaryKeySelective(updateOrder);
            // 用第一个子订单锁定用户
            List<CommonOrder> commonOrderList = null;
            List<CommonOrderAddResultDTO> commonOrderList = null;
            try {
                commonOrderList = commonOrderService.addTaoBaoOrder(orderList, uid);
                hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
                hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
                if (isCommonOrderAllAdd(commonOrderList)) {
                    Order order = new Order();
                    order.setOrderId(orderId);
                    order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
                    order.setUserInfo(new UserInfo(uid));
                    try {
                        PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                    } catch (Exception e) {
                    }
                }
            } catch (CommonOrderException e) {
                try {
                    LogHelper.errorDetailInfo(e, "addTaoBaoOrder或addHongBao出错", "订单号:" + orderId);
@@ -999,14 +1050,40 @@
            // 用第一个子订单锁定用户
            try {
                List<CommonOrder> commonOrders = commonOrderService.addTaoBaoOrder(orderList, uid);
                hongBaoV2Service.addHongBao(commonOrders, HongBaoV2.TYPE_SHARE_GOODS);
                List<CommonOrderAddResultDTO> commonOrders = commonOrderService.addTaoBaoOrder(orderList, uid);
                hongBaoV2Service.addHongBao(convertCommonOrder(commonOrders), HongBaoV2.TYPE_SHARE_GOODS);
                if (isCommonOrderAllAdd(commonOrders)) {
                    Order order = new Order();
                    order.setOrderId(orderId);
                    order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
                    order.setUserInfo(new UserInfo(uid));
                    try {
                        PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                    } catch (Exception e) {
                    }
                }
            } catch (CommonOrderException e) {
                e.printStackTrace();
            } catch (HongBaoException e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 是否为分享订单
     *
     * @param order
     * @return
     */
    private boolean isShareOrder(JDOrder order) {
        if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
            return false;
        Long positionId = order.getOrderItemList().get(0).getPositionId();
        if (positionId == JDApiUtil.POSITION_SHARE) {// 分享订单
            return true;
        }
        return false;
    }
    @Override
@@ -1092,8 +1169,18 @@
        }
        try {
            List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
            hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
            List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
            hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
            if (isCommonOrderAllAdd(commonOrderList)) {
                Order order = new Order();
                order.setOrderId(jdOrder.getOrderId() + "");
                order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
                order.setUserInfo(new UserInfo(uid));
                try {
                    PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                } catch (Exception e) {
                }
            }
        } catch (CommonOrderException e) {
            try {
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
@@ -1116,23 +1203,47 @@
     * @param uid
     */
    @Transactional
    private void processShareJDOrder(JDOrder order, Long uid) {
    private void processShareJDOrder(JDOrder jdOrder, Long uid) {
        try {
            List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(order, uid);
            hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
            List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
            hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
            if (isCommonOrderAllAdd(commonOrderList)) {
                Order order = new Order();
                order.setOrderId(jdOrder.getOrderId() + "");
                order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
                order.setUserInfo(new UserInfo(uid));
                try {
                    PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                } catch (Exception e) {
                }
            }
        } catch (CommonOrderException e) {
            try {
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } catch (HongBaoException e) {
            try {
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 是否是分享赚订单
     *
     * @param order
     * @return
     */
    private boolean isShareOrder(PDDOrder pddOrder) {
        String positionId = pddOrder.getpId();
        if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId))
            return true;
        else
            return false;
    }
    /**
@@ -1208,8 +1319,18 @@
        try {
            List<PDDOrder> pddOrderList = new ArrayList<>();
            pddOrderList.add(pddOrder);
            List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
            hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
            List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
            hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
            if (isCommonOrderAllAdd(commonOrderList)) {
                Order order = new Order();
                order.setOrderId(pddOrder.getOrderSn());
                order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
                order.setUserInfo(new UserInfo(uid));
                try {
                    PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                } catch (Exception e) {
                }
            }
        } catch (CommonOrderException e) {
            try {
                LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
@@ -1232,21 +1353,31 @@
     * @param uid
     */
    @Transactional
    private void processSharePDDOrder(PDDOrder order, Long uid) {
    private void processSharePDDOrder(PDDOrder pddOrder, Long uid) {
        try {
            List<PDDOrder> pddOrderList = new ArrayList<>();
            pddOrderList.add(order);
            List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
            hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
            pddOrderList.add(pddOrder);
            List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
            hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
            if (isCommonOrderAllAdd(commonOrderList)) {
                Order order = new Order();
                order.setOrderId(pddOrder.getOrderSn());
                order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
                order.setUserInfo(new UserInfo(uid));
                try {
                    PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                } catch (Exception e) {
                }
            }
        } catch (CommonOrderException e) {
            try {
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderId());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } catch (HongBaoException e) {
            try {
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
                LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderId());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
@@ -1272,4 +1403,53 @@
            }
    }
    @Override
    public boolean isShareOrder(CommonOrder commonOrder) {
        switch (commonOrder.getSourceType()) {
        case Constant.SOURCE_TYPE_TAOBAO:
            return isShareOrder(taoBaoOrderService.selectByTradeId(commonOrder.getTradeId()));
        case Constant.SOURCE_TYPE_JD:
            return isShareOrder(jdOrderService.selectDetailByOrderId(Long.parseLong(commonOrder.getOrderNo())));
        case Constant.SOURCE_TYPE_PDD:
            return isShareOrder(pddOrderService.selectByOrderSn(commonOrder.getOrderNo()).get(0));
        }
        return false;
    }
    /**
     * 转为普通订单
     *
     * @param dtoList
     * @return
     */
    private List<CommonOrder> convertCommonOrder(List<CommonOrderAddResultDTO> dtoList) {
        List<CommonOrder> commonOrderList = new ArrayList<>();
        if (dtoList != null)
            for (CommonOrderAddResultDTO dto : dtoList)
                commonOrderList.add(dto.getCommonOrder());
        return commonOrderList;
    }
    /**
     * 是否全是增加
     *
     * @param list
     * @return
     */
    private boolean isCommonOrderAllAdd(List<CommonOrderAddResultDTO> list) {
        if (list == null || list.size() == 0)
            return false;
        int addCount = 0;
        if (list != null)
            for (CommonOrderAddResultDTO dto : list) {
                if (dto.getType() == CommonOrderAddResultDTO.TYPE_ADD)
                    addCount++;
            }
        if (addCount == list.size())
            return true;
        else
            return false;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDOrderProcessServiceImpl.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/service/inter/jd/JDOrderProcessService.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java
@@ -5,6 +5,7 @@
import java.util.List;
import java.util.Map;
import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.jd.JDOrder;
import com.yeshi.fanli.entity.order.CommonOrder;
@@ -76,8 +77,9 @@
     *            到账状态
     * @return
     */
    public List<CommonOrderVO> getOrderByUid(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type, Integer orderState,
            String orderNo, String startTime, String endTime, Integer dateType, Integer source) throws CommonOrderException;
    public List<CommonOrderVO> getOrderByUid(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
            Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, Integer source)
            throws CommonOrderException;
    /**
     * 统计订单-根据红包类型 自购 邀请 分享
@@ -93,7 +95,8 @@
     * @param uid
     * @return
     */
    public long countBonusOrderNumber(Long uid, Integer type, Integer isToday, String startTime, String endTime, Integer source);
    public long countBonusOrderNumber(Long uid, Integer type, Integer isToday, String startTime, String endTime,
            Integer source);
    /**
     * 统计订单
@@ -101,7 +104,8 @@
     * @param uid
     * @return
     */
    public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer isToday, String startTime, String endTime, Integer source);
    public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer isToday, String startTime, String endTime,
            Integer source);
    /**
     * 统计奖金订单数量、金额
@@ -145,7 +149,7 @@
     * @return
     * @throws CommonOrderException
     */
    public List<CommonOrder> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrder, Long uid) throws CommonOrderException;
    public List<CommonOrderAddResultDTO> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrder, Long uid) throws CommonOrderException;
    /**
     * 缓存拼多多类普通订单
@@ -155,7 +159,7 @@
     * @return
     * @throws CommonOrderException
     */
    public List<CommonOrder> addPDDOrder(List<PDDOrder> pddOrderList, Long uid) throws CommonOrderException;
    public List<CommonOrderAddResultDTO> addPDDOrder(List<PDDOrder> pddOrderList, Long uid) throws CommonOrderException;
    /**
     * 缓存京东普通订单
@@ -165,7 +169,7 @@
     * @return
     * @throws CommonOrderException
     */
    public List<CommonOrder> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException;
    public List<CommonOrderAddResultDTO> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException;
    /**
     * 根据用户ID,订单状态,结算时间统计订单数量
@@ -219,10 +223,12 @@
     */
    public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
            Integer type, Integer orderState, String startTime, String endTime, Integer source) throws CommonOrderException;
            Integer type, Integer orderState, String startTime, String endTime, Integer source)
            throws CommonOrderException;
    public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
            String startTime, String endTime, Integer source) throws CommonOrderException;
    /**
     * 查询订单
     * 
@@ -282,11 +288,20 @@
            Long maxTime, int page, int pageSize);
    /**
     * 查询订单  -根据订单号
     * 查询订单 -根据订单号
     *
     * @param uid
     * @param orderNO
     * @return
     */
    public List<CommonOrder> getByOrderNo(Long uid, String orderNO);
    /**
     * 根据用户ID查询最近一条有效的订单
     *
     * @param uid
     * @return
     */
    public CommonOrder selectLatestValidByUid(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java
@@ -5,6 +5,7 @@
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.jd.JDOrder;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.pdd.PDDOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
@@ -97,15 +98,24 @@
    /**
     * 处理拼多多订单
     *
     * @param pddOrder
     */
    public void processPDDOrder(PDDOrder pddOrder);
    /**
     * 根据淘宝订单的排序值修复常规订单的排序值
     *
     * @param orderId
     */
    public void repairCommonOrderByByTaoBaoOrder(String orderId);
    /**
     * 是否是分享赚订单
     *
     * @param commonOrder
     * @return
     */
    public boolean isShareOrder(CommonOrder commonOrder);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/pdd/PDDOrderProcessService.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -20,8 +20,12 @@
import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.jd.JDOrder;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.pdd.PDDOrder;
import com.yeshi.fanli.entity.push.PushQueueRecord;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -36,6 +40,8 @@
import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
import com.yeshi.fanli.service.inter.lable.LabelService;
import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.OrderProcessService;
import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
import com.yeshi.fanli.service.inter.push.IOSPushService;
@@ -47,6 +53,7 @@
import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
import com.yeshi.fanli.util.cmq.PDDOrderCMQManager;
import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@@ -111,6 +118,12 @@
    @Resource
    private IntegralGetService integralGetService;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private HongBaoOrderService hongBaoOrderService;
    private static boolean isInited = false;
    public void onApplicationEvent(ContextRefreshedEvent arg0) {
@@ -146,6 +159,7 @@
            doPDDOrderJob();// 拼多多订单处理
            doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
            doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加
            doPlaceOrderIntegralJob();// 下单赠送金币任务
        }
    }
@@ -743,7 +757,121 @@
                }
            }
        });
    }
    private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) {
        CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
        if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId)
                && sourceType == commonOrder.getSourceType())
            return true;
        else
            return false;
    }
    // 下单获取金币任务
    public void doPlaceOrderIntegralJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Map<String, Order> map = PlaceOrderCMQManager.getInstance()
                            .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16);
                    if (map != null) {
                        // 是否是首单
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
                            String key = its.next();
                            Order order = map.get(key);
                            // 统计订单下的用户所获得的返利金额
                            List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId(order.getOrderType(),
                                    order.getOrderId());
                            Map<Long, BigDecimal> hongBaoMoney = new HashMap<>();
                            if (list != null)
                                for (CommonOrder commonOrder : list) {
                                    HongBaoOrder hongBaoOrder = hongBaoOrderService
                                            .selectDetailByCommonOrderId(commonOrder.getId());
                                    if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
                                        Long mainUid = hongBaoOrder.getHongBaoV2().getUserInfo().getId();
                                        if (hongBaoMoney.get(mainUid) == null)
                                            hongBaoMoney.put(mainUid, new BigDecimal(0));
                                        hongBaoMoney.put(mainUid,
                                                hongBaoMoney.get(mainUid).add(hongBaoOrder.getHongBaoV2().getMoney()));
                                        // 查询上级
                                        List<HongBaoV2> children = hongBaoV2Service
                                                .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
                                        if (children != null) {
                                            for (HongBaoV2 hongBao : children) {
                                                Long uid = hongBao.getUserInfo().getId();
                                                if (hongBaoMoney.get(uid) == null)
                                                    hongBaoMoney.put(uid, new BigDecimal(0));
                                                hongBaoMoney.put(uid, hongBaoMoney.get(uid).add(hongBao.getMoney()));
                                            }
                                        }
                                    }
                                }
                            if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                    order.getUserInfo().getId())) {// 有效的首单
                                if (hongBaoMoney.get(order.getUserInfo().getId()) == null || hongBaoMoney
                                        .get(order.getUserInfo().getId()).compareTo(new BigDecimal("0")) <= 0) {
                                    // TODO 分享奖金是0
                                }
                                // 获取上两级数据
                                UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                if (boss != null) {// 判断上级的红包
                                    if (hongBaoMoney.get(boss.getId()) == null
                                            || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                        // TODO 补偿资金
                                    }
                                }
                            } else {// 自购订单
                                UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                if (boss != null) {// 判断上级的红包
                                    if (hongBaoMoney.get(boss.getId()) == null
                                            || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                        // TODO 补偿资金1级
                                    }
                                }
                                boss = threeSaleSerivce.getBoss(boss.getId());
                                if (boss != null) {// 判断上级的红包
                                    if (hongBaoMoney.get(boss.getId()) == null
                                            || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                        // TODO 补偿资金2级
                                    }
                                }
                            }
                        }
                    }
                }
            }
        });
    }
    // 抖音广告监控
    public void doPlaceOrderAdJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Map<String, Order> map = PlaceOrderCMQManager.getInstance()
                            .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_AD, 16);
                    if (map != null) {
                        // 是否是首单
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
                            String key = its.next();
                            Order order = map.get(key);
                            if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                    order.getUserInfo().getId())) {// 有效的首单
                                // TODO 抖音的数据回调
                            }
                        }
                    }
                }
            }
        });
    }
}
fanli/src/main/java/com/yeshi/fanli/util/cmq/PlaceOrderCMQManager.java
New file
@@ -0,0 +1,92 @@
package com.yeshi.fanli.util.cmq;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.yeshi.utils.CMQUtil;
import com.google.gson.Gson;
import com.qcloud.cmq.Message;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.order.CommonOrder;
public class PlaceOrderCMQManager {
    private static String secretId = "AKIDTlpgJhLjOozvd6QI2XnpfGbgV4NQJk25";
    private static String secretKey = "xhCSUHo55oHUQ6XicFcmfIgspX0EEzWo";
    private static PlaceOrderCMQManager placeOrderCMQManager;
    private static CMQUtil cmqUtil;
    private final static String TOPIC_NAME = "topic_place_order";
    public static String QUEUE_AD = TOPIC_NAME + "_" + "ad";
    public static String QUEUE_INTEGRAL = TOPIC_NAME + "_" + "integral";
    public static String SUBSCRIBE_AD = "ad";
    public static String SUBSCRIBE_INTEGRAL = "integral";
    static {
        cmqUtil = CMQUtil.getInstance(secretId, secretKey);
        // 创建主题,添加订阅
        cmqUtil.createTopic(TOPIC_NAME);
        // 用户券订阅
        String[] subscripts = new String[] { SUBSCRIBE_AD, SUBSCRIBE_INTEGRAL };
        String[] queues = new String[] { QUEUE_AD, QUEUE_INTEGRAL };
        for (int i = 0; i < subscripts.length; i++) {
            String queueName = queues[i];
            try {
                cmqUtil.createQueue(queueName);
            } catch (Exception e) {
            }
            try {
                cmqUtil.subscribeTopic(TOPIC_NAME, subscripts[i], queueName);
            } catch (Exception e) {
            }
        }
    }
    public static PlaceOrderCMQManager getInstance() {
        if (placeOrderCMQManager == null)
            placeOrderCMQManager = new PlaceOrderCMQManager();
        return placeOrderCMQManager;
    }
    /**
     * 下单
     *
     * @param order(只需要订单号与sourceType)
     */
    public void addPlaceOrderMsg(Order order) {
        if (order == null)
            return;
        cmqUtil.publishTopicMessage(TOPIC_NAME, new Gson().toJson(order));
    }
    /**
     * 消费队列消息
     *
     * @param queueName
     * @param count
     * @return
     */
    public Map<String, Order> consumeQueueMsg(String queueName, int count) {
        List<Message> list = cmqUtil.recieveMsg(count, queueName);
        Map<String, Order> map = new HashMap<>();
        if (list != null)
            for (Message msg : list) {
                String result = msg.msgBody;
                Order dto = new Gson().fromJson(result, Order.class);
                map.put(msg.receiptHandle, dto);
            }
        return map;
    }
    public void deleteQueueMsg(String queueName, String receiptHandle) {
        cmqUtil.deleteMsg(queueName, receiptHandle);
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java
@@ -160,7 +160,7 @@
        goodsInfo.setMoneyInfo(moneyInfoVO);
        // 券信息
        if (goods.getCouponAmount().compareTo(BigDecimal.valueOf(0)) > 0) {
        if (goods.getCouponAmount()!=null&&goods.getCouponAmount().compareTo(BigDecimal.valueOf(0)) > 0) {
            // 计算券后价
            BigDecimal sub = goods.getPrice().subtract(goods.getCouponStartPrice());
            if (sub.compareTo(BigDecimal.valueOf(0)) >= 0) {