| | |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listChildrenByIds(@Param("idList") List<Long> idList); |
| | | |
| | | /** |
| | | * 获取奖金列表(1.4.9之前) |
| | | * |
| | |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, @Param("orderType") Integer orderType, |
| | | @Param("start") long start, @Param("count") int count); |
| | | List<HongBaoV2> listCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, |
| | | @Param("orderType") Integer orderType, @Param("maxDate") Date maxPreGetTime, @Param("start") long start, |
| | | @Param("count") int count); |
| | | |
| | | /** |
| | | * 计算可以结算红包的数量 |
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | long countCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, @Param("orderType") Integer orderType); |
| | | long countCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, |
| | | @Param("orderType") Integer orderType, @Param("maxDate") Date maxPreGetTime); |
| | | |
| | | /** |
| | | * 根据用户ID,订单状态和结算时间统计邀请赚的订单数量 |
| | |
| | | * @return |
| | | */ |
| | | Long countInviteOrderCountByUidAndSettleTime(@Param("uid") Long uid, @Param("state") int state, |
| | | @Param("minDate") Date minDate, @Param("maxDate") Date maxDate,@Param("orderType") int orderType); |
| | | @Param("minDate") Date minDate, @Param("maxDate") Date maxDate, @Param("orderType") int orderType); |
| | | |
| | | /** |
| | | * 根据用户ID,订单状态和结算时间统计分享赚的订单数量 |
| | |
| | | * @return |
| | | */ |
| | | Long countShareOrderCountByUidAndSettleTime(@Param("uid") Long uid, @Param("state") int state, |
| | | @Param("minDate") Date minDate, @Param("maxDate") Date maxDate,@Param("orderType") Integer orderType); |
| | | @Param("minDate") Date minDate, @Param("maxDate") Date maxDate, @Param("orderType") Integer orderType); |
| | | |
| | | /** |
| | | * 通过用户ID和状态查询数量 |
| | |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listByStateAndTypeAndUid(@Param("stateList") List<Integer> stateList, |
| | | @Param("typeList") List<Integer> typeList, @Param("uid") Long uid,@Param("start") long start,@Param("count")int count); |
| | | |
| | | |
| | | @Param("typeList") List<Integer> typeList, @Param("uid") Long uid, @Param("start") long start, |
| | | @Param("count") int count); |
| | | |
| | | /** |
| | | * 根据ID批量查询 |
| | | * @param idList |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listByIds(@Param("idList") List<Long> idList); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据订单交易id查询红包 |
| | | * @param idList |
| | | * @return |
| | | */ |
| | | List<HongBaoDTO> listByOrderTradeId(@Param("tradeId") String tradeId); |
| | | |
| | | |
| | | } |
| | |
| | | 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.TeamEincomeRecord; |
| | | |
| | | public interface TeamEincomeRecordMapper extends BaseMapper<TeamEincomeRecord> { |
| | | |
| | | TeamEincomeRecord selectByUidAndPreRecieveTimeAndType(Long uid, Date preRecieveTime, int type); |
| | | |
| | | TeamEincomeRecord selectByPrimaryKeyForUpdate(Long id); |
| | | TeamEincomeRecord selectByUidAndPreRecieveTimeAndType(@Param("uid") Long uid, |
| | | @Param("preRecieveTime") Date preRecieveTime, @Param("type") int type); |
| | | |
| | | List<TeamEincomeRecord> listByUidAndPreRecieveTimeAndState(Long uid, Date preRecieveTime, int state); |
| | | TeamEincomeRecord selectByPrimaryKeyForUpdate(Long id); |
| | | |
| | | List<TeamEincomeRecord> listByUidAndPreRecieveTimeAndState(@Param("uid") Long uid, |
| | | @Param("preRecieveTime") Date preRecieveTime, @Param("state") int state); |
| | | } |
| | |
| | | import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.TeamRewardPreRecieveMQMsg;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | |
|
| | | public enum OrderTopicTagEnum {
|
| | |
| | | banLiShopOrderRefund(BanLiShopOrderMQMsg.class), // 板栗商城订单退款
|
| | | banLiShopOrderPaid(BanLiShopOrderMQMsg.class), // 商城订单支付成功
|
| | | taoBaoOrderWeiQuan(TaoBaoWeiQuanOrder.class),// 淘宝维权订单
|
| | | teamRewardPreRecieved(OrderMoneyRecievedMQMsg.class);//团队奖金预到账
|
| | | teamRewardPreRecieved(TeamRewardPreRecieveMQMsg.class);//团队奖金预到账
|
| | |
|
| | | private final Class<?> clazz;
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.order.body;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 订单确认收货消息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class OrderWeiQuanMQMsg extends BaseMQMsgBody {
|
| | |
|
| | | private String orderNo;
|
| | | private String tradeId;
|
| | | private Integer sourceType;
|
| | |
|
| | | public OrderWeiQuanMQMsg(String orderNo, String tradeId, Integer sourceType) {
|
| | | this.orderNo = orderNo;
|
| | | this.tradeId = tradeId;
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | | |
| | | |
| | | public OrderWeiQuanMQMsg() {
|
| | |
|
| | | }
|
| | |
|
| | | public String getOrderNo() {
|
| | | return orderNo;
|
| | | }
|
| | |
|
| | | public void setOrderNo(String orderNo) {
|
| | | this.orderNo = orderNo;
|
| | | }
|
| | |
|
| | | public String getTradeId() {
|
| | | return tradeId;
|
| | | }
|
| | |
|
| | | public void setTradeId(String tradeId) {
|
| | | this.tradeId = tradeId;
|
| | | }
|
| | |
|
| | | public Integer getSourceType() {
|
| | | return sourceType;
|
| | | }
|
| | |
|
| | | public void setSourceType(Integer sourceType) {
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.order.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 团队奖金预到账消息
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class TeamRewardPreRecieveMQMsg extends BaseMQMsgBody {
|
| | | private String key;
|
| | | private Long uid;
|
| | | private Integer sourceType;
|
| | | private Date preGetTime;
|
| | | private Date createTime;
|
| | |
|
| | | public TeamRewardPreRecieveMQMsg(String key, Long uid, Integer sourceType, Date preGetTime, Date createTime) {
|
| | | super();
|
| | | this.key = key;
|
| | | this.uid = uid;
|
| | | this.sourceType = sourceType;
|
| | | this.preGetTime = preGetTime;
|
| | | this.createTime = createTime;
|
| | | }
|
| | | |
| | | public TeamRewardPreRecieveMQMsg() {
|
| | | }
|
| | |
|
| | | public Date getPreGetTime() {
|
| | | return preGetTime;
|
| | | }
|
| | |
|
| | | public void setPreGetTime(Date preGetTime) {
|
| | | this.preGetTime = preGetTime;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public String getKey() {
|
| | | return key;
|
| | | }
|
| | |
|
| | | public void setKey(String key) {
|
| | | this.key = key;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public Integer getSourceType() {
|
| | | return sourceType;
|
| | | }
|
| | |
|
| | | public void setSourceType(Integer sourceType) {
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.dto.order.dividents;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | public class UserDividentsDayDTO {
|
| | | private Long uid;
|
| | | private String day;
|
| | | private Date preGetTime;
|
| | |
|
| | | public UserDividentsDayDTO(Long uid, String day) {
|
| | | public UserDividentsDayDTO(Long uid, Date preGetTime) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.day = day;
|
| | | this.preGetTime = preGetTime;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | |
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public String getDay() {
|
| | | return day;
|
| | | public Date getPreGetTime() {
|
| | | return preGetTime;
|
| | | }
|
| | |
|
| | | public void setDay(String day) {
|
| | | this.day = day;
|
| | | public void setPreGetTime(Date preGetTime) {
|
| | | this.preGetTime = preGetTime;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public static int CODE_EXIST=1;
|
| | | |
| | | public TeamDividentsSourceOrderException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
| | | (hb_state=1 or hb_state=2) and
|
| | | hb_pre_get_time IS NOT NULL AND
|
| | | hb_pre_get_time>0 AND
|
| | | NOW()>=hb_pre_get_time limit
|
| | | #{maxDate}>=hb_pre_get_time limit
|
| | | #{start},#{count}
|
| | | </select>
|
| | |
|
| | |
| | | (hb_state=1 or hb_state=2) and
|
| | | hb_pre_get_time IS NOT NULL AND
|
| | | hb_pre_get_time>0 AND
|
| | | NOW()>=hb_pre_get_time
|
| | | #{maxDate}>=hb_pre_get_time
|
| | | </select>
|
| | |
|
| | |
|
| | |
| | | </set> |
| | | where ti_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | |
| | | <select id="selectByUidAndPreRecieveTimeAndType" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_income where ti_uid = #{uid} and ti_type=#{type} |
| | | and ti_pre_recieve_time=#{preRecieveTime} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_income where ti_id = #{id,jdbcType=BIGINT} for |
| | | update |
| | | </select> |
| | | |
| | | <select id="listByUidAndPreRecieveTimeAndState" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_team_income where ti_uid = #{uid} and |
| | | ti_pre_recieve_time=#{preRecieveTime} and ti_state=#{state} |
| | | </select> |
| | | |
| | | |
| | | |
| | | </mapper> |
| | |
| | | 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;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | |
| | | return inviteOrderSubsidyMapper.listByOrderNoAndType(orderNo, type);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void addOrderSubsidy(InviteOrderSubsidy orderSubsidy)
|
| | | throws InviteOrderSubsidyException, OrderTeamRewardException, CommonOrderException {
|
| | | throws InviteOrderSubsidyException, CommonOrderException {
|
| | | if (orderSubsidy.getMoney() == null || StringUtil.isNullOrEmpty(orderSubsidy.getOrderNo())
|
| | | || orderSubsidy.getSourceType() == null || orderSubsidy.getUid() == null)
|
| | | throw new InviteOrderSubsidyException(1, "数据不完整");
|
| | |
| | | // 必须是自购订单才返利
|
| | | HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId());
|
| | | if (parent != null
|
| | | && (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {// 不是超级会员的自购/分享才补贴
|
| | | && (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {//
|
| | |
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
|
| | | if (orderList == null || orderList.size() == 0)
|
| | |
| | | }
|
| | |
|
| | | List<HongBaoV2> hbList = hongBaoV2Service.listByIds(idList);
|
| | | Integer state = null;
|
| | | Integer state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | |
|
| | | // 产生改订单的返利总金额
|
| | | 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();
|
| | |
| | |
|
| | | try {
|
| | | addOrderSubsidy(orderSubsidy);
|
| | | } catch (OrderTeamRewardException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | } catch (CommonOrderException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | boolean isSettle = false;
|
| | | if (orderList != null)
|
| | | for (CommonOrder commonOrder : orderList) {
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS
|
| | | || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | isSettle = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (isSettle) {
|
| | | validByOrderIdAndSourceType(orderId, sourceType);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | |
|
| | | @Service
|
| | | public class OrderHongBaoMoneyComputeServiceImpl implements OrderHongBaoMoneyComputeService {
|
| | |
|
| | | static long newRuleTime = TimeUtil.convertToTimeTemp(Constant.NEW_ORDER_FANLI_RULE_TIME, "yyyy-MM-dd");
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
| | | return getBaseCommission(order);
|
| | | }
|
| | |
|
| | | private UserLevelEnum getCommonUserLevel(Date time, UserLevelEnum userLevel) {
|
| | | if (userLevel == null)
|
| | | return UserLevelEnum.daRen;
|
| | | if (time.getTime() < newRuleTime)
|
| | | return UserLevelUtil.getOldLevel(userLevel);
|
| | | else
|
| | | return userLevel;
|
| | | }
|
| | |
|
| | | // 获取基础佣金
|
| | | private BigDecimal getBaseCommission(CommonOrder order) {
|
| | | BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | |
|
| | | if (order.getThirdCreateTime().getTime() >= newRuleTime) {
|
| | | BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | | } else {
|
| | | BigDecimal rate = hongBaoManageService.getFanLiRate(order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeFanliMoney(CommonOrder order, UserLevelEnum userLevel) {
|
| | |
|
| | | BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime())
|
| | | .add(getOfficialSubsidyRate(order.getThirdCreateTime(), userLevel, false));
|
| | | .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
|
| | | getCommonUserLevel(order.getThirdCreateTime(), userLevel), false));
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeShareMoney(CommonOrder order, UserLevelEnum userLevel) {
|
| | | BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime())
|
| | | .add(getOfficialSubsidyRate(order.getThirdCreateTime(), userLevel, true));
|
| | | .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
|
| | | getCommonUserLevel(order.getThirdCreateTime(), userLevel), true));
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | |
| | |
|
| | | @Override
|
| | | public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer) {
|
| | | if (buyer == UserLevelEnum.superVIP) {
|
| | | BigDecimal rate = hongBaoManageService.getByKeyAndMaxTime("new_share_vip_21",
|
| | | order.getThirdCreateTime().getTime());
|
| | | BigDecimal fanLiMoney = computeFanliMoney(order, buyer);
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, fanLiMoney), new BigDecimal(100));
|
| | | }
|
| | |
|
| | | BigDecimal rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_6", order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer) {
|
| | | if (buyer == UserLevelEnum.superVIP)
|
| | | if (buyer == UserLevelEnum.superVIP || buyer == UserLevelEnum.tearcher)
|
| | | return null;
|
| | |
|
| | | BigDecimal rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_7", order.getThirdCreateTime().getTime());
|
| | | if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else if (order.getEstimate() != null)
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
|
| | | return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
|
| | | new BigDecimal(100));
|
| | | else
|
| | | return null;
|
| | | }
|
| | |
| | | BigDecimal officialSubsidyRate = getOfficialSubsidyRate(placeOrderTime, buyerUserLevel, false);
|
| | | return MoneyBigDecimalUtil.div(fanLiMoney.multiply(baseRate).multiply(rate),
|
| | | baseRate.add(officialSubsidyRate).multiply(new BigDecimal(100)));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal computeFirstTeamReward(BigDecimal money, Date placeOrderTime, UserLevelEnum userLevel) {
|
| | |
|
| | | if (userLevel != UserLevelEnum.superVIP)
|
| | | return null;
|
| | |
|
| | | BigDecimal firstRate = getTeamRewardRate(placeOrderTime, userLevel, true);
|
| | |
|
| | | if (firstRate == null)
|
| | | return null;
|
| | |
|
| | | BigDecimal reward = MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(firstRate, money), new BigDecimal(100));
|
| | |
|
| | | return reward;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 计算二级团队奖励
|
| | | * @Title: computeSecondTeamReward
|
| | | * @Description: |
| | | * @param secondTeamSubsidy 购买者上两级团队补贴
|
| | | * @param userLevel 当前用户的等级
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal computeSecondTeamReward(BigDecimal secondTeamSubsidy, Date placeOrderTime,
|
| | | UserLevelEnum userLevel) {
|
| | | if (userLevel != UserLevelEnum.superVIP)
|
| | | return null;
|
| | | // 获取奖励比例
|
| | | BigDecimal secondRate = getTeamRewardRate(placeOrderTime, userLevel, false);
|
| | | if (secondRate == null)
|
| | | return null;
|
| | | BigDecimal secondReward = MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(secondRate, secondTeamSubsidy),
|
| | | new BigDecimal(100));
|
| | | return secondReward;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | key = String.format("official_subsidy_share_%s", userLevel.getLevel());
|
| | | else
|
| | | key = String.format("official_subsidy_zigou_%s", userLevel.getLevel());
|
| | | BigDecimal rate = null;
|
| | | if (date != null)
|
| | | rate = hongBaoManageService.getByKeyAndMaxTime(key, date.getTime());
|
| | | else
|
| | | rate = new BigDecimal(hongBaoManageService.get(key));
|
| | | return rate;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取团队奖励比例
|
| | | * @Title: getTeamRewardRate
|
| | | * @Description: |
| | | * @param date
|
| | | * @param userLevel
|
| | | * @param first
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | private BigDecimal getTeamRewardRate(Date date, UserLevelEnum userLevel, boolean first) {
|
| | | if (userLevel == null)
|
| | | return null;
|
| | | if (userLevel != UserLevelEnum.superVIP)
|
| | | return new BigDecimal(0);
|
| | |
|
| | | String key = null;
|
| | | if (first)
|
| | | key = "team_reward_6_10";
|
| | | else
|
| | | key = "team_reward_7_10";
|
| | | BigDecimal rate = null;
|
| | | if (date != null)
|
| | | rate = hongBaoManageService.getByKeyAndMaxTime(key, date.getTime());
|
| | |
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.TeamRewardPreRecieveMQMsg;
|
| | | 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.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | 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;
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void inviteSettleTB(Long uid) throws OrderMoneySettleException {
|
| | | public void inviteSettleTB(Long uid, Date maxPregetTime) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, maxPregetTime);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | maxPregetTime, i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date(), 0);
|
| | | String taskKey = getTaskKey(uid);
|
| | |
|
| | | TeamRewardPreRecieveMQMsg mqMsg = new TeamRewardPreRecieveMQMsg(taskKey, uid, sourceType, maxPregetTime,
|
| | | new Date());
|
| | |
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | | String taskKey = getTaskKey(uid);
|
| | |
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | |
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanliInvite(hongBaoList, uid, Constant.SOURCE_TYPE_TAOBAO, taskKey);
|
| | | fanliInvite(hongBaoList, uid, Constant.SOURCE_TYPE_TAOBAO, taskKey, maxPregetTime);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | System.out.println(new Gson().toJson(mqMsg));
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void inviteSettleJD(Long uid) throws OrderMoneySettleException {
|
| | | public void inviteSettleJD(Long uid, Date maxPregetTime) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_JD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, maxPregetTime);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | maxPregetTime, i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date(), 0);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | |
|
| | | String taskKey = getTaskKey(uid);
|
| | | TeamRewardPreRecieveMQMsg mqMsg = new TeamRewardPreRecieveMQMsg(taskKey, uid, sourceType, maxPregetTime,
|
| | | new Date());
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | |
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanliInvite(hongBaoList, uid, sourceType, taskKey);
|
| | | fanliInvite(hongBaoList, uid, sourceType, taskKey, maxPregetTime);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | return TransactionStatus.RollbackTransaction;
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void inviteSettlePDD(Long uid) throws OrderMoneySettleException {
|
| | | public void inviteSettlePDD(Long uid, Date maxPregetTime) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_PDD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, maxPregetTime);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | maxPregetTime, i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date(), 0);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | | String taskKey = getTaskKey(uid);
|
| | | TeamRewardPreRecieveMQMsg mqMsg = new TeamRewardPreRecieveMQMsg(taskKey, uid, sourceType, maxPregetTime,
|
| | | new Date());
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | |
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanliInvite(hongBaoList, uid, sourceType, taskKey);
|
| | | fanliInvite(hongBaoList, uid, sourceType, taskKey, maxPregetTime);
|
| | | } catch (Exception e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void shareSettleTB(Long uid) throws OrderMoneySettleException {
|
| | | Date maxPregetTime = new Date();
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | |
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, maxPregetTime);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | maxPregetTime, i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void shareSettleJD(Long uid) throws OrderMoneySettleException {
|
| | | Date maxPregetTime = new Date();
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | |
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, maxPregetTime);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | maxPregetTime, i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void shareSettlePDD(Long uid) throws OrderMoneySettleException {
|
| | | Date maxPregetTime = new Date();
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | |
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, maxPregetTime);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | maxPregetTime, i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void fanliInvite(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key)
|
| | | private void fanliInvite(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key, Date maxPreGetTime)
|
| | | throws TeamEincomeRecordException, ParamsException, TeamRewardDebtException {
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | |
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | 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);
|
| | | teamRewardManager.addToEincome(uid, maxPreGetTime, invitemoney, sourceType);
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, key);
|
| | |
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : hbIdList) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | if (Constant.ENABLE_MQ)
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void inviteSubsidySettle(Long uid, String taskKey)
|
| | | public void inviteSubsidySettle(Long uid, String taskKey,Date maxPreGetTime)
|
| | | throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException {
|
| | | teamSubsidyManager.addToTeamEincome(uid, taskKey);
|
| | | teamSubsidyManager.addToTeamEincome(uid, taskKey,maxPreGetTime);
|
| | | }
|
| | |
|
| | | private String getTaskKey(Long uid) {
|
| | |
| | | || hb.getPreGetTime().getTime() > System.currentTimeMillis())
|
| | | continue;
|
| | | try {
|
| | | CMQManager.getInstance().addFanLiMsgNew(hb);
|
| | | if (Constant.ENABLE_MQ)
|
| | | CMQManager.getInstance().addFanLiMsgNew(hb);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | for (TaoBaoWeiQuanOrder order : orderList) {
|
| | | try {
|
| | | if (order.getState().contains("维权成功")) {
|
| | | CMQManager.getInstance().addWeiQuanOrderMsg(order);
|
| | | if (Constant.ENABLE_MQ)
|
| | | CMQManager.getInstance().addWeiQuanOrderMsg(order);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("维权订单加入到队列出错:" + order != null ? new Gson().toJson(order) : null);
|
| | |
| | | while (its.hasNext()) {
|
| | | Long uid = its.next();
|
| | | try {
|
| | | CMQManager.getInstance().addFanLiTiChengMsg(uid);
|
| | | if (Constant.ENABLE_MQ)
|
| | | CMQManager.getInstance().addFanLiTiChengMsg(uid);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.error(e);
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException {
|
| | | // 邀请赚到账
|
| | | Date now = new Date();
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleTB(uid);
|
| | | orderMoneySettleService.inviteSettleTB(uid, now);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleJD(uid);
|
| | | orderMoneySettleService.inviteSettleJD(uid, now);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | //
|
| | | try {
|
| | | orderMoneySettleService.inviteSettlePDD(uid);
|
| | | orderMoneySettleService.inviteSettlePDD(uid, now);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | //
|
| | | try {
|
| | | orderMoneySettleService.shareSettlePDD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void fanliPreInvaite(Long uid, Date maxPreGetTime) {
|
| | | // 邀请赚到账
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleTB(uid, maxPreGetTime);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleJD(uid, maxPreGetTime);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.inviteSettlePDD(uid, maxPreGetTime);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | if (!Constant.IS_TEST)
|
| | | if (Constant.ENABLE_MQ)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | if (Constant.ENABLE_MQ)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_JD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | if (Constant.ENABLE_MQ)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_JD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | if (Constant.ENABLE_MQ)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_PDD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | if (Constant.ENABLE_MQ)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_PDD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | if (Constant.ENABLE_MQ)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
| | | public List<HongBaoV2> getCanBalanceElmeFanliHongBao() {
|
| | | List<Integer> list = new ArrayList<>();
|
| | | list.add(HongBaoV2.TYPE_ELME);
|
| | | return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, 0, 1000);
|
| | | return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, new Date(), 0, 1000);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | TeamDividentsSourceOrder sourceOrder = selectByOrderNoSourceType(order.getOrderNo(), order.getSourceType());
|
| | | if (sourceOrder != null)
|
| | | throw new TeamDividentsSourceOrderException(1, "订单已存在");
|
| | | throw new TeamDividentsSourceOrderException(TeamDividentsSourceOrderException.CODE_EXIST, "订单已存在");
|
| | |
|
| | | if (order.getCreateTime() == null)
|
| | | order.setCreateTime(new Date());
|
| | |
| | | package com.yeshi.fanli.service.impl.order.tb;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.BanLiShopOrderMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderWeiQuanMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail.MsgTypeOrderTypeEnum;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | | public class TaoBaoWeiQuanOrderServiceImpl implements TaoBaoWeiQuanOrderService {
|
| | |
| | | @Resource
|
| | | private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void addWeiQuanOrder(TaoBaoWeiQuanOrder order) {
|
| | | if (order == null)
|
| | | return;
|
| | |
|
| | | boolean isAdd = false;
|
| | | boolean isUpdate = false;
|
| | | Long id = null;
|
| | |
|
| | | TaoBaoWeiQuanOrder taoBaoWeiQuanOrder = taoBaoWeiQuanOrderMapper
|
| | | .selectByOrderIdAndOrderItemId(order.getOrderId(), order.getOrderItemId());
|
| | | if (taoBaoWeiQuanOrder != null) {
|
| | | id = taoBaoWeiQuanOrder.getId();
|
| | | // 已经是最新的状态了
|
| | | if (taoBaoWeiQuanOrder.getState() != null && (taoBaoWeiQuanOrder.getState().contains("维权成功")))
|
| | | return;
|
| | |
| | | update.setUpdateTime(new Date());
|
| | | update.setWeiQuanFinishTime(order.getWeiQuanFinishTime());
|
| | | taoBaoWeiQuanOrderMapper.updateByPrimaryKeySelective(update);
|
| | |
|
| | | isUpdate = true;
|
| | | try {
|
| | | if (order.getState().contains("维权成功")) {
|
| | | // 更改CommonOrder的状态
|
| | |
| | | commonOrderService.updateByPrimaryKeySelective(updateCommonOrder);
|
| | | userOrderWeiQuanRecordService.addTaoBaoWeiQuan(taoBaoWeiQuanOrder);
|
| | | }
|
| | |
|
| | | // 维权状态不需要消息
|
| | | // List<MsgOrderDetail> msgList =
|
| | | // msgOrderDetailService.listMsgOrderByOrderId(order.getOrderId());
|
| | | // for (MsgOrderDetail msg : msgList) {
|
| | | // if (msg.getType() == MsgTypeOrderTypeEnum.fanli) {
|
| | | // userOrderMsgNotificationService.orderFanLiStateChanged(msg.getUser().getId(),
|
| | | // order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO, null,
|
| | | // null, CommonOrder.STATE_WQ);
|
| | | // } else if (msg.getType() == MsgTypeOrderTypeEnum.invite)
|
| | | // {
|
| | | // userOrderMsgNotificationService.orderInviteStateChanged(msg.getUser().getId(),
|
| | | // order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO, null,
|
| | | // null, CommonOrder.STATE_WQ);
|
| | | // } else if (msg.getType() == MsgTypeOrderTypeEnum.share) {
|
| | | // userOrderMsgNotificationService.orderShareStateChanged(msg.getUser().getId(),
|
| | | // order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO, null,
|
| | | // null, CommonOrder.STATE_WQ);
|
| | | // }
|
| | | // }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | |
| | | order.setCreateTime(new Date());
|
| | | order.setUpdateTime(new Date());
|
| | | taoBaoWeiQuanOrderMapper.insertSelective(order);
|
| | | id = order.getId();
|
| | | isAdd = true;
|
| | | if (order.getState().contains("维权成功")) {
|
| | | // 更改CommonOrder的状态
|
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 增加或修改
|
| | | if (isAdd || isUpdate) {
|
| | | if (id != null) {
|
| | | OrderWeiQuanMQMsg msg = new OrderWeiQuanMQMsg(order.getOrderId(), order.getOrderItemId(),
|
| | | Constant.SOURCE_TYPE_TAOBAO);
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.taoBaoOrderWeiQuan,
|
| | | msg);
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | 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 {
|
| | |
|
| | |
| | | * @param sourceType
|
| | | */
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType)
|
| | | throws InviteOrderSubsidyException, OrderTeamRewardException, CommonOrderException;
|
| | | throws InviteOrderSubsidyException, CommonOrderException;
|
| | |
|
| | | /**
|
| | | * 根据订单号与来源查询
|
| | |
| | | public BigDecimal computeSecondTeamSubsidy(BigDecimal fanLiMoney, Date placeOrderTime, UserLevelEnum buyerUserLevel,
|
| | | UserLevelEnum userLevel);
|
| | |
|
| | | /**
|
| | | * 计算一级团队奖励
|
| | | * @Title: computeFirstTeamReward
|
| | | * @Description: |
| | | * @param firstTeamSubsidy -购买者上一级团队补贴
|
| | | * @param secondTeamSubsidy-购买者上两级团队补贴
|
| | | * @param userLevel 当前用户的等级
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal computeFirstTeamReward(BigDecimal firstTeamSubsidy, Date placeOrderTime, UserLevelEnum userLevel);
|
| | |
|
| | | /**
|
| | | * 计算二级团队奖励
|
| | | * @Title: computeSecondTeamReward
|
| | | * @Description: |
| | | * @param secondTeamSubsidy 购买者上两级团队补贴
|
| | | * @param userLevel 当前用户的等级
|
| | | * @return |
| | | * BigDecimal 返回类型
|
| | | * @throws
|
| | | */
|
| | | public BigDecimal computeSecondTeamReward(BigDecimal secondTeamSubsidy, Date placeOrderTime,
|
| | | UserLevelEnum userLevel);
|
| | |
|
| | | /**
|
| | | * 计算团队补贴
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | |
| | | *
|
| | | * @param uid
|
| | | */
|
| | | public void inviteSettleTB(Long uid) throws OrderMoneySettleException;
|
| | | public void inviteSettleTB(Long uid,Date maxPregetTime) throws OrderMoneySettleException;
|
| | |
|
| | | public void inviteSettleJD(Long uid) throws OrderMoneySettleException;
|
| | | public void inviteSettleJD(Long uid,Date maxPregetTime) throws OrderMoneySettleException;
|
| | |
|
| | | public void inviteSettlePDD(Long uid) throws OrderMoneySettleException;
|
| | | public void inviteSettlePDD(Long uid,Date maxPregetTime) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 分享赚结算
|
| | |
| | | * @param taskKey
|
| | | * @throws OrderMoneySettleException
|
| | | */
|
| | | public void inviteSubsidySettle(Long uid, String taskKey)
|
| | | public void inviteSubsidySettle(Long uid, String taskKey,Date maxPreGetTime)
|
| | | throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException;
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.order.OrderItemException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | |
| | | public void fanliInvaiteAndShare();
|
| | |
|
| | | /**
|
| | | * 结算团队收益
|
| | | * @Title: fanliInvaite
|
| | | * @Description: |
| | | * @param maxPreGetTime |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | |
|
| | | public void fanliPreInvaite(Long uid, Date maxPreGetTime);
|
| | |
|
| | | /**
|
| | | * 分享赚与邀请赚返利
|
| | | */
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.order.OrderHongBaoRateParams;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | |
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | |
|
| | | @Component
|
| | | public class HongBaoV2AddManager {
|
| | |
| | | @Resource
|
| | | private UserLevelManager userLevelManager;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | /**
|
| | | * 添加红包信息
|
| | | *
|
| | |
| | | * @return
|
| | | * @throws HongBaoException
|
| | | * @throws UserAccountException
|
| | | * @throws CommonOrderException |
| | | * @throws OrderTeamRewardException |
| | | * @throws InviteOrderSubsidyException |
| | | */
|
| | | public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException, UserAccountException {
|
| | |
|
| | | if (commonOrderList != null && commonOrderList.size() > 0) {
|
| | | int orderType = commonOrderList.get(0).getSourceType();
|
| | | String orderId = commonOrderList.get(0).getOrderNo();
|
| | |
|
| | | Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
|
| | | int goodsCount = 0;
|
| | | boolean hasAdd = false;
|
| | | boolean hasUpdate = false;
|
| | | Set<Integer> stateSet = new HashSet<>();// 订单状态Set
|
| | |
|
| | | UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(commonOrderList.get(0).getUrank());
|
| | |
|
| | | if (userLevel == null)
|
| | | userLevel = UserLevelEnum.daRen;
|
| | |
|
| | | Date placeOrderDate = commonOrderList.get(0).getThirdCreateTime();
|
| | |
|
| | | for (CommonOrder commonOrder : commonOrderList) {
|
| | | stateSet.add(commonOrder.getState());
|
| | | goodsCount += commonOrder.getCount();
|
| | |
| | | throw new HongBaoException(1, "订单信息不完整");
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder == null) {
|
| | | saveHongBao(commonOrder, type, notificationMap);
|
| | | saveHongBao(commonOrder, type, notificationMap, userLevel, placeOrderDate);
|
| | | hasAdd = true;
|
| | | } else {
|
| | | boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
|
| | | if (update)
|
| | | boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap, placeOrderDate);
|
| | | if (update) {
|
| | | hasUpdate = true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (hasAdd) {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | throw new HongBaoException(201, "添加补贴出错");
|
| | | } catch (CommonOrderException e) {
|
| | | throw new HongBaoException(202, "添加补贴出错");
|
| | | }
|
| | | }
|
| | |
|
| | | int state = getOrderState(stateSet);
|
| | |
|
| | | if (hasAdd || hasUpdate) {
|
| | | // 补贴失效
|
| | | if (state == CommonOrder.STATE_SX)
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(orderId, orderType);
|
| | | else
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | LogHelper.errorDetailInfo(e, "淘宝订单补贴更新失败", orderId);
|
| | | } catch (CommonOrderException e) {
|
| | | LogHelper.errorDetailInfo(e, "淘宝订单补贴更新失败", orderId);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通知用户的返利情况
|
| | | */
|
| | | int state = getOrderState(stateSet);
|
| | |
|
| | | if (!Constant.IS_TEST) {
|
| | | if (hasAdd) {
|
| | | Iterator<Integer> its = notificationMap.keySet().iterator();
|
| | |
| | | Integer t = its.next();
|
| | | HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
|
| | | CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
|
| | | String orderId = commonOrderList.get(0).getOrderNo();
|
| | | Long uid = notify.getUserInfo().getId();
|
| | | BigDecimal money = notify.getMoney();
|
| | | switch (t) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | | userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getPayment(), money, goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_GOODS:
|
| | |
|
| | | userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getPayment(), money, goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getPayment(), money, goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getPayment(), money, goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | | |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | |
|
| | | break; |
| | | |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
|
| | | Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException {
|
| | | Map<Integer, HongBaoOrder> notificationMap, Date placeOrderTime)
|
| | | throws HongBaoException, UserAccountException {
|
| | | System.out.println(commonOrder.getOrderNo());
|
| | | // 锁行
|
| | | HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoOrder.getHongBaoV2().getId());
|
| | | if (oldHongBao == null)
|
| | | throw new HongBaoException(10, "红包对象不存在");
|
| | | UserLevelEnum buyerLevel = UserLevelUtil.getByOrderRank(oldHongBao.getUrank());
|
| | | if (buyerLevel == null)
|
| | | throw new HongBaoException(201, "用户等级为空");
|
| | |
|
| | | // 已经失效,已经领取,新老状态一致的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | return false;
|
| | |
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getRate(new OrderHongBaoRateParams(0, type, false,
|
| | | oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | | BigDecimal money = orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, buyerLevel);
|
| | | // 免单处理
|
| | | boolean mianDan = false;
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | HongBaoV2 hongBao = createFanLiUpdateHongBao(commonOrder, fanliRate, hongBaoOrder.getHongBaoV2().getId(),
|
| | | HongBaoV2 hongBao = createFanLiUpdateHongBao(commonOrder, money, hongBaoOrder.getHongBaoV2().getId(),
|
| | | mianDan);
|
| | |
|
| | | // 新老红包状态一致不处理
|
| | |
| | | tempHongBao.setMoney(hongBao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | | HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
|
| | | tempHongBaoOrder.getCommonOrder()
|
| | | .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
|
| | |
|
| | | tempHongBaoOrder.getHongBaoV2()
|
| | | .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
|
| | | notificationMap.put(type, tempHongBaoOrder);
|
| | |
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | continue;
|
| | | BigDecimal rate = null;
|
| | |
|
| | | if (child.getType() == HongBaoV2.TYPE_YIJI) {
|
| | | rate = hongBaoManageService.getRate(new OrderHongBaoRateParams(1, oldHongBao.getType(), false,
|
| | | oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | } else if (child.getType() == HongBaoV2.TYPE_ERJI) {
|
| | | rate = hongBaoManageService.getRate(new OrderHongBaoRateParams(2, oldHongBao.getType(), false,
|
| | | oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | }
|
| | |
|
| | | HongBaoV2 childUpdate = createInviteUpdateHongBao(child, hongBao.getState(),
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))), commonOrder);
|
| | | HongBaoV2 childUpdate = createInviteUpdateHongBao(child, hongBao.getState(), money, commonOrder);
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
|
| | |
|
| | | // 加入通知
|
| | |
| | | tempHongBao.setMoney(child.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | if (!mianDan) {
|
| | | ThreeSale threeSale = threeSaleSerivce.selectByWorkerId(commonOrder.getUserInfo().getId());
|
| | | if (threeSale != null && threeSale.getSucceedTime() != null
|
| | | && threeSale.getSucceedTime() <= commonOrder.getThirdCreateTime().getTime()) {
|
| | | && threeSale.getSucceedTime() <= placeOrderTime.getTime()) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(commonOrder.getUserInfo().getId());
|
| | | if (boss != null) {
|
| | | boss = userInfoService.selectAvailableByPrimaryKey(boss.getId());
|
| | |
| | |
|
| | | if (boss != null) {
|
| | | // 插入一级子红包
|
| | | BigDecimal firstRate = hongBaoManageService.getRate(new OrderHongBaoRateParams(1, type,
|
| | | false, oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | | if (firstRate != null && firstRate.compareTo(new BigDecimal(0)) > 0) {
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | UserLevelEnum bossUserLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | if (money != null) {
|
| | | HongBaoV2 firstHongbao = createInviteHongBao(boss.getId(), oldHongBao, commonOrder,
|
| | | HongBaoV2.TYPE_YIJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(),
|
| | | firstRate.divide(new BigDecimal(100))));
|
| | | HongBaoV2.TYPE_YIJI, money, bossUserLevel);
|
| | | if (firstHongbao != null)
|
| | | addInviteHongBao(firstHongbao, null, notificationMap, commonOrder);
|
| | | }
|
| | |
| | | boss = userInfoService.selectAvailableByPrimaryKey(boss.getId());
|
| | | }
|
| | | if (boss != null) {
|
| | | // 二级红包
|
| | | BigDecimal secondRate = hongBaoManageService.getRate(new OrderHongBaoRateParams(2, type,
|
| | | false, oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | | if (secondRate != null && secondRate.compareTo(new BigDecimal(0)) > 0) {
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder,
|
| | | buyerLevel);
|
| | | bossUserLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | if (money != null) {
|
| | | HongBaoV2 secondHongbao = createInviteHongBao(boss.getId(), oldHongBao, commonOrder,
|
| | | HongBaoV2.TYPE_ERJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | | HongBaoV2.TYPE_ERJI, money, bossUserLevel);
|
| | | if (secondHongbao != null)
|
| | | addInviteHongBao(secondHongbao, null, notificationMap, commonOrder);
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | | } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | BigDecimal fanliRate = hongBaoManageService.getRate(new OrderHongBaoRateParams(0, type, false,
|
| | | oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | |
|
| | | HongBaoV2 hongBao = createShareUpdateHongBao(commonOrder, fanliRate, oldHongBao.getId());
|
| | | BigDecimal money = orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, buyerLevel);
|
| | |
|
| | | HongBaoV2 hongBao = createShareUpdateHongBao(commonOrder, money, oldHongBao.getId());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
|
| | | // 通知
|
| | | if (notificationMap.get(type) == null) {
|
| | |
| | | tempHongBao.setMoney(hongBao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | continue;
|
| | |
|
| | | BigDecimal rate = null;
|
| | | if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
|
| | | rate = hongBaoManageService.getRate(new OrderHongBaoRateParams(1, oldHongBao.getType(), false,
|
| | | oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {
|
| | | rate = hongBaoManageService.getRate(new OrderHongBaoRateParams(2, oldHongBao.getType(), false,
|
| | | oldHongBao.getUrank() == 100, commonOrder.getThirdCreateTime()));
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | }
|
| | | HongBaoV2 childUpdate = createInviteUpdateHongBao(child, hongBao.getState(),
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))), commonOrder);
|
| | | HongBaoV2 childUpdate = createInviteUpdateHongBao(child, hongBao.getState(), money, commonOrder);
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
|
| | | // 添加通知
|
| | | if (notificationMap.get(child.getType()) == null) {
|
| | |
| | | .setMoney(childUpdate.getMoney() == null ? new BigDecimal(0) : childUpdate.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
|
| | | throws HongBaoException, UserAccountException {
|
| | | private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap,
|
| | | UserLevelEnum buyerLevel, Date placeOrderDate) throws HongBaoException, UserAccountException {
|
| | |
|
| | | boolean vip = commonOrder.getUrank() != null && commonOrder.getUrank() == 100;
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService
|
| | | .getRate(new OrderHongBaoRateParams(0, type, false, vip, commonOrder.getThirdCreateTime()));
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {
|
| | | // 查询是否有免单计划
|
| | | BigDecimal mianDanMoney = null;
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | |
| | | BigDecimal payMent = commonOrder.getPayment();
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS)
|
| | | payMent = commonOrder.getSettlement();
|
| | |
|
| | | CommonOrderGoods goods = commonOrderGoodsMapper
|
| | | .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId());
|
| | | if (goods != null) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | HongBaoV2 hongBao = createFanLiHongBao(commonOrder, fanliRate, mianDanMoney);
|
| | | HongBaoV2 hongBao = createFanLiHongBao(commonOrder,
|
| | | orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, buyerLevel), mianDanMoney,
|
| | | buyerLevel);
|
| | | if (hongBao == null)
|
| | | return;
|
| | | addFanLiOrShareHongBao(hongBao, commonOrder, notificationMap);
|
| | | UserInfo boss = threeSaleSerivce.getBoss(hongBao.getUserInfo().getId());
|
| | | if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO && mianDanMoney == null) {// 1级BOSS存在且红包未失效,免单不支持多级分销
|
| | | // 插入一级子红包
|
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getRate(new OrderHongBaoRateParams(1, type, false, vip, commonOrder.getThirdCreateTime()));
|
| | | if (firstRate.compareTo(new BigDecimal(0)) <= 0)// 返利比例为0的不分成
|
| | | BigDecimal money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | if (money == null)// 返利资金为空不参与分成
|
| | | return;
|
| | |
|
| | | UserLevelEnum bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | |
|
| | | HongBaoV2 firstHongbao = createInviteHongBao(boss.getId(), hongBao, commonOrder, HongBaoV2.TYPE_YIJI,
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
|
| | | money, bossLevel);
|
| | |
|
| | | addInviteHongBao(firstHongbao, null, notificationMap, commonOrder);
|
| | |
|
| | | // 插入二级子红包
|
| | | boss = threeSaleSerivce.getBoss(boss.getId());
|
| | | if (boss != null) {// 二级BOSS存在且是非会员订单
|
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getRate(new OrderHongBaoRateParams(2, type, false, vip, commonOrder.getThirdCreateTime()));
|
| | | if (secondRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | if (money == null)
|
| | | return;
|
| | | HongBaoV2 secondHongbao = createInviteHongBao(boss.getId(), hongBao, commonOrder,
|
| | | HongBaoV2.TYPE_ERJI,
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
|
| | | HongBaoV2.TYPE_ERJI, money, bossLevel);
|
| | | addInviteHongBao(secondHongbao, null, notificationMap, commonOrder);
|
| | | }
|
| | | }
|
| | |
| | | if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
|
| | | return;
|
| | | // 分享赚
|
| | | BigDecimal shareRate = null;
|
| | | BigDecimal money = null;
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
|
| | | && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))// 来自于淘礼金的分享
|
| | | shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
|
| | | else
|
| | | shareRate = hongBaoManageService
|
| | | .getRate(new OrderHongBaoRateParams(0, type, false, vip, commonOrder.getThirdCreateTime()));
|
| | | {
|
| | | BigDecimal shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_WQ)
|
| | | money = MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
|
| | | MoneyBigDecimalUtil.div(shareRate, new BigDecimal(100)));
|
| | | else
|
| | | money = MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
|
| | | MoneyBigDecimalUtil.div(shareRate, new BigDecimal(100)));
|
| | | } else
|
| | | money = orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, buyerLevel);
|
| | |
|
| | | if (shareRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | HongBaoV2 hongBao = createShareHongBao(commonOrder, shareRate, vip);
|
| | | HongBaoV2 hongBao = createShareHongBao(commonOrder, money, buyerLevel);
|
| | | if (hongBao == null)
|
| | | return;
|
| | | addFanLiOrShareHongBao(hongBao, commonOrder, notificationMap);
|
| | | // 4月17日后才有一级分享赚
|
| | | if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-17", "yyyy-MM-dd")) {
|
| | | if (placeOrderDate.getTime() > TimeUtil.convertToTimeTemp("2019-04-17", "yyyy-MM-dd")) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(hongBao.getUserInfo().getId());
|
| | | if (boss != null) {
|
| | | BigDecimal firstLevelRate = hongBaoManageService
|
| | | .getRate(new OrderHongBaoRateParams(1, type, false, vip, commonOrder.getThirdCreateTime()));
|
| | | if (firstLevelRate == null || firstLevelRate.compareTo(new BigDecimal("0")) == 0)
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel);
|
| | | if (money == null)
|
| | | return;
|
| | |
|
| | | UserLevelEnum bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | HongBaoV2 firstHongbao = createInviteHongBao(boss.getId(), hongBao, commonOrder,
|
| | | HongBaoV2.TYPE_SHARE_YIJI,
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstLevelRate.divide(new BigDecimal(100))));
|
| | | HongBaoV2.TYPE_SHARE_YIJI, money, bossLevel);
|
| | |
|
| | | addInviteHongBao(firstHongbao, hongBao.getUserInfo().getNickName(), notificationMap, commonOrder);
|
| | |
|
| | | // 二级分享赚
|
| | | boss = threeSaleSerivce.getBoss(boss.getId());
|
| | | if (boss != null) {
|
| | | BigDecimal secondLevelRate = hongBaoManageService.getRate(
|
| | | new OrderHongBaoRateParams(2, type, false, vip, commonOrder.getThirdCreateTime()));
|
| | | if (secondLevelRate.compareTo(new BigDecimal(0)) <= 0)// 返利比例为0就不统计
|
| | | money = orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder, buyerLevel);
|
| | | if (money == null)// 返利比例为0就不统计
|
| | | return;
|
| | | bossLevel = userLevelManager.getUserLevel(boss.getId());
|
| | | HongBaoV2 secondChild = createInviteHongBao(boss.getId(), hongBao, commonOrder,
|
| | | HongBaoV2.TYPE_SHARE_ERJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(),
|
| | | secondLevelRate.divide(new BigDecimal(100))));
|
| | | HongBaoV2.TYPE_SHARE_ERJI, money, bossLevel);
|
| | | addInviteHongBao(secondChild, null, notificationMap, commonOrder);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | * @return
|
| | | */
|
| | | private HongBaoV2 createInviteHongBao(Long uid, HongBaoV2 parent, CommonOrder commonOrder, int hongBaoType,
|
| | | BigDecimal money) {
|
| | | BigDecimal money, UserLevelEnum userLevel) {
|
| | | if (parent == null)
|
| | | return null;
|
| | | if (parent.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | |
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | return null;
|
| | |
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(uid);
|
| | |
|
| | | HongBaoV2 child = new HongBaoV2();
|
| | | child.setParent(parent);
|
| | |
| | | }
|
| | |
|
| | | child.setUserInfo(user);
|
| | | child.setUrank(level.getOrderRank());
|
| | | child.setUrank(user.getRank());
|
| | | child.setVersion(2);
|
| | | child.setCreateTime(new Date());
|
| | | child.setOrderType(commonOrder.getSourceType());
|
| | | if (child.getMoney() == null)
|
| | | return null;
|
| | | if (child.getMoney().compareTo(new BigDecimal(0)) <= 0 && userLevel == UserLevelEnum.daRen)
|
| | | return null;
|
| | | return child;
|
| | | }
|
| | |
| | | * -返利比例
|
| | | * @param mianDanMoney
|
| | | * 免单金额
|
| | | * @param isVIP-是否为VIP订单
|
| | | * @return
|
| | | * @throws HongBaoException
|
| | | * @throws UserAccountException
|
| | | */
|
| | | private HongBaoV2 createFanLiHongBao(CommonOrder commonOrder, BigDecimal fanliRate, BigDecimal mianDanMoney) throws HongBaoException, UserAccountException {
|
| | | private HongBaoV2 createFanLiHongBao(CommonOrder commonOrder, BigDecimal money, BigDecimal mianDanMoney,
|
| | | UserLevelEnum userLevel) throws HongBaoException, UserAccountException {
|
| | | HongBaoV2 hongBao = new HongBaoV2();
|
| | | hongBao.setUserInfo(commonOrder.getUserInfo());
|
| | | hongBao.setCreateTime(new Date());
|
| | | hongBao.setType(HongBaoV2.TYPE_ZIGOU);
|
| | | hongBao.setVersion(2);
|
| | | hongBao.setMoney(money);
|
| | | if (commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
|
| | |
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS || CommonOrder.STATE_WQ == commonOrder.getState()) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天半到账
|
| | | hongBao.setPreGetTime(new Date(
|
| | | commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 12L));
|
| | |
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | if (user == null)
|
| | | throw new UserAccountException(1001, "用户不存在/被封禁");
|
| | | UserLevelEnum userLevel = userLevelManager.getUserLevel(commonOrder.getUserInfo().getId(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | if (userLevel != null)
|
| | | hongBao.setUrank(userLevel.getOrderRank());
|
| | | else {
|
| | | hongBao.setUrank(user.getRank());
|
| | | }
|
| | | hongBao.setUrank(userLevel.getOrderRank());
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | | return hongBao;
|
| | | }
|
| | |
| | | tempHongBao.setMoney(hongBao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(hongBao.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | * @throws HongBaoException
|
| | | * @throws UserAccountException
|
| | | */
|
| | | private HongBaoV2 createShareHongBao(CommonOrder commonOrder, BigDecimal shareRate, boolean isVip)
|
| | | private HongBaoV2 createShareHongBao(CommonOrder commonOrder, BigDecimal money, UserLevelEnum userLevel)
|
| | | throws HongBaoException, UserAccountException {
|
| | | HongBaoV2 hongBao = new HongBaoV2();
|
| | | hongBao.setCreateTime(new Date());
|
| | | hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | hongBao.setVersion(2);
|
| | | hongBao.setMoney(money);
|
| | | if (commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | |
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | if (user == null)
|
| | | throw new UserAccountException(1001, "用户不存在/被封禁");
|
| | | UserLevelEnum userLevel = userLevelManager.getUserLevel(commonOrder.getUserInfo().getId(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | if (userLevel != null)
|
| | | hongBao.setUrank(userLevel.getOrderRank());
|
| | | else
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setUrank(userLevel.getOrderRank());
|
| | | hongBao.setUserInfo(user);
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | | return hongBao;
|
| | |
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
|
| | |
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | | |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | |
|
| | | break; |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | tempHongBao.setMoney(hongBao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | | HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
|
| | | tempHongBaoOrder.getCommonOrder()
|
| | | .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
|
| | |
|
| | | tempHongBaoOrder.getHongBaoV2()
|
| | | .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
|
| | | notificationMap.put(type, tempHongBaoOrder);
|
| | |
| | | tempHongBao.setMoney(child.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | tempHongBao.setMoney(hongBao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | .setMoney(childUpdate.getMoney() == null ? new BigDecimal(0) : childUpdate.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | |
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | tempHongBao.setMoney(hongBao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | tempCommonOrder.setThirdCreateTime(commonOrder.getThirdCreateTime());
|
| | | notificationMap.put(hongBao.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | |
| | | level = UserLevelEnum.daRen;
|
| | | BigDecimal rate = getSourceOrderDividentsRate(level);
|
| | | TeamDividentsSourceOrder order = TeamDividentsSourceOrderFactory.create(commonOrderList, rate);
|
| | | if (order == null)
|
| | | return;
|
| | | try {
|
| | | teamDividentsSourceOrderService.addTeamDividentsSourceOrder(order);
|
| | | } catch (TeamDividentsSourceOrderException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ParamsException e) {
|
| | | e.printStackTrace();
|
| | | throw new TeamDividentsSourceOrderException(101, "参数不完整");
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 没有参与分红的用户
|
| | | if (uidLevel == null || uidLevel.size() == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | BigDecimal perDivident = computePerDivident(uidLevel, totalMoney);
|
| | | for (Iterator<Long> its = uidLevel.keySet().iterator(); its.hasNext();) {
|
| | | Long uid = its.next();
|
| | |
| | | * @throws
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addToTeamEincome(Long uid, String day) throws TeamDividentsRecordException, TeamDividentsDebtException,
|
| | | UserMoneyDetailException, ParamsException, TeamEincomeRecordException {
|
| | | Date preSendTime = new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd"));
|
| | | public void addToTeamEincome(Long uid, Date preSendTime) throws TeamDividentsRecordException,
|
| | | TeamDividentsDebtException, UserMoneyDetailException, ParamsException, TeamEincomeRecordException {
|
| | | String day = TimeUtil.getGernalTime(preSendTime.getTime(), "yyyy-MM-dd");
|
| | | BigDecimal money = teamDividentsSourceUserService.sumMoneyByUidAndDay(uid, day);
|
| | | // 查询需要扣除的资金
|
| | | List<TeamDividentsDebt> list = teamDividentsDebtService.listNeedRepayDebt(uid, preSendTime, 1, 1000);
|
| | |
| | | } else if (sourceOrder.getState() == TeamDividentsSourceOrder.STATE_CAN_SEND) {
|
| | | teamDividentsSourceOrderService.invalidOrder(orderNo, sourceType, "订单维权");
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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 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.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | /**
|
| | | * 团队分红管理
|
| | |
| | | private TeamEincomeManager teamEincomeManager;
|
| | |
|
| | | public void addOrUpdateOrder(String orderNo, int sourceType)
|
| | | throws InviteOrderSubsidyException, OrderTeamRewardException, CommonOrderException {
|
| | | throws InviteOrderSubsidyException, CommonOrderException {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderNo, sourceType);
|
| | | }
|
| | |
|
| | |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @Transactional
|
| | | public void addToTeamEincome(Long uid, String taskKey)
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | public void addToTeamEincome(Long uid, String taskKey,Date preGetTime)
|
| | | 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) {
|
| | |
| | | throw new OrderMoneySettleException(1, "订单类型未获取到");
|
| | |
|
| | | if (subsidyList.size() > 0) {
|
| | | BigDecimal debtMoney = inviteOrderSubsidyDebtService.getTotalDebtMoney(uid, date);
|
| | | BigDecimal debtMoney = inviteOrderSubsidyDebtService.getTotalDebtMoney(uid, preGetTime);
|
| | | BigDecimal originalDebtMoney = new BigDecimal(debtMoney.toString());// 总的欠款
|
| | | List<InviteOrderSubsidy> copySubsidyList = new ArrayList<>();
|
| | | copySubsidyList.addAll(subsidyList);
|
| | |
| | | BigDecimal bannce = null;
|
| | | if (repayMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | try {
|
| | | bannce = inviteOrderSubsidyDebtService.repayDebtByUid(uid, date, repayMoney);
|
| | | bannce = inviteOrderSubsidyDebtService.repayDebtByUid(uid, preGetTime, repayMoney);
|
| | | // 剩余的补贴金额
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new OrderMoneySettleException(2, "还款异常");
|
| | |
| | | }
|
| | |
|
| | | // 加入团队收益中间表
|
| | | teamEincomeManager.addTeamSubsidy(uid, date, totalMoney, sourceType);
|
| | | teamEincomeManager.addTeamSubsidy(uid, preGetTime, totalMoney, sourceType);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | public static boolean IS_OUTNET = false;
|
| | |
|
| | | public static boolean IS_TEST = true;
|
| | | |
| | | public static boolean ENABLE_MQ = false;
|
| | |
|
| | | public static int PAGE_SIZE = 20;
|
| | |
|
| | |
| | | public static final WXAPPInfo WXMP_APP_INFO=new WXAPPInfo("wxc22f3bd53cb25012", "4c7b166fecb6d9f53837e993f2214673", "", "");
|
| | |
|
| | |
|
| | | //新的规则生效时间
|
| | | public static final String NEW_ORDER_FANLI_RULE_TIME="2020-04-18";
|
| | | |
| | | |
| | | // 新人抽奖-最大次数
|
| | | public static final int MAX_COUNT_LOTTERY_NEWBIES = 5;
|
| | |
|
| | |
| | | String key = its.next();
|
| | | UserDividentsDayDTO dto = map.get(key);
|
| | | try {
|
| | | teamDividentsManager.addToTeamEincome(dto.getUid(), dto.getDay());
|
| | | teamDividentsManager.addToTeamEincome(dto.getUid(), dto.getPreGetTime());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | | for (CommonOrder commonOrder : commonOrderList) {
|
| | | if (commonOrder.geteIncome() != null)
|
| | | money = money.add(commonOrder.geteIncome());
|
| | |
|
| | | if (commonOrder.getState() == CommonOrder.STATE_SX)
|
| | | invalidCount++;
|
| | | }
|
| | |
|
| | | if (money.compareTo(new BigDecimal(0)) <= 0)
|
| | | |
| | | if (invalidCount >= commonOrderList.size())
|
| | | return null;
|
| | |
|
| | | if (invalidCount >= commonOrderList.size())
|
| | | if (money.compareTo(new BigDecimal(0)) <= 0)
|
| | | return null;
|
| | |
|
| | | BigDecimal dividents = MoneyBigDecimalUtil.div(money.multiply(rate), new BigDecimal(100));
|
| | |
| | | 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.TeamRewardPreRecieveMQMsg;
|
| | | 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.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;
|
| | |
| | | } catch (InviteOrderSubsidyException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | | } catch (OrderTeamRewardException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | | } catch (CommonOrderException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.teamRewardPreRecieved.name())) {// 团队奖金预到账
|
| | | TeamRewardPreRecieveMQMsg dto = new Gson().fromJson(new String(message.getBody()),
|
| | | TeamRewardPreRecieveMQMsg.class);
|
| | | try {
|
| | | teamSubsidyManager.addToTeamEincome(dto.getUid(), message.getKey(), dto.getPreGetTime());
|
| | | return Action.CommitMessage;
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TeamEincomeRecordException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ParamsException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderWeiQuanMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserForbiddenMQMsg;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.TeamDividentsDebtException;
|
| | | import com.yeshi.fanli.exception.order.dividents.TeamDividentsSourceOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderService;
|
| | | import com.yeshi.fanli.service.manger.order.TeamDividentsManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | |
| | | List<CommonOrder> commonOrderList = commonOrderService.listBySourceTypeAndOrderId(dto.getSourceType(),
|
| | | dto.getOrderNo());
|
| | | BigDecimal eincome = new BigDecimal(0);
|
| | | Date settleTime = null;
|
| | | for (CommonOrder order : commonOrderList) {
|
| | | if (order.getState() == CommonOrder.STATE_JS)
|
| | | eincome = eincome.add(order.geteIncome());
|
| | | if (settleTime == null)
|
| | | settleTime = order.getSettleTime();
|
| | | }
|
| | |
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(settleTime);
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | Date preSendTime = new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd"));
|
| | |
|
| | | TeamDividentsSourceOrder sourceOrder = new TeamDividentsSourceOrder();
|
| | | sourceOrder.setMoney(eincome);
|
| | | sourceOrder.setOrderNo(dto.getOrderNo());
|
| | | sourceOrder.setPreSendTime(preSendTime);
|
| | | sourceOrder.setSourceType(dto.getSourceType());
|
| | | sourceOrder.setState(TeamDividentsSourceOrder.STATE_CAN_SEND);
|
| | | sourceOrder.setUid(dto.getSourceUid());
|
| | | try {
|
| | | teamDividentsSourceOrderService.addTeamDividentsSourceOrder(sourceOrder);
|
| | | return Action.CommitMessage;
|
| | | } catch (ParamsException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TeamDividentsSourceOrderException e) {
|
| | | e.printStackTrace();
|
| | | teamDividentsManager.addDividentsSourceOrder(commonOrderList);
|
| | | }
|
| | |
|
| | | catch (TeamDividentsSourceOrderException e) {
|
| | | if (e.getCode() == TeamDividentsSourceOrderException.CODE_EXIST)
|
| | | return Action.CommitMessage;
|
| | | else {
|
| | | e.printStackTrace();
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.taoBaoOrderWeiQuan.name())) {
|
| | | TaoBaoWeiQuanOrder dto = new Gson().fromJson(new String(message.getBody()), TaoBaoWeiQuanOrder.class);
|
| | | OrderWeiQuanMQMsg dto = new Gson().fromJson(new String(message.getBody()), OrderWeiQuanMQMsg.class);
|
| | | try {
|
| | | teamDividentsManager.weiQuan(dto.getOrderId(), Constant.SOURCE_TYPE_TAOBAO);
|
| | | teamDividentsManager.weiQuan(dto.getOrderNo(), dto.getSourceType());
|
| | | return Action.CommitMessage;
|
| | | } catch (TeamDividentsDebtException e) {
|
| | | e.printStackTrace();
|
| | |
| | |
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 获取上一个等级
|
| | | * @Title: getNextLevel
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取2.1之前的用户等级(普通会员与高级会员降级为达人,导师降级为超级会员)
|
| | | * @Title: getOldLevel
|
| | | * @Description: |
| | | * @param level
|
| | | * @return |
| | | * UserLevelEnum 返回类型
|
| | | * @throws
|
| | | */
|
| | |
|
| | | public static UserLevelEnum getOldLevel(UserLevelEnum userLevel) {
|
| | | if (userLevel == null || userLevel == UserLevelEnum.normalVIP || userLevel == UserLevelEnum.highVIP) {
|
| | | return UserLevelEnum.daRen;
|
| | | } else if (userLevel == UserLevelEnum.tearcher)
|
| | | return UserLevelEnum.superVIP;
|
| | | return userLevel;
|
| | | }
|
| | | }
|