| | |
| | | package com.yeshi.fanli.dao.mybatis.order.dividents; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsRecord; |
| | | |
| | |
| | | * TeamDividentsRecord 返回类型 |
| | | * @throws |
| | | */ |
| | | TeamDividentsRecord selectByUidAndDayForUpdate(Long uid, String day); |
| | | TeamDividentsRecord selectByUidAndDayForUpdate(@Param("uid") Long uid, @Param("day")String day); |
| | | |
| | | } |
| | |
| | | * TeamDividentsSourceOrder 返回类型 |
| | | * @throws |
| | | */ |
| | | TeamDividentsSourceOrder selectByOrderNoSourceType(@Param("orderNo") String orderNo, |
| | | TeamDividentsSourceOrder selectByOrderNoAndSourceType(@Param("orderNo") String orderNo, |
| | | @Param("sourceType") int sourceType); |
| | | |
| | | } |
| | |
| | | import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.InterTokenMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.ThreeSaleSeparateMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserForbiddenMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserRedPackGiftMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserRegisterMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserSystemCouponUseMQMsg;
|
| | |
| | | redPackGiftDrawback(UserRedPackGiftMQMsg.class), // 红包赠送退回
|
| | | inviteCodeActive(InviteCodeActiveMQMsg.class), // 邀请码激活
|
| | | forbiddenUser(UserForbiddenMQMsg.class), // 封禁用户
|
| | | userInfoUpdate(UserInfoUpdateMQMsg.class); // 用户信息修改
|
| | | userInfoUpdate(UserInfoUpdateMQMsg.class), // 用户信息修改
|
| | | userLevelChanged(UserLevelChangedMQMsg.class), // 用户等级变化
|
| | | threeSaleSeparate(ThreeSaleSeparateMQMsg.class);// 邀请关系脱离
|
| | |
|
| | | private final Class<?> clazz;
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | public class ThreeSaleSeparateMQMsg {
|
| | | private Long bossUid;
|
| | | private Long workerUid;
|
| | | private Date createTime;
|
| | |
|
| | | public ThreeSaleSeparateMQMsg(Long bossUid, Long workerUid, Date createTime) {
|
| | | this.bossUid = bossUid;
|
| | | this.workerUid = workerUid;
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Long getBossUid() {
|
| | | return bossUid;
|
| | | }
|
| | |
|
| | | public void setBossUid(Long bossUid) {
|
| | | this.bossUid = bossUid;
|
| | | }
|
| | |
|
| | | public Long getWorkerUid() {
|
| | | return workerUid;
|
| | | }
|
| | |
|
| | | public void setWorkerUid(Long workerUid) {
|
| | | this.workerUid = workerUid;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | |
|
| | | /**
|
| | | * 金币任务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class UserLevelChangedMQMsg extends BaseMQMsgBody {
|
| | | private Long uid;
|
| | | private UserLevelEnum fromLevel;
|
| | | private UserLevelEnum toLevel;
|
| | | private Date createTime;
|
| | |
|
| | | public UserLevelChangedMQMsg(Long uid, UserLevelEnum fromLevel, UserLevelEnum toLevel, Date createTime) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.fromLevel = fromLevel;
|
| | | this.toLevel = toLevel;
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public UserLevelEnum getFromLevel() {
|
| | | return fromLevel;
|
| | | }
|
| | |
|
| | | public void setFromLevel(UserLevelEnum fromLevel) {
|
| | | this.fromLevel = fromLevel;
|
| | | }
|
| | |
|
| | | public UserLevelEnum getToLevel() {
|
| | | return toLevel;
|
| | | }
|
| | |
|
| | | public void setToLevel(UserLevelEnum toLevel) {
|
| | | this.toLevel = toLevel;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
| | |
| | | private Integer superFirstCount;
|
| | | @Column(name = "tuls_super_second_count")
|
| | | private Integer superSecondCount;
|
| | | @Column(name = "tuls_tearcher_first_count")
|
| | | private Integer tearcherFirstCount;
|
| | | @Column(name = "tuls_tearcher_second_count")
|
| | | private Integer tearcherSecondCount;
|
| | |
|
| | | @Column(name = "tuls_create_time")
|
| | | private Date createTime;
|
| | | @Column(name = "tuls_update_time")
|
| | |
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public Integer getTearcherFirstCount() {
|
| | | return tearcherFirstCount;
|
| | | }
|
| | |
|
| | | public void setTearcherFirstCount(Integer tearcherFirstCount) {
|
| | | this.tearcherFirstCount = tearcherFirstCount;
|
| | | }
|
| | |
|
| | | public Integer getTearcherSecondCount() {
|
| | | return tearcherSecondCount;
|
| | | }
|
| | |
|
| | | public void setTearcherSecondCount(Integer tearcherSecondCount) {
|
| | | this.tearcherSecondCount = tearcherSecondCount;
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.entity.bus.user.vip;
|
| | |
|
| | | public enum UserLevelEnum {
|
| | | //team_subsidy_6_pre_0_0
|
| | | //team_subsidy_6_pre_0_3
|
| | | //team_subsidy_6_pre_0_7
|
| | | //team_subsidy_6_pre_0_10
|
| | | //team_subsidy_6_pre_0_11
|
| | | |
| | | |
| | | //team_subsidy_6_pre_3_0
|
| | | //team_subsidy_6_pre_3_3
|
| | | //team_subsidy_6_pre_3_7
|
| | | //team_subsidy_6_pre_3_10
|
| | | //team_subsidy_6_pre_3_11
|
| | | |
| | | |
| | | //team_subsidy_6_pre_7_0
|
| | | //team_subsidy_6_pre_7_3
|
| | | //team_subsidy_6_pre_7_7
|
| | | //team_subsidy_6_pre_7_10
|
| | | //team_subsidy_6_pre_7_11
|
| | | |
| | | |
| | | //team_subsidy_6_pre_10_0=0
|
| | | //team_subsidy_6_pre_10_3=0
|
| | | //team_subsidy_6_pre_10_7=0
|
| | | //team_subsidy_6_pre_10_10=0
|
| | | //team_subsidy_6_pre_10_11=0
|
| | | |
| | | |
| | | //team_subsidy_6_pre_11_0=0
|
| | | //team_subsidy_6_pre_11_3=0
|
| | | //team_subsidy_6_pre_11_7=0
|
| | | //team_subsidy_6_pre_11_10=0
|
| | | //team_subsidy_6_pre_11_11=0
|
| | | |
| | | |
| | | |
| | | //team_subsidy_7_pre_0_0
|
| | | //team_subsidy_7_pre_0_3
|
| | | //team_subsidy_7_pre_0_7
|
| | | //team_subsidy_7_pre_0_10
|
| | | //team_subsidy_7_pre_0_11
|
| | | |
| | | |
| | | //team_subsidy_7_pre_3_0
|
| | | //team_subsidy_7_pre_3_3
|
| | | //team_subsidy_7_pre_3_7
|
| | | //team_subsidy_7_pre_3_10
|
| | | //team_subsidy_7_pre_3_11
|
| | | |
| | | |
| | | //team_subsidy_7_pre_7_0
|
| | | //team_subsidy_7_pre_7_3
|
| | | //team_subsidy_7_pre_7_7
|
| | | //team_subsidy_7_pre_7_10
|
| | | //team_subsidy_7_pre_7_11
|
| | | |
| | | |
| | | //team_subsidy_7_pre_10_0=0
|
| | | //team_subsidy_7_pre_10_3=0
|
| | | //team_subsidy_7_pre_10_7=0
|
| | | //team_subsidy_7_pre_10_10=0
|
| | | //team_subsidy_7_pre_10_11=0
|
| | | |
| | | |
| | | //team_subsidy_7_pre_11_0=0
|
| | | //team_subsidy_7_pre_11_3=0
|
| | | //team_subsidy_7_pre_11_7=0
|
| | | //team_subsidy_7_pre_11_10=0
|
| | | //team_subsidy_7_pre_11_11=0
|
| | | |
| | | |
| | | |
| | |
|
| | | daRen(0, 0, "快省达人", "actived", "http://www.baidu.com"),
|
| | | normalVIP(3, 30, "普通会员", "vipPre1", "http://www.baidu.com"),
|
| | | highVIP(7, 70, "高级会员", "vipPre2", "http://www.baidu.com"),
|
| | | superVIP(10, 100, "超级会员", "vip", "http://www.baidu.com");
|
| | | superVIP(10, 100, "超级会员", "vip", "http://www.baidu.com"),
|
| | | tearcher(11, 101, "资深导师", "tearcher", "http://www.baidu.com");
|
| | |
|
| | | private int level;
|
| | | private int orderRank;
|
| | |
| | |
|
| | | import com.xxl.job.core.biz.model.ReturnT;
|
| | | import com.xxl.job.core.handler.annotation.XxlJob;
|
| | | import com.yeshi.fanli.dto.order.dividents.UserDividentsDayDTO;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceUserService;
|
| | | import com.yeshi.fanli.service.manger.order.TeamDividentsManager;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | //订单团队分红
|
| | |
| | |
|
| | | long count = teamDividentsSourceOrderService.countCanSendUidByPreSendTime(preSendTime);
|
| | | int pageSize = 500;
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize);
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | for (int i = 0; i < totalPage; i++) {
|
| | | List<Long> list = teamDividentsSourceOrderService.listCanSendUidByPreSendTime(preSendTime, i + 1, pageSize);
|
| | | for (Long uid : list) {
|
| | |
| | | targetUidList.addAll(uidList);
|
| | | }
|
| | |
|
| | | for (Long uid : targetUidList)
|
| | | CMQManager.getInstance().addTeamDividentsMsg(new UserDividentsDayDTO(uid, day));
|
| | | // for (Long uid : targetUidList)
|
| | | // CMQManager.getInstance().addTeamDividentsMsg(new
|
| | | // UserDividentsDayDTO(uid, day));
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
|
| | | }
|
| | |
| | | from yeshi_ec_team_dividents_record where td_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByUidAndDayForUpdate" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_dividents_record where td_uid = |
| | | #{uid} and td_day=#{day} for update |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_team_dividents_record where td_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tdo_update_time" property="updateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tdo_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">tdo_id,tdo_uid,tdo_order_no,tdo_source_type,tdo_state,tdo_money,tdo_pre_send_time,tdo_send_time,tdo_create_time,tdo_update_time |
| | | <sql id="Base_Column_List">tdo_id,tdo_uid,tdo_order_no,tdo_source_type,tdo_state,tdo_money,tdo_pre_send_time,tdo_send_time,tdo_create_time,tdo_update_time,tdo_beizhu |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_team_dividents_source_order |
| | | (tdo_id,tdo_uid,tdo_order_no,tdo_source_type,tdo_state,tdo_money,tdo_pre_send_time,tdo_send_time,tdo_create_time,tdo_update_time) |
| | | (tdo_id,tdo_uid,tdo_order_no,tdo_source_type,tdo_state,tdo_money,tdo_pre_send_time,tdo_send_time,tdo_create_time,tdo_update_time,tdo_beizhu) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{money,jdbcType=DECIMAL},#{preSendTime,jdbcType=TIMESTAMP},#{sendTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{money,jdbcType=DECIMAL},#{preSendTime,jdbcType=TIMESTAMP},#{sendTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{beiZhu,jdbcType=VARCHAR}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder" |
| | |
| | | <if test="sendTime != null">tdo_send_time,</if> |
| | | <if test="createTime != null">tdo_create_time,</if> |
| | | <if test="updateTime != null">tdo_update_time,</if> |
| | | <if test="beiZhu != null">tdo_beizhu,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="sendTime != null">#{sendTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | |
| | | #{preSendTime,jdbcType=TIMESTAMP},tdo_send_time = |
| | | #{sendTime,jdbcType=TIMESTAMP},tdo_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},tdo_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where tdo_id = #{id,jdbcType=BIGINT} |
| | | #{updateTime,jdbcType=TIMESTAMP} ,tdo_beizhu |
| | | =#{beiZhu,jdbcType=VARCHAR} where tdo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder"> |
| | |
| | | <if test="sendTime != null">tdo_send_time=#{sendTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">tdo_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">tdo_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="beiZhu !=null">tdo_beizhu =#{beiZhu,jdbcType=VARCHAR},</if> |
| | | </set> |
| | | where tdo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_dividents_source_order where tdo_id = |
| | | #{0} for |
| | | from yeshi_ec_team_dividents_source_order where tdo_id = #{0} for |
| | | update |
| | | </select> |
| | | |
| | | |
| | | <select id="lisByUidAndPreSendTimeAndState" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | |
| | | tdo_pre_send_time=#{preSendTime} and tdo_state=#{state} limit |
| | | #{start},#{count} |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="countByUidAndPreSendTimeAndState" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_team_dividents_source_order where tdo_uid=#{uid} |
| | | and |
| | | tdo_pre_send_time=#{preSendTime} and tdo_state=#{state} |
| | | <select id="countByUidAndPreSendTimeAndState" resultType="java.lang.Long">select |
| | | count(*) from yeshi_ec_team_dividents_source_order where |
| | | tdo_uid=#{uid} and tdo_pre_send_time=#{preSendTime} and |
| | | tdo_state=#{state} |
| | | </select> |
| | | |
| | | |
| | | <select id="listUidByPreSendTimeAndState" resultType="java.lang.Long"> |
| | | select |
| | | distinct(tdo_uid) |
| | | from yeshi_ec_team_dividents_source_order where |
| | | tdo_uid=#{uid} and |
| | | |
| | | <select id="listUidByPreSendTimeAndState" resultType="java.lang.Long">select |
| | | distinct(tdo_uid) from yeshi_ec_team_dividents_source_order where |
| | | tdo_pre_send_time=#{preSendTime} and |
| | | tdo_state=#{state} limit |
| | | #{start},#{count} |
| | | </select> |
| | | |
| | | |
| | | <select id="countUidByPreSendTimeAndState" resultType="java.lang.Long"> |
| | | select |
| | | count(distinct(tdo_uid)) |
| | | from yeshi_ec_team_dividents_source_order |
| | | where tdo_uid=#{uid} and |
| | | tdo_pre_send_time=#{preSendTime} and |
| | | |
| | | <select id="countUidByPreSendTimeAndState" resultType="java.lang.Long">select |
| | | count(distinct(tdo_uid)) from yeshi_ec_team_dividents_source_order |
| | | where tdo_pre_send_time=#{preSendTime} and |
| | | tdo_state=#{state} |
| | | </select> |
| | | |
| | | |
| | | |
| | | <update id="setStateByUidAndState"> |
| | | update yeshi_ec_team_dividents_source_order |
| | | <set> |
| | | tdo_state=#{targetState}, |
| | | tdo_update_time=now(), |
| | | <set>tdo_state=#{targetState}, tdo_update_time=now(), |
| | | tdo_beizhu=#{beiZhu}, |
| | | </set> |
| | | where tdo_uid = #{uid} and tdo_state=#{state} |
| | | </update> |
| | | |
| | | |
| | | <select id="selectByOrderNoAndSourceType" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_dividents_source_order |
| | | where tdo_order_no=#{orderNo} |
| | | and |
| | | tdo_source_type=#{sourceType} |
| | | from yeshi_ec_team_dividents_source_order where |
| | | tdo_order_no=#{orderNo} and tdo_source_type=#{sourceType} |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | sum(tdsu_money) |
| | | from yeshi_ec_team_dividents_source_user where |
| | | tdsu_target_uid =#{uid} and tdsu_day=#{day} |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tuls_update_time" property="updateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tuls_tearcher_first_count" property="tearcherFirstCount" |
| | | jdbcType="INTEGER" /> |
| | | <result column="tuls_tearcher_second_count" property="tearcherSecondCount" |
| | | jdbcType="INTEGER" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time |
| | | <sql id="Base_Column_List">tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time,tuls_tearcher_first_count,tuls_tearcher_second_count |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_team_user_level_statistic where tuls_uid = |
| | | #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" |
| | | parameterType="com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_team_user_level_statistic |
| | | (tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time) |
| | | (tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time,tuls_tearcher_first_count,tuls_tearcher_second_count) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{level,jdbcType=VARCHAR},#{normalFirstCount,jdbcType=INTEGER},#{normalSecondCount,jdbcType=INTEGER},#{highFirstCount,jdbcType=INTEGER},#{highSecondCount,jdbcType=INTEGER},#{superFirstCount,jdbcType=INTEGER},#{superSecondCount,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | (#{id,jdbcType=BIGINT},#{level,jdbcType=VARCHAR},#{normalFirstCount,jdbcType=INTEGER},#{normalSecondCount,jdbcType=INTEGER},#{highFirstCount,jdbcType=INTEGER},#{highSecondCount,jdbcType=INTEGER},#{superFirstCount,jdbcType=INTEGER},#{superSecondCount,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{tearcherFirstCount,jdbcType=INTEGER},#{tearcherSecondCount,jdbcType=INTEGER}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic" |
| | |
| | | <if test="superSecondCount != null">tuls_super_second_count,</if> |
| | | <if test="createTime != null">tuls_create_time,</if> |
| | | <if test="updateTime != null">tuls_update_time,</if> |
| | | <if test="tearcherFirstCount != null">tuls_tearcher_first_count,</if> |
| | | <if test="tearcherSecondCount != null">tuls_tearcher_second_count,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="superSecondCount != null">#{superSecondCount,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tearcherFirstCount != null">#{tearcherFirstCount,jdbcType=INTEGER},</if> |
| | | <if test="tearcherSecondCount != null">#{tearcherSecondCount,jdbcType=INTEGER}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | |
| | | #{superFirstCount,jdbcType=INTEGER},tuls_super_second_count = |
| | | #{superSecondCount,jdbcType=INTEGER},tuls_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},tuls_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where tuls_uid = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | #{updateTime,jdbcType=TIMESTAMP} ,tuls_tearcher_first_count |
| | | =#{tearcherFirstCount,jdbcType=INTEGER} ,tuls_tearcher_second_count |
| | | =#{tearcherSecondCount,jdbcType=INTEGER} where tuls_uid = |
| | | #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic"> |
| | | update yeshi_ec_team_user_level_statistic |
| | |
| | | </if> |
| | | <if test="createTime != null">tuls_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">tuls_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tearcherFirstCount !=null">tuls_tearcher_first_count |
| | | =#{tearcherFirstCount,jdbcType=INTEGER},</if> |
| | | <if test="tearcherSecondCount !=null">tuls_tearcher_second_count |
| | | =#{tearcherSecondCount,jdbcType=INTEGER},</if> |
| | | </set> |
| | | where tuls_uid = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | public String get(final String key) {
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | hongBaoManage.getValue();
|
| | | return hongBaoManage.getValue();
|
| | | return null;
|
| | | }
|
| | |
|
| | |
| | | @Override
|
| | | public TeamDividentsSourceOrder selectByOrderNoSourceType(String orderNo, int sourceType) {
|
| | |
|
| | | return teamDividentsSourceOrderMapper.selectByOrderNoSourceType(orderNo, sourceType);
|
| | | return teamDividentsSourceOrderMapper.selectByOrderNoAndSourceType(orderNo, sourceType);
|
| | |
|
| | | }
|
| | |
|
| | |
| | | public List<ThreeSale> listFirstTeamByUndeleted(long start, int count, Long uid) {
|
| | | return threeSaleMapper.listFirstTeamByUndeleted(start, count, uid);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public long countFirstTeamByUndeleted(Long uid) {
|
| | | return threeSaleMapper.countFirstTeamByUndeleted(uid);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listSecondTeamByUndeleted(long start, int count, Long uid) {
|
| | | return threeSaleMapper.listSecondTeamByUndeleted(start, count, uid);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public long countSecondTeamByUndeleted(Long uid) {
|
| | | return threeSaleMapper.countSecondTeamByUndeleted(uid);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listSecondTeam(long start, int count, Long uid, Integer state) {
|
| | | return threeSaleMapper.listSecondTeam(start, count, uid, state);
|
| | |
| | |
|
| | | return deepList;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<ThreeSale> getMyBossDeepList(Long uid) {
|
| | | // TODO Auto-generated method stub
|
| | | return null;
|
| | | //TODO 需要更加简便的方式处理
|
| | | return getMyBossDeepList(uid, 100);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void remvoeBreak(Long id, Long uid, Long tid) {
|
| | |
| | | if (threeSale == null) {
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Long workerId = threeSale.getWorker().getId();
|
| | | if (tid.longValue() != workerId.longValue()) {
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Integer expire = threeSale.getExpire();
|
| | | if (expire == ThreeSale.EXPIRE_NORMAL) {
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | int upExpire = expire;
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | | if (bossId.longValue() == uid.longValue()) { // 直接粉丝
|
| | | if (expire == ThreeSale.EXPIRE_BREAK_VIP_DEL4) {
|
| | | upExpire =ThreeSale.EXPIRE_BREAK_VIP_DEL34;
|
| | | upExpire = ThreeSale.EXPIRE_BREAK_VIP_DEL34;
|
| | | } else {
|
| | | upExpire = ThreeSale.EXPIRE_BREAK_VIP_DEL3;
|
| | | }
|
| | | } else { // 间接粉丝
|
| | | if (expire == ThreeSale.EXPIRE_BREAK_VIP_DEL3) {
|
| | | upExpire =ThreeSale.EXPIRE_BREAK_VIP_DEL34;
|
| | | upExpire = ThreeSale.EXPIRE_BREAK_VIP_DEL34;
|
| | | } else {
|
| | | upExpire = ThreeSale.EXPIRE_BREAK_VIP_DEL4;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | ThreeSale update = new ThreeSale();
|
| | | update.setId(id);
|
| | | update.setExpire(upExpire);
|
| | | update.setUpdateTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | |
| | | int normalFirstCount = 0;
|
| | | int highFirstCount = 0;
|
| | | int superFirstCount = 0;
|
| | | int tearcherFirstCount = 0;
|
| | | for (ThreeSale ts : list) {
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(ts.getWorker().getId());
|
| | | if (level == UserLevelEnum.normalVIP) {
|
| | |
| | | highFirstCount++;
|
| | | } else if (level == UserLevelEnum.superVIP) {
|
| | | superFirstCount++;
|
| | | } else if (level == UserLevelEnum.tearcher) {
|
| | | tearcherFirstCount++;
|
| | | }
|
| | | }
|
| | |
|
| | | int normalSecondCount = 0;
|
| | | int highSecondCount = 0;
|
| | | int superSecondCount = 0;
|
| | | int tearcherSecondCount = 0;
|
| | |
|
| | | long secondCount = threeSaleSerivce.countSecondTeam(uid, state);
|
| | | int pageSize = 1000;
|
| | |
| | | highSecondCount++;
|
| | | } else if (level == UserLevelEnum.superVIP) {
|
| | | superSecondCount++;
|
| | | } else if (level == UserLevelEnum.tearcher) {
|
| | | tearcherSecondCount++;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | statistic.setHighSecondCount(highSecondCount);
|
| | | statistic.setSuperFirstCount(superFirstCount);
|
| | | statistic.setSuperSecondCount(superSecondCount);
|
| | | statistic.setTearcherFirstCount(tearcherFirstCount);
|
| | | statistic.setTearcherSecondCount(tearcherSecondCount);
|
| | | statistic.setId(uid);
|
| | | statistic.setLevel(level);
|
| | | add(statistic);
|
| | |
| | | public void add(TeamUserLevelStatistic statistic) {
|
| | | TeamUserLevelStatistic old = selectByUid(statistic.getId());
|
| | | if (old == null) {
|
| | | if(statistic.getCreateTime()==null)
|
| | | if (statistic.getCreateTime() == null)
|
| | | statistic.setCreateTime(new Date());
|
| | | teamUserLevelStatisticMapper.insertSelective(statistic);
|
| | | } else {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateUserLevel(Long uid) {
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(uid);
|
| | | TeamUserLevelStatistic statistic = new TeamUserLevelStatistic();
|
| | | statistic.setId(uid);
|
| | | statistic.setLevel(level);
|
| | | statistic.setUpdateTime(new Date());
|
| | | teamUserLevelStatisticMapper.updateByPrimaryKeySelective(statistic);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | * @throws
|
| | | */
|
| | | public void add(TeamUserLevelStatistic statistic);
|
| | |
|
| | | /**
|
| | | * 更新用户等级
|
| | | * @Title: updateUserLevel
|
| | | * @Description: |
| | | * @param uid |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void updateUserLevel(Long uid);
|
| | | }
|
| | |
| | | import com.yeshi.fanli.exception.order.dividents.TeamDividentsRecordException;
|
| | | import com.yeshi.fanli.service.inter.money.TeamDividentsDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsRecordService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceUserService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | |
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | /**
|
| | | * 开始分红
|
| | | * @Title: startDividents
|
| | |
| | | public void startDividents(Long sourceUid) throws ParamsException {
|
| | | String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
|
| | | Date preSendTime = new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd"));
|
| | | startDividents(sourceUid, preSendTime);
|
| | | }
|
| | |
|
| | | // 是否可以分红
|
| | | private boolean isCanDividents(TeamUserLevelStatistic tus) {
|
| | | if (Constant.IS_TEST)
|
| | | return true;
|
| | |
|
| | | if (tus != null && (tus.getLevel() == UserLevelEnum.highVIP || tus.getLevel() == UserLevelEnum.superVIP
|
| | | || tus.getLevel() == UserLevelEnum.tearcher)) {
|
| | | if (tus.getLevel() == UserLevelEnum.highVIP) {
|
| | | int vipFirstCount = tus.getNormalFirstCount() + tus.getHighFirstCount() + tus.getSuperFirstCount()
|
| | | + tus.getTearcherFirstCount();
|
| | | if (vipFirstCount >= 3)// 直接粉丝普通会员等级以上的用户>=3
|
| | | return true;
|
| | | } else if (tus.getLevel() == UserLevelEnum.superVIP) {
|
| | | int firstCount = tus.getSuperFirstCount() + tus.getTearcherFirstCount();
|
| | | int secondCount = tus.getNormalSecondCount() + tus.getHighSecondCount() + tus.getSuperSecondCount()
|
| | | + tus.getTearcherSecondCount();
|
| | | if (firstCount >= 3 && secondCount >= 3) {// 直接粉丝超级会员等级以上的用户>=3
|
| | | // 间接粉丝普通会员以上等级>=3
|
| | | return true;
|
| | | }
|
| | | } else {
|
| | | int firstCount = tus.getSuperFirstCount() + tus.getTearcherFirstCount();
|
| | | int secondCount = tus.getHighSecondCount() + tus.getSuperSecondCount() + tus.getTearcherSecondCount();
|
| | | if (firstCount >= 3 && secondCount >= 3) {// 直接粉丝超级会员等级以上的用户>=3
|
| | | // 间接粉丝高级会员以上等级>=3
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void startDividents(Long sourceUid, Date preSendTime) throws ParamsException {
|
| | | String day = TimeUtil.getGernalTime(preSendTime.getTime(), "yyyy-MM-dd");
|
| | | // 查询出可用于分红的用户的总金额
|
| | | long count = teamDividentsSourceOrderService.countCanSendByUidAndPreSendTime(sourceUid, preSendTime);
|
| | | int pageSize = 1000;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 分红金额为0的不参与
|
| | | if (totalMoney.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | |
|
| | | // 查询出可以参与分红的用户
|
| | | List<ThreeSale> threeSalesList = threeSaleSerivce.getMyBossDeepList(sourceUid);
|
| | | if (threeSalesList == null)
|
| | | return;
|
| | |
|
| | | Map<Long, UserLevelEnum> uidLevel = new HashMap<Long, UserLevelEnum>();
|
| | | for (ThreeSale ts : threeSalesList) {
|
| | | if (ts.getBoss() != null) {
|
| | | TeamUserLevelStatistic tus = teamUserLevelStatisticService.selectByUid(ts.getBoss().getId());
|
| | | if (tus != null
|
| | | && (tus.getLevel() == UserLevelEnum.highVIP || tus.getLevel() == UserLevelEnum.superVIP)) {
|
| | | // TODO 需要判断团队的超级会员与高级会员
|
| | | if (tus == null)
|
| | | teamUserLevelStatisticService.initData(ts.getBoss().getId());
|
| | | tus = teamUserLevelStatisticService.selectByUid(ts.getBoss().getId());
|
| | |
|
| | | if (isCanDividents(tus)) {
|
| | | uidLevel.put(tus.getId(), tus.getLevel());
|
| | | }
|
| | | }
|
| | |
| | | teamDividentsSourceUser.setTargetUid(uid);
|
| | | teamDividentsSourceUserService.addTeamDividentsSourceUser(teamDividentsSourceUser);
|
| | | }
|
| | | // if (1 / 0 > 0)
|
| | | // return;
|
| | | }
|
| | |
|
| | | // 计算平均分红
|
| | |
| | | if (userLevel == UserLevelEnum.highVIP) {
|
| | | return perDivident;
|
| | | } else if (userLevel == UserLevelEnum.superVIP) {
|
| | | return MoneyBigDecimalUtil.mul(perDivident, new BigDecimal(2));
|
| | | } else if (userLevel == UserLevelEnum.tearcher) {
|
| | | return MoneyBigDecimalUtil.mul(perDivident, new BigDecimal(2));
|
| | | }
|
| | | return null;
|
| | |
| | | record.setUid(uid);
|
| | | teamDividentsRecordService.addTeamDividentsRecord(record);
|
| | |
|
| | | UserMoneyDetail detail = UserMoneyDetailFactory.createOrderTeamDividents(uid, money, new Date());
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, money, detail);
|
| | |
|
| | | // TODO 加入通知
|
| | | // 有分红才显示资金明细
|
| | | if (money.compareTo(new BigDecimal(0)) > 0) {
|
| | | UserMoneyDetail detail = UserMoneyDetailFactory.createOrderTeamDividents(uid, money, new Date());
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, money, detail);
|
| | | // TODO 加入通知
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
| | | BigDecimal money = sourceOrder.getMoney();
|
| | | // 查询参与这一单分红的人
|
| | | String day = TimeUtil.getGernalTime(sourceOrder.getSendTime().getTime(), "yyyy-MM-dd");
|
| | | if (Constant.IS_TEST)
|
| | | day = TimeUtil.getGernalTime(sourceOrder.getPreSendTime().getTime(), "yyyy-MM-dd");
|
| | |
|
| | | List<TeamDividentsSourceUser> list = teamDividentsSourceUserService
|
| | | .listBySourceUidAndDay(sourceOrder.getUid(), day);
|
| | | // 计算每个人的比例
|
| | |
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取源订单需要参与分红的比例
|
| | | * @Title: getSourceOrderDividentsRate
|
| | | * @Description: |
| | | * @param level
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal getSourceOrderDividentsRate(UserLevelEnum level) {
|
| | | String rate = hongBaoManageService.get("team_source_order_dividents_" + level.getLevel());
|
| | | return new BigDecimal(rate);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.factory.order.dividents;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | public class TeamDividentsSourceOrderFactory {
|
| | |
|
| | | public static TeamDividentsSourceOrder create(List<CommonOrder> commonOrderList,
|
| | | BigDecimal rate) {
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | int invalidCount = 0;
|
| | | for (CommonOrder commonOrder : commonOrderList) {
|
| | | if (commonOrder.geteIncome() != null)
|
| | | money = money.add(commonOrder.geteIncome());
|
| | |
|
| | | if (commonOrder.getState() == CommonOrder.STATE_SX)
|
| | | invalidCount++;
|
| | | }
|
| | |
|
| | | if (money.compareTo(new BigDecimal(0)) <= 0)
|
| | | return null;
|
| | |
|
| | | if (invalidCount >= commonOrderList.size())
|
| | | return null;
|
| | |
|
| | | BigDecimal dividents = MoneyBigDecimalUtil.div(money.multiply(rate), new BigDecimal(100));
|
| | | TeamDividentsSourceOrder sourceOrder = new TeamDividentsSourceOrder();
|
| | | sourceOrder.setMoney(dividents);
|
| | | sourceOrder.setOrderNo(commonOrderList.get(0).getOrderNo());
|
| | | sourceOrder.setSourceType(commonOrderList.get(0).getSourceType());
|
| | | sourceOrder.setState(TeamDividentsSourceOrder.STATE_CAN_SEND);
|
| | | sourceOrder.setUid(commonOrderList.get(0).getUserInfo().getId());
|
| | |
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrderList.get(0).getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | sourceOrder.setPreSendTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
|
| | |
|
| | | return sourceOrder;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.ThreeSaleSeparateMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component |
| | | @Component
|
| | | public class UserVIPMessageListener implements MessageListener {
|
| | |
|
| | | @Resource
|
| | | private UserVIPPreInfoService userVIPPreInfoService;
|
| | |
|
| | | @Resource
|
| | | private TeamUserLevelStatisticService teamUserLevelStatisticService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | | |
| | | LogHelper.mqInfo("consumer-UserVIPMessageListener", message.getMsgID(), message.getTopic(),
|
| | | message.getTag(), new String(message.getBody()));
|
| | |
|
| | | LogHelper.mqInfo("consumer-UserVIPMessageListener", message.getMsgID(), message.getTopic(), message.getTag(),
|
| | | new String(message.getBody()));
|
| | | String tag = message.getTag();
|
| | | if (tag == null)
|
| | | tag = "";
|
| | |
| | | if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | // 邀请成功
|
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {
|
| | | UserInviteMQMsg msg = new Gson().fromJson(new String(message.getBody()),UserInviteMQMsg.class);
|
| | | UserInviteMQMsg msg = new Gson().fromJson(new String(message.getBody()), UserInviteMQMsg.class);
|
| | | // 会员等级升级
|
| | | userVIPPreInfoService.verifyVipPreInfo(msg.getBossId(), true);
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userLevelChanged.name())) {// 用户等级发生变化
|
| | | UserLevelChangedMQMsg msg = new Gson().fromJson(new String(message.getBody()),
|
| | | UserLevelChangedMQMsg.class);
|
| | | // 更新上2级的邀请统计
|
| | | teamUserLevelStatisticService.updateUserLevel(msg.getUid());
|
| | | UserInfo boss = threeSaleSerivce.getBoss(msg.getUid());
|
| | | if (boss != null) {
|
| | | teamUserLevelStatisticService.initData(boss.getId());
|
| | | boss = threeSaleSerivce.getBoss(boss.getId());
|
| | | if (boss != null) {
|
| | | teamUserLevelStatisticService.initData(boss.getId());
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.threeSaleSeparate.name())) {// 邀请关系脱离
|
| | | ThreeSaleSeparateMQMsg msg = new Gson().fromJson(new String(message.getBody()),
|
| | | ThreeSaleSeparateMQMsg.class);
|
| | | // 更新上两级邀请统计
|
| | | teamUserLevelStatisticService.initData(msg.getBossUid());
|
| | | UserInfo boss = threeSaleSerivce.getBoss(msg.getBossUid());
|
| | | if (boss != null) {
|
| | | teamUserLevelStatisticService.initData(boss.getId());
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | | |
| | | // 订单到账相关
|
| | | if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {
|
| | | OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsg.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU) {// 自购到账
|
| | | // 会员等级升级
|
| | | userVIPPreInfoService.verifyVipPreInfo(dto.getUid(), false);
|
| | | } else if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) {// 分享到账
|
| | | // 会员等级升级
|
| | | userVIPPreInfoService.verifyVipPreInfo(dto.getUid(), false);
|
| | |
|
| | | } else if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | // 订单到账相关
|
| | | if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {
|
| | | OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsg.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU) {// 自购到账
|
| | | // 会员等级升级
|
| | | userVIPPreInfoService.verifyVipPreInfo(dto.getUid(), false);
|
| | | } else if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) {// 分享到账
|
| | | // 会员等级升级
|
| | | userVIPPreInfoService.verifyVipPreInfo(dto.getUid(), false);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | |
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <!-- 邀请队员成功 -->
|
| | | <!-- 邀请队员成功,用户等级发生变化,邀请关系脱离 -->
|
| | | <entry value-ref="userVIPMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_USER" />
|
| | | <property name="expression" value="inviteSuccess" />
|
| | | <property name="expression"
|
| | | value="inviteSuccess||userLevelChanged||threeSaleSeparate" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | |
| | | |
| | |
|
| | |
|
| | | <!-- 订单到账 -->
|
| | | <entry value-ref="userVIPMessageListener">
|
| | | <key>
|
| | |
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | |
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | |
| | | </property>
|
| | | </bean>
|
| | |
|
| | | <!--团队分红消息订阅 -->
|
| | | <bean id="orderDividentsMessageListener"
|
| | | class="com.yeshi.fanli.util.rocketmq.consumer.order.OrderDividentsMessageListener"></bean>
|
| | | <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean -->
|
| | | <bean id="orderDividentsConsumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | | <property name="properties"> <!--消费者配置信息 -->
|
| | | <props>
|
| | | <prop key="AccessKey">${rocketmq.AccessKey}</prop>
|
| | | <prop key="SecretKey">${rocketmq.SecretKey}</prop>
|
| | | <prop key="GROUP_ID">GID_ORDER_TEAM_DIVIDENTS</prop>
|
| | | <prop key="NAMESRV_ADDR">${rocketmq.NAMESRV_ADDR}</prop>
|
| | | <prop key="ConsumeThreadNums">50</prop>
|
| | | </props>
|
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <!-- 订单收货 ,淘宝订单维权 -->
|
| | | <entry value-ref="orderDividentsMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression" value="orderConfirm||taoBaoOrderWeiQuan" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | |
|
| | | <!-- 用户被封禁 -->
|
| | | <entry value-ref="orderDividentsMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_USER" />
|
| | | <property name="expression" value="forbiddenUser" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | </beans> |