admin
2020-04-30 9b94a83132a60a0c7dba86063ba073aa18bda58b
订单增加子来源类型,线上用户等级同步优化
4个文件已修改
161 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/entity/order/CommonOrder.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 139 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/CommonOrderFactory.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/SyncBeforeInfoMessageListener.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/order/CommonOrder.java
@@ -124,6 +124,17 @@
    @Column(name = "co_urank")
    private Integer urank;// 用户等级 100-为超级会员
    @Column(name = "co_child_source_type")
    private String childSourceType;// 子来源类型
    public String getChildSourceType() {
        return childSourceType;
    }
    public void setChildSourceType(String childSourceType) {
        this.childSourceType = childSourceType;
    }
    public Integer getUrank() {
        return urank;
    }
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -25,6 +25,8 @@
        <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" />
        <result column="co_child_source_type" property="childSourceType"
            jdbcType="VARCHAR" />
        <association property="userInfo" column="co_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT" />
@@ -58,6 +60,8 @@
        <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" />
        <result column="co_child_source_type" property="childSourceType"
            jdbcType="VARCHAR" />
        <association property="userInfo" column="co_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT" />
@@ -157,7 +161,7 @@
        <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,co_urank
    <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,co_child_source_type
    </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,
@@ -221,9 +225,9 @@
    </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_urank)
        (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,co_child_source_type)
        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},#{urank,jdbcType=INTEGER})
        (#{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},#{childSourceType,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder"
        useGeneratedKeys="true" keyProperty="id">
@@ -250,6 +254,7 @@
            <if test="tradeId != null">co_trade_id,</if>
            <if test="stateDesc != null">co_state_desc,</if>
            <if test="urank != null">co_urank,</if>
            <if test="childSourceType != null">co_child_source_type,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -273,7 +278,8 @@
            <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="urank != null">#{urank,jdbcType=INTEGER}</if>
            <if test="urank != null">#{urank,jdbcType=INTEGER},</if>
            <if test="childSourceType != null">#{childSourceType,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update
@@ -297,7 +303,8 @@
        #{updateTime,jdbcType=TIMESTAMP} ,co_trade_id
        =#{tradeId,jdbcType=VARCHAR},co_state_desc
        =#{stateDesc,jdbcType=VARCHAR} ,co_urank =#{urank,jdbcType=INTEGER}
        where co_id = #{id,jdbcType=BIGINT}
        ,co_child_source_type =#{childSourceType,jdbcType=VARCHAR} where co_id
        = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder">
        update yeshi_ec_common_order
@@ -323,10 +330,11 @@
            <if test="orderBy != null">co_order_by=#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">co_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">co_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <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>
            <if test="childSourceType !=null">co_child_source_type=#{childSourceType,jdbcType=VARCHAR},
            </if>
        </set>
        where co_id = #{id,jdbcType=BIGINT}
    </update>
@@ -452,10 +460,9 @@
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() > 0">
            <foreach collection="listSource" item="item" open="AND (" close=")" separator="or">
                co.co_source_type = #{item}
            </foreach>
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
@@ -489,10 +496,9 @@
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() > 0">
            <foreach collection="listSource" item="item" open="AND (" close=")" separator="or">
                co.co_source_type = #{item}
            </foreach>
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
@@ -626,10 +632,9 @@
            '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() > 0">
            <foreach collection="listSource" item="item" open="AND (" close=")" separator="or">
                co.co_source_type = #{item}
            </foreach>
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
    </sql>
    <select id="getOrderCount" resultMap="OrderCountMap">
@@ -810,11 +815,10 @@
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单时间 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <if test="payment != null">
            AND co.co_payment <![CDATA[<]]> #{payment}
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countQueryByUid" resultType="java.lang.Long">
@@ -913,8 +917,9 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="payment != null">
            AND co.co_payment <![CDATA[<]]> #{payment}
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </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
@@ -952,8 +957,9 @@
            <foreach collection="listShopId" item="shopId" open=" and ("
                separator=" or " close=")">g.`cog_shop_id` =#{shopId}</foreach>
        </if>
        <if test="payment != null">
            AND co.co_payment <![CDATA[<]]> #{payment}
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        <if test="minTime != null">
            <!-- 高风险订单 -->
@@ -979,8 +985,9 @@
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <if test="payment != null">
            AND co.co_payment <![CDATA[<]]> #{payment}
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
@@ -1086,46 +1093,42 @@
        DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY
        co.`co_order_no`,co.`co_source_type`)A
    </select>
    <select id="searchOrderByUid" 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 <include refid="Hongbao_Column_List" /> 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
        <foreach collection="list" item="esOrder" open=" and ("    close=")" separator=" or ">
            (co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type = #{esOrder.platform})
        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
        <include refid="Hongbao_Column_List" />
        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
        <foreach collection="list" item="esOrder" open=" and (" close=")"
            separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type =
            #{esOrder.platform})
        </foreach>
        GROUP BY co.`co_order_no`, co.`co_source_type`
        ORDER BY co.co_third_create_time DESC
        LIMIT ${start},${count}
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countSearchOrderByUid" 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 ]]>
        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 ]]>
        )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
        <foreach collection="list" item="esOrder" open=" and ("    close=")" separator=" or ">
            (co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type = #{esOrder.platform})
        <foreach collection="list" item="esOrder" open=" and (" close=")"
            separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type =
            #{esOrder.platform})
        </foreach>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="getMinSettleTimeAndUid" resultMap="BaseResultMap">
        SELECT d.`co_uid`,MAX(d.`co_settle_time`) AS  co_settle_time FROM `yeshi_ec_common_order` d
        WHERE d.`co_settle_time` IS NOT NULL AND d.`co_payment` > 1
        GROUP BY d.`co_uid`
    </select>
    <select id="getMinSettleTimeAndUid" resultMap="BaseResultMap">SELECT
        d.`co_uid`,MAX(d.`co_settle_time`) AS co_settle_time FROM
        `yeshi_ec_common_order` d WHERE d.`co_settle_time` IS NOT NULL AND
        d.`co_payment` &gt; 1 GROUP BY d.`co_uid`</select>
    <select id="getOrderList" resultMap="ResultMap">
        SELECT hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
@@ -1156,10 +1159,9 @@
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() > 0">
            <foreach collection="listSource" item="item" open="AND (" close=")" separator="or">
                co.co_source_type = #{item}
            </foreach>
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
@@ -1192,16 +1194,15 @@
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() > 0">
            <foreach collection="listSource" item="item" open="AND (" close=")" separator="or">
                co.co_source_type = #{item}
            </foreach>
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="countOrderByUidAndSettled" resultType="Long">
        SELECT COUNT(d.`co_id`) FROM `yeshi_ec_common_order` d
        WHERE d.`co_uid` = #{uid} AND d.`co_settle_time` IS NOT NULL  AND d.`co_payment` >= #{payment}
    <select id="countOrderByUidAndSettled" resultType="Long">SELECT
        COUNT(d.`co_id`) FROM `yeshi_ec_common_order` d WHERE d.`co_uid` =
        #{uid} AND d.`co_settle_time` IS NOT NULL AND d.`co_payment` &gt;=
        #{payment}
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/CommonOrderFactory.java
@@ -160,6 +160,7 @@
                new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")));
        commonOrder.setUpdateTime(new Date());
        commonOrder.setTradeId(taoBaoOrder.getTradeId());
        commonOrder.setChildSourceType(taoBaoOrder.getOrderType());
        return commonOrder;
    }
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/SyncBeforeInfoMessageListener.java
@@ -31,6 +31,7 @@
import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
@@ -82,7 +83,6 @@
                // 老用户同步绑定信息
                userInfoModifyRecordService.syncBeforeInfo(uid);
                // 低版本全部升级普通会员
@@ -160,6 +160,14 @@
                                    }
                                }
                            }
                        } else {//之前老版本处理为普通会员的用户升级新版本
                            if (vipInfo.getProcess() == UserVIPPreInfo.PROCESS_1
                                    && vipInfo.getCreateTime().getTime() < TimeUtil
                                            .convertToTimeTemp("2020-04-30 14:10:00", "yyyy-MM-dd HH:mm:ss")) {
                                // 计算等级
                                userVIPPreInfoService.upgradeVipByMyOrder(uid);
                                userVIPPreInfoService.upgradeVipByTeamNum(uid);
                            }
                        }
                    }
                }