2个文件已删除
32个文件已修改
15个文件已添加
| | |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.ESOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyServiceV2;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | |
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyServiceV2 inviteOrderSubsidyServiceV2;
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyServiceV2;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
| | | package com.yeshi.fanli.dao.mybatis.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | | List<InviteOrderSubsidyDebt> listByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney,
|
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid, @Param("start") long start,
|
| | | List<InviteOrderSubsidyDebt> listByLeftMoneyAndUidAndMaxEstimatePayTime(@Param("minMoney") BigDecimal minMoney,
|
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid,
|
| | | @Param("maxEstimatePayTime") Date maxEstimatePayTime, @Param("start") long start,
|
| | | @Param("count") int count);
|
| | |
|
| | | /**
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | long countByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney, @Param("maxMoney") BigDecimal maxMoney,
|
| | | @Param("uid") Long uid);
|
| | | long countByLeftMoneyAndUidAndMaxEstimatePayTime(@Param("minMoney") BigDecimal minMoney,
|
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid,
|
| | | @Param("maxEstimatePayTime") Date maxEstimatePayTime);
|
| | |
|
| | | InviteOrderSubsidyDebt selectByPrimaryKeyForUpdate(Long id);
|
| | |
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | BigDecimal sumLeftMoneyByUid(Long uid);
|
| | | BigDecimal sumLeftMoneyByUid(@Param("uid")Long uid,@Param("maxEstimatePayTime")Date maxEstimatePayTime);
|
| | |
|
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | List<TeamDividentsDebt> listByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney, |
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid, @Param("start") long start, |
| | | List<TeamDividentsDebt> listByLeftMoneyAndUidAndMaxEstimatePayTime(@Param("minMoney") BigDecimal minMoney, |
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid, |
| | | @Param("maxEstimatePayTime") Date maxEstimatePayTime, @Param("start") long start, |
| | | @Param("count") int count); |
| | | |
| | | /** |
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | long countByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney, @Param("maxMoney") BigDecimal maxMoney, |
| | | @Param("uid") Long uid); |
| | | long countByLeftMoneyAndUidAndMaxEstimatePayTime(@Param("minMoney") BigDecimal minMoney, |
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid, |
| | | @Param("maxEstimatePayTime") Date maxEstimatePayTime); |
| | | |
| | | TeamDividentsDebt selectByPrimaryKeyForUpdate(Long id); |
| | | |
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | BigDecimal sumLeftMoneyByUid(Long uid); |
| | | |
| | | BigDecimal sumLeftMoneyByUid(@Param("uid") Long uid, @Param("maxEstimatePayTime") Date maxEstimatePayTime); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord; |
| | | |
| | | public interface TeamEincomeRecordMapper extends BaseMapper<TeamEincomeRecord> { |
| | | |
| | | TeamEincomeRecord selectByUidAndPreRecieveTimeAndType(Long uid, Date preRecieveTime, int type); |
| | | |
| | | TeamEincomeRecord selectByPrimaryKeyForUpdate(Long id); |
| | | |
| | | List<TeamEincomeRecord> listByUidAndPreRecieveTimeAndState(Long uid, Date preRecieveTime, int state); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import com.yeshi.fanli.dao.BaseMapper;
|
| | | import com.yeshi.fanli.entity.money.TeamRewardDebt;
|
| | |
|
| | | public interface TeamRewardDebtMapper extends BaseMapper<TeamRewardDebt> {
|
| | |
|
| | | /**
|
| | | * 检索(根据剩余资金与用户ID)
|
| | | * |
| | | * @param minMoney
|
| | | * @param maxMoney
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | | List<TeamRewardDebt> listByLeftMoneyAndUidAndMaxEstimatePayTime(@Param("minMoney") BigDecimal minMoney,
|
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid,@Param("maxEstimatePayTime")Date maxEstimatePayTime, @Param("start") long start,
|
| | | @Param("count") int count);
|
| | |
|
| | | /**
|
| | | * 检索(根据剩余资金与用户ID)
|
| | | * |
| | | * @param minMoney
|
| | | * @param maxMoney
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | long countByLeftMoneyAndUidAndMaxEstimatePayTime(@Param("minMoney") BigDecimal minMoney, @Param("maxMoney") BigDecimal maxMoney,
|
| | | @Param("uid") Long uid,@Param("maxEstimatePayTime")Date maxEstimatePayTime);
|
| | |
|
| | | TeamRewardDebt selectByPrimaryKeyForUpdate(Long id);
|
| | |
|
| | | /**
|
| | | * 计算欠款金额(根据用户ID)
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | BigDecimal sumLeftMoneyByUid (@Param("uid") Long uid,@Param("maxEstimatePayTime") Date maxEstimatePayTime);
|
| | | |
| | | |
| | | TeamRewardDebt selectBySourceId(Long sourceId);
|
| | |
|
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money;
|
| | |
|
| | | import com.yeshi.fanli.dao.BaseMapper;
|
| | | import com.yeshi.fanli.entity.money.TeamRewardDebtRepayHistory;
|
| | |
|
| | | public interface TeamRewardDebtRepayHistoryMapper extends BaseMapper<TeamRewardDebtRepayHistory> {
|
| | |
|
| | | } |
| | |
| | | banLiShopOrderDelay(BanLiShopOrderMQMsg.class), // 板栗商城下单
|
| | | banLiShopOrderRefund(BanLiShopOrderMQMsg.class), // 板栗商城订单退款
|
| | | banLiShopOrderPaid(BanLiShopOrderMQMsg.class), // 商城订单支付成功
|
| | | taoBaoOrderWeiQuan(TaoBaoWeiQuanOrder.class);// 淘宝维权订单
|
| | | taoBaoOrderWeiQuan(TaoBaoWeiQuanOrder.class),// 淘宝维权订单
|
| | | teamRewardPreRecieved(OrderMoneyRecievedMQMsg.class);//团队奖金预到账
|
| | |
|
| | | private final Class<?> clazz;
|
| | |
|
| | |
| | | @Column(name = "tuls_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | @Column(name = "tuls_daren_first_count")
|
| | | private Integer daRenFirstCount;
|
| | | @Column(name = "tuls_daren_second_count")
|
| | | private Integer daRenSecondCount;
|
| | |
|
| | | public Integer getDaRenFirstCount() {
|
| | | return daRenFirstCount;
|
| | | }
|
| | |
|
| | | public void setDaRenFirstCount(Integer daRenFirstCount) {
|
| | | this.daRenFirstCount = daRenFirstCount;
|
| | | }
|
| | |
|
| | | public Integer getDaRenSecondCount() {
|
| | | return daRenSecondCount;
|
| | | }
|
| | |
|
| | | public void setDaRenSecondCount(Integer daRenSecondCount) {
|
| | | this.daRenSecondCount = daRenSecondCount;
|
| | | }
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
| | | private Date updateTime;
|
| | | @Column(name = "sd_trade_id")
|
| | | private String tradeId;
|
| | | @Column(name = "sd_estimate_pay_time")
|
| | | private Date estimatePayTime;
|
| | |
|
| | | public InviteOrderSubsidyDebt(Long uid, BigDecimal originMoney, Long sourceId, String tradeId,
|
| | | Date estimatePayTime) {
|
| | | this.uid = uid;
|
| | | this.originMoney = originMoney;
|
| | | this.sourceId = sourceId;
|
| | | this.tradeId = tradeId;
|
| | | this.estimatePayTime = estimatePayTime;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public InviteOrderSubsidyDebt() {
|
| | | |
| | | }
|
| | |
|
| | | public Date getEstimatePayTime() {
|
| | | return estimatePayTime;
|
| | | }
|
| | |
|
| | | public void setEstimatePayTime(Date estimatePayTime) {
|
| | | this.estimatePayTime = estimatePayTime;
|
| | | }
|
| | |
|
| | | public String getTradeId() {
|
| | | return tradeId;
|
| | |
| | | */
|
| | | @Table("yeshi_ec_team_income")
|
| | | public class TeamEincomeRecord {
|
| | |
|
| | | public final static int TYPE_TEAM_REWARD = 1;// 团队奖金
|
| | | public final static int TYPE_TEAM_SUBSIDY = 2;// 团队补贴
|
| | | public final static int TYPE_TEAM_DIVIDENTS = 3;// 团队分红
|
| | |
|
| | | public final static int STATE_RECIEVED = 2;// 已经领取
|
| | | public final static int STATE_NOT_RECIEVE = 1;// 未领取
|
| | |
|
| | | @Column(name = "ti_id")
|
| | | private Long id;
|
| | | @Column(name = "ti_uid")
|
New file |
| | |
| | | package com.yeshi.fanli.entity.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 团队奖金欠账
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_team_reward_debt")
|
| | | public class TeamRewardDebt {
|
| | | @Column(name = "rd_id")
|
| | | private Long id;
|
| | | @Column(name = "rd_uid")
|
| | | private Long uid;
|
| | | @Column(name = "rd_origin_money")
|
| | | private BigDecimal originMoney;
|
| | | @Column(name = "rd_left_money")
|
| | | private BigDecimal leftMoney;
|
| | | @Column(name = "rd_source_id")
|
| | | private Long sourceId;
|
| | | @Column(name = "rd_beizhu")
|
| | | private String beiZhu;
|
| | | @Column(name = "rd_create_time")
|
| | | private Date createTime;
|
| | | @Column(name = "rd_update_time")
|
| | | private Date updateTime;
|
| | | @Column(name = "rd_trade_id")
|
| | | private String tradeId;
|
| | | @Column(name = "rd_estimate_pay_time")
|
| | | private Date estimatePayTime;//预计偿还时间
|
| | |
|
| | | public TeamRewardDebt(Long uid, BigDecimal originMoney, Long sourceId, String beiZhu, Date createTime,
|
| | | String tradeId, Date estimatePayTime) {
|
| | | this.uid = uid;
|
| | | this.originMoney = originMoney;
|
| | | this.sourceId = sourceId;
|
| | | this.beiZhu = beiZhu;
|
| | | this.createTime = createTime;
|
| | | this.tradeId = tradeId;
|
| | | this.estimatePayTime = estimatePayTime;
|
| | | }
|
| | | |
| | | public TeamRewardDebt() {
|
| | | |
| | | }
|
| | |
|
| | | public Date getEstimatePayTime() {
|
| | | return estimatePayTime;
|
| | | }
|
| | |
|
| | | public void setEstimatePayTime(Date estimatePayTime) {
|
| | | this.estimatePayTime = estimatePayTime;
|
| | | }
|
| | |
|
| | | public String getTradeId() {
|
| | | return tradeId;
|
| | | }
|
| | |
|
| | | public void setTradeId(String tradeId) {
|
| | | this.tradeId = tradeId;
|
| | | }
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public BigDecimal getOriginMoney() {
|
| | | return originMoney;
|
| | | }
|
| | |
|
| | | public void setOriginMoney(BigDecimal originMoney) {
|
| | | this.originMoney = originMoney;
|
| | | }
|
| | |
|
| | | public BigDecimal getLeftMoney() {
|
| | | return leftMoney;
|
| | | }
|
| | |
|
| | | public void setLeftMoney(BigDecimal leftMoney) {
|
| | | this.leftMoney = leftMoney;
|
| | | }
|
| | |
|
| | | public Long getSourceId() {
|
| | | return sourceId;
|
| | | }
|
| | |
|
| | | public void setSourceId(Long sourceId) {
|
| | | this.sourceId = sourceId;
|
| | | }
|
| | |
|
| | | public String getBeiZhu() {
|
| | | return beiZhu;
|
| | | }
|
| | |
|
| | | public void setBeiZhu(String beiZhu) {
|
| | | this.beiZhu = beiZhu;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 订单补贴欠账还款记录
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_team_reward_debt_repay_history")
|
| | | public class TeamRewardDebtRepayHistory {
|
| | | @Column(name = "rh_id")
|
| | | private Long id;
|
| | | @Column(name = "rh_debt_id")
|
| | | private TeamRewardDebt debt;
|
| | | @Column(name = "rh_money")
|
| | | private BigDecimal money;
|
| | | @Column(name = "rh_uid")
|
| | | private Long uid;
|
| | | @Column(name = "rh_beizhu")
|
| | | private String beiZhu;
|
| | | @Column(name = "rh_create_time")
|
| | | private Date createTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public TeamRewardDebt getDebt() {
|
| | | return debt;
|
| | | }
|
| | |
|
| | | public void setDebt(TeamRewardDebt debt) {
|
| | | this.debt = debt;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public String getBeiZhu() {
|
| | | return beiZhu;
|
| | | }
|
| | |
|
| | | public void setBeiZhu(String beiZhu) {
|
| | | this.beiZhu = beiZhu;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
| | |
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import jxl.write.DateTime;
|
| | |
|
| | | /**
|
| | | * 邀请订单补贴
|
| | | *
|
| | |
| | |
|
| | | @Table("yeshi_ec_order_team_dividents_debt")
|
| | | public class TeamDividentsDebt {
|
| | | @Column(name="tdd_id")
|
| | | @Column(name = "tdd_id")
|
| | | private Long id;
|
| | | @Column(name="tdd_uid")
|
| | | @Column(name = "tdd_uid")
|
| | | private Long uid;
|
| | | @Column(name="tdd_origin_money")
|
| | | @Column(name = "tdd_origin_money")
|
| | | private BigDecimal originMoney;
|
| | | @Column(name="tdd_left_money")
|
| | | @Column(name = "tdd_left_money")
|
| | | private BigDecimal leftMoney;
|
| | | @Column(name="tdd_order_no")
|
| | | @Column(name = "tdd_order_no")
|
| | | private String orderNo;
|
| | | @Column(name="tdd_source_type")
|
| | | @Column(name = "tdd_source_type")
|
| | | private Integer sourceType;
|
| | | @Column(name="tdd_create_time")
|
| | | @Column(name = "tdd_create_time")
|
| | | private Date createTime;
|
| | | @Column(name="tdd_update_time")
|
| | | @Column(name = "tdd_update_time")
|
| | | private Date updateTime;
|
| | | @Column(name = "tdd_estimate_pay_time")
|
| | | private Date estimatePayTime;
|
| | |
|
| | | public TeamDividentsDebt(Long uid, BigDecimal originMoney, String orderNo, Integer sourceType,
|
| | | Date estimatePayTime) {
|
| | | this.uid = uid;
|
| | | this.originMoney = originMoney;
|
| | | this.orderNo = orderNo;
|
| | | this.sourceType = sourceType;
|
| | | this.estimatePayTime = estimatePayTime;
|
| | | }
|
| | |
|
| | | public TeamDividentsDebt() {
|
| | |
|
| | | }
|
| | |
|
| | | public Date getEstimatePayTime() {
|
| | | return estimatePayTime;
|
| | | }
|
| | |
|
| | | public void setEstimatePayTime(Date estimatePayTime) {
|
| | | this.estimatePayTime = estimatePayTime;
|
| | | }
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
New file |
| | |
| | | package com.yeshi.fanli.exception.money;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class TeamRewardDebtException extends BaseException {
|
| | |
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public TeamRewardDebtException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public TeamRewardDebtException() {
|
| | | super();
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | <result column="sd_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="sd_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="sd_trade_id" property="tradeId" jdbcType="VARCHAR" /> |
| | | <result column="sd_estimate_pay_time" property="estimatePayTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time,sd_trade_id</sql> |
| | | <sql id="Base_Column_List">sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time,sd_trade_id,sd_estimate_pay_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_id = #{0} for update |
| | | </select> |
| | | <select id="listByLeftMoneyAndUid" resultMap="BaseResultMap"> |
| | | <select id="listByLeftMoneyAndUidAndMaxEstimatePayTime" |
| | | resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = #{uid} |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = #{uid} and |
| | | #{maxEstimatePayTime}>=sd_estimate_pay_time |
| | | <if test="minMoney!=null">and sd_left_money>=#{minMoney}</if> |
| | | <if test="maxMoney!=null">and #{maxMoney}>sd_left_money</if> |
| | | limit #{start},#{count} |
| | | </select> |
| | | <select id="countByLeftMoneyAndUid" resultType="java.lang.Long"> |
| | | <select id="countByLeftMoneyAndUidAndMaxEstimatePayTime" |
| | | resultType="java.lang.Long"> |
| | | select count(*) from yeshi_ec_invite_order_subsidy_debt where sd_uid = |
| | | #{uid} |
| | | #{uid} and #{maxEstimatePayTime}>=sd_estimate_pay_time |
| | | <if test="minMoney!=null">and sd_left_money>=#{minMoney}</if> |
| | | <if test="maxMoney!=null">and #{maxMoney}>sd_left_money</if> |
| | | </select> |
| | | <select id="sumLeftMoneyByUid" resultType="java.math.BigDecimal" |
| | | parameterType="java.lang.Long">select sum(sd_left_money) from |
| | | yeshi_ec_invite_order_subsidy_debt where sd_uid = #{0}</select> |
| | | <select id="sumLeftMoneyByUid" resultType="java.math.BigDecimal">select |
| | | sum(sd_left_money) from |
| | | yeshi_ec_invite_order_subsidy_debt where sd_uid |
| | | = #{uid} and #{maxEstimatePayTime}>=sd_estimate_pay_time |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_invite_order_subsidy_debt where sd_id = #{id,jdbcType=BIGINT}</delete> |
| | | yeshi_ec_invite_order_subsidy_debt where sd_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_invite_order_subsidy_debt |
| | | (sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time,sd_trade_id) |
| | | (sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time,sd_trade_id,sd_estimate_pay_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{sourceId,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{tradeId,jdbcType=VARCHAR})</insert> |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{sourceId,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{tradeId,jdbcType=VARCHAR},#{estimatePayTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_invite_order_subsidy_debt |
| | |
| | | <if test="createTime != null">sd_create_time,</if> |
| | | <if test="updateTime != null">sd_update_time,</if> |
| | | <if test="tradeId != null">sd_trade_id,</if> |
| | | <if test="estimatePayTime != null">sd_estimate_pay_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR}</if> |
| | | <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR},</if> |
| | | <if test="estimatePayTime != null">#{estimatePayTime,jdbcType=TIMESTAMP}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt">update |
| | |
| | | #{beiZhu,jdbcType=VARCHAR},sd_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},sd_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,sd_trade_id |
| | | =#{tradeId,jdbcType=VARCHAR} where sd_id = #{id,jdbcType=BIGINT}</update> |
| | | =#{tradeId,jdbcType=VARCHAR} ,sd_estimate_pay_time |
| | | =#{estimatePayTime,jdbcType=TIMESTAMP} where sd_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt"> |
| | | update yeshi_ec_invite_order_subsidy_debt |
| | | <set> |
| | |
| | | <if test="createTime != null">sd_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">sd_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tradeId !=null">sd_trade_id =#{tradeId,jdbcType=VARCHAR},</if> |
| | | <if test="estimatePayTime !=null">sd_estimate_pay_time |
| | | =#{estimatePayTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </set> |
| | | where sd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tdd_update_time" property="updateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tdd_estimate_pay_time" property="estimatePayTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">tdd_id,tdd_uid,tdd_origin_money,tdd_left_money,tdd_order_no,tdd_source_type,tdd_create_time,tdd_update_time |
| | | <sql id="Base_Column_List">tdd_id,tdd_uid,tdd_origin_money,tdd_left_money,tdd_order_no,tdd_source_type,tdd_create_time,tdd_update_time,tdd_estimate_pay_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | from yeshi_ec_order_team_dividents_debt where tdd_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_order_team_dividents_debt where tdd_id = #{0} for update |
| | | </select> |
| | | <select id="listByLeftMoneyAndUid" resultMap="BaseResultMap"> |
| | | <select id="listByLeftMoneyAndUidAndMaxEstimatePayTime" |
| | | resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_order_team_dividents_debt where tdd_uid = #{uid} |
| | | from yeshi_ec_order_team_dividents_debt where tdd_uid = #{uid} and |
| | | #{maxEstimatePayTime}>=tdd_estimate_pay_time |
| | | <if test="minMoney!=null">and tdd_left_money>=#{minMoney}</if> |
| | | <if test="maxMoney!=null">and #{maxMoney}>tdd_left_money</if> |
| | | limit #{start},#{count} |
| | | </select> |
| | | <select id="countByLeftMoneyAndUid" resultType="java.lang.Long"> |
| | | select count(*) from yeshi_ec_order_team_dividents_debt where tdd_uid = |
| | | #{uid} |
| | | <select id="countByLeftMoneyAndUidAndMaxEstimatePayTime" |
| | | resultType="java.lang.Long"> |
| | | select count(*) from yeshi_ec_order_team_dividents_debt where tdd_uid |
| | | = #{uid} and #{maxEstimatePayTime}>=tdd_estimate_pay_time |
| | | <if test="minMoney!=null">and tdd_left_money>=#{minMoney}</if> |
| | | <if test="maxMoney!=null">and #{maxMoney}>tdd_left_money</if> |
| | | </select> |
| | | <select id="sumLeftMoneyByUid" resultType="java.math.BigDecimal" |
| | | parameterType="java.lang.Long">select sum(tdd_left_money) from |
| | | yeshi_ec_order_team_dividents_debt where tdd_uid = #{0} |
| | | <select id="sumLeftMoneyByUid" resultType="java.math.BigDecimal">select |
| | | sum(tdd_left_money) from |
| | | yeshi_ec_order_team_dividents_debt where |
| | | tdd_uid = #{uid} and #{maxEstimatePayTime}>=tdd_estimate_pay_time |
| | | </select> |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_order_team_dividents_debt where tdd_id = |
| | | #{id,jdbcType=BIGINT} |
| | |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsDebt" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_order_team_dividents_debt |
| | | (tdd_id,tdd_uid,tdd_origin_money,tdd_left_money,tdd_order_no,tdd_source_type,tdd_create_time,tdd_update_time) |
| | | (tdd_id,tdd_uid,tdd_origin_money,tdd_left_money,tdd_order_no,tdd_source_type,tdd_create_time,tdd_update_time,tdd_estimate_pay_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{estimatePayTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsDebt" |
| | |
| | | <if test="sourceType != null">tdd_source_type,</if> |
| | | <if test="createTime != null">tdd_create_time,</if> |
| | | <if test="updateTime != null">tdd_update_time,</if> |
| | | <if test="estimatePayTime != null">tdd_estimate_pay_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="estimatePayTime != null">#{estimatePayTime,jdbcType=TIMESTAMP}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | |
| | | #{orderNo,jdbcType=VARCHAR},tdd_source_type = |
| | | #{sourceType,jdbcType=INTEGER},tdd_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},tdd_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where tdd_id = #{id,jdbcType=BIGINT} |
| | | #{updateTime,jdbcType=TIMESTAMP} ,tdd_estimate_pay_time |
| | | =#{estimatePayTime,jdbcType=TIMESTAMP} where tdd_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.order.dividents.TeamDividentsDebt"> |
| | |
| | | <if test="sourceType != null">tdd_source_type=#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">tdd_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">tdd_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="estimatePayTime !=null">tdd_estimate_pay_time |
| | | =#{estimatePayTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </set> |
| | | where tdd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.money.TeamEincomeRecordMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.money.TeamEincomeRecord"> |
| | | <id column="ti_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="ti_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="ti_type" property="type" jdbcType="INTEGER" /> |
| | | <result column="ti_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="ti_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="ti_source_type" property="sourceType" jdbcType="INTEGER" /> |
| | | <result column="ti_pre_recieve_time" property="preRecieveTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="ti_recieve_time" property="recieveTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="ti_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="ti_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="ti_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">ti_id,ti_uid,ti_type,ti_money,ti_state,ti_source_type,ti_pre_recieve_time,ti_recieve_time,ti_create_time,ti_update_time,ti_beizhu |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_income where ti_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_team_income where ti_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.TeamEincomeRecord" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_team_income |
| | | (ti_id,ti_uid,ti_type,ti_money,ti_state,ti_source_type,ti_pre_recieve_time,ti_recieve_time,ti_create_time,ti_update_time,ti_beizhu) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{type,jdbcType=INTEGER},#{money,jdbcType=DECIMAL},#{state,jdbcType=INTEGER},#{sourceType,jdbcType=INTEGER},#{preRecieveTime,jdbcType=TIMESTAMP},#{recieveTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{beiZhu,jdbcType=VARCHAR}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.TeamEincomeRecord" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_team_income |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ti_id,</if> |
| | | <if test="uid != null">ti_uid,</if> |
| | | <if test="type != null">ti_type,</if> |
| | | <if test="money != null">ti_money,</if> |
| | | <if test="state != null">ti_state,</if> |
| | | <if test="sourceType != null">ti_source_type,</if> |
| | | <if test="preRecieveTime != null">ti_pre_recieve_time,</if> |
| | | <if test="recieveTime != null">ti_recieve_time,</if> |
| | | <if test="createTime != null">ti_create_time,</if> |
| | | <if test="updateTime != null">ti_update_time,</if> |
| | | <if test="beiZhu != null">ti_beizhu,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="type != null">#{type,jdbcType=INTEGER},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="preRecieveTime != null">#{preRecieveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="recieveTime != null">#{recieveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.TeamEincomeRecord">update |
| | | yeshi_ec_team_income set ti_uid = #{uid,jdbcType=BIGINT},ti_type = |
| | | #{type,jdbcType=INTEGER},ti_money = #{money,jdbcType=DECIMAL},ti_state |
| | | = #{state,jdbcType=INTEGER},ti_source_type = |
| | | #{sourceType,jdbcType=INTEGER},ti_pre_recieve_time = |
| | | #{preRecieveTime,jdbcType=TIMESTAMP},ti_recieve_time = |
| | | #{recieveTime,jdbcType=TIMESTAMP},ti_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},ti_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP},ti_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR} where ti_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.TeamEincomeRecord"> |
| | | update yeshi_ec_team_income |
| | | <set> |
| | | <if test="uid != null">ti_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="type != null">ti_type=#{type,jdbcType=INTEGER},</if> |
| | | <if test="money != null">ti_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="state != null">ti_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="sourceType != null">ti_source_type=#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="preRecieveTime != null">ti_pre_recieve_time=#{preRecieveTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="recieveTime != null">ti_recieve_time=#{recieveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">ti_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">ti_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="beiZhu != null">ti_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | </set> |
| | | where ti_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.money.TeamRewardDebtMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.money.TeamRewardDebt"> |
| | | <id column="rd_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="rd_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="rd_origin_money" property="originMoney" |
| | | jdbcType="DECIMAL" /> |
| | | <result column="rd_left_money" property="leftMoney" jdbcType="DECIMAL" /> |
| | | <result column="rd_source_id" property="sourceId" jdbcType="BIGINT" /> |
| | | <result column="rd_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="rd_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="rd_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="rd_trade_id" property="tradeId" jdbcType="VARCHAR" /> |
| | | <result column="rd_estimate_pay_time" property="estimatePayTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">rd_id,rd_uid,rd_origin_money,rd_left_money,rd_source_id,rd_beizhu,rd_create_time,rd_update_time,rd_trade_id,rd_estimate_pay_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_reward_debt where rd_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_reward_debt where rd_id = #{0} for update |
| | | </select> |
| | | <select id="selectBySourceId" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_reward_debt where rd_source_id = #{0} |
| | | </select> |
| | | <select id="listByLeftMoneyAndUidAndMaxEstimatePayTime" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_reward_debt where rd_uid = #{uid} and |
| | | #{maxEstimatePayTime}>=rd_estimate_pay_time |
| | | <if test="minMoney!=null">and rd_left_money>=#{minMoney}</if> |
| | | <if test="maxMoney!=null">and #{maxMoney}>rd_left_money</if> |
| | | limit #{start},#{count} |
| | | </select> |
| | | <select id="countByLeftMoneyAndUidAndMaxEstimatePayTime" resultType="java.lang.Long"> |
| | | select count(*) from yeshi_ec_team_reward_debt where rd_uid = #{uid} |
| | | and #{maxEstimatePayTime}>=rd_estimate_pay_time |
| | | <if test="minMoney!=null">and rd_left_money>=#{minMoney}</if> |
| | | <if test="maxMoney!=null">and #{maxMoney}>rd_left_money</if> |
| | | </select> |
| | | <select id="sumLeftMoneyByUid" resultType="java.math.BigDecimal">select sum(rd_left_money) from yeshi_ec_team_reward_debt |
| | | where rd_uid = #{uid} and #{maxEstimatePayTime}>=rd_estimate_pay_time |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_team_reward_debt where rd_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.TeamRewardDebt" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_team_reward_debt |
| | | (rd_id,rd_uid,rd_origin_money,rd_left_money,rd_source_id,rd_beizhu,rd_create_time,rd_update_time,rd_trade_id,rd_estimate_pay_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{sourceId,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{tradeId,jdbcType=VARCHAR},#{estimatePayTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.TeamRewardDebt" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_team_reward_debt |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rd_id,</if> |
| | | <if test="uid != null">rd_uid,</if> |
| | | <if test="originMoney != null">rd_origin_money,</if> |
| | | <if test="leftMoney != null">rd_left_money,</if> |
| | | <if test="sourceId != null">rd_source_id,</if> |
| | | <if test="beiZhu != null">rd_beizhu,</if> |
| | | <if test="createTime != null">rd_create_time,</if> |
| | | <if test="updateTime != null">rd_update_time,</if> |
| | | <if test="tradeId != null">rd_trade_id,</if> |
| | | <if test="estimatePayTime != null">rd_estimate_pay_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="sourceId != null">#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR},</if> |
| | | <if test="estimatePayTime != null">#{estimatePayTime,jdbcType=TIMESTAMP}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.TeamRewardDebt">update |
| | | yeshi_ec_team_reward_debt set rd_uid = |
| | | #{uid,jdbcType=BIGINT},rd_origin_money = |
| | | #{originMoney,jdbcType=DECIMAL},rd_left_money = |
| | | #{leftMoney,jdbcType=DECIMAL},rd_source_id = |
| | | #{sourceId,jdbcType=BIGINT},rd_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR},rd_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},rd_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,rd_trade_id |
| | | =#{tradeId,jdbcType=VARCHAR} ,rd_estimate_pay_time |
| | | =#{estimatePayTime,jdbcType=TIMESTAMP} where rd_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.TeamRewardDebt"> |
| | | update yeshi_ec_team_reward_debt |
| | | <set> |
| | | <if test="uid != null">rd_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">rd_origin_money=#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">rd_left_money=#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="sourceId != null">rd_source_id=#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">rd_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">rd_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">rd_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tradeId !=null">rd_trade_id =#{tradeId,jdbcType=VARCHAR},</if> |
| | | <if test="estimatePayTime !=null">rd_estimate_pay_time |
| | | =#{estimatePayTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </set> |
| | | where rd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | |
|
| | | <mapper
|
| | | namespace="com.yeshi.fanli.dao.mybatis.money.TeamRewardDebtRepayHistoryMapper">
|
| | | <resultMap id="BaseResultMap"
|
| | | type="com.yeshi.fanli.entity.money.TeamRewardDebtRepayHistory">
|
| | | <id column="rh_id" property="id" jdbcType="BIGINT" />
|
| | | <result column="rh_money" property="money" jdbcType="DECIMAL" />
|
| | | <result column="rh_uid" property="uid" jdbcType="BIGINT" />
|
| | | <result column="rh_beizhu" property="beiZhu" jdbcType="VARCHAR" />
|
| | | <result column="rh_create_time" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <association property="debt" column="rh_debt_id"
|
| | | javaType="com.yeshi.fanli.entity.money.TeamRewardDebt">
|
| | | <id column="rh_debt_id" property="id" jdbcType="BIGINT" />
|
| | | </association>
|
| | | </resultMap>
|
| | | <sql id="Base_Column_List">rh_id,rh_debt_id,rh_money,rh_uid,rh_beizhu,rh_create_time
|
| | | </sql>
|
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
| | | parameterType="java.lang.Long">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_team_reward_debt_repay_history where rh_id =
|
| | | #{id,jdbcType=BIGINT}
|
| | | </select>
|
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
| | | yeshi_ec_team_reward_debt_repay_history where rh_id =
|
| | | #{id,jdbcType=BIGINT}
|
| | | </delete>
|
| | | <insert id="insert"
|
| | | parameterType="com.yeshi.fanli.entity.money.TeamRewardDebtRepayHistory"
|
| | | useGeneratedKeys="true" keyProperty="id">insert into
|
| | | yeshi_ec_team_reward_debt_repay_history
|
| | | (rh_id,rh_debt_id,rh_money,rh_uid,rh_beizhu,rh_create_time) values
|
| | | (#{id,jdbcType=BIGINT},#{debt.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{uid,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})
|
| | | </insert>
|
| | | <insert id="insertSelective"
|
| | | parameterType="com.yeshi.fanli.entity.money.TeamRewardDebtRepayHistory"
|
| | | useGeneratedKeys="true" keyProperty="id">
|
| | | insert into yeshi_ec_team_reward_debt_repay_history
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | | <if test="id != null">rh_id,</if>
|
| | | <if test="debt != null">rh_debt_id,</if>
|
| | | <if test="money != null">rh_money,</if>
|
| | | <if test="uid != null">rh_uid,</if>
|
| | | <if test="beiZhu != null">rh_beizhu,</if>
|
| | | <if test="createTime != null">rh_create_time,</if>
|
| | | </trim>
|
| | | values
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if>
|
| | | <if test="debt != null">#{debt.id,jdbcType=BIGINT},</if>
|
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if>
|
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
|
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if>
|
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | </trim>
|
| | | </insert>
|
| | | <update id="updateByPrimaryKey"
|
| | | parameterType="com.yeshi.fanli.entity.money.TeamRewardDebtRepayHistory">update yeshi_ec_team_reward_debt_repay_history
|
| | | set
|
| | | rh_debt_id = #{debt.id,jdbcType=BIGINT},rh_money =
|
| | | #{money,jdbcType=DECIMAL},rh_uid = #{uid,jdbcType=BIGINT},rh_beizhu =
|
| | | #{beiZhu,jdbcType=VARCHAR},rh_create_time =
|
| | | #{createTime,jdbcType=TIMESTAMP} where rh_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | <update id="updateByPrimaryKeySelective"
|
| | | parameterType="com.yeshi.fanli.entity.money.TeamRewardDebtRepayHistory">
|
| | | update yeshi_ec_team_reward_debt_repay_history
|
| | | <set>
|
| | | <if test="debt != null">rh_debt_id=#{debt.id,jdbcType=BIGINT},</if>
|
| | | <if test="money != null">rh_money=#{money,jdbcType=DECIMAL},</if>
|
| | | <if test="uid != null">rh_uid=#{uid,jdbcType=BIGINT},</if>
|
| | | <if test="beiZhu != null">rh_beizhu=#{beiZhu,jdbcType=VARCHAR},</if>
|
| | | <if test="createTime != null">rh_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | </set>
|
| | | where rh_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | </mapper>
|
| | |
| | | jdbcType="INTEGER" /> |
| | | <result column="tuls_tearcher_second_count" property="tearcherSecondCount" |
| | | jdbcType="INTEGER" /> |
| | | <result column="tuls_daren_first_count" property="daRenFirstCount" |
| | | jdbcType="INTEGER" /> |
| | | <result column="tuls_daren_second_count" property="daRenSecondCount" |
| | | jdbcType="INTEGER" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time,tuls_tearcher_first_count,tuls_tearcher_second_count |
| | | <sql id="Base_Column_List">tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time,tuls_tearcher_first_count,tuls_tearcher_second_count,tuls_daren_first_count,tuls_daren_second_count |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_team_user_level_statistic where tuls_uid = |
| | | #{id,jdbcType=BIGINT}</delete> |
| | | #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" |
| | | parameterType="com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_team_user_level_statistic |
| | | (tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time,tuls_tearcher_first_count,tuls_tearcher_second_count) |
| | | (tuls_uid,tuls_level,tuls_normal_first_count,tuls_normal_second_count,tuls_high_first_count,tuls_high_second_count,tuls_super_first_count,tuls_super_second_count,tuls_create_time,tuls_update_time,tuls_tearcher_first_count,tuls_tearcher_second_count,tuls_daren_first_count,tuls_daren_second_count) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{level,jdbcType=VARCHAR},#{normalFirstCount,jdbcType=INTEGER},#{normalSecondCount,jdbcType=INTEGER},#{highFirstCount,jdbcType=INTEGER},#{highSecondCount,jdbcType=INTEGER},#{superFirstCount,jdbcType=INTEGER},#{superSecondCount,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{tearcherFirstCount,jdbcType=INTEGER},#{tearcherSecondCount,jdbcType=INTEGER}) |
| | | (#{id,jdbcType=BIGINT},#{level,jdbcType=VARCHAR},#{normalFirstCount,jdbcType=INTEGER},#{normalSecondCount,jdbcType=INTEGER},#{highFirstCount,jdbcType=INTEGER},#{highSecondCount,jdbcType=INTEGER},#{superFirstCount,jdbcType=INTEGER},#{superSecondCount,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{tearcherFirstCount,jdbcType=INTEGER},#{tearcherSecondCount,jdbcType=INTEGER},#{daRenFirstCount,jdbcType=INTEGER},#{daRenSecondCount,jdbcType=INTEGER}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic" |
| | |
| | | <if test="updateTime != null">tuls_update_time,</if> |
| | | <if test="tearcherFirstCount != null">tuls_tearcher_first_count,</if> |
| | | <if test="tearcherSecondCount != null">tuls_tearcher_second_count,</if> |
| | | <if test="daRenFirstCount != null">tuls_daren_first_count,</if> |
| | | <if test="daRenSecondCount != null">tuls_daren_second_count,</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="tearcherFirstCount != null">#{tearcherFirstCount,jdbcType=INTEGER},</if> |
| | | <if test="tearcherSecondCount != null">#{tearcherSecondCount,jdbcType=INTEGER}</if> |
| | | <if test="tearcherSecondCount != null">#{tearcherSecondCount,jdbcType=INTEGER},</if> |
| | | <if test="daRenFirstCount != null">#{daRenFirstCount,jdbcType=INTEGER},</if> |
| | | <if test="daRenSecondCount != null">#{daRenSecondCount,jdbcType=INTEGER},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | |
| | | #{createTime,jdbcType=TIMESTAMP},tuls_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,tuls_tearcher_first_count |
| | | =#{tearcherFirstCount,jdbcType=INTEGER} ,tuls_tearcher_second_count |
| | | =#{tearcherSecondCount,jdbcType=INTEGER} where tuls_uid = |
| | | #{id,jdbcType=BIGINT}</update> |
| | | =#{tearcherSecondCount,jdbcType=INTEGER} ,tuls_daren_first_count |
| | | =#{daRenFirstCount,jdbcType=INTEGER} ,tuls_daren_second_count |
| | | =#{daRenSecondCount,jdbcType=INTEGER} where tuls_uid = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic"> |
| | | update yeshi_ec_team_user_level_statistic |
| | |
| | | <if test="createTime != null">tuls_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">tuls_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tearcherFirstCount !=null">tuls_tearcher_first_count |
| | | =#{tearcherFirstCount,jdbcType=INTEGER},</if> |
| | | =#{tearcherFirstCount,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="tearcherSecondCount !=null">tuls_tearcher_second_count |
| | | =#{tearcherSecondCount,jdbcType=INTEGER},</if> |
| | | =#{tearcherSecondCount,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="daRenFirstCount !=null">tuls_daren_first_count |
| | | =#{daRenFirstCount,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="daRenSecondCount !=null">tuls_daren_second_count |
| | | =#{daRenSecondCount,jdbcType=INTEGER}, |
| | | </if> |
| | | </set> |
| | | where tuls_uid = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | @Resource
|
| | | private InviteOrderSubsidyDebtRepayHistoryMapper inviteOrderSubsidyDebtRepayHistoryMapper;
|
| | |
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void addDebt(InviteOrderSubsidyDebt debt) throws InviteOrderSubsidyDebtException {
|
| | | if (debt == null || debt.getOriginMoney() == null || debt.getOriginMoney() == null || debt.getUid() == null) {
|
| | |
| | | inviteOrderSubsidyDebtMapper.insertSelective(debt);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repayDebt(Long debtId, BigDecimal money) throws InviteOrderSubsidyDebtException {
|
| | | InviteOrderSubsidyDebt debt = inviteOrderSubsidyDebtMapper.selectByPrimaryKeyForUpdate(debtId);
|
| | |
| | | inviteOrderSubsidyDebtRepayHistoryMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws InviteOrderSubsidyDebtException {
|
| | | public BigDecimal repayDebtByUid(Long uid, Date maxEstimatePayTime, BigDecimal money)
|
| | | throws InviteOrderSubsidyDebtException {
|
| | | // 还钱
|
| | | long count = countNeedRepayDebt(uid);
|
| | | long count = countNeedRepayDebt(uid, maxEstimatePayTime);
|
| | | int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
|
| | | List<InviteOrderSubsidyDebt> totalList = new ArrayList<>();
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<InviteOrderSubsidyDebt> tempList = listNeedRepayDebt(uid, i + 1, 200);
|
| | | List<InviteOrderSubsidyDebt> tempList = listNeedRepayDebt(uid, maxEstimatePayTime, i + 1, 200);
|
| | | if (tempList != null && tempList.size() > 0) {
|
| | | totalList.addAll(tempList);
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | return leftMoney;//返回剩余的资金
|
| | | return leftMoney;// 返回剩余的资金
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid, int page, int count) {
|
| | | return inviteOrderSubsidyDebtMapper.listByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid, (page - 1) * count,
|
| | | count);
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid, Date maxEstimatePayTime, int page, int count) {
|
| | | return inviteOrderSubsidyDebtMapper.listByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null,
|
| | | uid, maxEstimatePayTime, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countNeedRepayDebt(Long uid) {
|
| | | return inviteOrderSubsidyDebtMapper.countByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid);
|
| | | public long countNeedRepayDebt(Long uid, Date maxEstimatePayTime) {
|
| | | return inviteOrderSubsidyDebtMapper.countByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null,
|
| | | uid, maxEstimatePayTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTotalDebtMoney(Long uid) {
|
| | | BigDecimal money = inviteOrderSubsidyDebtMapper.sumLeftMoneyByUid(uid);
|
| | | public BigDecimal getTotalDebtMoney(Long uid, Date maxEstimatePayTime) {
|
| | | BigDecimal money = inviteOrderSubsidyDebtMapper.sumLeftMoneyByUid(uid, maxEstimatePayTime);
|
| | | if (money == null)
|
| | | money = new BigDecimal(0);
|
| | | return money;
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws TeamDividentsDebtException {
|
| | | public BigDecimal repayDebtByUid(Long uid, Date maxEstimatePayTime, BigDecimal money)
|
| | | throws TeamDividentsDebtException {
|
| | | // 还钱
|
| | | long count = countNeedRepayDebt(uid);
|
| | | long count = countNeedRepayDebt(uid, maxEstimatePayTime);
|
| | | int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
|
| | | List<TeamDividentsDebt> totalList = new ArrayList<>();
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<TeamDividentsDebt> tempList = listNeedRepayDebt(uid, i + 1, 200);
|
| | | List<TeamDividentsDebt> tempList = listNeedRepayDebt(uid, maxEstimatePayTime, i + 1, 200);
|
| | | if (tempList != null && tempList.size() > 0) {
|
| | | totalList.addAll(tempList);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TeamDividentsDebt> listNeedRepayDebt(Long uid, int page, int count) {
|
| | | return teamDividentsDebtMapper.listByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid, (page - 1) * count,
|
| | | count);
|
| | | public List<TeamDividentsDebt> listNeedRepayDebt(Long uid, Date maxEstimatePayTime, int page, int count) {
|
| | | return teamDividentsDebtMapper.listByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null, uid,
|
| | | maxEstimatePayTime, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countNeedRepayDebt(Long uid) {
|
| | | return teamDividentsDebtMapper.countByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid);
|
| | | public long countNeedRepayDebt(Long uid, Date maxEstimatePayTime) {
|
| | | return teamDividentsDebtMapper.countByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null, uid,
|
| | | maxEstimatePayTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTotalDebtMoney(Long uid) {
|
| | | BigDecimal money = teamDividentsDebtMapper.sumLeftMoneyByUid(uid);
|
| | | public BigDecimal getTotalDebtMoney(Long uid, Date maxEstimatePayTime) {
|
| | | BigDecimal money = teamDividentsDebtMapper.sumLeftMoneyByUid(uid, maxEstimatePayTime);
|
| | | if (money == null)
|
| | | money = new BigDecimal(0);
|
| | | return money;
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.money;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.money.TeamEincomeRecordMapper;
|
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | | import com.yeshi.fanli.service.inter.money.TeamEincomeRecordService;
|
| | |
|
| | | @Service
|
| | | public class TeamEincomeRecordServiceImpl implements TeamEincomeRecordService {
|
| | |
|
| | | @Resource
|
| | | private TeamEincomeRecordMapper teamEincomeRecordMapper;
|
| | |
|
| | | @Override
|
| | | public void addTeamEincomeRecord(TeamEincomeRecord record) throws TeamEincomeRecordException, ParamsException {
|
| | | if (record.getUid() == null || record.getMoney() == null || record.getType() == null
|
| | | || record.getPreRecieveTime() == null)
|
| | | throw new ParamsException(1, "参数不完整");
|
| | |
|
| | | TeamEincomeRecord oldRecord = teamEincomeRecordMapper.selectByUidAndPreRecieveTimeAndType(record.getUid(),
|
| | | record.getPreRecieveTime(), record.getType());
|
| | | if (oldRecord != null)
|
| | | throw new TeamEincomeRecordException(1, "已存在");
|
| | | if (record.getCreateTime() == null)
|
| | | record.setCreateTime(new Date());
|
| | | teamEincomeRecordMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TeamEincomeRecord> listCanRecieveRecord(Date preRecieveTime, Long uid) {
|
| | |
|
| | | return teamEincomeRecordMapper.listByUidAndPreRecieveTimeAndState(uid, preRecieveTime,
|
| | | TeamEincomeRecord.STATE_NOT_RECIEVE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TeamEincomeRecord selectByPrimaryKeyForUpdate(Long id) {
|
| | | return teamEincomeRecordMapper.selectByPrimaryKeyForUpdate(id);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void setRecieved(Long id) {
|
| | | TeamEincomeRecord record = teamEincomeRecordMapper.selectByPrimaryKeyForUpdate(id);
|
| | | if (record != null) {
|
| | | TeamEincomeRecord update = new TeamEincomeRecord();
|
| | | update.setId(id);
|
| | | update.setRecieveTime(new Date());
|
| | | update.setState(TeamEincomeRecord.STATE_RECIEVED);
|
| | | update.setUpdateTime(new Date());
|
| | | teamEincomeRecordMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.money.TeamRewardDebtMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.TeamRewardDebtRepayHistoryMapper;
|
| | | import com.yeshi.fanli.entity.money.TeamRewardDebt;
|
| | | import com.yeshi.fanli.entity.money.TeamRewardDebtRepayHistory;
|
| | | import com.yeshi.fanli.exception.money.TeamRewardDebtException;
|
| | | import com.yeshi.fanli.service.inter.money.TeamRewardDebtService;
|
| | |
|
| | | @Service
|
| | | public class TeamRewardDebtServiceImpl implements TeamRewardDebtService {
|
| | | @Resource
|
| | | private TeamRewardDebtMapper teamRewardDebtMapper;
|
| | |
|
| | | @Resource
|
| | | private TeamRewardDebtRepayHistoryMapper teamRewardDebtRepayHistoryMapper;
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void addDebt(TeamRewardDebt debt) throws TeamRewardDebtException {
|
| | | if (debt == null || debt.getOriginMoney() == null || debt.getOriginMoney() == null || debt.getUid() == null) {
|
| | | throw new TeamRewardDebtException(1, "数据不完整");
|
| | | }
|
| | | if (debt.getCreateTime() == null)
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setLeftMoney(debt.getOriginMoney());
|
| | | teamRewardDebtMapper.insertSelective(debt);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repayDebt(Long debtId, BigDecimal money) throws TeamRewardDebtException {
|
| | | TeamRewardDebt debt = teamRewardDebtMapper.selectByPrimaryKeyForUpdate(debtId);
|
| | | if (debt == null)
|
| | | throw new TeamRewardDebtException(1, "债务ID不存在");
|
| | | if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
|
| | | throw new TeamRewardDebtException(3, "还钱必须大于0");
|
| | | if (debt.getLeftMoney().compareTo(money) < 0)
|
| | | throw new TeamRewardDebtException(2, "还钱过多");
|
| | | // 还钱
|
| | | TeamRewardDebt update = new TeamRewardDebt();
|
| | | update.setId(debt.getId());
|
| | | update.setLeftMoney(debt.getLeftMoney().subtract(money));
|
| | | update.setUpdateTime(new Date());
|
| | | teamRewardDebtMapper.updateByPrimaryKeySelective(update);
|
| | | // 加入还钱记录
|
| | | TeamRewardDebtRepayHistory record = new TeamRewardDebtRepayHistory();
|
| | | record.setCreateTime(new Date());
|
| | | record.setDebt(debt);
|
| | | record.setMoney(money);
|
| | | record.setUid(debt.getUid());
|
| | | teamRewardDebtRepayHistoryMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public BigDecimal repayDebtByUid(Long uid,Date maxEstimatePayTime, BigDecimal money) throws TeamRewardDebtException {
|
| | | // 还钱
|
| | | long count = countNeedRepayDebt(uid,maxEstimatePayTime);
|
| | | int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
|
| | | List<TeamRewardDebt> totalList = new ArrayList<>();
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<TeamRewardDebt> tempList = listNeedRepayDebt(uid,maxEstimatePayTime, i + 1, 200);
|
| | | if (tempList != null && tempList.size() > 0) {
|
| | | totalList.addAll(tempList);
|
| | | }
|
| | | }
|
| | |
|
| | | // 剩余资金
|
| | | BigDecimal leftMoney = new BigDecimal(money.toString());
|
| | |
|
| | | for (TeamRewardDebt debt : totalList) {
|
| | | if (leftMoney.compareTo(new BigDecimal(0)) <= 0)// 余额不足扣款
|
| | | break;
|
| | | BigDecimal repayMoney = null;
|
| | | if (debt.getLeftMoney().compareTo(leftMoney) >= 0)
|
| | | repayMoney = new BigDecimal(leftMoney.toString());
|
| | | else
|
| | | repayMoney = debt.getLeftMoney();
|
| | | try {
|
| | | repayDebt(debt.getId(), repayMoney);
|
| | | leftMoney = leftMoney.subtract(repayMoney);
|
| | | } catch (TeamRewardDebtException e) {
|
| | | // 上笔还款未成功,继续下一笔还款
|
| | | }
|
| | | }
|
| | |
|
| | | return leftMoney;// 返回剩余的资金
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TeamRewardDebt> listNeedRepayDebt(Long uid,Date maxEstimatePayTime, int page, int count) {
|
| | | return teamRewardDebtMapper.listByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null, uid,maxEstimatePayTime, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countNeedRepayDebt(Long uid,Date maxEstimatePayTime) {
|
| | | return teamRewardDebtMapper.countByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null, uid,maxEstimatePayTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTotalDebtMoney(Long uid,Date maxEstimatePayTime) {
|
| | | BigDecimal money = teamRewardDebtMapper.sumLeftMoneyByUid(uid, maxEstimatePayTime);
|
| | | if (money == null)
|
| | | money = new BigDecimal(0);
|
| | | return money;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TeamRewardDebt selectBySourceId(Long sourceId) {
|
| | | return teamRewardDebtMapper.selectBySourceId(sourceId);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
|
| | | import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | |
| | | userInfoMapper.addHongBaoByUid(uid, money);
|
| | | try {
|
| | | if (!Constant.IS_TEST)
|
| | | UserMoneyChangeCMQManager.getInstance().addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, money));
|
| | | UserMoneyChangeCMQManager.getInstance().addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, money));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getBalance(Long uid) {
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKey(uid);
|
| | | if (userInfo == null)
|
| | | return null;
|
| | | return userInfo.getMyHongBao();
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanDrawBackMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | 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.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDebtException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | |
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
| | | weiQuanDrawBack.setOrderItemId(weiQuanOrder.getOrderItemId());
|
| | | weiQuanDrawBack.setUser(child.getUserInfo());
|
| | | taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 加入返还记录
|
| | |
|
| | | // 加入邀请补贴返还记录
|
| | | doInviteOrderSubsidy(orderId, Constant.SOURCE_TYPE_TAOBAO, uid, settleMent, wqMoney,
|
| | | weiQuanOrder.getOrderItemId());
|
| | |
|
| | | // 如果资金大于0才扣除
|
| | |
|
| | | if (drawBackMoney != null && drawBackMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
| | | drawBackMoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请订单补贴维权处理
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | private void doInviteOrderSubsidy(String orderId, int sourceType, Long uid, BigDecimal settleMent,
|
| | | BigDecimal weiQuanMoney, String tradeId) throws TaoBaoWeiQuanException {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderId, sourceType);
|
| | | if (subSidy != null)// 添加借贷关系
|
| | | {
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(settleMent, weiQuanMoney, subSidy.getOriginalMoney());
|
| | | if (drawBackMoney.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | InviteOrderSubsidyDebt debt = new InviteOrderSubsidyDebt();
|
| | | debt.setBeiZhu("订单售后:" + orderId + "-" + sourceType);
|
| | | debt.setOriginMoney(drawBackMoney);
|
| | | debt.setUid(uid);
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setSourceId(subSidy.getId());
|
| | | debt.setTradeId(tradeId);
|
| | | try {
|
| | | inviteOrderSubsidyDebtService.addDebt(debt);
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new TaoBaoWeiQuanException(101, "邀请订单补贴异常");
|
| | | }
|
| | |
|
| | | // TODO 删除团队奖励维权处理
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | 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.InviteOrderSubsidyServiceV2;
|
| | | 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.util.TimeUtil;
|
| | |
|
| | | @Service
|
| | | public class InviteOrderSubsidyServiceImplV2 implements InviteOrderSubsidyServiceV2 {
|
| | | public class InviteOrderSubsidyServiceImplV2 implements InviteOrderSubsidyService {
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyMapper inviteOrderSubsidyMapper;
|
| | |
| | | return inviteOrderSubsidyMapper.getByOrderNoAndTypeForUpdate(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<InviteOrderSubsidy> listByOrderNoAndType(String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.listByOrderNoAndType(orderNo, type);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void addOrderSubsidy(InviteOrderSubsidy orderSubsidy)
|
| | | throws InviteOrderSubsidyException, OrderTeamRewardException, CommonOrderException {
|
| | |
| | | update.setState(orderSubsidy.getState());
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | //TODO 删除添加奖励
|
| | | } else {// 添加
|
| | | if (orderSubsidy.getCreateTime() == null)
|
| | | orderSubsidy.setCreateTime(new Date());
|
| | | inviteOrderSubsidyMapper.insertSelective(orderSubsidy);
|
| | | //TODO 删除添加奖励
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | if (list != null && list.size() > 0) {
|
| | | // 必须是自购订单才返利
|
| | | HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId());
|
| | | if (parent != null && parent.getUrank() != UserLevelEnum.superVIP.getOrderRank()
|
| | | if (parent != null
|
| | | && (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {// 不是超级会员的自购/分享才补贴
|
| | | boolean isShare = (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS);
|
| | |
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
|
| | | if (orderList == null || orderList.size() == 0)
|
| | |
| | | }
|
| | |
|
| | | List<HongBaoV2> hbList = hongBaoV2Service.listByIds(idList);
|
| | | int state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | | // 确定是否使用了奖励券
|
| | | if (orderHongBaoMapService.selectByOrderIdAndSourceType(orderId, sourceType) != null) {
|
| | | state = InviteOrderSubsidy.STATE_INVALID;
|
| | | } else {
|
| | | // 确定是否返利到账5天后
|
| | | if (recieveMoneyMoreThan(hbList, 5)) {
|
| | | state = InviteOrderSubsidy.STATE_VALID;
|
| | | } else {
|
| | | state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | | }
|
| | | }
|
| | | Integer state = null;
|
| | |
|
| | | // 产生改订单的返利总金额
|
| | | BigDecimal totalBuyFanLiMoney = new BigDecimal(0);
|
| | |
| | | if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | totalBuyFanLiMoney = totalBuyFanLiMoney.add(v2.getMoney());
|
| | |
|
| | | if (state == null && (v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU)) {// 红包状态为已领取或者是待领取,则设置为补贴有效
|
| | | state = InviteOrderSubsidy.STATE_VALID;
|
| | | }
|
| | | }
|
| | |
|
| | | if (state == null)
|
| | | state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | | // 计算奖励金
|
| | | 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) {
|
| | | 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)
|
| | | 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.setOrderNo(orderId);
|
| | | orderSubsidy.setSourceType(sourceType);
|
| | | orderSubsidy.setState(state);
|
| | | if (type == HongBaoV2.TYPE_YIJI)
|
| | | if (type == HongBaoV2.TYPE_YIJI || type == HongBaoV2.TYPE_SHARE_YIJI)
|
| | | orderSubsidy.setLevel(InviteOrderSubsidy.LEVEL_ONE);
|
| | | else
|
| | | orderSubsidy.setLevel(InviteOrderSubsidy.LEVEL_TWO);
|
| | | // 会员才能补贴
|
| | | if (userLevel != UserLevelEnum.daRen) {
|
| | | try {
|
| | | addOrderSubsidy(orderSubsidy);
|
| | | } catch (OrderTeamRewardException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | } catch (CommonOrderException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | }
|
| | | // 分享赚不能使用返利奖励券,不用等待5天
|
| | | if (isShare) {
|
| | | validByOrderIdAndSourceType(orderId, sourceType);
|
| | | }
|
| | |
|
| | | try {
|
| | | addOrderSubsidy(orderSubsidy);
|
| | | } catch (OrderTeamRewardException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | } catch (CommonOrderException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private boolean recieveMoneyMoreThan(List<HongBaoV2> hbList, int day) {
|
| | | // 是否全部是到账状态或失效状态
|
| | | int invalidCount = 0;// 失效个数
|
| | | int recieveCount = 0;// 到账的个数
|
| | | long maxGetTime = 0;
|
| | | for (HongBaoV2 v2 : hbList) {
|
| | | if (v2.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | invalidCount++;
|
| | | else if (v2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | recieveCount++;
|
| | | if (v2.getGetTime() != null && v2.getGetTime().getTime() > maxGetTime)
|
| | | maxGetTime = v2.getGetTime().getTime();
|
| | |
|
| | | }
|
| | | }
|
| | | if (invalidCount + recieveCount == hbList.size() && recieveCount > 0 && maxGetTime > 0) {// 全部已到账
|
| | | // 查询到账时间距离当前时间是否超过指定天
|
| | | if (System.currentTimeMillis() - maxGetTime > 1000 * 60 * 60 * 24L * day)
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(orderSubsidy);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public BigDecimal sumRecievedMoneyByUid(long uid, Integer level) {
|
| | | BigDecimal money = inviteOrderSubsidyMapper.sumRecievedMoneyByUid(uid, level);
|
| | |
| | | }
|
| | | return money;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public BigDecimal sumValidMoneyByUidAndDate(long uid, Integer day, Integer level) {
|
| | | BigDecimal money = inviteOrderSubsidyMapper.sumValidMoneyByUidAndDate(uid, day, level);
|
| | |
| | | }
|
| | | return money;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public BigDecimal sumMoneyByUidAndDateAndState(long uid, Integer day, Integer level, Integer state) {
|
| | | BigDecimal money = inviteOrderSubsidyMapper.sumMoneyByUidAndDateAndState(uid, day, level, state);
|
| | |
| | | }
|
| | | return money;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | }
|
| | |
| | | public BigDecimal computeFirstTeamSubsidy(BigDecimal fanLiMoney, Date placeOrderTime, UserLevelEnum buyerUserLevel,
|
| | | UserLevelEnum userLevel) {
|
| | | BigDecimal rate = getTeamSubsidyRate(placeOrderTime, buyerUserLevel, userLevel, true);
|
| | | if (rate == null)
|
| | | if (rate == null || rate.compareTo(new BigDecimal(0)) == 0)
|
| | | return null;
|
| | | BigDecimal baseRate = hongBaoManageService.getBaseFanliRate(placeOrderTime.getTime());
|
| | | BigDecimal officialSubsidyRate = getOfficialSubsidyRate(placeOrderTime, buyerUserLevel, false);
|
| | |
| | | public BigDecimal computeSecondTeamSubsidy(BigDecimal fanLiMoney, Date placeOrderTime, UserLevelEnum buyerUserLevel,
|
| | | UserLevelEnum userLevel) {
|
| | | BigDecimal rate = getTeamSubsidyRate(placeOrderTime, buyerUserLevel, userLevel, false);
|
| | | if (rate == null)
|
| | | if (rate == null || rate.compareTo(new BigDecimal(0)) == 0)
|
| | | return null;
|
| | | BigDecimal baseRate = hongBaoManageService.getBaseFanliRate(placeOrderTime.getTime());
|
| | | BigDecimal officialSubsidyRate = getOfficialSubsidyRate(placeOrderTime, buyerUserLevel, false);
|
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.math.RoundingMode;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | |
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.TeamRewardDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | | import com.yeshi.fanli.exception.money.TeamRewardDebtException;
|
| | | 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.hongbao.AccountDetailsHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.TeamRewardDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager;
|
| | | 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.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | |
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | // 邀请补贴
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Resource
|
| | | private TeamRewardDebtService teamRewardDebtService;
|
| | |
|
| | | @Resource
|
| | | private TeamRewardManager teamRewardManager;
|
| | |
|
| | | @Resource
|
| | | private TeamSubsidyManager teamSubsidyManager;
|
| | |
|
| | | // 下级被封禁,红包失效
|
| | | private void invalidHongBaoForbidden(Long id) {
|
| | |
| | | OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date(), 0);
|
| | |
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | |
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanliInviteTB(hongBaoList, uid, taskKey);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | fanliInvite(hongBaoList, uid, Constant.SOURCE_TYPE_TAOBAO, taskKey);
|
| | | } catch (Exception e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | |
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date(), 0);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | |
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanliInviteOther(hongBaoList, uid, sourceType, taskKey);
|
| | | try {
|
| | | fanliInvite(hongBaoList, uid, sourceType, taskKey);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | |
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date(), 0);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | |
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanliInviteOther(hongBaoList, uid, sourceType, taskKey);
|
| | | try {
|
| | | fanliInvite(hongBaoList, uid, sourceType, taskKey);
|
| | | } catch (Exception e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | |
| | | return hongBao;
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void fanliInviteTB(List<HongBaoV2> hongBaoList, Long uid, String key) throws TaoBaoWeiQuanException {
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | Date balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | if (!StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getOrderNo()))
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
|
| | | }
|
| | |
|
| | | try {
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, key);
|
| | | } catch (Exception e1) {
|
| | | throw new TaoBaoWeiQuanException(200, "插入返利临时表出错");
|
| | | }
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : hbIdList) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void fanliInviteOther(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key) {
|
| | | private void fanliInvite(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key)
|
| | | throws TeamEincomeRecordException, ParamsException, TeamRewardDebtException {
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | |
| | | continue;
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | TeamRewardDebt debt = teamRewardDebtService.selectBySourceId(hongBao.getId());
|
| | | BigDecimal money = hongBao.getMoney();
|
| | | if (debt != null && debt.getLeftMoney().compareTo(new BigDecimal(0)) > 0
|
| | | && money.compareTo(debt.getLeftMoney()) >= 0) {
|
| | | money = money.subtract(debt.getLeftMoney());
|
| | | // 还钱
|
| | | teamRewardDebtService.repayDebt(debt.getId(), debt.getLeftMoney());
|
| | | }
|
| | |
|
| | | invitemoney = invitemoney.add(money);
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | |
| | | // 2018-08-05 过后的订单才处理维权
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate, sourceType);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate, sourceType);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, sourceType, (int) validCount,
|
| | | (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, sourceType, inviteOrders.size(), inviteGoodsCount,
|
| | | invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date date = new Date(TimeUtil.convertToTimeTemp(
|
| | | ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd"));
|
| | | // 获取当前的月份
|
| | | teamRewardManager.addToEincome(uid, date, invitemoney, sourceType);
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, key);
|
| | |
| | | *
|
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @throws ParamsException |
| | | * @throws TeamEincomeRecordException |
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void inviteSubsidySettle(Long uid, String taskKey) throws OrderMoneySettleException {
|
| | | // 查询key
|
| | | List<HongBaoV2SettleTemp> list = hongBaoV2SettleTempService.listByKey(taskKey);
|
| | | if (list != null && list.size() > 0) {
|
| | |
|
| | | Integer sourceType = null;
|
| | | List<InviteOrderSubsidy> subsidyList = new ArrayList<>();
|
| | | for (HongBaoV2SettleTemp temp : list) {
|
| | | Long hongBaoId = temp.getHongBaoId();
|
| | | HongBaoV2 hongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoId);
|
| | | if (hongBao != null)
|
| | | sourceType = hongBao.getOrderType();
|
| | | if (hongBao.getParent() != null)
|
| | | hongBao = hongBao.getParent();
|
| | | HongBaoOrder order = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (order != null && order.getCommonOrder() != null) {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndTypeForUpdate(uid,
|
| | | order.getCommonOrder().getOrderNo(), order.getCommonOrder().getSourceType());
|
| | | if (subSidy != null && subSidy.getState() == InviteOrderSubsidy.STATE_VALID) {
|
| | | subsidyList.add(subSidy);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (sourceType == null)
|
| | | throw new OrderMoneySettleException(1, "订单类型未获取到");
|
| | |
|
| | | if (subsidyList.size() > 0) {
|
| | | BigDecimal debtMoney = inviteOrderSubsidyDebtService.getTotalDebtMoney(uid);
|
| | | BigDecimal originalDebtMoney = new BigDecimal(debtMoney.toString());// 总的欠款
|
| | | List<InviteOrderSubsidy> copySubsidyList = new ArrayList<>();
|
| | | copySubsidyList.addAll(subsidyList);
|
| | | while (debtMoney.compareTo(new BigDecimal(0)) > 0 && copySubsidyList.size() > 0) {// 有欠款,还有还的
|
| | | debtMoney = kouKuan(copySubsidyList, debtMoney);
|
| | | }
|
| | | // 还款
|
| | | BigDecimal repayMoney = originalDebtMoney.subtract(debtMoney);
|
| | | BigDecimal bannce = null;
|
| | | if (repayMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | try {
|
| | | bannce = inviteOrderSubsidyDebtService.repayDebtByUid(uid, repayMoney);
|
| | | // 剩余的补贴金额
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new OrderMoneySettleException(2, "还款异常");
|
| | | }
|
| | | }
|
| | | if (bannce != null && bannce.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 如果有还剩下的钱就加到第一个上面
|
| | | subsidyList.get(0).setMoney(subsidyList.get(0).getMoney().add(bannce));
|
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | for (InviteOrderSubsidy subsidy : subsidyList) {
|
| | | inviteOrderSubsidyService.settleById(subsidy.getId(), subsidy.getMoney());
|
| | | totalMoney = totalMoney.add(subsidy.getMoney());
|
| | | }
|
| | |
|
| | | // 到账
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | try {
|
| | | userMoneyDetail = UserMoneyDetailFactory.createInviteSubsidy(uid, sourceType, totalMoney,
|
| | | new Date());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new OrderMoneySettleException(1, "账户明细构建出错");
|
| | | }
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, totalMoney, userMoneyDetail);
|
| | | // 添加消息
|
| | | userMoneyMsgNotificationService.inviteOrderSubSidy(uid, new Date(), "系统自动下发", totalMoney,
|
| | | userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | | }
|
| | | }
|
| | | public void inviteSubsidySettle(Long uid, String taskKey)
|
| | | throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException {
|
| | | teamSubsidyManager.addToTeamEincome(uid, taskKey);
|
| | | }
|
| | |
|
| | | private String getTaskKey(Long uid) {
|
| | | return uid + "-" + UUID.randomUUID().toString();
|
| | | }
|
| | |
|
| | | private BigDecimal kouKuan(List<InviteOrderSubsidy> subsidyList, BigDecimal debtMoney) {
|
| | | BigDecimal average = debtMoney.divide(new BigDecimal(subsidyList.size()), 2, RoundingMode.UP);
|
| | | for (int i = 0; i < subsidyList.size(); i++) {
|
| | | InviteOrderSubsidy sidy = subsidyList.get(i);
|
| | | BigDecimal subMoney = null;
|
| | | if (average.compareTo(sidy.getMoney()) >= 0) {
|
| | | subMoney = sidy.getMoney();
|
| | | } else {
|
| | | subMoney = average;
|
| | | }
|
| | | if (subMoney.compareTo(debtMoney) > 0)
|
| | | subMoney = debtMoney;
|
| | | debtMoney = debtMoney.subtract(subMoney);
|
| | | sidy.setMoney(sidy.getMoney().subtract(subMoney));
|
| | |
|
| | | if (sidy.getMoney().compareTo(new BigDecimal(0)) == 0) {
|
| | | subsidyList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | return debtMoney;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | int state = ThreeSale.STATE_SUCCESS;
|
| | | long count = threeSaleSerivce.countFirstTeam(uid, state);
|
| | | List<ThreeSale> list = threeSaleSerivce.listFirstTeam(0L, (int) count, uid, state);
|
| | | int daRenFirstCount = 0;
|
| | | int normalFirstCount = 0;
|
| | | int highFirstCount = 0;
|
| | | int superFirstCount = 0;
|
| | | int tearcherFirstCount = 0;
|
| | | for (ThreeSale ts : list) {
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(ts.getWorker().getId());
|
| | | if (level == UserLevelEnum.normalVIP) {
|
| | | if (level == UserLevelEnum.daRen) {
|
| | | daRenFirstCount++;
|
| | | } else if (level == UserLevelEnum.normalVIP) {
|
| | | normalFirstCount++;
|
| | | } else if (level == UserLevelEnum.highVIP) {
|
| | | highFirstCount++;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | int daRenSecondCount = 0;
|
| | | int normalSecondCount = 0;
|
| | | int highSecondCount = 0;
|
| | | int superSecondCount = 0;
|
| | |
| | | if (list != null)
|
| | | for (ThreeSale ts : list) {
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(ts.getWorker().getId());
|
| | | if (level == UserLevelEnum.normalVIP) {
|
| | | if (level == UserLevelEnum.daRen) {
|
| | | daRenSecondCount++;
|
| | | } else if (level == UserLevelEnum.normalVIP) {
|
| | | normalSecondCount++;
|
| | | } else if (level == UserLevelEnum.highVIP) {
|
| | | highSecondCount++;
|
| | |
| | |
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(uid);
|
| | | TeamUserLevelStatistic statistic = new TeamUserLevelStatistic();
|
| | | statistic.setDaRenFirstCount(daRenFirstCount);
|
| | | statistic.setDaRenSecondCount(daRenSecondCount);
|
| | | statistic.setNormalFirstCount(normalFirstCount);
|
| | | statistic.setNormalSecondCount(normalSecondCount);
|
| | | statistic.setHighFirstCount(highFirstCount);
|
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | |
| | | * @return 还剩下的资金
|
| | | * @throws InviteOrderSubsidyDebtException
|
| | | */
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws InviteOrderSubsidyDebtException;
|
| | | public BigDecimal repayDebtByUid(Long uid,Date maxEstimatePayTime, BigDecimal money) throws InviteOrderSubsidyDebtException;
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | |
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid, int page, int count);
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid,Date maxEstimatePayTime, int page, int count);
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countNeedRepayDebt(Long uid);
|
| | | public long countNeedRepayDebt(Long uid,Date maxEstimatePayTime);
|
| | |
|
| | | /**
|
| | | * 获取总共欠钱金额
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getTotalDebtMoney(Long uid);
|
| | | public BigDecimal getTotalDebtMoney(Long uid,Date maxEstimatePayTime);
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsDebt;
|
| | |
| | | * @return 还剩下的资金
|
| | | * @throws TeamDividentsDebtException
|
| | | */
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws TeamDividentsDebtException;
|
| | | public BigDecimal repayDebtByUid(Long uid,Date maxEstimatePayTime, BigDecimal money) throws TeamDividentsDebtException;
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | |
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<TeamDividentsDebt> listNeedRepayDebt(Long uid, int page, int count);
|
| | | public List<TeamDividentsDebt> listNeedRepayDebt(Long uid,Date maxEstimatePayTime, int page, int count);
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countNeedRepayDebt(Long uid);
|
| | | public long countNeedRepayDebt(Long uid,Date maxEstimatePayTime);
|
| | |
|
| | | /**
|
| | | * 获取总共欠钱金额
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getTotalDebtMoney(Long uid);
|
| | | public BigDecimal getTotalDebtMoney(Long uid,Date maxEstimatePayTime);
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void addTeamEincomeRecord(TeamEincomeRecord record) throws TeamEincomeRecordException,ParamsException;
|
| | | public void addTeamEincomeRecord(TeamEincomeRecord record) throws TeamEincomeRecordException, ParamsException;
|
| | |
|
| | | public List<TeamEincomeRecord> listCanRecieveRecord(Date preRecieveTime,Long uid);
|
| | |
|
| | |
|
| | | public TeamEincomeRecord selectByPrimaryKeyForUpdate(Long id);
|
| | |
|
| | | |
| | | public void setRecieved(Long id);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.TeamRewardDebt;
|
| | | import com.yeshi.fanli.exception.money.TeamRewardDebtException;
|
| | |
|
| | | public interface TeamRewardDebtService {
|
| | |
|
| | | /**
|
| | | * 添加债务
|
| | | * |
| | | * @param debt
|
| | | * @throws TeamRewardDebtException
|
| | | */
|
| | | public void addDebt(TeamRewardDebt debt) throws TeamRewardDebtException;
|
| | |
|
| | | /**
|
| | | * 偿还债务
|
| | | * |
| | | * @param debtId
|
| | | * @param money
|
| | | */
|
| | | public void repayDebt(Long debtId, BigDecimal money) throws TeamRewardDebtException;
|
| | |
|
| | | /**
|
| | | * 还款
|
| | | * |
| | | * @param uid
|
| | | * @param money
|
| | | * @return 还剩下的资金
|
| | | * @throws TeamRewardDebtException
|
| | | */
|
| | | public BigDecimal repayDebtByUid(Long uid,Date maxEstimatePayTime, BigDecimal money) throws TeamRewardDebtException;
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | | * |
| | | * @param uid
|
| | | * @param page
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<TeamRewardDebt> listNeedRepayDebt(Long uid,Date maxEstimatePayTime, int page, int count);
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countNeedRepayDebt(Long uid,Date maxEstimatePayTime);
|
| | |
|
| | | /**
|
| | | * 获取总共欠钱金额
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getTotalDebtMoney(Long uid,Date maxEstimatePayTime);
|
| | | |
| | | /**
|
| | | * 通过唯一标识查询
|
| | | * @Title: selectBySourceId
|
| | | * @Description: |
| | | * @param sourceId
|
| | | * @return |
| | | * TeamRewardDebt 返回类型
|
| | | * @throws
|
| | | */
|
| | | public TeamRewardDebt selectBySourceId(Long sourceId);
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public void addUserMoney(Long uid, BigDecimal money, UserMoneyDetail detail);
|
| | |
|
| | | /**
|
| | | * 获取用户账户余额
|
| | | * @Title: getBalance
|
| | | * @Description: |
| | | * @param uid
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal getBalance(Long uid);
|
| | |
|
| | | }
|
| | |
| | | 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;
|
| | | import com.yeshi.fanli.exception.order.OrderTeamRewardException;
|
| | |
|
| | | public interface InviteOrderSubsidyService {
|
| | |
|
| | |
| | | * @return
|
| | | */
|
| | | public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type);
|
| | | |
| | | |
| | | public List<InviteOrderSubsidy> listByOrderNoAndType(String orderNo, Integer type);
|
| | |
|
| | | /**
|
| | | * 查询补贴(加锁)
|
| | |
| | | * @return
|
| | | */
|
| | | public InviteOrderSubsidy getByOrderNoAndTypeForUpdate(Long uid, String orderNo, Integer type);
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 添加或修改(按照订单号与来源)
|
| | |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType) throws InviteOrderSubsidyException;
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType)
|
| | | throws InviteOrderSubsidyException, OrderTeamRewardException, CommonOrderException;
|
| | |
|
| | | /**
|
| | | * 根据订单号与来源查询
|
| | |
| | | */
|
| | | 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);
|
| | | 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);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | |
|
| | | /**
|
| | | * 订单资金结算服务
|
| | |
| | | * @param taskKey
|
| | | * @throws OrderMoneySettleException
|
| | | */
|
| | | public void inviteSubsidySettle(Long uid, String taskKey) throws OrderMoneySettleException;
|
| | | public void inviteSubsidySettle(Long uid, String taskKey)
|
| | | throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException;
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.manger.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | | import com.yeshi.fanli.service.inter.money.TeamEincomeRecordService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.money.TeamEincomeRecordFactory;
|
| | |
|
| | | /**
|
| | | * 团队收益管理
|
| | |
| | | @Component
|
| | | public class TeamEincomeManager {
|
| | |
|
| | | @Resource
|
| | | private TeamEincomeRecordService teamEincomeRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | |
|
| | | /**
|
| | | * @throws ParamsException |
| | | * @throws TeamEincomeRecordException |
| | | * 添加团队奖金
|
| | | * @Title: addTeamReward
|
| | | * @Description:
|
| | |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void addTeamReward(Long uid, Date preSendTime,int sourceType) {
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addTeamReward(Long uid, Date preSendTime, BigDecimal money, int sourceType)
|
| | | throws TeamEincomeRecordException, ParamsException {
|
| | | String day = TimeUtil.getGernalTime(preSendTime.getTime(), "yyyy-MM-dd");
|
| | | TeamEincomeRecord record = TeamEincomeRecordFactory.createTeamReward(day, uid, money, sourceType, null);
|
| | | teamEincomeRecordService.addTeamEincomeRecord(record);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void addTeamSubsidy(Long uid, String taskKey,int sourceType) {
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addTeamSubsidy(Long uid, Date preSendTime, BigDecimal money, int sourceType)
|
| | | throws TeamEincomeRecordException, ParamsException {
|
| | | String day = TimeUtil.getGernalTime(preSendTime.getTime(), "yyyy-MM-dd");
|
| | | TeamEincomeRecord record = TeamEincomeRecordFactory.createTeamSubsidy(day, uid, money, sourceType, null);
|
| | | teamEincomeRecordService.addTeamEincomeRecord(record);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void addTeamDividents(Long uid, Date preSendTime) {
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addTeamDividents(Long uid, Date preSendTime, BigDecimal money)
|
| | | throws TeamEincomeRecordException, ParamsException {
|
| | | String day = TimeUtil.getGernalTime(preSendTime.getTime(), "yyyy-MM-dd");
|
| | | TeamEincomeRecord record = TeamEincomeRecordFactory.createTeamDividents(day, uid, money, null);
|
| | | teamEincomeRecordService.addTeamEincomeRecord(record);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 到账到用户余额
|
| | | * @Title: addTOUserAccount
|
| | | * @Description: |
| | | * @param day
|
| | | * @param uid |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addTOUserAccount(Date preSendTime, Long uid) {
|
| | | Date now = new Date();
|
| | | List<TeamEincomeRecord> list = teamEincomeRecordService.listCanRecieveRecord(preSendTime, uid);
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | for (TeamEincomeRecord record : list) {
|
| | | record = teamEincomeRecordService.selectByPrimaryKeyForUpdate(record.getId());
|
| | | money = money.add(record.getMoney());
|
| | | teamEincomeRecordService.setRecieved(record.getId());
|
| | | }
|
| | |
|
| | | // TODO 到账
|
| | | UserMoneyDetail detail = null;
|
| | | userMoneyService.addUserMoney(uid, money, detail);
|
| | | // 发送消息
|
| | | BigDecimal balance = userMoneyService.getBalance(uid);
|
| | | userMoneyMsgNotificationService.teamReceive(uid, money, balance, now);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsDebt;
|
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsRecord;
|
| | |
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceUser;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.TeamDividentsDebtException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.dividents.TeamDividentsRecordException;
|
| | | import com.yeshi.fanli.exception.order.dividents.TeamDividentsSourceOrderException;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceUserService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
|
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.factory.order.dividents.TeamDividentsSourceOrderFactory;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private TeamEincomeManager teamEincomeManager;
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addDividentsSourceOrder(List<CommonOrder> commonOrderList) throws TeamDividentsSourceOrderException {
|
| | |
| | | * @throws
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addDividents(Long uid, String day)
|
| | | throws TeamDividentsRecordException, TeamDividentsDebtException, UserMoneyDetailException, ParamsException {
|
| | | public void addToTeamEincome(Long uid, String day) throws TeamDividentsRecordException, TeamDividentsDebtException,
|
| | | UserMoneyDetailException, ParamsException, TeamEincomeRecordException {
|
| | | Date preSendTime = new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd"));
|
| | | BigDecimal money = teamDividentsSourceUserService.sumMoneyByUidAndDay(uid, day);
|
| | | // 查询需要扣除的资金
|
| | | List<TeamDividentsDebt> list = teamDividentsDebtService.listNeedRepayDebt(uid, 1, 1000);
|
| | | List<TeamDividentsDebt> list = teamDividentsDebtService.listNeedRepayDebt(uid, preSendTime, 1, 1000);
|
| | | for (TeamDividentsDebt debt : list) {
|
| | | if (money.subtract(debt.getLeftMoney()).compareTo(new BigDecimal(0)) >= 0) {// 还有钱还
|
| | | money = money.subtract(debt.getLeftMoney());
|
| | |
| | |
|
| | | // 有分红才显示资金明细
|
| | | if (money.compareTo(new BigDecimal(0)) > 0) {
|
| | | UserMoneyDetail detail = UserMoneyDetailFactory.createOrderTeamDividents(uid, money, new Date());
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, money, detail);
|
| | | // TODO 加入通知
|
| | | }
|
| | |
|
| | | teamEincomeManager.addTeamDividents(uid, preSendTime, money);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
New file |
| | |
| | | package com.yeshi.fanli.service.manger.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.money.TeamRewardDebt;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | | import com.yeshi.fanli.exception.money.TeamRewardDebtException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoOrderException;
|
| | | import com.yeshi.fanli.service.inter.money.TeamRewardDebtService;
|
| | | 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.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | /**
|
| | | * 团队分红管理
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class TeamRewardManager {
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private TeamRewardDebtService teamRewardDebtService;
|
| | |
|
| | | @Resource
|
| | | private TeamEincomeManager teamEincomeManager;
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addToEincome(Long uid, Date date, BigDecimal money, int sourceType)
|
| | | throws TeamEincomeRecordException, ParamsException, TeamRewardDebtException {
|
| | | // 查询是否有欠账
|
| | | BigDecimal debtMoney = teamRewardDebtService.getTotalDebtMoney(uid, date);
|
| | | // 有欠账
|
| | | if (debtMoney.compareTo(new BigDecimal(0)) > 0)
|
| | | money = teamRewardDebtService.repayDebtByUid(uid, date, money);
|
| | |
|
| | | teamEincomeManager.addTeamReward(uid, date, money, sourceType);
|
| | | }
|
| | |
|
| | | public void weiQuan(String orderNo, int sourceType, String tradeId)
|
| | | throws TaoBaoOrderException, InviteOrderSubsidyDebtException, TeamRewardDebtException {
|
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {// 只处理淘宝的维权
|
| | | TaoBaoWeiQuanOrder taoBaoWeiQuanOrder = taoBaoWeiQuanOrderService.selectByTradeId(tradeId);
|
| | |
|
| | | // 只处理维权成功
|
| | | if (!taoBaoWeiQuanOrder.getState().startsWith("维权成功"))
|
| | | return;
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderService.selectByTradeId(tradeId);
|
| | | if (taoBaoOrder == null)
|
| | | return;
|
| | |
|
| | | if (taoBaoOrder.getSettlement() == null)
|
| | | throw new TaoBaoOrderException(1, "订单未更新");
|
| | |
|
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(sourceType, tradeId);
|
| | | if (commonOrder == null)
|
| | | return;
|
| | |
|
| | | // 查询订单
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService.selectDetailByCommonOrderId(commonOrder.getId());
|
| | |
|
| | | if (hongBaoOrder == null)
|
| | | return;
|
| | |
|
| | | List<HongBaoV2> children = hongBaoV2Service.listChildrenById(hongBaoOrder.getHongBaoV2().getId());
|
| | |
|
| | | if (children == null)
|
| | | return;
|
| | |
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child != null)//
|
| | | {
|
| | | if (child.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | continue;
|
| | |
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(taoBaoOrder.getSettlement(),
|
| | | taoBaoWeiQuanOrder.getMoney(), child.getMoney());
|
| | | if (drawBackMoney.compareTo(new BigDecimal(0)) <= 0)
|
| | | continue;
|
| | |
|
| | | TeamRewardDebt oldDebt = teamRewardDebtService.selectBySourceId(child.getId());
|
| | | if (oldDebt != null)
|
| | | continue;
|
| | |
|
| | | if (child.getPreGetTime() == null) {
|
| | | throw new TeamRewardDebtException(2, "订单还未更新");
|
| | | }
|
| | |
|
| | | TeamRewardDebt debt = new TeamRewardDebt();
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setOriginMoney(drawBackMoney);
|
| | | debt.setSourceId(child.getId());
|
| | | debt.setTradeId(tradeId);
|
| | | debt.setUid(child.getUserInfo().getId());
|
| | | debt.setEstimatePayTime(child.getPreGetTime());
|
| | | teamRewardDebtService.addDebt(debt);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private BigDecimal computeDrawBackMoney(BigDecimal settlement, BigDecimal wqMoney, BigDecimal hongBaoMoney) {
|
| | | BigDecimal money = (hongBaoMoney.multiply(wqMoney)).divide(settlement, 2, BigDecimal.ROUND_UP);
|
| | | if (money.compareTo(hongBaoMoney) > 0)
|
| | | money = hongBaoMoney;
|
| | | return money;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.manger.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.math.RoundingMode;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.exception.order.OrderTeamRewardException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoOrderException;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | | 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.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | /**
|
| | | * 团队分红管理
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class TeamSubsidyManager {
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Resource
|
| | | private TeamEincomeManager teamEincomeManager;
|
| | |
|
| | | public void addOrUpdateOrder(String orderNo, int sourceType)
|
| | | throws InviteOrderSubsidyException, OrderTeamRewardException, CommonOrderException {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderNo, sourceType);
|
| | | }
|
| | |
|
| | | private BigDecimal computeDrawBackMoney(BigDecimal settlement, BigDecimal wqMoney, BigDecimal hongBaoMoney) {
|
| | | BigDecimal money = (hongBaoMoney.multiply(wqMoney)).divide(settlement, 2, BigDecimal.ROUND_UP);
|
| | | if (money.compareTo(hongBaoMoney) > 0)
|
| | | money = hongBaoMoney;
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void weiQuan(String orderNo, int sourceType, String tradeId)
|
| | | throws TaoBaoOrderException, InviteOrderSubsidyDebtException {
|
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {// 只处理淘宝的维权
|
| | | TaoBaoWeiQuanOrder taoBaoWeiQuanOrder = taoBaoWeiQuanOrderService.selectByTradeId(tradeId);
|
| | |
|
| | | // 只处理维权成功
|
| | | if (!taoBaoWeiQuanOrder.getState().startsWith("维权成功"))
|
| | | return;
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderService.selectByTradeId(tradeId);
|
| | | if (taoBaoOrder == null)
|
| | | return;
|
| | |
|
| | | if (taoBaoOrder.getSettlement() == null)
|
| | | throw new TaoBaoOrderException(1, "订单未更新");
|
| | |
|
| | | List<InviteOrderSubsidy> subSidyList = inviteOrderSubsidyService.listByOrderNoAndType(orderNo, sourceType);
|
| | | for (InviteOrderSubsidy subSidy : subSidyList) {
|
| | | if (subSidy != null)// 添加借贷关系
|
| | | {
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(taoBaoOrder.getSettlement(),
|
| | | taoBaoWeiQuanOrder.getMoney(), subSidy.getOriginalMoney());
|
| | | if (drawBackMoney.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | InviteOrderSubsidyDebt debt = new InviteOrderSubsidyDebt();
|
| | | debt.setBeiZhu("订单售后:" + orderNo + "-" + sourceType);
|
| | | debt.setOriginMoney(drawBackMoney);
|
| | | debt.setUid(subSidy.getUid());
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setSourceId(subSidy.getId());
|
| | | debt.setTradeId(tradeId);
|
| | | inviteOrderSubsidyDebtService.addDebt(debt);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加到临时结算
|
| | | * @Title: addToTeamEincome
|
| | | * @Description: |
| | | * @param uid
|
| | | * @param taskKey
|
| | | * @throws OrderMoneySettleException
|
| | | * @throws TeamEincomeRecordException
|
| | | * @throws ParamsException |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @Transactional
|
| | | public void addToTeamEincome(Long uid, String taskKey)
|
| | | throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException {
|
| | | // 查询key
|
| | | List<HongBaoV2SettleTemp> list = hongBaoV2SettleTempService.listByKey(taskKey);
|
| | | if (list != null && list.size() > 0) {
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date date = new Date(TimeUtil.convertToTimeTemp(
|
| | | ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd"));
|
| | |
|
| | | Integer sourceType = null;
|
| | | List<InviteOrderSubsidy> subsidyList = new ArrayList<>();
|
| | | for (HongBaoV2SettleTemp temp : list) {
|
| | | Long hongBaoId = temp.getHongBaoId();
|
| | | HongBaoV2 hongBao = hongBaoV2Service.selectByPrimaryKey(hongBaoId);
|
| | | if (hongBao != null)
|
| | | sourceType = hongBao.getOrderType();
|
| | | if (hongBao.getParent() != null)
|
| | | hongBao = hongBao.getParent();
|
| | | HongBaoOrder order = hongBaoOrderService.selectDetailByHongBaoId(hongBao.getId());
|
| | | if (order != null && order.getCommonOrder() != null) {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndTypeForUpdate(uid,
|
| | | order.getCommonOrder().getOrderNo(), order.getCommonOrder().getSourceType());
|
| | | if (subSidy != null && subSidy.getState() == InviteOrderSubsidy.STATE_VALID) {
|
| | | subsidyList.add(subSidy);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (sourceType == null)
|
| | | throw new OrderMoneySettleException(1, "订单类型未获取到");
|
| | |
|
| | | if (subsidyList.size() > 0) {
|
| | | BigDecimal debtMoney = inviteOrderSubsidyDebtService.getTotalDebtMoney(uid, date);
|
| | | BigDecimal originalDebtMoney = new BigDecimal(debtMoney.toString());// 总的欠款
|
| | | List<InviteOrderSubsidy> copySubsidyList = new ArrayList<>();
|
| | | copySubsidyList.addAll(subsidyList);
|
| | | while (debtMoney.compareTo(new BigDecimal(0)) > 0 && copySubsidyList.size() > 0) {// 有欠款,还有还的
|
| | | debtMoney = kouKuan(copySubsidyList, debtMoney);
|
| | | }
|
| | | // 还款
|
| | | BigDecimal repayMoney = originalDebtMoney.subtract(debtMoney);
|
| | | BigDecimal bannce = null;
|
| | | if (repayMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | try {
|
| | | bannce = inviteOrderSubsidyDebtService.repayDebtByUid(uid, date, repayMoney);
|
| | | // 剩余的补贴金额
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new OrderMoneySettleException(2, "还款异常");
|
| | | }
|
| | | }
|
| | | if (bannce != null && bannce.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 如果有还剩下的钱就加到第一个上面
|
| | | subsidyList.get(0).setMoney(subsidyList.get(0).getMoney().add(bannce));
|
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | for (InviteOrderSubsidy subsidy : subsidyList) {
|
| | | inviteOrderSubsidyService.settleById(subsidy.getId(), subsidy.getMoney());
|
| | | totalMoney = totalMoney.add(subsidy.getMoney());
|
| | | }
|
| | |
|
| | | // 加入团队收益中间表
|
| | | teamEincomeManager.addTeamSubsidy(uid, date, totalMoney, sourceType);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private BigDecimal kouKuan(List<InviteOrderSubsidy> subsidyList, BigDecimal debtMoney) {
|
| | | BigDecimal average = debtMoney.divide(new BigDecimal(subsidyList.size()), 2, RoundingMode.UP);
|
| | | for (int i = 0; i < subsidyList.size(); i++) {
|
| | | InviteOrderSubsidy sidy = subsidyList.get(i);
|
| | | BigDecimal subMoney = null;
|
| | | if (average.compareTo(sidy.getMoney()) >= 0) {
|
| | | subMoney = sidy.getMoney();
|
| | | } else {
|
| | | subMoney = average;
|
| | | }
|
| | | if (subMoney.compareTo(debtMoney) > 0)
|
| | | subMoney = debtMoney;
|
| | | debtMoney = debtMoney.subtract(subMoney);
|
| | | sidy.setMoney(sidy.getMoney().subtract(subMoney));
|
| | |
|
| | | if (sidy.getMoney().compareTo(new BigDecimal(0)) == 0) {
|
| | | subsidyList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | return debtMoney;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | String key = its.next();
|
| | | UserDividentsDayDTO dto = map.get(key);
|
| | | try {
|
| | | teamDividentsManager.addDividents(dto.getUid(), dto.getDay());
|
| | | teamDividentsManager.addToTeamEincome(dto.getUid(), dto.getDay());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
New file |
| | |
| | | package com.yeshi.fanli.util.factory.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | public class TeamEincomeRecordFactory {
|
| | |
|
| | | /**
|
| | | * 团队奖励
|
| | | * @Title: createTeamReward
|
| | | * @Description: |
| | | * @param day
|
| | | * @param uid
|
| | | * @param money
|
| | | * @param sourceType
|
| | | * @param beiZhu
|
| | | * @return |
| | | * TeamEincomeRecord 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static TeamEincomeRecord createTeamReward(String day, Long uid, BigDecimal money, int sourceType,
|
| | | String beiZhu) {
|
| | | TeamEincomeRecord record = new TeamEincomeRecord();
|
| | | record.setBeiZhu(beiZhu);
|
| | | record.setCreateTime(new Date());
|
| | | record.setMoney(money);
|
| | | record.setPreRecieveTime(new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd")));
|
| | | record.setRecieveTime(null);
|
| | | record.setSourceType(sourceType);
|
| | | record.setState(TeamEincomeRecord.STATE_NOT_RECIEVE);
|
| | | record.setType(TeamEincomeRecord.TYPE_TEAM_REWARD);
|
| | | record.setUid(uid);
|
| | | return record;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 团队补贴
|
| | | * @Title: createTeamSubsidy
|
| | | * @Description: |
| | | * @param day
|
| | | * @param uid
|
| | | * @param money
|
| | | * @param sourceType
|
| | | * @param beiZhu
|
| | | * @return |
| | | * TeamEincomeRecord 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static TeamEincomeRecord createTeamSubsidy(String day, Long uid, BigDecimal money, int sourceType,
|
| | | String beiZhu) {
|
| | | TeamEincomeRecord record = new TeamEincomeRecord();
|
| | | record.setBeiZhu(beiZhu);
|
| | | record.setCreateTime(new Date());
|
| | | record.setMoney(money);
|
| | | record.setPreRecieveTime(new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd")));
|
| | | record.setRecieveTime(null);
|
| | | record.setSourceType(sourceType);
|
| | | record.setState(TeamEincomeRecord.STATE_NOT_RECIEVE);
|
| | | record.setType(TeamEincomeRecord.TYPE_TEAM_SUBSIDY);
|
| | | record.setUid(uid);
|
| | | return record;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 团队分红
|
| | | * @Title: createTeamDividents
|
| | | * @Description: |
| | | * @param day
|
| | | * @param uid
|
| | | * @param money
|
| | | * @param beiZhu
|
| | | * @return |
| | | * TeamEincomeRecord 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static TeamEincomeRecord createTeamDividents(String day, Long uid, BigDecimal money, String beiZhu) {
|
| | | TeamEincomeRecord record = new TeamEincomeRecord();
|
| | | record.setBeiZhu(beiZhu);
|
| | | record.setCreateTime(new Date());
|
| | | record.setMoney(money);
|
| | | record.setPreRecieveTime(new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd")));
|
| | | record.setRecieveTime(null);
|
| | | record.setState(TeamEincomeRecord.STATE_NOT_RECIEVE);
|
| | | record.setType(TeamEincomeRecord.TYPE_TEAM_DIVIDENTS);
|
| | | record.setUid(uid);
|
| | | return record;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.order;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.MessageListener;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.aliyun.openservices.ons.api.SendResult;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserSystemCouponUseMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.exception.order.OrderTeamRewardException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyServiceV2;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.service.manger.order.TeamSubsidyManager;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | |
| | | @Component
|
| | | public class InviteOrderSubsidyMessageListener implements MessageListener {
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyServiceV2 inviteOrderSubsidyServiceV2;
|
| | | private TeamSubsidyManager teamSubsidyManager;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponRecordService userSystemCouponRecordService;
|
| | |
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(), dto.getType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | try {
|
| | | inviteOrderSubsidyServiceV2.addOrUpdateByOrder(dto.getOrderId(), dto.getType());
|
| | | teamSubsidyManager.addOrUpdateOrder(dto.getOrderId(), dto.getType());
|
| | | return Action.CommitMessage;
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | e.printStackTrace();
|
| | |
| | | return Action.ReconsumeLater;
|
| | | } else {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(dto.getOrderId(), dto.getType());
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | teamSubsidyManager.addOrUpdateOrder(dto.getOrderId(), dto.getType());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {
|
| | | OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsg.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU) {// 自购到账
|
| | | // 判断订单号是否在补贴中
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {// 延时消息发送
|
| | | sendOrderSubsidyUpdateLater(dto, 5);
|
| | | }
|
| | | } else if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_INVITE) {// 邀请到账
|
| | | // 补贴到账
|
| | | try {
|
| | | orderMoneySettleService.inviteSubsidySettle(dto.getUid(), message.getKey());
|
| | | return Action.CommitMessage;
|
| | | } catch (OrderMoneySettleException e) {
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | | }
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiDelay.name())) {
|
| | | OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsg.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU) {// 延时时间已到
|
| | | // 判断订单号是否在补贴中
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {
|
| | | // 判断是否要使用奖励券
|
| | | UserSystemCouponRecord record = userSystemCouponRecordService
|
| | | .getRecordByOrderNo(dto.getOrderId(), UserSystemCouponRecord.STATE_SUCCESS);
|
| | | if (record != null
|
| | | && record.getCouponType()
|
| | | .equalsIgnoreCase(SystemCoupon.CouponTypeEnum.rebatePercentCoupon.name())
|
| | | && record.getGoodSource() == dto.getSourceType()) {// 成功使用了奖励券
|
| | |
|
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(), dto.getType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | inviteOrderSubsidyServiceV2.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else
|
| | |
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else {
|
| | | // 使数据有效
|
| | | try {
|
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(),
|
| | | dto.getType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | inviteOrderSubsidyServiceV2.validByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else
|
| | |
|
| | | inviteOrderSubsidyService.validByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | e.printStackTrace();
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } else if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.useSystemCoupon.name())) {
|
| | | UserSystemCouponUseMQMsg dto = new Gson().fromJson(new String(message.getBody()),
|
| | | UserSystemCouponUseMQMsg.class);
|
| | | if (dto != null && dto.getCouponType()
|
| | | .equalsIgnoreCase(SystemCoupon.CouponTypeEnum.rebatePercentCoupon.name())) {// 返利奖励券的使用
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {
|
| | | // 使相关订单失效
|
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(), dto.getSourceType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | inviteOrderSubsidyServiceV2.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | | //
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 发送订单延时消息
|
| | | * |
| | | * @param day
|
| | | */
|
| | | private boolean sendOrderSubsidyUpdateLater(OrderMoneyRecievedMQMsg dto, int day) {
|
| | |
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiDelay, dto);
|
| | | msg.setKey(dto.getSourceType() + "_" + dto.getOrderId());
|
| | | long delayTime = System.currentTimeMillis() + (Constant.IS_TEST ? 1000 * 30L : 1000 * 60 * 60 * 24L * day);
|
| | | msg.setStartDeliverTime(delayTime);
|
| | | SendResult sendResult = producer.send(msg);
|
| | | if (sendResult != null) {
|
| | | return true;
|
| | | } else {
|
| | | MQUnSendInfo info = new MQUnSendInfo();
|
| | | info.setBody(new String(msg.getBody()));
|
| | | if (msg.getStartDeliverTime() > 0)
|
| | | info.setDeliverTime(new Date(msg.getStartDeliverTime()));
|
| | | info.setKey(msg.getKey());
|
| | | info.setTag(msg.getTag());
|
| | | info.setTopic(msg.getTopic());
|
| | | try {
|
| | | mqUnSendInfoService.addMQUnSendInfo(info);
|
| | | } catch (MQUnSendInfoException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return TransactionStatus.CommitTransaction;
|
| | | else
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiDelay.name())) {
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.teamRewardPreRecieved.name())) {
|
| | | if (hongBaoV2SettleTempService.countByKey(msg.getKey()) > 0)
|
| | | return TransactionStatus.CommitTransaction;
|
| | | else
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiDelay.name())) {
|
| | | OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(msg.getBody()),
|
| | | OrderMoneyRecievedMQMsg.class);
|
| | | if (dto != null) {
|
| | |
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression"
|
| | | value="orderStatistic||orderUpdate||orderFanLiActual||orderFanLiDelay" /><!--expression |
| | | value="orderStatistic||orderUpdate" /><!--expression |
| | | 即 Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 -->
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | |
|
| | |
|
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_USER" />
|
| | | <property name="expression" value="useSystemCoupon" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | |
|
| | | </map>
|
| | | </property>
|
| | | </bean>
|