Merge remote-tracking branch 'origin/div' into div
10个文件已删除
30个文件已修改
1个文件已添加
| | |
| | | */ |
| | | long countCanSendSourceUidByPreSendTime(@Param("preSendTime") Date preSendTime); |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 源用户相关订单失效 |
| | | * @Title: invalidOrderBySourceUid |
| | | * @Description: |
| | | * @param sourceUid |
| | | * @param beiZhu |
| | | * @param stateList |
| | | * @return |
| | | * int 返回类型 |
| | | * @throws |
| | | */ |
| | | int invalidOrderBySourceUid(@Param("sourceUid") Long sourceUid, @Param("beiZhu") String beiZhu, |
| | | @Param("stateList") List<Integer> stateList); |
| | | |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.user.vip; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic; |
| | | |
| | | public interface TeamUserLevelStatisticMapper extends BaseMapper<TeamUserLevelStatistic> { |
| | | |
| | | /** |
| | | * 根据用户列表查询 |
| | | * @Title: listByUids |
| | | * @Description: |
| | | * @param uidList |
| | | * @return |
| | | * List<TeamUserLevelStatistic> 返回类型 |
| | | * @throws |
| | | */ |
| | | List<TeamUserLevelStatistic> listByUids(@Param("uidList") List<Long> uidList); |
| | | } |
| | |
| | | private boolean valid;
|
| | | private int delayHour;// 延时的时间(小时记)
|
| | | private Date staticticDate;// 统计到的时间
|
| | | private boolean miandan;
|
| | |
|
| | | public OrderMQMsg(String orderId, Integer type, Long uid, int handleType, boolean valid, int delayHour,
|
| | | Date staticticDate) {
|
| | | Date staticticDate, boolean miandan) {
|
| | | super();
|
| | | this.orderId = orderId;
|
| | | this.type = type;
|
| | |
| | | this.valid = valid;
|
| | | this.delayHour = delayHour;
|
| | | this.staticticDate = staticticDate;
|
| | | this.miandan = miandan;
|
| | | }
|
| | |
|
| | | public Date getStaticticDate() {
|
| | |
| | | public void setValid(boolean valid) {
|
| | | this.valid = valid;
|
| | | }
|
| | |
|
| | | public boolean isMiandan() {
|
| | | return miandan;
|
| | | }
|
| | |
|
| | | public void setMiandan(boolean miandan) {
|
| | | this.miandan = miandan;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.order;
|
| | |
|
| | | public class HongBaoAddResult {
|
| | | public final static int CODE_ADD=1;
|
| | | public final static int CODE_UPDATE=2;
|
| | | public final static int CODE_ADD_AND_UPDATE=12;
|
| | | |
| | | |
| | | private int resultCode;
|
| | | private boolean miandan;
|
| | |
|
| | | public HongBaoAddResult() {
|
| | |
|
| | | }
|
| | |
|
| | | public HongBaoAddResult(int resultCode, boolean miandan) {
|
| | | this.resultCode = resultCode;
|
| | | this.miandan = miandan;
|
| | | }
|
| | |
|
| | | public int getResultCode() {
|
| | | return resultCode;
|
| | | }
|
| | |
|
| | | public void setResultCode(int resultCode) {
|
| | | this.resultCode = resultCode;
|
| | | }
|
| | |
|
| | | public boolean isMiandan() {
|
| | | return miandan;
|
| | | }
|
| | |
|
| | | public void setMiandan(boolean miandan) {
|
| | | this.miandan = miandan;
|
| | | }
|
| | | }
|
| | |
| | | private BigDecimal money;
|
| | | @Column(name = "sou_pre_send_time")
|
| | | private Date preSendTime;
|
| | | @Column(name = "sou_send_time")
|
| | | private Date sendTime;
|
| | | @Column(name = "sou_create_time")
|
| | | private Date createTime;
|
| | | @Column(name = "sou_update_time")
|
| | |
| | | @Column(name = "sou_beizhu")
|
| | | private String beiZhu;
|
| | |
|
| | | public Date getSendTime() {
|
| | | return sendTime;
|
| | | }
|
| | |
|
| | | public void setSendTime(Date sendTime) {
|
| | | this.sendTime = sendTime;
|
| | | }
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
| | | import com.xxl.job.core.biz.model.ReturnT;
|
| | | import com.xxl.job.core.handler.annotation.XxlJob;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | 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.TimeUtil;
|
| | |
| | | @Resource
|
| | | private TeamDividentsManager teamDividentsManager;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceOrderService teamDividentsSourceOrderService;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceUserService teamDividentsSourceUserService;
|
| | |
| | | import com.yeshi.fanli.dto.mq.UidDateDTO;
|
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord;
|
| | | import com.yeshi.fanli.service.inter.money.TeamEincomeRecordService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderUserMapService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceUserService;
|
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager;
|
| | |
| | | @Resource
|
| | | private TeamDividentsManager teamDividentsManager;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceOrderService teamDividentsSourceOrderService;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceOrderUserMapService teamDividentsSourceOrderUserMapService;
|
| | |
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord;
|
| | | import com.yeshi.fanli.service.inter.money.TeamEincomeRecordService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | 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.StringUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private TeamDividentsManager teamDividentsManager;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceOrderService teamDividentsSourceOrderService;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceUserService teamDividentsSourceUserService;
|
| | |
| | | <result column="sou_update_time" property="updateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="sou_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="sou_send_time" property="sendTime" jdbcType="TIMESTAMP" /> |
| | | <association property="sourceOrder" column="sou_source_order_id" |
| | | javaType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder"> |
| | | <id column="sou_source_order_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | <sql id="Base_Column_List">sou_id,sou_source_order_id,sou_source_uid,sou_target_uid,sou_state,sou_type,sou_rate,sou_money,sou_pre_send_time,sou_create_time,sou_update_time,sou_beizhu |
| | | <sql id="Base_Column_List">sou_id,sou_source_order_id,sou_source_uid,sou_target_uid,sou_state,sou_type,sou_rate,sou_money,sou_pre_send_time,sou_create_time,sou_update_time,sou_beizhu,sou_send_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrderUserMap" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_team_dividents_source_order_user |
| | | (sou_id,sou_source_order_id,sou_source_uid,sou_target_uid,sou_state,sou_type,sou_rate,sou_money,sou_pre_send_time,sou_create_time,sou_update_time,sou_beizhu) |
| | | (sou_id,sou_source_order_id,sou_source_uid,sou_target_uid,sou_state,sou_type,sou_rate,sou_money,sou_pre_send_time,sou_create_time,sou_update_time,sou_beizhu,sou_send_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{sourceOrder.id,jdbcType=BIGINT},#{sourceUid,jdbcType=BIGINT},#{targetUid,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{type,jdbcType=INTEGER},#{rate,jdbcType=DECIMAL},#{money,jdbcType=DECIMAL},#{preSendTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{beiZhu,jdbcType=VARCHAR}) |
| | | (#{id,jdbcType=BIGINT},#{sourceOrder.id,jdbcType=BIGINT},#{sourceUid,jdbcType=BIGINT},#{targetUid,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{type,jdbcType=INTEGER},#{rate,jdbcType=DECIMAL},#{money,jdbcType=DECIMAL},#{preSendTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{beiZhu,jdbcType=VARCHAR},#{sendTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrderUserMap" |
| | |
| | | <if test="createTime != null">sou_create_time,</if> |
| | | <if test="updateTime != null">sou_update_time,</if> |
| | | <if test="beiZhu != null">sou_beizhu,</if> |
| | | <if test="sendTime != null">sou_send_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="sendTime != null">#{sendTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrderUserMap">update yeshi_ec_team_dividents_source_order_user set |
| | | sou_source_order_id = #{sourceOrder.id,jdbcType=BIGINT},sou_source_uid |
| | | = |
| | | #{sourceUid,jdbcType=BIGINT},sou_target_uid = |
| | | = #{sourceUid,jdbcType=BIGINT},sou_target_uid = |
| | | #{targetUid,jdbcType=BIGINT},sou_state = |
| | | #{state,jdbcType=INTEGER},sou_type = #{type,jdbcType=INTEGER},sou_rate |
| | | = #{rate,jdbcType=DECIMAL},sou_money = |
| | |
| | | #{preSendTime,jdbcType=TIMESTAMP},sou_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},sou_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP},sou_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR} where sou_id = #{id,jdbcType=BIGINT} |
| | | #{beiZhu,jdbcType=VARCHAR} ,sou_send_time |
| | | =#{sendTime,jdbcType=TIMESTAMP} where sou_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrderUserMap"> |
| | |
| | | <if test="createTime != null">sou_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">sou_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="beiZhu != null">sou_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="sendTime !=null">sou_send_time =#{sendTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where sou_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | |
| | | <update id="invalidOrderBySourceUid"> |
| | | update yeshi_ec_team_dividents_source_order_user |
| | | <set> |
| | | sou_state=4, |
| | | sou_update_time=now(), |
| | | sou_beizhu=#{beiZhu}, |
| | | </set> |
| | | where sou_source_uid=#{sourceUid} |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" open=" and (" separator=" or " |
| | | close=")" item="state">sou_state=#{state}</foreach> |
| | | </if> |
| | | |
| | | </update> |
| | | |
| | | <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_dividents_source_order_user where sou_id = |
| | | #{0} for |
| | | from yeshi_ec_team_dividents_source_order_user where sou_id = #{0} for |
| | | update |
| | | </select> |
| | | |
| | | |
| | | <select id="list" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_dividents_source_order_user where |
| | | 1=1 |
| | | <if test="sourceOrderId!=null"> |
| | | and sou_source_order_id=#{sourceOrderId} |
| | | </if> |
| | | |
| | | <if test="sourceUid!=null"> |
| | | and sou_source_uid=#{sourceUid} |
| | | </if> |
| | | |
| | | <if test="targetUid!=null"> |
| | | and sou_target_uid=#{targetUid} |
| | | </if> |
| | | <if test="preSendTime!=null"> |
| | | and sou_pre_send_time=#{preSendTime} |
| | | </if> |
| | | |
| | | from yeshi_ec_team_dividents_source_order_user where 1=1 |
| | | <if test="sourceOrderId!=null">and sou_source_order_id=#{sourceOrderId}</if> |
| | | <if test="sourceUid!=null">and sou_source_uid=#{sourceUid}</if> |
| | | <if test="targetUid!=null">and sou_target_uid=#{targetUid}</if> |
| | | <if test="preSendTime!=null">and sou_pre_send_time=#{preSendTime}</if> |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" open=" and (" separator=" or " |
| | | close=")" item="state"></foreach> |
| | | sou_state=#{state} |
| | | close=")" item="state">sou_state=#{state}</foreach> |
| | | </if> |
| | | |
| | | <if test="typeList!=null"> |
| | | <foreach collection="typeList" open=" and (" separator=" or " |
| | | close=")" item="type"></foreach> |
| | | sou_type=#{type} |
| | | close=")" item="type">sou_type=#{type}</foreach> |
| | | </if> |
| | | |
| | | limit #{start},#{count} |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="count" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_team_dividents_source_order_user where |
| | | select count(*) from yeshi_ec_team_dividents_source_order_user where |
| | | 1=1 |
| | | <if test="sourceOrderId!=null"> |
| | | and sou_source_order_id=#{sourceOrderId} |
| | | </if> |
| | | |
| | | <if test="sourceUid!=null"> |
| | | and sou_source_uid=#{sourceUid} |
| | | </if> |
| | | |
| | | <if test="targetUid!=null"> |
| | | and sou_target_uid=#{targetUid} |
| | | </if> |
| | | <if test="preSendTime!=null"> |
| | | and sou_pre_send_time=#{preSendTime} |
| | | </if> |
| | | |
| | | <if test="sourceOrderId!=null">and sou_source_order_id=#{sourceOrderId}</if> |
| | | <if test="sourceUid!=null">and sou_source_uid=#{sourceUid}</if> |
| | | <if test="targetUid!=null">and sou_target_uid=#{targetUid}</if> |
| | | <if test="preSendTime!=null">and sou_pre_send_time=#{preSendTime}</if> |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" open=" and (" separator=" or " |
| | | close=")" item="state"></foreach> |
| | | sou_state=#{state} |
| | | close=")" item="state">sou_state=#{state}</foreach> |
| | | </if> |
| | | |
| | | <if test="typeList!=null"> |
| | | <foreach collection="typeList" open=" and (" separator=" or " |
| | | close=")" item="type"></foreach> |
| | | sou_type=#{type} |
| | | close=")" item="type">sou_type=#{type}</foreach> |
| | | </if> |
| | | |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="listCanSendSourceUidByPreSendTime" resultType="java.lang.Long"> |
| | | |
| | | SELECT DISTINCT(o.`sou_source_uid`) FROM |
| | | <select id="listCanSendSourceUidByPreSendTime" resultType="java.lang.Long">SELECT |
| | | DISTINCT(o.`sou_source_uid`) FROM |
| | | `yeshi_ec_team_dividents_source_order_user` o WHERE o.`sou_state`=2 |
| | | AND o.`sou_pre_send_time`=#{preSendTime} limit #{start},#{count} |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="countCanSendSourceUidByPreSendTime" resultType="java.lang.Long"> |
| | | |
| | | SELECT count(DISTINCT(o.`sou_source_uid`)) FROM |
| | | <select id="countCanSendSourceUidByPreSendTime" resultType="java.lang.Long">SELECT |
| | | count(DISTINCT(o.`sou_source_uid`)) FROM |
| | | `yeshi_ec_team_dividents_source_order_user` o WHERE o.`sou_state`=2 |
| | | AND o.`sou_pre_send_time`=#{preSendTime} limit #{start},#{count} |
| | | |
| | | AND o.`sou_pre_send_time`=#{preSendTime} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | |
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.fanli.entity.jd.JDOrder; |
| | | import com.yeshi.fanli.entity.jd.JDOrderItem; |
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods; |
| | | import com.yeshi.fanli.entity.order.CommonOrderTradeIdMap; |
| | |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.config.SystemCouponService; |
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService; |
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service; |
| | |
| | | |
| | | @Resource |
| | | private InviteOrderSubsidyService inviteOrderSubsidyService; |
| | | |
| | | @Resource |
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService; |
| | | |
| | | @Resource |
| | | private UserVIPInfoService userVIPInfoService; |
| | |
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType) { |
| | | // 奖励订单、免单 使用记录 |
| | | if (sourceType == null) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData, hongBao); |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData, |
| | | hongBao); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip, |
| | | acceptData, hongBao); |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip, acceptData, |
| | | hongBao); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip, |
| | | acceptData, hongBao); |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip, acceptData, |
| | | hongBao); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip, |
| | | acceptData, hongBao); |
| | |
| | | * @param signList |
| | | */ |
| | | private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType, |
| | | List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData, BigDecimal hongBao) throws Exception { |
| | | List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData, BigDecimal hongBao) |
| | | throws Exception { |
| | | |
| | | // 是否免单商品 |
| | | boolean freeOrder = false; |
| | |
| | | } |
| | | |
| | | // 使用奖励券 金额额限制 |
| | | if (hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) > 0){ |
| | | if (hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) > 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 是否可使用奖励券 |
| | | if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType |
| | | && HongBaoV2.STATE_YILINGQU == hongBaoState && !vip && CommonOrder.STATE_WQ != order.getState()) { |
| | |
| | | orderStateMap.put("fontColor", "#666666"); |
| | | order.setOrderState(orderStateMap); |
| | | |
| | | |
| | | // 订单标识 |
| | | List<String> signList = new ArrayList<String>(); |
| | | /* 订单返利类型 转换 */ |
| | |
| | | order.setOrderOrigin("3"); |
| | | order.setHongBaoTypePic(CommonOrder.TYPE_INVITE); |
| | | signList.add(CommonOrder.TYPE_INVITE); |
| | | |
| | | // 红包加上补贴金额 |
| | | InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderNo, |
| | | sourceType); |
| | | if (orderSubsidy != null && orderSubsidy.getMoney() != null) { |
| | | BigDecimal subsidyMoney = orderSubsidy.getMoney(); |
| | | // 维权金额 |
| | | InviteOrderSubsidyDebt subsidyDebt = inviteOrderSubsidyDebtService |
| | | .getBySourceId(orderSubsidy.getId()); |
| | | if (subsidyDebt != null && subsidyDebt.getOriginMoney() != null) { |
| | | subsidyMoney = subsidyMoney.subtract(subsidyDebt.getOriginMoney()); |
| | | } |
| | | // 最终补贴 |
| | | if (subsidyMoney.compareTo(new BigDecimal(0)) > 0) { |
| | | hongBao = hongBao.add(subsidyMoney); |
| | | } |
| | | } |
| | | } |
| | | order.setSignList(signList); |
| | | |
| | |
| | | order.setAccountState(stateMap); |
| | | |
| | | Map<String, String> hongBaoMap = new HashMap<String, String>(); |
| | | hongBaoMap.put("content", hongBaoState_Str + "收益 ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString()); |
| | | hongBaoMap.put("content", |
| | | hongBaoState_Str + "收益 ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString()); |
| | | hongBaoMap.put("fontColor", hongbaoInfoFontColor); |
| | | order.setHongBaoInfo(hongBaoMap); |
| | | |
| | |
| | | text = "免单中"; |
| | | } else if (UserSystemCouponRecord.STATE_SUCCESS == state) { |
| | | text = "已免单"; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | |
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.HongBaoDTO;
|
| | | import com.yeshi.fanli.dto.order.HongBaoAddResult;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException, UserAccountException {
|
| | | public HongBaoAddResult addHongBao(List<CommonOrder> commonOrderList, int type)
|
| | | throws HongBaoException, UserAccountException {
|
| | | Set<Integer> stateSet = new HashSet<>();// 订单状态Set
|
| | | if (commonOrderList != null && commonOrderList.size() > 0) {
|
| | | int orderType = commonOrderList.get(0).getSourceType();
|
| | |
|
| | | boolean miandan = false;
|
| | | Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
|
| | | int goodsCount = 0;
|
| | | boolean hasAdd = false;
|
| | |
| | | throw new HongBaoException(1, "订单信息不完整");
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder == null) {
|
| | | saveHongBao(commonOrder, type, notificationMap);
|
| | | miandan = saveHongBao(commonOrder, type, notificationMap);
|
| | | hasAdd = true;
|
| | | } else {
|
| | | boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
|
| | |
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money,new BigDecimal(0), goodsCount, commonOrder.getState(),
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,new BigDecimal(0),
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | |
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money,new BigDecimal(0), goodsCount, commonOrder.getState(),
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | |
| | |
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,new BigDecimal(0),
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | int resultCode = 0;
|
| | | if (hasAdd && hasUpdate)
|
| | | return 12;
|
| | | return new HongBaoAddResult(HongBaoAddResult.CODE_ADD_AND_UPDATE, miandan);
|
| | | else if (hasAdd)
|
| | | return 1;
|
| | | return new HongBaoAddResult(HongBaoAddResult.CODE_ADD, miandan);
|
| | | else if (hasUpdate)
|
| | | return 2;
|
| | | return resultCode;
|
| | | return new HongBaoAddResult(HongBaoAddResult.CODE_UPDATE, miandan);
|
| | | return new HongBaoAddResult(resultCode, miandan);
|
| | | }
|
| | | return 0;
|
| | | return new HongBaoAddResult(0, false);
|
| | | }
|
| | |
|
| | | private int getOrderState(Set<Integer> states) {
|
| | |
| | | return false;
|
| | |
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,commonOrder.getCreateTime().getTime());
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime());
|
| | | // 免单处理
|
| | | boolean mianDan = false;
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
|
| | |
| | | && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))
|
| | | fanliRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
|
| | | else
|
| | | fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,commonOrder.getCreateTime().getTime());
|
| | | fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime());
|
| | |
|
| | | List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
|
| | | .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
|
| | |
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
|
| | | private boolean saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
|
| | | throws HongBaoException, UserAccountException {
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,commonOrder.getCreateTime().getTime());
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime());
|
| | | // 查询是否有免单计划
|
| | | BigDecimal mianDanMoney = null;
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | |
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | if (firstRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | return mianDanMoney != null;
|
| | | HongBaoV2 firstHongbao = new HongBaoV2();
|
| | | firstHongbao.setUserInfo(boss);
|
| | | firstHongbao.setUrank(boss.getRank());
|
| | |
| | | }
|
| | | // 返利为0的不通知
|
| | | if (firstHongbao.getMoney() == null || firstHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | return mianDanMoney != null;
|
| | |
|
| | | hongBaoV2Mapper.insertSelective(firstHongbao);
|
| | | // 用户通知
|
| | |
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | if (secondRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | return mianDanMoney != null;
|
| | | HongBaoV2 secondHongbao = new HongBaoV2();
|
| | | secondHongbao.setUserInfo(boss);
|
| | | secondHongbao.setUrank(boss.getRank());
|
| | |
| | |
|
| | | // 返利为0的不统计
|
| | | if (secondHongbao.getMoney() == null || secondHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | return mianDanMoney != null;
|
| | |
|
| | | hongBaoV2Mapper.insertSelective(secondHongbao);
|
| | |
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | return mianDanMoney != null;
|
| | | } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | // 分享赚不加入失效的订单
|
| | | if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
|
| | | return;
|
| | | return false;
|
| | | // 分享赚
|
| | | BigDecimal shareRate = null;
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
|
| | | && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))// 来自于淘礼金的分享
|
| | | shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
|
| | | else
|
| | | shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,commonOrder.getCreateTime().getTime());
|
| | | shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime());
|
| | |
|
| | | // 判断订单分享活动是否开启
|
| | | if ("1".equalsIgnoreCase(configService.get(ConfigKeyEnum.shareGoodsActivityOpen.getKey()))) {
|
| | |
| | | }
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.InviteOrderSubsidyMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.manger.user.UserLevelManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | |
|
| | | @Service
|
| | | public class InviteOrderSubsidyServiceImpl implements InviteOrderSubsidyService {
|
| | | @Resource
|
| | | private InviteOrderSubsidyMapper inviteOrderSubsidyMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMapService orderHongBaoMapService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserLevelManager userLevelManager;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Override
|
| | | public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.getByOrderNoAndType(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public InviteOrderSubsidy getByOrderNoAndTypeForUpdate(Long uid, String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.getByOrderNoAndTypeForUpdate(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<InviteOrderSubsidy> listByOrderNoAndType(String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.listByOrderNoAndType(orderNo, type);
|
| | | }
|
| | |
|
| | | private void addOrderSubsidy(InviteOrderSubsidy orderSubsidy)
|
| | | throws InviteOrderSubsidyException, CommonOrderException {
|
| | | if (orderSubsidy.getMoney() == null || StringUtil.isNullOrEmpty(orderSubsidy.getOrderNo())
|
| | | || orderSubsidy.getSourceType() == null || orderSubsidy.getUid() == null)
|
| | | throw new InviteOrderSubsidyException(1, "数据不完整");
|
| | | InviteOrderSubsidy old = getByOrderNoAndType(orderSubsidy.getUid(), orderSubsidy.getOrderNo(),
|
| | | orderSubsidy.getSourceType());
|
| | | if (old != null) {// 修改
|
| | | if (old.getState() == InviteOrderSubsidy.STATE_INVALID
|
| | | || old.getState() == InviteOrderSubsidy.STATE_SUBSIDIZED)
|
| | | return;
|
| | |
|
| | | // 修改状态
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(old.getId());
|
| | | update.setMoney(orderSubsidy.getMoney());
|
| | | if (old.getState() == InviteOrderSubsidy.STATE_UNKNOWN) {// 状态未确定之前才可以更改原始补贴资金
|
| | | update.setOriginalMoney(orderSubsidy.getOriginalMoney());
|
| | | }
|
| | | update.setState(orderSubsidy.getState());
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | } else {// 添加
|
| | | if (orderSubsidy.getCreateTime() == null)
|
| | | orderSubsidy.setCreateTime(new Date());
|
| | | inviteOrderSubsidyMapper.insertSelective(orderSubsidy);
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType) throws InviteOrderSubsidyException {
|
| | | List<HongBaoOrder> list = hongBaoOrderService.listByOrderIdAndSourceType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0) {
|
| | | // 必须是自购订单才返利
|
| | | HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId());
|
| | | if (parent != null
|
| | | && (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {//
|
| | |
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
|
| | | if (orderList == null || orderList.size() == 0)
|
| | | throw new InviteOrderSubsidyException(10, "订单为空");
|
| | | CommonOrder firstOrder = orderList.get(0);
|
| | | Date placeOrderTime = firstOrder.getThirdCreateTime();
|
| | |
|
| | | if (placeOrderTime.getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME)
|
| | | return;
|
| | |
|
| | | int urank = firstOrder.getUrank();
|
| | | UserLevelEnum buyerUserLevel = UserLevelUtil.getByOrderRank(urank);
|
| | | if (buyerUserLevel == null)
|
| | | throw new InviteOrderSubsidyException(11, "用户等级为空");
|
| | |
|
| | | List<Long> idList = new ArrayList<>();
|
| | | for (HongBaoOrder ho : list)
|
| | | if (ho.getHongBaoV2() != null)
|
| | | idList.add(ho.getHongBaoV2().getId());
|
| | | // 查询该订单号下的所有子红包
|
| | | List<HongBaoV2> children = hongBaoV2Service.listChildrenByIds(idList);
|
| | | if (children != null && children.size() > 0) {
|
| | | Map<Long, Integer> uidHongBaoMap = new ConcurrentHashMap<>();
|
| | | for (HongBaoV2 v2 : children) {// 按用户ID统计红包
|
| | | Long uid = v2.getUserInfo().getId();
|
| | | if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | uidHongBaoMap.put(uid, v2.getType());
|
| | | }
|
| | | }
|
| | |
|
| | | List<HongBaoV2> hbList = hongBaoV2Service.listByIds(idList);
|
| | | Integer state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | |
|
| | | // 产生改订单的返利总金额
|
| | | BigDecimal totalBuyFanLiMoney = new BigDecimal(0);
|
| | | // 计算总返利
|
| | | for (HongBaoV2 v2 : hbList) {
|
| | | if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | totalBuyFanLiMoney = totalBuyFanLiMoney.add(v2.getMoney());
|
| | | }
|
| | |
|
| | | // 计算奖励金
|
| | | for (Iterator<Long> its = uidHongBaoMap.keySet().iterator(); its.hasNext();) {
|
| | | Long uid = its.next();
|
| | | UserLevelEnum userLevel = userLevelManager.getUserLevel(uid, placeOrderTime);
|
| | |
|
| | | int type = uidHongBaoMap.get(uid);
|
| | | if (type == HongBaoV2.TYPE_YIJI || type == HongBaoV2.TYPE_ERJI
|
| | | || type == HongBaoV2.TYPE_SHARE_YIJI || type == HongBaoV2.TYPE_SHARE_ERJI) {
|
| | | BigDecimal money = null;
|
| | | if (type == HongBaoV2.TYPE_YIJI || type == HongBaoV2.TYPE_SHARE_YIJI)
|
| | | money = orderHongBaoMoneyComputeService.computeFirstTeamSubsidy(totalBuyFanLiMoney,
|
| | | placeOrderTime, buyerUserLevel, userLevel);
|
| | | else
|
| | | money = orderHongBaoMoneyComputeService.computeSecondTeamSubsidy(totalBuyFanLiMoney,
|
| | | placeOrderTime, buyerUserLevel, userLevel);
|
| | |
|
| | | if (money == null)
|
| | | continue;
|
| | |
|
| | | InviteOrderSubsidy orderSubsidy = new InviteOrderSubsidy();
|
| | | orderSubsidy.setMoney(money);
|
| | | orderSubsidy.setOriginalMoney(money);
|
| | | orderSubsidy.setUid(uid);
|
| | | orderSubsidy.setOrderNo(orderId);
|
| | | orderSubsidy.setSourceType(sourceType);
|
| | | orderSubsidy.setState(state);
|
| | | if (type == HongBaoV2.TYPE_YIJI || type == HongBaoV2.TYPE_SHARE_YIJI)
|
| | | orderSubsidy.setLevel(InviteOrderSubsidy.LEVEL_ONE);
|
| | | else
|
| | | orderSubsidy.setLevel(InviteOrderSubsidy.LEVEL_TWO);
|
| | |
|
| | | try {
|
| | | addOrderSubsidy(orderSubsidy);
|
| | | } catch (CommonOrderException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | boolean isSettle = false;
|
| | | if (orderList != null)
|
| | | for (CommonOrder commonOrder : orderList) {
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS
|
| | | || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | isSettle = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (isSettle) {
|
| | | validByOrderIdAndSourceType(orderId, sourceType);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | return inviteOrderSubsidyMapper.countByOrderNoAndType(orderId, sourceType);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void invalidByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | List<InviteOrderSubsidy> list = inviteOrderSubsidyMapper.listByOrderNoAndType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0)
|
| | | for (InviteOrderSubsidy subsidy : list) {
|
| | | if (subsidy.getState() == InviteOrderSubsidy.STATE_UNKNOWN
|
| | | || subsidy.getState() == InviteOrderSubsidy.STATE_VALID) {
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId());
|
| | | update.setState(InviteOrderSubsidy.STATE_INVALID);
|
| | | update.setUpdateTime(new Date());
|
| | | update.setInValidTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void validByOrderIdAndSourceType(String orderId, int sourceType) throws InviteOrderSubsidyException {
|
| | | // 查询预计到账时间
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
|
| | | if (orderList == null || orderList.size() == 0)
|
| | | throw new InviteOrderSubsidyException(31, "订单不存在");
|
| | |
|
| | | if (orderList.get(0).getSettleTime() == null)
|
| | | throw new InviteOrderSubsidyException(32, "订单尚未确认收货");
|
| | |
|
| | | // 确认收货时间的下月25号到账
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(orderList.get(0).getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | Date preGetTime = new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd"));
|
| | |
|
| | | List<InviteOrderSubsidy> list = inviteOrderSubsidyMapper.listByOrderNoAndType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0)
|
| | | for (InviteOrderSubsidy subsidy : list) {
|
| | | if (subsidy.getState() == InviteOrderSubsidy.STATE_UNKNOWN) {
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId());
|
| | | update.setState(InviteOrderSubsidy.STATE_VALID);
|
| | | update.setUpdateTime(new Date());
|
| | | update.setValidTime(new Date());
|
| | | update.setPreGetTime(preGetTime);
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void settleById(Long id, BigDecimal money) {
|
| | | InviteOrderSubsidy orderSubsidy = new InviteOrderSubsidy(id);
|
| | | orderSubsidy.setMoney(money);
|
| | | orderSubsidy.setState(InviteOrderSubsidy.STATE_SUBSIDIZED);
|
| | | orderSubsidy.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(orderSubsidy);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal sumRecievedMoneyByUid(long uid, Integer level) {
|
| | | BigDecimal money = inviteOrderSubsidyMapper.sumRecievedMoneyByUid(uid, level);
|
| | | if (money == null) {
|
| | | money = new BigDecimal(0);
|
| | | }
|
| | | return money;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal sumValidMoneyByUidAndDate(long uid, Integer day, Integer level) {
|
| | | BigDecimal money = inviteOrderSubsidyMapper.sumValidMoneyByUidAndDate(uid, day, level);
|
| | | if (money == null) {
|
| | | money = new BigDecimal(0);
|
| | | }
|
| | | return money;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal sumMoneyByUidAndDateAndState(long uid, Integer day, Integer level, Integer state) {
|
| | | BigDecimal money = inviteOrderSubsidyMapper.sumMoneyByUidAndDateAndState(uid, day, level, state);
|
| | | if (money == null) {
|
| | | money = new BigDecimal(0);
|
| | | }
|
| | | return money;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<InviteOrderSubsidy> listByOrderNoAndTypeAndUid(String orderNo, Integer type, Long uid) {
|
| | | return inviteOrderSubsidyMapper.listByOrderNoAndTypeAndUid(orderNo, type, uid);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer) {
|
| | | BigDecimal rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_6", order.getThirdCreateTime().getTime());
|
| | | if (buyer == UserLevelEnum.superVIP || buyer == UserLevelEnum.tearcher)
|
| | | rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_vip_6", order.getThirdCreateTime().getTime());
|
| | |
|
| | | if (rate.compareTo(new BigDecimal(0)) == 0)
|
| | | return null;
|
| | |
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer) {
|
| | | if (buyer == UserLevelEnum.superVIP || buyer == UserLevelEnum.tearcher)
|
| | | return null;
|
| | |
|
| | | BigDecimal rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_7", order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeFirstTeamSubsidy(BigDecimal fanLiMoney, Date placeOrderTime, UserLevelEnum buyerUserLevel,
|
| | | UserLevelEnum userLevel) {
|
| | | BigDecimal rate = getTeamSubsidyRate(placeOrderTime, buyerUserLevel, userLevel, true);
|
| | | if (rate == null || rate.compareTo(new BigDecimal(0)) == 0)
|
| | | return null;
|
| | | BigDecimal baseRate = hongBaoManageService.getBaseFanliRate(placeOrderTime.getTime());
|
| | | BigDecimal officialSubsidyRate = getOfficialSubsidyRate(placeOrderTime, buyerUserLevel, false);
|
| | | return MoneyBigDecimalUtil.div(fanLiMoney.multiply(baseRate).multiply(rate),
|
| | | baseRate.add(officialSubsidyRate).multiply(new BigDecimal(100)));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeSecondTeamSubsidy(BigDecimal fanLiMoney, Date placeOrderTime, UserLevelEnum buyerUserLevel,
|
| | | UserLevelEnum userLevel) {
|
| | | BigDecimal rate = getTeamSubsidyRate(placeOrderTime, buyerUserLevel, userLevel, false);
|
| | | if (rate == null || rate.compareTo(new BigDecimal(0)) == 0)
|
| | | return null;
|
| | | BigDecimal baseRate = hongBaoManageService.getBaseFanliRate(placeOrderTime.getTime());
|
| | | BigDecimal officialSubsidyRate = getOfficialSubsidyRate(placeOrderTime, buyerUserLevel, false);
|
| | | return MoneyBigDecimalUtil.div(fanLiMoney.multiply(baseRate).multiply(rate),
|
| | | baseRate.add(officialSubsidyRate).multiply(new BigDecimal(100)));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取粉丝的补贴比例
|
| | | * @Title: getSecondTeamSubsidy
|
| | | * @Description: |
| | | * @param date
|
| | | * @param buyerUserLevel
|
| | | * @param userLevel
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | @Override
|
| | | public BigDecimal getTeamSubsidyRate(Date date, UserLevelEnum buyerUserLevel, UserLevelEnum userLevel,
|
| | | boolean direct) {
|
| | | String key = null;
|
| | | if (direct)
|
| | | key = String.format("team_subsidy_6_pre_%s_%s", buyerUserLevel.getLevel(), userLevel.getLevel());
|
| | | else
|
| | | key = String.format("team_subsidy_7_pre_%s_%s", buyerUserLevel.getLevel(), userLevel.getLevel());
|
| | | public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer,
|
| | | List<UserTeamLevel> bossLevelList) {
|
| | | BigDecimal rate = null;
|
| | | if (date != null)
|
| | | rate = hongBaoManageService.getByKeyAndMaxTime(key, date.getTime());
|
| | | else
|
| | | rate = new BigDecimal(hongBaoManageService.get(key));
|
| | | return rate;
|
| | | if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
|
| | | rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 1).getRate();
|
| | | if (rate == null)
|
| | | return null;
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | } else {// 老的返利比例
|
| | | rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_6", order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer,
|
| | | List<UserTeamLevel> bossLevelList) {
|
| | | BigDecimal rate = null;
|
| | | if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
|
| | | rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 2).getRate();
|
| | | if (rate == null)
|
| | | return null;
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | } else {// 老的返利比例
|
| | | rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_7", order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return rate;
|
| | | }
|
| | |
|
| | | private BigDecimal getRateByLevel(UserLevelEnum level) {
|
| | | if (level == UserLevelEnum.daRen)
|
| | | return new BigDecimal(58);
|
| | | else if (level == UserLevelEnum.normalVIP)
|
| | | return new BigDecimal(66);
|
| | | else if (level == UserLevelEnum.highVIP)
|
| | | return new BigDecimal(78);
|
| | | else if (level == UserLevelEnum.superVIP)
|
| | | return new BigDecimal(85);
|
| | | else if (level == UserLevelEnum.tearcher)
|
| | | return new BigDecimal(86);
|
| | | return null;
|
| | | private BigDecimal getRateByLevel(UserLevelEnum level, Date date) {
|
| | | BigDecimal baseRate = hongBaoManageService.getBaseFanliRate(date.getTime());
|
| | |
|
| | | BigDecimal subsidyRate = getOfficialSubsidyRate(date, level, false);
|
| | |
|
| | | return baseRate.add(subsidyRate);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserTeamRate getTeamRewardRate(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList,
|
| | | public UserTeamRate getTeamRewardRate(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList, Date date,
|
| | | int deep) {
|
| | | if (deep == 1) {// 直接邀请人奖金
|
| | | UserTeamLevel boss = bossLevelList.get(0);
|
| | |
| | | } else if (buyerLevel == UserLevelEnum.normalVIP && boss.getLevel() == UserLevelEnum.normalVIP) {
|
| | | rate = new BigDecimal(9);
|
| | | } else {
|
| | | BigDecimal bossRate = getRateByLevel(boss.getLevel());
|
| | | BigDecimal buyerRate = getRateByLevel(buyerLevel);
|
| | | BigDecimal bossRate = getRateByLevel(boss.getLevel(), date);
|
| | | BigDecimal buyerRate = getRateByLevel(buyerLevel, date);
|
| | | rate = bossRate.subtract(buyerRate);
|
| | | if (rate.compareTo(new BigDecimal(0)) < 0)
|
| | | rate = new BigDecimal(0);
|
| | |
| | | if (bossLevelList == null || bossLevelList.size() < 2)
|
| | | return null;
|
| | |
|
| | | BigDecimal buyerRate = getRateByLevel(buyerLevel);
|
| | | BigDecimal firstRate = getTeamRewardRate(buyerLevel, bossLevelList, 1).getRate();
|
| | | BigDecimal buyerRate = getRateByLevel(buyerLevel, date);
|
| | | BigDecimal firstRate = getTeamRewardRate(buyerLevel, bossLevelList, date, 1).getRate();
|
| | |
|
| | | UserTeamLevel boss = bossLevelList.get(1);
|
| | | UserTeamLevel firstBoss = bossLevelList.get(0);
|
| | |
| | | }
|
| | | // 极差计算法
|
| | | if (rate == null) {
|
| | | rate = getRateByLevel(boss.getLevel()).subtract(buyerRate).subtract(firstRate);
|
| | | rate = getRateByLevel(boss.getLevel(), date).subtract(buyerRate).subtract(firstRate);
|
| | | if (rate.compareTo(new BigDecimal(0)) < 0)
|
| | | rate = new BigDecimal(0);
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | public List<UserTeamRate> getTeamRewardMoreThan2LevelRates(UserLevelEnum buyerLevel,
|
| | | List<UserTeamLevel> bossLevelList) {
|
| | | List<UserTeamLevel> bossLevelList, Date date) {
|
| | | if (bossLevelList == null || bossLevelList.size() < 3)
|
| | | return null;
|
| | |
|
| | | UserTeamRate firstBoss = getTeamRewardRate(buyerLevel, bossLevelList, 1);
|
| | | UserTeamRate firstBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 1);
|
| | | if (firstBoss == null)
|
| | | return null;
|
| | | UserTeamRate secondBoss = getTeamRewardRate(buyerLevel, bossLevelList, 2);
|
| | | UserTeamRate secondBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 2);
|
| | | if (secondBoss == null)
|
| | | return null;
|
| | |
|
| | | BigDecimal buyerRate = getRateByLevel(buyerLevel);
|
| | | BigDecimal buyerRate = getRateByLevel(buyerLevel, date);
|
| | |
|
| | | BigDecimal totalRate = firstBoss.getRate().add(secondBoss.getRate()).add(buyerRate);
|
| | |
|
| | | List<UserTeamRate> rateList = new ArrayList<>();
|
| | |
|
| | | for (int i = 2; i < bossLevelList.size(); i++) {
|
| | | BigDecimal rate = getRateByLevel(bossLevelList.get(i).getLevel());
|
| | | BigDecimal rate = getRateByLevel(bossLevelList.get(i).getLevel(), date);
|
| | | if (rate.compareTo(totalRate) > 0) {
|
| | | BigDecimal subRate = rate.subtract(totalRate);
|
| | | totalRate = subRate.add(totalRate);// 累计分成比例
|
| | |
| | |
|
| | | // 团队分红
|
| | | @Override
|
| | | public List<UserTeamRate> getTeamDividentsRates(UserLevelEnum buyerLevel,
|
| | | List<UserTeamLevel> bossLevelList) {
|
| | | public List<UserTeamRate> getTeamDividentsRates(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList,
|
| | | Date date) {
|
| | | List<UserTeamRate> rateList = new ArrayList<>();
|
| | |
|
| | | List<UserTeamLevel> levelList = new ArrayList<>();
|
| | |
| | |
|
| | | @Override
|
| | | public UserTeamRate getTearcherSubsidy(UserLevelEnum buyerLevel, BigDecimal money,
|
| | | List<UserTeamLevel> bossLevelList) {
|
| | | List<UserTeamLevel> bossLevelList, Date date) {
|
| | | // TODO Auto-generated method stub
|
| | | return null;
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.manger.order.TeamRewardManager;
|
| | | import com.yeshi.fanli.service.manger.order.TeamSubsidyManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
|
| | |
| | | @Resource
|
| | | private TeamRewardManager teamRewardManager;
|
| | |
|
| | | @Resource
|
| | | private TeamSubsidyManager teamSubsidyManager;
|
| | |
|
| | | // 下级被封禁,红包失效
|
| | | private void invalidHongBaoForbidden(Long id) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请补贴结算
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @throws ParamsException |
| | | * @throws TeamEincomeRecordException |
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void inviteSubsidySettle(Long uid, String taskKey, Date maxPreGetTime)
|
| | | throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException {
|
| | | teamSubsidyManager.addToTeamEincome(uid, taskKey, maxPreGetTime);
|
| | | }
|
| | |
|
| | | private String getTaskKey(Long uid) {
|
| | | return uid + "-" + UUID.randomUUID().toString();
|
| | |
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
|
| | | import com.yeshi.fanli.dto.order.HongBaoAddResult;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
|
| | | import com.yeshi.fanli.entity.elme.ElmeOrder;
|
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | |
| | | private void addHongBaoWithMQ(List<CommonOrderAddResultDTO> commonOrderList, String orderId, Long uid,
|
| | | int sourceType, int hongBaoType) {
|
| | | final List<CommonOrder> coList = convertCommonOrder(commonOrderList);
|
| | | int resultCode = 0;
|
| | | HongBaoAddResult result = null;
|
| | | try {
|
| | | long time = TimeUtil.convertToTimeTemp("2019-12-06", "yyyy-MM-dd");
|
| | | if (!Constant.IS_TEST)
|
| | | time = TimeUtil.convertToTimeTemp("2019-12-20", "yyyy-MM-dd");
|
| | |
|
| | | if (coList.get(0).getThirdCreateTime().getTime() < time)
|
| | | resultCode = hongBaoV2Service.addHongBao(coList, hongBaoType);
|
| | | result = hongBaoV2Service.addHongBao(coList, hongBaoType);
|
| | | else
|
| | | resultCode = hongBaoV2AddManager.addHongBao(coList, hongBaoType);
|
| | | result = hongBaoV2AddManager.addHongBao(coList, hongBaoType);
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + orderId);
|
| | |
| | |
|
| | | }
|
| | | if (!Constant.IS_TEST)
|
| | | if (resultCode == 1) {// 只发送新增消息
|
| | | if (result.getResultCode() == HongBaoAddResult.CODE_ADD) {// 只发送新增消息
|
| | | OrderMQMsg mqMsg = new OrderMQMsg(orderId, sourceType, uid, OrderMQMsg.HANDLE_TYPE_ADD,
|
| | | isCommonOrderValid(coList), 0, new Date());
|
| | | isCommonOrderValid(coList), 0, new Date(), result.isMiandan());
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderStatistic, mqMsg);
|
| | | producer.send(msg);
|
| | | }
|
| | |
| | | public TeamDividentsSourceOrder addTeamDividentsSourceOrder(TeamDividentsSourceOrder order)
|
| | | throws TeamDividentsSourceOrderException, ParamsException {
|
| | | if (order == null || order.getMoney() == null || StringUtil.isNullOrEmpty(order.getOrderNo())
|
| | | || order.getSourceType() == null || order.getState() == null || order.getUid() == null
|
| | | || order.getPreSendTime() == null)
|
| | | || order.getSourceType() == null || order.getState() == null || order.getUid() == null)
|
| | | throw new ParamsException(1, "参数不完整");
|
| | |
|
| | | TeamDividentsSourceOrder sourceOrder = selectByOrderNoSourceType(order.getOrderNo(), order.getSourceType());
|
| | |
| | | TeamDividentsSourceOrderUserMap update = new TeamDividentsSourceOrderUserMap();
|
| | | update.setId(id);
|
| | | update.setState(TeamDividentsSourceOrderUserMap.STATE_YILINGQU);
|
| | | update.setSendTime(new Date());
|
| | | update.setUpdateTime(new Date());
|
| | | teamDividentsSourceOrderUserMapMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void invalidOrderBySourceUid(Long sourceUid, String beiZhu) {
|
| | | List<Integer> stateList = new ArrayList<>();
|
| | | stateList.add(TeamDividentsSourceOrderUserMap.STATE_FK);
|
| | | stateList.add(TeamDividentsSourceOrderUserMap.STATE_JS);
|
| | | teamDividentsSourceOrderUserMapMapper.invalidOrderBySourceUid(sourceUid, beiZhu, stateList);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void orderSettle(Long sourceOrderId, Date preSendTime, BigDecimal income) {
|
| | |
| | |
|
| | | TeamDividentsSourceOrderUserMap update = new TeamDividentsSourceOrderUserMap();
|
| | | update.setId(map.getId());
|
| | | update.setMoney(MoneyBigDecimalUtil.div(income.multiply(map.getRate()), new BigDecimal(100), 4));
|
| | | update.setMoney(MoneyBigDecimalUtil.div(income.multiply(map.getRate()), new BigDecimal(100), 3));
|
| | | update.setUpdateTime(new Date());
|
| | | update.setState(TeamDividentsSourceOrderUserMap.STATE_JS);
|
| | | update.setPreSendTime(preSendTime);
|
| | | teamDividentsSourceOrderUserMapMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | |
| | | if (map.getState() == TeamDividentsSourceOrderUserMap.STATE_FK) {
|
| | | TeamDividentsSourceOrderUserMap update = new TeamDividentsSourceOrderUserMap();
|
| | | update.setId(map.getId());
|
| | | update.setMoney(MoneyBigDecimalUtil.div(income.multiply(map.getRate()), new BigDecimal(100), 4));
|
| | | update.setMoney(MoneyBigDecimalUtil.div(income.multiply(map.getRate()), new BigDecimal(100), 3));
|
| | | update.setUpdateTime(new Date());
|
| | | teamDividentsSourceOrderUserMapMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.user.vip;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private TeamUserLevelStatisticMapper teamUserLevelStatisticMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInviteValidRecordService userInviteValidRecordService;
|
| | | |
| | |
|
| | | @Override
|
| | | public TeamUserLevelStatistic selectByUid(Long uid) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TeamUserLevelStatistic> listByUids(List<Long> uids) {
|
| | |
|
| | | List<TeamUserLevelStatistic> resultList = new ArrayList<>();
|
| | |
|
| | | List<TeamUserLevelStatistic> list = teamUserLevelStatisticMapper.listByUids(uids);
|
| | | // 放入Map中
|
| | | Map<Long, TeamUserLevelStatistic> map = new HashMap<>();
|
| | | if (list != null)
|
| | | for (TeamUserLevelStatistic s : list) {
|
| | | map.put(s.getId(), s);
|
| | | }
|
| | |
|
| | | for (Long uid : uids) {
|
| | | if (map.get(uid) == null) {
|
| | | initData(uid);
|
| | | TeamUserLevelStatistic statistic = selectByUid(uid);
|
| | | resultList.add(statistic);
|
| | | } else {
|
| | | resultList.add(map.get(uid));
|
| | | }
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void initData(Long uid) {
|
| | | int pageSize = 1000;
|
| | | |
| | |
|
| | | // 直接粉丝统计
|
| | | int daRenFirstCount = 0;
|
| | | int highFirstCount = 0;
|
| | | int superFirstCount = 0;
|
| | | int tearcherFirstCount = 0;
|
| | | for (int i = 0; i < 100; i ++) {
|
| | | for (int i = 0; i < 100; i++) {
|
| | | List<UserInviteValidRecord> list = userInviteValidRecordService.listFirstTeam(i * pageSize, pageSize, uid);
|
| | | if (list == null || list.size() == 0) {
|
| | | break;
|
| | | }
|
| | | |
| | |
|
| | | for (UserInviteValidRecord ts : list) {
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(ts.getWorkerId());
|
| | | if (level == UserLevelEnum.daRen) {
|
| | | daRenFirstCount++;
|
| | | } else if (level == UserLevelEnum.highVIP) {
|
| | | } else if (level == UserLevelEnum.highVIP) {
|
| | | highFirstCount++;
|
| | | } else if (level == UserLevelEnum.superVIP) {
|
| | | superFirstCount++;
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | // 间接粉丝统计
|
| | | int daRenSecondCount = 0;
|
| | | int highSecondCount = 0;
|
| | | int superSecondCount = 0;
|
| | | int tearcherSecondCount = 0;
|
| | | for (int i = 0; i < 100; i ++) {
|
| | | for (int i = 0; i < 100; i++) {
|
| | | List<UserInviteValidRecord> list = userInviteValidRecordService.listSecondTeam(i * pageSize, pageSize, uid);
|
| | | if (list == null || list.size() == 0) {
|
| | | break;
|
| | | }
|
| | | |
| | |
|
| | | for (UserInviteValidRecord ts : list) {
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(ts.getWorkerId());
|
| | | if (level == UserLevelEnum.daRen) {
|
| | |
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.dto.HongBaoDTO;
|
| | | import com.yeshi.fanli.dto.order.HongBaoAddResult;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | |
| | | * @return 0-未添加也未更新 1-只添加 2-只更新 12-有添加也有更新
|
| | | * @throws HongBaoException
|
| | | */
|
| | | public int addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException,UserAccountException ;
|
| | | public HongBaoAddResult addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException,UserAccountException ;
|
| | |
|
| | | /**
|
| | | * 奖金列表(1.4.9之前的版本)
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | |
|
| | | public interface InviteOrderSubsidyService {
|
| | |
|
| | |
| | | * @return
|
| | | */
|
| | | public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type);
|
| | | |
| | | |
| | | public List<InviteOrderSubsidy> listByOrderNoAndType(String orderNo, Integer type);
|
| | | |
| | | |
| | | public List<InviteOrderSubsidy> listByOrderNoAndTypeAndUid(String orderNo, Integer type,Long uid);
|
| | |
|
| | | /**
|
| | | * 查询补贴(加锁)
|
| | | * @param uid
|
| | | * @param orderNo
|
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | public InviteOrderSubsidy getByOrderNoAndTypeForUpdate(Long uid, String orderNo, Integer type);
|
| | |
|
| | | /**
|
| | | * 添加或修改(按照订单号与来源)
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType)
|
| | | throws InviteOrderSubsidyException, CommonOrderException;
|
| | |
|
| | | /**
|
| | | * 根据订单号与来源查询
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @return
|
| | | */
|
| | | public long countByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | /**
|
| | | * 使订单号对应的数据失效
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void invalidByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | /**
|
| | | * 使订单号对应的数据有效
|
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void validByOrderIdAndSourceType(String orderId, int sourceType) throws InviteOrderSubsidyException;
|
| | |
|
| | | /**
|
| | | * 结算金额
|
| | | * @param id
|
| | | * @param money
|
| | | */
|
| | | public void settleById(Long id, BigDecimal money);
|
| | |
|
| | | /**
|
| | | * 统计已到账金额
|
| | | * @param uid
|
| | | * @param level
|
| | | * @return
|
| | | */
|
| | | public BigDecimal sumRecievedMoneyByUid(long uid, Integer level);
|
| | |
|
| | | /**
|
| | | * 统计有效金额
|
| | | * @param uid
|
| | | * @param day
|
| | | * @param level
|
| | | * @return
|
| | | */
|
| | | public BigDecimal sumValidMoneyByUidAndDate(long uid, Integer day, Integer level);
|
| | |
|
| | | public BigDecimal sumMoneyByUidAndDateAndState(long uid, Integer day, Integer level, Integer state);
|
| | | }
|
| | |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer);
|
| | | public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer,
|
| | | List<UserTeamLevel> bossLevelList);
|
| | |
|
| | | /**
|
| | | * 计算间接粉丝邀请奖金
|
| | |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer);
|
| | |
|
| | | /**
|
| | | * 计算直接粉丝团队补贴
|
| | | * @Title: computeFirstTeamSubsidy
|
| | | * @Description: |
| | | * @param order
|
| | | * @param buyerUserLevel
|
| | | * @param userLevel
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal computeFirstTeamSubsidy(BigDecimal fanLiMoney, Date placeOrderTime, UserLevelEnum buyerUserLevel,
|
| | | UserLevelEnum userLevel);
|
| | |
|
| | | /**
|
| | | * 计算间接粉丝团队补贴
|
| | | * @Title: computeSecondTeamSubsidy
|
| | | * @Description: |
| | | * @param order
|
| | | * @param buyerUserLevel
|
| | | * @param userLevel
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | |
|
| | | public BigDecimal computeSecondTeamSubsidy(BigDecimal fanLiMoney, Date placeOrderTime, UserLevelEnum buyerUserLevel,
|
| | | UserLevelEnum userLevel);
|
| | |
|
| | | /**
|
| | | * 计算团队补贴
|
| | | * @param date 下单时间
|
| | | * @param buyerUserLevel 下单时 下单人当时等级
|
| | | * @param userLevel 下单时 上级人对应等级
|
| | | * @param direct 是否直接邀请关系
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getTeamSubsidyRate(Date date, UserLevelEnum buyerUserLevel, UserLevelEnum userLevel,
|
| | | boolean direct);
|
| | | public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer,
|
| | | List<UserTeamLevel> bossLevelList);
|
| | |
|
| | | /**
|
| | | * 获取团队奖金
|
| | |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public UserTeamRate getTeamRewardRate(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList,
|
| | | public UserTeamRate getTeamRewardRate(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList, Date date,
|
| | | int deep);
|
| | |
|
| | | /**
|
| | |
| | | * @throws
|
| | | */
|
| | | public List<UserTeamRate> getTeamRewardMoreThan2LevelRates(UserLevelEnum buyerLevel,
|
| | | List<UserTeamLevel> bossLevelList);
|
| | | List<UserTeamLevel> bossLevelList, Date date);
|
| | |
|
| | | /**
|
| | | * 获取分红
|
| | |
| | | * List<UserTeamMoney> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public List<UserTeamRate> getTeamDividentsRates(UserLevelEnum buyerLevel,
|
| | | List<UserTeamLevel> bossLevelList);
|
| | | public List<UserTeamRate> getTeamDividentsRates(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList,
|
| | | Date date);
|
| | |
|
| | | /**
|
| | | * 获取资深导师 补贴
|
| | |
| | | * UserTeamMoney 返回类型
|
| | | * @throws
|
| | | */
|
| | | public UserTeamRate getTearcherSubsidy(UserLevelEnum buyerLevel, BigDecimal rate,
|
| | | List<UserTeamLevel> bossLevelList);
|
| | | public UserTeamRate getTearcherSubsidy(UserLevelEnum buyerLevel, BigDecimal rate, List<UserTeamLevel> bossLevelList,
|
| | | Date date);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | |
|
| | | /**
|
| | | * 订单资金结算服务
|
| | |
| | | * @param sourceType
|
| | | */
|
| | | public void ziGouSettle(String orderId, int sourceType, String taskKey) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 邀请补贴结算
|
| | | * @param uid
|
| | | * @param taskKey
|
| | | * @throws OrderMoneySettleException
|
| | | */
|
| | | public void inviteSubsidySettle(Long uid, String taskKey, Date maxPreGetTime)
|
| | | throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException;
|
| | |
|
| | | }
|
| | |
| | | public void invalidBySourceOrderId(Long sourceOrderId);
|
| | |
|
| | | /**
|
| | | * 用户对应的订单失效
|
| | | * @Title: invalidOrderBySourceUid
|
| | | * @Description: |
| | | * @param sourceUid |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void invalidOrderBySourceUid(Long sourceUid,String beiZhu);
|
| | |
|
| | | /**
|
| | | * 订单结算
|
| | | * @Title: orderSettle
|
| | | * @Description:
|
| | |
| | | package com.yeshi.fanli.service.inter.user.vip;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
|
| | |
|
| | | /**
|
| | |
| | | public TeamUserLevelStatistic selectByUid(Long uid);
|
| | |
|
| | | /**
|
| | | * 根据列表查询
|
| | | * @Title: selectByUids
|
| | | * @Description: |
| | | * @param uid
|
| | | * @return |
| | | * List<TeamUserLevelStatistic> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public List<TeamUserLevelStatistic> listByUids(List<Long> uids);
|
| | |
|
| | | /**
|
| | | * 初始化数据
|
| | | * @Title: initData
|
| | | * @Description:
|
| | |
| | | package com.yeshi.fanli.service.manger.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.order.HongBaoAddResult;
|
| | | import com.yeshi.fanli.dto.order.UserTeamLevel;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | 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.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.manger.user.UserLevelManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private TeamUserLevelStatisticService teamUserLevelStatisticService;
|
| | |
|
| | | /**
|
| | | * 添加红包信息
|
| | | *
|
| | |
| | | * @throws OrderTeamRewardException
|
| | | * @throws InviteOrderSubsidyException
|
| | | */
|
| | | public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException, UserAccountException {
|
| | | public HongBaoAddResult addHongBao(List<CommonOrder> commonOrderList, int type)
|
| | | throws HongBaoException, UserAccountException {
|
| | |
|
| | | if (commonOrderList != null && commonOrderList.size() > 0) {
|
| | | int orderType = commonOrderList.get(0).getSourceType();
|
| | |
| | |
|
| | | Date placeOrderDate = commonOrderList.get(0).getThirdCreateTime();
|
| | |
|
| | | boolean miandan = false;
|
| | |
|
| | | for (CommonOrder commonOrder : commonOrderList) {
|
| | | stateSet.add(commonOrder.getState());
|
| | | goodsCount += commonOrder.getCount();
|
| | |
| | | throw new HongBaoException(1, "订单信息不完整");
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder == null) {
|
| | | saveHongBao(commonOrder, type, notificationMap, userLevel, placeOrderDate);
|
| | | miandan = saveHongBao(commonOrder, type, notificationMap, userLevel, placeOrderDate);
|
| | | hasAdd = true;
|
| | | } else {
|
| | | boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap, placeOrderDate);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | if (hasAdd) {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | throw new HongBaoException(201, "添加补贴出错");
|
| | | } catch (CommonOrderException e) {
|
| | | throw new HongBaoException(202, "添加补贴出错");
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | int state = getOrderState(stateSet);
|
| | |
|
| | | if (hasAdd || hasUpdate) {
|
| | | // 补贴失效
|
| | | if (state == CommonOrder.STATE_SX)
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(orderId, orderType);
|
| | | else
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | LogHelper.errorDetailInfo(e, "淘宝订单补贴更新失败", orderId);
|
| | | } catch (CommonOrderException e) {
|
| | | LogHelper.errorDetailInfo(e, "淘宝订单补贴更新失败", orderId);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通知用户的返利情况
|
| | |
| | | CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
|
| | | Long uid = notify.getUserInfo().getId();
|
| | |
|
| | | List<InviteOrderSubsidy> subsidyList = inviteOrderSubsidyService.listByOrderNoAndTypeAndUid(orderId,
|
| | | orderType, uid);
|
| | | BigDecimal subsidy = new BigDecimal(0);
|
| | | if (subsidyList != null)
|
| | | for (InviteOrderSubsidy s : subsidyList) {
|
| | | if (s.getState() != InviteOrderSubsidy.STATE_INVALID)
|
| | | subsidy = subsidy.add(s.getOriginalMoney());
|
| | | }
|
| | |
|
| | | BigDecimal money = notify.getMoney();
|
| | | switch (t) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | |
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
| | |
|
| | | int resultCode = 0;
|
| | | if (hasAdd && hasUpdate)
|
| | | return 12;
|
| | | return new HongBaoAddResult(HongBaoAddResult.CODE_ADD_AND_UPDATE, miandan);
|
| | | else if (hasAdd)
|
| | | return 1;
|
| | | return new HongBaoAddResult(HongBaoAddResult.CODE_ADD, miandan);
|
| | | else if (hasUpdate)
|
| | | return 2;
|
| | | return resultCode;
|
| | | return new HongBaoAddResult(HongBaoAddResult.CODE_UPDATE, miandan);
|
| | | return new HongBaoAddResult(resultCode, miandan);
|
| | | }
|
| | | return 0;
|
| | | return new HongBaoAddResult(0, false);
|
| | | }
|
| | |
|
| | | private int getOrderState(Set<Integer> states) {
|
| | |
| | | return CommonOrder.STATE_JS;
|
| | | }
|
| | | return CommonOrder.STATE_SX;
|
| | | }
|
| | |
|
| | | private List<UserTeamLevel> getBossList(Long uid, int deep) {
|
| | | List<UserTeamLevel> resultList = new ArrayList<>();
|
| | | List<ThreeSale> threeSales = threeSaleSerivce.getMyBossDeepList(uid, deep);
|
| | |
|
| | | if (threeSales != null) {
|
| | | List<Long> uidList = new ArrayList<Long>();
|
| | | for (ThreeSale ts : threeSales)
|
| | | uidList.add(ts.getBoss().getId());
|
| | | List<TeamUserLevelStatistic> levelList = teamUserLevelStatisticService.listByUids(uidList);
|
| | | if (levelList != null)
|
| | | for (TeamUserLevelStatistic s : levelList) {
|
| | | resultList.add(new UserTeamLevel(s.getId(), s.getLevel()));
|
| | | }
|
| | | }
|
| | |
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
|
| | |
| | | // 获取子红包
|
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null && children.size() > 0) {
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | |
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | continue;
|
| | |
|
| | | if (child.getType() == HongBaoV2.TYPE_YIJI) {
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel,
|
| | | bossList);
|
| | | } else if (child.getType() == HongBaoV2.TYPE_ERJI) {
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel,
|
| | | bossList);
|
| | | }
|
| | |
|
| | | HongBaoV2 childUpdate = createInviteUpdateHongBao(child, hongBao.getState(), money, commonOrder);
|
| | |
| | | }
|
| | |
|
| | | if (boss != null) {
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | |
|
| | | // 插入一级子红包
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel,
|
| | | bossList);
|
| | | UserLevelEnum bossUserLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | if (money != null) {
|
| | | HongBaoV2 firstHongbao = createInviteHongBao(boss.getId(), oldHongBao, commonOrder,
|
| | |
| | | }
|
| | | if (boss != null) {
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder,
|
| | | buyerLevel);
|
| | | buyerLevel, bossList);
|
| | | bossUserLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | if (money != null) {
|
| | | HongBaoV2 secondHongbao = createInviteHongBao(boss.getId(), oldHongBao, commonOrder,
|
| | |
| | |
|
| | | // 获取子红包
|
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null)
|
| | | if (children != null && children.size() > 0) {
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | continue;
|
| | |
|
| | | if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel,
|
| | | bossList);
|
| | | } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel,
|
| | | bossList);
|
| | | }
|
| | | HongBaoV2 childUpdate = createInviteUpdateHongBao(child, hongBao.getState(), money, commonOrder);
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap,
|
| | | private boolean saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap,
|
| | | UserLevelEnum buyerLevel, Date placeOrderDate) throws HongBaoException, UserAccountException {
|
| | |
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {
|
| | |
| | | orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, buyerLevel), mianDanMoney,
|
| | | buyerLevel);
|
| | | if (hongBao == null)
|
| | | return;
|
| | | return mianDanMoney != null;
|
| | | addFanLiOrShareHongBao(hongBao, commonOrder, notificationMap);
|
| | | UserInfo boss = threeSaleSerivce.getBoss(hongBao.getUserInfo().getId());
|
| | | if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO && mianDanMoney == null) {// 1级BOSS存在且红包未失效,免单不支持多级分销
|
| | | BigDecimal money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | |
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | |
|
| | | BigDecimal money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel,
|
| | | bossList);
|
| | | if (money == null)// 返利资金为空不参与分成
|
| | | return;
|
| | | return mianDanMoney != null;
|
| | |
|
| | | UserLevelEnum bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | |
|
| | |
| | | // 插入二级子红包
|
| | | boss = threeSaleSerivce.getBoss(boss.getId());
|
| | | if (boss != null) {// 二级BOSS存在且是非会员订单
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel, bossList);
|
| | | bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | if (money == null)
|
| | | return;
|
| | | return mianDanMoney != null;
|
| | | HongBaoV2 secondHongbao = createInviteHongBao(boss.getId(), hongBao, commonOrder,
|
| | | HongBaoV2.TYPE_ERJI, money, bossLevel);
|
| | | addInviteHongBao(secondHongbao, null, notificationMap, commonOrder);
|
| | |
| | | } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | // 分享赚不加入失效的订单
|
| | | if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
|
| | | return;
|
| | | return false;
|
| | | // 分享赚
|
| | | BigDecimal money = null;
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
|
| | |
| | | money = orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, buyerLevel);
|
| | |
|
| | | if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | return false;
|
| | | HongBaoV2 hongBao = createShareHongBao(commonOrder, money, buyerLevel);
|
| | | if (hongBao == null)
|
| | | return;
|
| | | return false;
|
| | | addFanLiOrShareHongBao(hongBao, commonOrder, notificationMap);
|
| | | // 4月17日后才有一级分享赚
|
| | | if (placeOrderDate.getTime() > TimeUtil.convertToTimeTemp("2019-04-17", "yyyy-MM-dd")) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(hongBao.getUserInfo().getId());
|
| | | if (boss != null) {
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | |
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | |
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel, bossList);
|
| | | if (money == null)
|
| | | return;
|
| | | return false;
|
| | | UserLevelEnum bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | HongBaoV2 firstHongbao = createInviteHongBao(boss.getId(), hongBao, commonOrder,
|
| | | HongBaoV2.TYPE_SHARE_YIJI, money, bossLevel);
|
| | |
| | | // 二级分享赚
|
| | | boss = threeSaleSerivce.getBoss(boss.getId());
|
| | | if (boss != null) {
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel,
|
| | | bossList);
|
| | | if (money == null)// 返利比例为0就不统计
|
| | | return;
|
| | | return false;
|
| | | bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | HongBaoV2 secondChild = createInviteHongBao(boss.getId(), hongBao, commonOrder,
|
| | | HongBaoV2.TYPE_SHARE_ERJI, money, bossLevel);
|
| | |
| | | // }
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | package com.yeshi.fanli.service.manger.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | if (commonOrderList.get(0).getThirdCreateTime().getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME)
|
| | | return;
|
| | |
|
| | | Date placeOrderTime = commonOrderList.get(0).getThirdCreateTime();
|
| | |
|
| | | UserLevelEnum level = UserLevelUtil.getByOrderRank(commonOrderList.get(0).getUrank());
|
| | | if (level == null)
|
| | | level = UserLevelEnum.daRen;
|
| | |
| | | return;
|
| | |
|
| | | // 计算团队分红比例
|
| | | List<UserTeamRate> rateList = orderHongBaoMoneyComputeService.getTeamDividentsRates(level, bossList);
|
| | | List<UserTeamRate> rateList = orderHongBaoMoneyComputeService.getTeamDividentsRates(level, bossList,
|
| | | placeOrderTime);
|
| | | if (rateList != null)
|
| | | for (UserTeamRate rate : rateList) {
|
| | | BigDecimal money = MoneyBigDecimalUtil.div(rate.getRate().multiply(order.getMoney()),
|
| | |
| | | }
|
| | | }
|
| | | // 计算二级外分红比例
|
| | | rateList = orderHongBaoMoneyComputeService.getTeamRewardMoreThan2LevelRates(level, bossList);
|
| | | rateList = orderHongBaoMoneyComputeService.getTeamRewardMoreThan2LevelRates(level, bossList, placeOrderTime);
|
| | | if (rateList != null)
|
| | | for (UserTeamRate rate : rateList) {
|
| | | BigDecimal money = MoneyBigDecimalUtil.div(rate.getRate().multiply(order.getMoney()),
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void invalidBySourceUid(Long sourceUid, String beiZhu) {
|
| | | // teamDividentsSourceOrderService.invalidOrderByUid(sourceUid, beiZhu);
|
| | | teamDividentsSourceOrderUserMapService.invalidOrderBySourceUid(sourceUid, beiZhu);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单结算
|
| | | * @Title: orderSettle
|
| | |
| | | "4c7b166fecb6d9f53837e993f2214673", "", "");
|
| | |
|
| | | // 新的规则生效时间
|
| | | public static final long NEW_ORDER_FANLI_RULE_TIME = TimeUtil.convertToTimeTemp("2020-04-18", "yyyy-MM-dd");
|
| | | public static final long NEW_ORDER_FANLI_RULE_TIME = TimeUtil.convertToTimeTemp("2020-04-14", "yyyy-MM-dd");
|
| | |
|
| | | // 使用奖励券最大金额限制
|
| | | public static final BigDecimal REWARD_COUPON_LIMIT_MONEY = new BigDecimal("10");
|
| | |
| | | public class TeamDividentsSourceOrderFactory {
|
| | |
|
| | | public static TeamDividentsSourceOrder create(List<CommonOrder> commonOrderList) {
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | BigDecimal money = null;
|
| | | int orderState = CommonOrderUtil.getState(commonOrderList);
|
| | | if (orderState == CommonOrder.STATE_SX)
|
| | | return null;
|
| | |
|
| | | if (orderState == CommonOrder.STATE_FK) {
|
| | | money = CommonOrderUtil.computeEstimate(commonOrderList);
|
| | | } else {
|
| | | money = CommonOrderUtil.computeIncome(commonOrderList);
|
| | | }
|
| | |
|
| | | if (money.compareTo(new BigDecimal(0)) <= 0)
|
| | | return null;
|
| | |
|
| | |
| | | public class OrderDividentsMessageListener implements MessageListener {
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceOrderService teamDividentsSourceOrderService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | |
| | | // 查询上级红包
|
| | | UserForbiddenMQMsg dto = new Gson().fromJson(new String(message.getBody()), UserForbiddenMQMsg.class);
|
| | | if (dto != null) {
|
| | | teamDividentsSourceOrderService.invalidOrderByUid(dto.getUid(), "用户被封禁");
|
| | | teamDividentsSourceManager.invalidBySourceUid(dto.getUid(), "用户被封禁");
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | |
| | | <beans xmlns="http://www.springframework.org/schema/beans"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
| | | <bean id="inviteOrderSubsidyMsgListener"
|
| | | class="com.yeshi.fanli.util.rocketmq.consumer.order.InviteOrderSubsidyMessageListener"></bean> <!--Listener 配置 -->
|
| | | <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean -->
|
| | | <bean id="inviteOrderSubsidyConsumer" 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_INVITE_ORDER_SUBSIDY</prop>
|
| | | <prop key="NAMESRV_ADDR">${rocketmq.NAMESRV_ADDR}</prop>
|
| | | <!--将消费者线程数固定为 50 个 <prop key="ConsumeThreadNums">50</prop> -->
|
| | | </props>
|
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <!-- 订单补贴订阅 -->
|
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression"
|
| | | value="orderStatistic||orderUpdate||teamRewardPreRecieved" /><!--expression |
| | | 即 Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 -->
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | |
|
| | | <!-- 板栗商城订单消息订阅 -->
|
| | | <bean id="banLiShopOrderMessageListener"
|
| | |
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_USER" />
|
| | | <property name="expression"
|
| | | value="userLevelChanged||threeSaleSeparate" />
|
| | | <property name="expression" value="userLevelChanged||threeSaleSeparate" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | |
|
| | | <!-- 订单到账 订单收货-->
|
| | | <!-- 订单到账 订单收货 -->
|
| | | <entry value-ref="userVIPMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | |
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression" value="orderConfirm||taoBaoOrderWeiQuan" />
|
| | | <property name="expression" value="orderStatistic||taoBaoOrderWeiQuan" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|