1个文件已删除
36个文件已修改
30个文件已添加
| | |
| | | String imei = acceptData.getImei();
|
| | | result = guessLikeDeviceTB(idfa, imei, page);
|
| | | } else {
|
| | | result = commonTemplateContentService.getContentList(type, cid, page, Constant.PAGE_SIZE);
|
| | | // 大淘客页码只能为10,50,100,200
|
| | | result = commonTemplateContentService.getContentList(type, cid, page, 10);
|
| | | }
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | |
| | | List<SwiperPicture> bannerList = new ArrayList<>();
|
| | | root.put("bannerList", new Gson().toJson(bannerList));
|
| | | }
|
| | | |
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
|
| | | List<TaoBaoGoodsBrief> goodsList = result.getGoodsList();
|
| | |
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 猜你喜欢-淘宝设备推荐
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @return
|
| | |
| | | @Cacheable(value = "commonContentCache", key = "#idfa+'-'+#imei+'-'+#page")
|
| | | private CommonContentResult guessLikeDeviceTB(String idfa, String imei, Integer page) {
|
| | | TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa);
|
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null |
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null
|
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | CommonContentResult result = new CommonContentResult();
|
| | | result.setCount(searchResult.getPageEntity().getTotalCount());
|
| | |
| | | List<HongBaoV2> listChildrenById(Long id); |
| | | |
| | | /** |
| | | * 获取子红包列表 |
| | | * @param idList |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listChildrenByIds(@Param("idList") List<Long> idList); |
| | | /** |
| | | * 获取奖金列表(1.4.9之前) |
| | | * |
| | | * @param uid |
| | |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, |
| | | List<HongBaoV2> listCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, @Param("orderType") Integer orderType, |
| | | @Param("start") long start, @Param("count") int count); |
| | | |
| | | /** |
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | long countCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid); |
| | | long countCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, @Param("orderType") Integer orderType); |
| | | |
| | | /** |
| | | * 根据用户ID,订单状态和结算时间统计邀请赚的订单数量 |
| | |
| | | */ |
| | | 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); |
| | | |
| | | |
| | | /** |
| | | * 根据ID批量查询 |
| | | * @param idList |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listByIds(@Param("idList") List<Long> idList); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.hongbao; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp; |
| | | |
| | | public interface HongBaoV2SettleTempMapper extends BaseMapper<HongBaoV2SettleTemp> { |
| | | |
| | | /** |
| | | * 根据Key检索 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | List<HongBaoV2SettleTemp> listByKey(String key); |
| | | |
| | | long countByKey(String key); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt; |
| | | |
| | | public interface InviteOrderSubsidyDebtMapper extends BaseMapper<InviteOrderSubsidyDebt> { |
| | | |
| | | /** |
| | | * 检索(根据剩余资金与用户ID) |
| | | * |
| | | * @param minMoney |
| | | * @param maxMoney |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | List<InviteOrderSubsidyDebt> listByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney, |
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid, @Param("start") long start, |
| | | @Param("count") int count); |
| | | |
| | | /** |
| | | * 检索(根据剩余资金与用户ID) |
| | | * |
| | | * @param minMoney |
| | | * @param maxMoney |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | long countByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney, @Param("maxMoney") BigDecimal maxMoney, |
| | | @Param("uid") Long uid); |
| | | |
| | | InviteOrderSubsidyDebt selectByPrimaryKeyForUpdate(Long id); |
| | | |
| | | /** |
| | | * 计算欠款金额(根据用户ID) |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | BigDecimal sumLeftMoneyByUid(Long uid); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory; |
| | | |
| | | public interface InviteOrderSubsidyDebtRepayHistoryMapper extends BaseMapper<InviteOrderSubsidyDebtRepayHistory> { |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.mq; |
| | | |
| | | 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.mq.MQUnSendInfo; |
| | | |
| | | public interface MQUnSendInfoMapper extends BaseMapper<MQUnSendInfo> { |
| | | |
| | | MQUnSendInfo selectByTopicTagAndKey(@Param("topic") String topic, @Param("tag") String tag, |
| | | @Param("key") String key); |
| | | |
| | | /** |
| | | * 根据最大发送时间检索 |
| | | * |
| | | * @param maxSendTime |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<MQUnSendInfo> listByMaxSendTime(@Param("maxSendTime") Date maxSendTime, @Param("start") long start, |
| | | @Param("count") int count); |
| | | |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | |
| | | public interface HongBaoOrderMapper extends BaseMapper<HongBaoOrder> { |
| | |
| | | */ |
| | | public int countWeiQuanOrderWithMinCommision(@Param("uid")Long uid,@Param("minMoney") BigDecimal minMoney,@Param("minTime") Date minTime); |
| | | |
| | | |
| | | /** |
| | | * 根据订单ID与来源类型查询 |
| | | * @param orderId |
| | | * @param sourceType |
| | | * @return |
| | | */ |
| | | public List<HongBaoOrder> listByOrderIdAndSourceType(@Param("orderId") String orderId, |
| | | @Param("sourceType") int sourceType); |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.order; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | |
| | | |
| | | /** |
| | | * 查询用户补贴 |
| | | * |
| | | * @param uid |
| | | * @param orderNo |
| | | * @param Type |
| | | * @return |
| | | */ |
| | | InviteOrderSubsidy getByOrderNoAndType(@Param("uid")Long uid, @Param("orderNo")String orderNo,@Param("type") Integer type); |
| | | InviteOrderSubsidy getByOrderNoAndType(@Param("uid") Long uid, @Param("orderNo") String orderNo, |
| | | @Param("type") Integer type); |
| | | |
| | | /** |
| | | * 查询加锁 |
| | | * |
| | | * @param uid |
| | | * @param orderNo |
| | | * @param type |
| | | * @return |
| | | */ |
| | | InviteOrderSubsidy getByOrderNoAndTypeForUpdate(@Param("uid") Long uid, @Param("orderNo") String orderNo, |
| | | @Param("type") Integer type); |
| | | |
| | | /** |
| | | * 根据订单号与来源类型查询 |
| | | * |
| | | * @param orderNo |
| | | * @param type |
| | | * @return |
| | | */ |
| | | long countByOrderNoAndType(@Param("orderNo") String orderNo, @Param("type") Integer type); |
| | | |
| | | /** |
| | | * 根据订单号与来源类型查询 |
| | | * |
| | | * @param orderNo |
| | | * @param type |
| | | * @return |
| | | */ |
| | | List<InviteOrderSubsidy> listByOrderNoAndType(@Param("orderNo") String orderNo, @Param("type") Integer type); |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.order; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.order.OrderHongBaoMap; |
| | | |
| | | public interface OrderHongBaoMapMapper extends BaseMapper<OrderHongBaoMap>{ |
| | | public interface OrderHongBaoMapMapper extends BaseMapper<OrderHongBaoMap> { |
| | | |
| | | /** |
| | | * 获取奖励金额 |
| | | * |
| | | * @param orderNo |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | BigDecimal getCouponHongbaoByOrderNo(@Param("orderNo")String orderNo, @Param("uid")Long uid); |
| | | BigDecimal getCouponHongbaoByOrderNo(@Param("orderNo") String orderNo, @Param("uid") Long uid); |
| | | |
| | | /** |
| | | * 根据订单号查询 |
| | | * |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | List<OrderHongBaoMap> listByOrderId(Long orderId); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dto.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | /**
|
| | | * 订单到账MQ消息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class OrderMoneyRecievedMQMsgDTO {
|
| | | public static final int TYPE_ZIGOU = 1;// 自购到账
|
| | | public static final int TYPE_SHARE = 2;// 分享到账
|
| | | public static final int TYPE_INVITE = 3;// 邀请到账
|
| | | private int type;// 到账类型
|
| | | private Long uid;
|
| | | private Integer sourceType;// 订单来源类型
|
| | | private String orderId;// 订单号
|
| | | private BigDecimal money;// 到账金额
|
| | | private Date date;// 到账时间
|
| | |
|
| | | public OrderMoneyRecievedMQMsgDTO() {
|
| | |
|
| | | }
|
| | |
|
| | | public OrderMoneyRecievedMQMsgDTO(int type, Long uid, Integer sourceType, String orderId, BigDecimal money,
|
| | | Date date) {
|
| | | this.type = type;
|
| | | this.uid = uid;
|
| | | this.sourceType = sourceType;
|
| | | this.orderId = orderId;
|
| | | this.money = money;
|
| | | this.date = date;
|
| | | }
|
| | |
|
| | | public int getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(int type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | public String getOrderId() {
|
| | | return orderId;
|
| | | }
|
| | |
|
| | | public void setOrderId(String orderId) {
|
| | | this.orderId = orderId;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public Date getDate() {
|
| | | return date;
|
| | | }
|
| | |
|
| | | public void setDate(Date date) {
|
| | | this.date = date;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.user.coupon;
|
| | |
|
| | | /**
|
| | | * 用券的mq消息实体
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class UserSystemCouponUseMQMsgDTO {
|
| | | private Long userSystemCouponId;// 用户的券ID
|
| | | private String orderId;// 订单号
|
| | | private Integer sourceType;// 订单来源
|
| | |
|
| | | public UserSystemCouponUseMQMsgDTO(Long userSystemCouponId, String orderId, Integer sourceType) {
|
| | | this.userSystemCouponId = userSystemCouponId;
|
| | | this.orderId = orderId;
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | | |
| | | public UserSystemCouponUseMQMsgDTO() {
|
| | | |
| | | }
|
| | |
|
| | | public Long getUserSystemCouponId() {
|
| | | return userSystemCouponId;
|
| | | }
|
| | |
|
| | | public void setUserSystemCouponId(Long userSystemCouponId) {
|
| | | this.userSystemCouponId = userSystemCouponId;
|
| | | }
|
| | |
|
| | | public String getOrderId() {
|
| | | return orderId;
|
| | | }
|
| | |
|
| | | public void setOrderId(String orderId) {
|
| | | this.orderId = orderId;
|
| | | }
|
| | |
|
| | | public Integer getSourceType() {
|
| | | return sourceType;
|
| | | }
|
| | |
|
| | | public void setSourceType(Integer sourceType) {
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | public final static int STATE_KELINGQU = 2;
|
| | | public final static int STATE_YILINGQU = 3;
|
| | | public final static int STATE_SHIXIAO = 4;
|
| | | |
| | |
|
| | | // 5-部分失效(返回客户端显示用,不用作逻辑处理)
|
| | | public final static int STATE_BUFENSHIXIAO = 5;
|
| | |
|
| | | // 自购红包 老版 2属于自购
|
| | | // 自购红包 老版 2属于自购
|
| | | public final static int TYPE_ZIGOU = 1;
|
| | | // 活动红包
|
| | | public final static int TYPE_HUODONG = 3;
|
| | | // 新人红包
|
| | | public final static int TYPE_XINREN = 4;
|
| | | |
| | |
|
| | | // 使用券红包
|
| | | public final static int TYPE_COUPON = 10;
|
| | | |
| | |
|
| | | public final static int TYPE_YAOQING = 5;
|
| | | // 一级分销红包
|
| | | public final static int TYPE_YIJI = 6;
|
| | | // 二级分销红包
|
| | | public final static int TYPE_ERJI = 7;
|
| | | |
| | |
|
| | | // 分享商品得来的红包
|
| | | public final static int TYPE_SHARE_GOODS = 20;
|
| | | // 一级分享赚分销红包
|
| | |
| | |
|
| | | // 金币兑换红包
|
| | | public final static int TYPE_EXCHANGE = 30;
|
| | | |
| | | //饿了么红包
|
| | | public final static int TYPE_ELME=25;
|
| | |
|
| | | // 饿了么红包
|
| | | public final static int TYPE_ELME = 25;
|
| | |
|
| | | @Column(name = "hb_id")
|
| | | private Long id;
|
| | |
| | | // 更新时间
|
| | | @Column(name = "cog_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | // 订单类型
|
| | | @Column(name = "cog_order_type")
|
| | | private Integer orderType;
|
| | |
|
| | | public HongBaoV2() {
|
| | |
|
| | |
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public Integer getOrderType() {
|
| | | return orderType;
|
| | | }
|
| | |
|
| | | public void setOrderType(Integer orderType) {
|
| | | this.orderType = orderType;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 订单补贴欠账
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_invite_order_subsidy_debt")
|
| | | public class InviteOrderSubsidyDebt {
|
| | | @Column(name = "sd_id")
|
| | | private Long id;
|
| | | @Column(name = "sd_uid")
|
| | | private Long uid;
|
| | | @Column(name = "sd_origin_money")
|
| | | private BigDecimal originMoney;
|
| | | @Column(name = "sd_left_money")
|
| | | private BigDecimal leftMoney;
|
| | | @Column(name = "sd_source_id")
|
| | | private Long sourceId;
|
| | | @Column(name = "sd_beizhu")
|
| | | private String beiZhu;
|
| | | @Column(name = "sd_create_time")
|
| | | private Date createTime;
|
| | | @Column(name = "sd_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public BigDecimal getOriginMoney() {
|
| | | return originMoney;
|
| | | }
|
| | |
|
| | | public void setOriginMoney(BigDecimal originMoney) {
|
| | | this.originMoney = originMoney;
|
| | | }
|
| | |
|
| | | public BigDecimal getLeftMoney() {
|
| | | return leftMoney;
|
| | | }
|
| | |
|
| | | public void setLeftMoney(BigDecimal leftMoney) {
|
| | | this.leftMoney = leftMoney;
|
| | | }
|
| | |
|
| | | public Long getSourceId() {
|
| | | return sourceId;
|
| | | }
|
| | |
|
| | | public void setSourceId(Long sourceId) {
|
| | | this.sourceId = sourceId;
|
| | | }
|
| | |
|
| | | public String getBeiZhu() {
|
| | | return beiZhu;
|
| | | }
|
| | |
|
| | | public void setBeiZhu(String beiZhu) {
|
| | | this.beiZhu = beiZhu;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 订单补贴欠账还款记录
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_invite_order_subsidy_debt_repay_history")
|
| | | public class InviteOrderSubsidyDebtRepayHistory {
|
| | | @Column(name = "rh_id")
|
| | | private Long id;
|
| | | @Column(name = "rh_debt_id")
|
| | | private InviteOrderSubsidyDebt debt;
|
| | | @Column(name = "rh_money")
|
| | | private BigDecimal money;
|
| | | @Column(name = "rh_uid")
|
| | | private Long uid;
|
| | | @Column(name = "rh_beizhu")
|
| | | private String beiZhu;
|
| | | @Column(name = "rh_create_time")
|
| | | private Date createTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public InviteOrderSubsidyDebt getDebt() {
|
| | | return debt;
|
| | | }
|
| | |
|
| | | public void setDebt(InviteOrderSubsidyDebt debt) {
|
| | | this.debt = debt;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public String getBeiZhu() {
|
| | | return beiZhu;
|
| | | }
|
| | |
|
| | | public void setBeiZhu(String beiZhu) {
|
| | | this.beiZhu = beiZhu;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
| | |
| | | ""), buyScore("购买积分", "http://img.flqapp.com/resource/money_detail/icon_score.png", ""), extract("提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png",
|
| | | ""), extractVerify("提现验证", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractReject("提现被拒", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),orderReward("返利奖励金","http://img.flqapp.com/resource/money_detail/icon_order_reward.png",""),repeatStatistic("重复统计返利/奖金扣除","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""), |
| | | elmeFanli("饿了么返利到账","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""),
|
| | | extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", "");
|
| | | extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), |
| | | extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),
|
| | | subsidy("额外补贴","","");
|
| | | |
| | |
|
| | | private final String desc;
|
New file |
| | |
| | | package com.yeshi.fanli.entity.mq;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 消息发送失败的缓存表
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_mq_unsend_info")
|
| | | public class MQUnSendInfo {
|
| | | @Column(name = "mui_id")
|
| | | private Long id;
|
| | | @Column(name = "mui_topic")
|
| | | private String topic;
|
| | | @Column(name = "mui_tag")
|
| | | private String tag;
|
| | | @Column(name = "mui_body")
|
| | | private String body;
|
| | | @Column(name = "mui_key")
|
| | | private String key;
|
| | | @Column(name = "mui_deliver_time")
|
| | | private Date deliverTime;// 延时
|
| | | @Column(name = "mui_last_send_time")
|
| | | private Date lastSendTime;// 发送时间
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getTopic() {
|
| | | return topic;
|
| | | }
|
| | |
|
| | | public void setTopic(String topic) {
|
| | | this.topic = topic;
|
| | | }
|
| | |
|
| | | public String getTag() {
|
| | | return tag;
|
| | | }
|
| | |
|
| | | public void setTag(String tag) {
|
| | | this.tag = tag;
|
| | | }
|
| | |
|
| | | public String getBody() {
|
| | | return body;
|
| | | }
|
| | |
|
| | | public void setBody(String body) {
|
| | | this.body = body;
|
| | | }
|
| | |
|
| | | public String getKey() {
|
| | | return key;
|
| | | }
|
| | |
|
| | | public void setKey(String key) {
|
| | | this.key = key;
|
| | | }
|
| | |
|
| | | public Date getDeliverTime() {
|
| | | return deliverTime;
|
| | | }
|
| | |
|
| | | public void setDeliverTime(Date deliverTime) {
|
| | | this.deliverTime = deliverTime;
|
| | | }
|
| | |
|
| | | public Date getLastSendTime() {
|
| | | return lastSendTime;
|
| | | }
|
| | |
|
| | | public void setLastSendTime(Date lastSendTime) {
|
| | | this.lastSendTime = lastSendTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.order;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | @Table("yeshi_ec_hongbao_v2_settle_temp")
|
| | | public class HongBaoV2SettleTemp {
|
| | | @Column(name = "id")
|
| | | private Long id;
|
| | | @Column(name = "task_key")
|
| | | private String taskKey;
|
| | | @Column(name = "hongbao_id")
|
| | | private Long hongBaoId;
|
| | | @Column(name = "create_time")
|
| | | private Date createTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getTaskKey() {
|
| | | return taskKey;
|
| | | }
|
| | |
|
| | | public void setTaskKey(String taskKey) {
|
| | | this.taskKey = taskKey;
|
| | | }
|
| | |
|
| | | public Long getHongBaoId() {
|
| | | return hongBaoId;
|
| | | }
|
| | |
|
| | | public void setHongBaoId(Long hongBaoId) {
|
| | | this.hongBaoId = hongBaoId;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
| | |
| | | private Long uid;
|
| | | @Column(name = "os_money")
|
| | | private BigDecimal money;
|
| | | @Column(name = "os_original_money")
|
| | | private BigDecimal originalMoney;// 原返利
|
| | | @Column(name = "os_order_no")
|
| | | private String orderNo;
|
| | | @Column(name = "os_source_type")
|
| | |
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public BigDecimal getOriginalMoney() {
|
| | | return originalMoney;
|
| | | }
|
| | |
|
| | | public void setOriginalMoney(BigDecimal originalMoney) {
|
| | | this.originalMoney = originalMoney;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.money;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class InviteOrderSubsidyDebtException extends BaseException {
|
| | |
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public InviteOrderSubsidyDebtException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public InviteOrderSubsidyDebtException() {
|
| | | super();
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.money;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class OrderMoneySettleException extends BaseException {
|
| | |
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public OrderMoneySettleException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public OrderMoneySettleException() {
|
| | | super();
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.mq;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class MQUnSendInfoException extends BaseException {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | public MQUnSendInfoException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public MQUnSendInfoException() {
|
| | | super();
|
| | | }
|
| | | }
|
| | |
| | | for (int i = 0; i < 24; i++) {
|
| | | Date da = new Date(startTime.getTime() + 1000 * 60 * 60L * i);
|
| | | if (da.getTime() > now.getTime())
|
| | | return;
|
| | | break;
|
| | | List<JDOrder> tempOrderList = getHourOrder(da);
|
| | | if (tempOrderList != null && tempOrderList.size() > 0)
|
| | | orderList.addAll(tempOrderList);
|
| | |
| | | private static Logger requestLogger = Logger.getLogger("requestLog");
|
| | |
|
| | | private static Logger requestTimeLogger = Logger.getLogger("requestTimeLog");
|
| | | |
| | |
|
| | | private static Logger jobLogger = Logger.getLogger("jobLog");
|
| | |
|
| | | private static Logger mqLogger = Logger.getLogger("mqLog");
|
| | |
|
| | | public static void userInfo(Object obj) {
|
| | | userLogger.info(obj);
|
| | |
| | | public static void shareGoods(Object obj) {
|
| | | shareGoodsLogger.info(obj);
|
| | | }
|
| | | |
| | |
|
| | | public static void job(Object obj) {
|
| | | jobLogger.info(obj);
|
| | | }
|
| | |
|
| | | public static void mqError(String errorMsg, String topic, String tag, Object data) {
|
| | | String error = errorMsg + "\ntopic:" + topic + "\ntag:" + tag + "\nbody:" + data;
|
| | | mqLogger.error(error);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 登录信息
|
| | | *
|
| | |
| | | <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
|
| | | <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
| | |
|
| | | <result column="hb_order_type" property="orderType" jdbcType="INTEGER" />
|
| | | <association property="userInfo" column="hb_uid"
|
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
| | | <id column="hb_uid" property="id" jdbcType="BIGINT" />
|
| | |
| | | <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
| | |
|
| | | <result column="orderId" property="orderId" jdbcType="VARCHAR" />
|
| | | |
| | | <result column="hb_order_type" property="orderType" jdbcType="INTEGER" />
|
| | |
|
| | | <result column="payMoney" property="payMoney" jdbcType="DECIMAL" />
|
| | |
|
| | |
| | | </resultMap>
|
| | |
|
| | |
|
| | | <sql id="Base_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time
|
| | | <sql id="Base_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time,hb_order_type
|
| | | </sql>
|
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
| | | parameterType="java.lang.Long">
|
| | |
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_hongbao_v2 where hb_pid = #{0}
|
| | | </select>
|
| | |
|
| | |
|
| | | <select id="listChildrenByIds" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_hongbao_v2 where
|
| | | <foreach collection="idList" item="id" open="(" separator=" or "
|
| | | close=")">
|
| | | hb_pid=#{id}
|
| | | </foreach>
|
| | | </select>
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | <select id="listCanBalanceHongBaoByType" resultMap="BaseResultMap">
|
| | |
| | | <if test="uid!=null">
|
| | | and hb_uid=#{uid}
|
| | | </if>
|
| | | |
| | | <if test="orderType!=null">
|
| | | and hb_order_type=#{orderType}
|
| | | </if>
|
| | |
|
| | | <foreach collection="types" item="type" open=" and ("
|
| | | separator=" or " close=")">
|
| | |
| | | count(hb_id)
|
| | | from yeshi_ec_hongbao_v2 where hb_uid=#{uid} and
|
| | | `hb_version`=2
|
| | | |
| | | <if test="orderType!=null">
|
| | | and hb_order_type=#{orderType}
|
| | | </if>
|
| | |
|
| | | <foreach collection="types" item="type" open=" and ("
|
| | | separator=" or " close=")">
|
| | |
| | | <select id="listBySourceTypeAndTradeIdListAndUid" resultMap="BaseResultMap">
|
| | | SELECT a.* FROM
|
| | | (
|
| | | SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`=#{uid}
|
| | | ) a |
| | | SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
|
| | | v.`hb_uid`=#{uid}
|
| | | ) a
|
| | | LEFT JOIN
|
| | | (
|
| | | SELECT ho.`ho_hongbao_id` AS hbId FROM yeshi_ec_hongbao_order ho LEFT JOIN
|
| | | yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
|
| | | SELECT ho.`ho_hongbao_id` AS hbId FROM
|
| | | yeshi_ec_hongbao_order ho
|
| | | LEFT JOIN
|
| | | yeshi_ec_common_order co ON
|
| | | co.`co_id`=ho.`ho_order_id` WHERE
|
| | | co.`co_source_type`=#{sourceType}
|
| | | <if test="tradeIdList!=null">
|
| | | <foreach collection="tradeIdList" open=" and (" close=")"
|
| | |
| | | b
|
| | | ON a.hb_id=b.hbId OR a.hb_pid=b.hbId WHERE b.hbId >0
|
| | | </select>
|
| | | |
| | |
|
| | | <select id="listByStateAndTypeAndUid" resultMap="BaseResultMap">
|
| | | |
| | |
|
| | | SELECT * FROM yeshi_ec_hongbao_v2 v where v.hb_uid=#{uid}
|
| | | <if test="stateList!=null">
|
| | | <foreach collection="stateList" open=" and (" item="state" separator=" or " close=")">
|
| | | <foreach collection="stateList" open=" and (" item="state"
|
| | | separator=" or " close=")">
|
| | | hb_state=#{state}
|
| | | </foreach>
|
| | | </if>
|
| | | |
| | |
|
| | | <if test="typeList!=null">
|
| | | <foreach collection="typeList" open=" and (" item="type" separator=" or " close=")">
|
| | | <foreach collection="typeList" open=" and (" item="type"
|
| | | separator=" or " close=")">
|
| | | hb_type=#{type}
|
| | | </foreach>
|
| | | </if>
|
| | | order by hb_create_time asc,hb_id asc
|
| | | limit #{start},#{count}
|
| | | </select>
|
| | | |
| | | |
| | |
|
| | | <select id="listByIds" resultMap="BaseResultMap">
|
| | | SELECT * FROM yeshi_ec_hongbao_v2 v where
|
| | | <foreach collection="idList" item="id" separator=" or " open="("
|
| | | close=")">
|
| | | v.hb_id=#{id}
|
| | | </foreach>
|
| | | </select>
|
| | |
|
| | |
|
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
| | | yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
|
| | | </delete>
|
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
|
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao_v2
|
| | | (hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time)
|
| | | (hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time,hb_order_type)
|
| | | values
|
| | | (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{version,jdbcType=INTEGER},#{beizhu,jdbcType=VARCHAR},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
|
| | | (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{version,jdbcType=INTEGER},#{beizhu,jdbcType=VARCHAR},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{orderType,jdbcType=INTEGER})
|
| | | </insert>
|
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
|
| | | useGeneratedKeys="true" keyProperty="id">
|
| | |
| | | <if test="getTime != null">hb_get_time,</if>
|
| | | <if test="createTime != null">hb_create_time,</if>
|
| | | <if test="updateTime != null">hb_update_time,</if>
|
| | | <if test="orderType != null">hb_order_type,</if>
|
| | | </trim>
|
| | | values
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | |
| | | <if test="getTime != null">#{getTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="orderType != null">#{orderType,jdbcType=INTEGER},</if>
|
| | | </trim>
|
| | | </insert>
|
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">update
|
| | |
| | | #{preGetTime,jdbcType=TIMESTAMP},hb_get_time =
|
| | | #{getTime,jdbcType=TIMESTAMP},hb_create_time =
|
| | | #{createTime,jdbcType=TIMESTAMP},hb_update_time =
|
| | | #{updateTime,jdbcType=TIMESTAMP} where hb_id = #{id,jdbcType=BIGINT}
|
| | | #{updateTime,jdbcType=TIMESTAMP},hb_order_type =
|
| | | #{orderType,jdbcType=INTEGER} where hb_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
|
| | | update yeshi_ec_hongbao_v2
|
| | |
| | | <if test="getTime != null">hb_get_time=#{getTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="createTime != null">hb_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">hb_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="orderType != null">hb_order_type=#{orderType,jdbcType=INTEGER},</if>
|
| | | </set>
|
| | | where hb_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.hongbao.HongBaoV2SettleTempMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp"> |
| | | <id column="id" property="id" jdbcType="BIGINT" /> |
| | | <result column="task_key" property="taskKey" jdbcType="VARCHAR" /> |
| | | <result column="hongbao_id" property="hongBaoId" jdbcType="BIGINT" /> |
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">id,task_key,hongbao_id,create_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_v2_settle_temp where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="listByKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_v2_settle_temp where task_key = #{0} |
| | | </select> |
| | | |
| | | <select id="countByKey" resultType="java.lang.Long" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_hongbao_v2_settle_temp where task_key = #{0} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_hongbao_v2_settle_temp where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_hongbao_v2_settle_temp (id,task_key,hongbao_id,create_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{taskKey,jdbcType=VARCHAR},#{hongBaoId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_hongbao_v2_settle_temp |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">id,</if> |
| | | <if test="taskKey != null">task_key,</if> |
| | | <if test="hongBaoId != null">hongbao_id,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="taskKey != null">#{taskKey,jdbcType=VARCHAR},</if> |
| | | <if test="hongBaoId != null">#{hongBaoId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp">update |
| | | yeshi_ec_hongbao_v2_settle_temp set task_key = |
| | | #{taskKey,jdbcType=VARCHAR},hongbao_id = |
| | | #{hongBaoId,jdbcType=BIGINT},create_time = |
| | | #{createTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp"> |
| | | update yeshi_ec_hongbao_v2_settle_temp |
| | | <set> |
| | | <if test="taskKey != null">task_key=#{taskKey,jdbcType=VARCHAR},</if> |
| | | <if test="hongBaoId != null">hongbao_id=#{hongBaoId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.money.InviteOrderSubsidyDebtMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt"> |
| | | <id column="sd_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="sd_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="sd_origin_money" property="originMoney" |
| | | jdbcType="DECIMAL" /> |
| | | <result column="sd_left_money" property="leftMoney" jdbcType="DECIMAL" /> |
| | | <result column="sd_source_id" property="sourceId" jdbcType="BIGINT" /> |
| | | <result column="sd_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="sd_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="sd_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_id = |
| | | #{0} for update |
| | | </select> |
| | | |
| | | |
| | | <select id="listByLeftMoneyAndUid" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = |
| | | #{uid} |
| | | <if test="minMoney!=null"> |
| | | and sd_left_money>=#{minMoney} |
| | | </if> |
| | | |
| | | <if test="maxMoney!=null"> |
| | | and #{maxMoney}>sd_left_money |
| | | </if> |
| | | limit #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="countByLeftMoneyAndUid" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = |
| | | #{uid} |
| | | <if test="minMoney!=null"> |
| | | and sd_left_money>=#{minMoney} |
| | | </if> |
| | | |
| | | <if test="maxMoney!=null"> |
| | | and #{maxMoney}>sd_left_money |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="sumLeftMoneyByUid" resultType="java.math.BigDecimal"> |
| | | select |
| | | sum(sd_left_money) |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = |
| | | #{0} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_invite_order_subsidy_debt where sd_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_invite_order_subsidy_debt |
| | | (sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{sourceId,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_invite_order_subsidy_debt |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">sd_id,</if> |
| | | <if test="uid != null">sd_uid,</if> |
| | | <if test="originMoney != null">sd_origin_money,</if> |
| | | <if test="leftMoney != null">sd_left_money,</if> |
| | | <if test="sourceId != null">sd_source_id,</if> |
| | | <if test="beiZhu != null">sd_beizhu,</if> |
| | | <if test="createTime != null">sd_create_time,</if> |
| | | <if test="updateTime != null">sd_update_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="sourceId != null">#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt">update |
| | | yeshi_ec_invite_order_subsidy_debt set sd_uid = |
| | | #{uid,jdbcType=BIGINT},sd_origin_money = |
| | | #{originMoney,jdbcType=DECIMAL},sd_left_money = |
| | | #{leftMoney,jdbcType=DECIMAL},sd_source_id = |
| | | #{sourceId,jdbcType=BIGINT},sd_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR},sd_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},sd_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where sd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt"> |
| | | update yeshi_ec_invite_order_subsidy_debt |
| | | <set> |
| | | <if test="uid != null">sd_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">sd_origin_money=#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">sd_left_money=#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="sourceId != null">sd_source_id=#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">sd_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">sd_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">sd_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where sd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper |
| | | namespace="com.yeshi.fanli.dao.mybatis.money.InviteOrderSubsidyDebtRepayHistoryMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory"> |
| | | <id column="rh_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="rh_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="rh_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="rh_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="rh_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <association property="debt" column="rh_debt_id" |
| | | javaType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt"> |
| | | <id column="rh_debt_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">rh_id,rh_debt_id,rh_money,rh_uid,rh_beizhu,rh_create_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt_repay_history where rh_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_invite_order_subsidy_debt_repay_history where rh_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | (rh_id,rh_debt_id,rh_money,rh_uid,rh_beizhu,rh_create_time) values |
| | | (#{id,jdbcType=BIGINT},#{debt.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{uid,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rh_id,</if> |
| | | <if test="debt != null">rh_debt_id,</if> |
| | | <if test="money != null">rh_money,</if> |
| | | <if test="uid != null">rh_uid,</if> |
| | | <if test="beiZhu != null">rh_beizhu,</if> |
| | | <if test="createTime != null">rh_create_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="debt != null">#{debt.id,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory">update yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | set rh_debt_id = #{debt.id,jdbcType=BIGINT},rh_money = |
| | | #{money,jdbcType=DECIMAL},rh_uid = #{uid,jdbcType=BIGINT},rh_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR},rh_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP} where rh_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory"> |
| | | update yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | <set> |
| | | <if test="debt != null">rh_debt_id=#{debt.id,jdbcType=BIGINT},</if> |
| | | <if test="money != null">rh_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="uid != null">rh_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">rh_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">rh_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where rh_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.mq.MQUnSendInfoMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.mq.MQUnSendInfo"> |
| | | <id column="mui_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="mui_topic" property="topic" jdbcType="VARCHAR" /> |
| | | <result column="mui_tag" property="tag" jdbcType="VARCHAR" /> |
| | | <result column="mui_body" property="body" jdbcType="VARCHAR" /> |
| | | <result column="mui_key" property="key" jdbcType="VARCHAR" /> |
| | | <result column="mui_deliver_time" property="deliverTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="mui_last_send_time" property="lastSendTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">mui_id,mui_topic,mui_tag,mui_body,mui_key,mui_deliver_time,mui_last_send_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_mq_unsend_info where mui_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByTopicTagAndKey" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_mq_unsend_info where mui_topic = #{topic} and |
| | | mui_tag=#{tag} and mui_key=#{key} limit 1 |
| | | </select> |
| | | |
| | | |
| | | <select id="listByMaxSendTime" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_mq_unsend_info where #{maxSendTime} > mui_last_send_time |
| | | order by mui_last_send_time limit #{start},#{count} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_mq_unsend_info where mui_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_mq_unsend_info |
| | | (mui_id,mui_topic,mui_tag,mui_body,mui_key,mui_deliver_time,mui_last_send_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{topic,jdbcType=VARCHAR},#{tag,jdbcType=VARCHAR},#{body,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{deliverTime,jdbcType=TIMESTAMP},#{lastSendTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_mq_unsend_info |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">mui_id,</if> |
| | | <if test="topic != null">mui_topic,</if> |
| | | <if test="tag != null">mui_tag,</if> |
| | | <if test="body != null">mui_body,</if> |
| | | <if test="key != null">mui_key,</if> |
| | | <if test="deliverTime != null">mui_deliver_time,</if> |
| | | <if test="lastSendTime != null">mui_last_send_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="topic != null">#{topic,jdbcType=VARCHAR},</if> |
| | | <if test="tag != null">#{tag,jdbcType=VARCHAR},</if> |
| | | <if test="body != null">#{body,jdbcType=VARCHAR},</if> |
| | | <if test="key != null">#{key,jdbcType=VARCHAR},</if> |
| | | <if test="deliverTime != null">#{deliverTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="lastSendTime != null">#{lastSendTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo">update |
| | | yeshi_ec_mq_unsend_info set mui_topic = |
| | | #{topic,jdbcType=VARCHAR},mui_tag = #{tag,jdbcType=VARCHAR},mui_body |
| | | = |
| | | #{body,jdbcType=VARCHAR},mui_key = |
| | | #{key,jdbcType=VARCHAR},mui_deliver_time = |
| | | #{deliverTime,jdbcType=TIMESTAMP},mui_last_send_time = |
| | | #{lastSendTime,jdbcType=TIMESTAMP} where mui_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo"> |
| | | update yeshi_ec_mq_unsend_info |
| | | <set> |
| | | <if test="topic != null">mui_topic=#{topic,jdbcType=VARCHAR},</if> |
| | | <if test="tag != null">mui_tag=#{tag,jdbcType=VARCHAR},</if> |
| | | <if test="body != null">mui_body=#{body,jdbcType=VARCHAR},</if> |
| | | <if test="key != null">mui_key=#{key,jdbcType=VARCHAR},</if> |
| | | <if test="deliverTime != null">mui_deliver_time=#{deliverTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="lastSendTime != null">mui_last_send_time=#{lastSendTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </set> |
| | | where mui_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | (co.`co_estimate`>=#{money} OR co.`co_eIncome`>=#{money}) |
| | | </select> |
| | | |
| | | <select id="countWeiQuanOrderByUid" |
| | | resultType="java.lang.Integer"> |
| | | SELECT COUNT(*) FROM |
| | | <select id="countWeiQuanOrderByUid" resultType="java.lang.Integer"> |
| | | SELECT COUNT(*) |
| | | FROM |
| | | ( |
| | | SELECT IF(v.`hb_pid` IS NOT |
| | | NULL,p.`hb_id`,v.`hb_id`) AS id FROM |
| | |
| | | wo.`tmo_id`>0 and wo |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="listByOrderIdAndSourceType" resultMap="BaseResultMap"> |
| | | SELECT ho.* |
| | | FROM yeshi_ec_common_order co LEFT JOIN yeshi_ec_hongbao_order |
| | | ho ON |
| | | ho.`ho_order_id`=co.`co_id` WHERE co.`co_order_no`=#{orderId} AND |
| | | co.`co_source_type`=#{sourceType} AND ho.`ho_id`>0 |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_hongbao_order where ho_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.HongBaoOrder" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao_order |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_hongbao_order |
| | | (ho_id,ho_hongbao_id,ho_order_id,ho_create_time) values |
| | | (#{id,jdbcType=BIGINT},#{hongBaoV2.id,jdbcType=BIGINT},#{commonOrder.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.order.InviteOrderSubsidyMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.order.InviteOrderSubsidy"> |
| | | <id column="os_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="os_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="os_money" property="money" jdbcType="DECIMAL"/> |
| | | <result column="os_order_no" property="orderNo" jdbcType="VARCHAR"/> |
| | | <result column="os_source_type" property="sourceType" jdbcType="INTEGER"/> |
| | | <result column="os_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="os_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="os_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_invite_order_subsidy (os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_invite_order_subsidy |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">os_id,</if> |
| | | <if test="uid != null">os_uid,</if> |
| | | <if test="money != null">os_money,</if> |
| | | <if test="orderNo != null">os_order_no,</if> |
| | | <if test="sourceType != null">os_source_type,</if> |
| | | <if test="state != null">os_state,</if> |
| | | <if test="createTime != null">os_create_time,</if> |
| | | <if test="updateTime != null">os_update_time,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy">update yeshi_ec_invite_order_subsidy set os_uid = #{uid,jdbcType=BIGINT},os_money = #{money,jdbcType=DECIMAL},os_order_no = #{orderNo,jdbcType=VARCHAR},os_source_type = #{sourceType,jdbcType=INTEGER},os_state = #{state,jdbcType=INTEGER},os_create_time = #{createTime,jdbcType=TIMESTAMP},os_update_time = #{updateTime,jdbcType=TIMESTAMP} where os_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy">update yeshi_ec_invite_order_subsidy |
| | | <set> |
| | | <if test="uid != null">os_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">os_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="orderNo != null">os_order_no=#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">os_source_type=#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">os_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">os_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">os_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where os_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <select id="getByOrderNoAndType" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_invite_order_subsidy |
| | | WHERE os_uid = #{uid} AND os_order_no = #{orderNo} AND os_source_type = #{type} |
| | | LIMIT 1 |
| | | </select> |
| | | |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.order.InviteOrderSubsidy"> |
| | | <id column="os_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="os_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="os_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="os_order_no" property="orderNo" jdbcType="VARCHAR" /> |
| | | <result column="os_source_type" property="sourceType" jdbcType="INTEGER" /> |
| | | <result column="os_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="os_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="os_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="os_original_money" property="originalMoney" |
| | | jdbcType="DECIMAL" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time,os_original_money |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <select id="listByOrderNoAndType" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy where os_order_no = #{orderNo} AND |
| | | os_source_type = #{type} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_invite_order_subsidy |
| | | (os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time,os_original_money) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{originalMoney,jdbcType=DECIMAL}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_invite_order_subsidy |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">os_id,</if> |
| | | <if test="uid != null">os_uid,</if> |
| | | <if test="money != null">os_money,</if> |
| | | <if test="orderNo != null">os_order_no,</if> |
| | | <if test="sourceType != null">os_source_type,</if> |
| | | <if test="state != null">os_state,</if> |
| | | <if test="createTime != null">os_create_time,</if> |
| | | <if test="updateTime != null">os_update_time,</if> |
| | | <if test="originalMoney != null">os_original_money,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="originalMoney != null">#{originalMoney,jdbcType=DECIMAL}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy">update |
| | | yeshi_ec_invite_order_subsidy set os_uid = |
| | | #{uid,jdbcType=BIGINT},os_money = |
| | | #{money,jdbcType=DECIMAL},os_order_no = |
| | | #{orderNo,jdbcType=VARCHAR},os_source_type = |
| | | #{sourceType,jdbcType=INTEGER},os_state = |
| | | #{state,jdbcType=INTEGER},os_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},os_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,os_original_money |
| | | =#{originalMoney,jdbcType=DECIMAL} where os_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy"> |
| | | update yeshi_ec_invite_order_subsidy |
| | | <set> |
| | | <if test="uid != null">os_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">os_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="orderNo != null">os_order_no=#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">os_source_type=#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">os_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">os_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">os_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="originalMoney !=null">os_original_money =#{originalMoney,jdbcType=DECIMAL}, |
| | | </if> |
| | | </set> |
| | | where os_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <select id="getByOrderNoAndType" resultMap="BaseResultMap">SELECT * FROM |
| | | yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND os_order_no = |
| | | #{orderNo} AND os_source_type = #{type} LIMIT 1 |
| | | </select> |
| | | |
| | | <select id="getByOrderNoAndTypeForUpdate" resultMap="BaseResultMap">SELECT * |
| | | FROM |
| | | yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND |
| | | os_order_no = |
| | | #{orderNo} AND os_source_type = #{type} for update |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="countByOrderNoAndType" resultType="java.lang.Long">SELECT count(*) |
| | | FROM yeshi_ec_invite_order_subsidy WHERE os_order_no = #{orderNo} AND |
| | | os_source_type = #{type} |
| | | </select> |
| | | </mapper> |
| | |
| | | </set> |
| | | where ohm_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getCouponHongbaoByOrderNo" resultType="java.math.BigDecimal"> |
| | | SELECT COALESCE(SUM(hb.`hb_money`),0)AS couponMoney |
| | | SELECT |
| | | COALESCE(SUM(hb.`hb_money`),0)AS couponMoney |
| | | FROM `yeshi_ec_order_hongbaov2_map` hm |
| | | LEFT JOIN `yeshi_ec_order` o ON o.`id` = hm.`ohm_order_id` |
| | | LEFT JOIN (SELECT v2.`hb_money`,v2.`hb_id` FROM yeshi_ec_hongbao_v2 v2 |
| | | WHERE v2.`hb_uid`= #{uid} AND v2.`hb_type` = 10 )hb ON hb.hb_id = hm.`ohm_hongbao_id` |
| | | WHERE hb.hb_id IS NOT NULL AND o.`orderid` = #{orderNo} |
| | | LEFT JOIN `yeshi_ec_order` o ON |
| | | o.`id` = hm.`ohm_order_id` |
| | | LEFT JOIN (SELECT v2.`hb_money`,v2.`hb_id` |
| | | FROM yeshi_ec_hongbao_v2 v2 |
| | | WHERE v2.`hb_uid`= #{uid} AND v2.`hb_type` = 10 )hb ON hb.hb_id = |
| | | hm.`ohm_hongbao_id` |
| | | WHERE hb.hb_id IS NOT NULL AND o.`orderid` = |
| | | #{orderNo} |
| | | </select> |
| | | |
| | | |
| | | <select id="listByOrderId" resultMap="BaseResultMap"> |
| | | select * from yeshi_ec_order_hongbaov2_map where ohm_order_id=#{0} |
| | | </select> |
| | | |
| | | |
| | | |
| | | </mapper> |
| | |
| | | List<Integer> cidList = new ArrayList<>();
|
| | | cidList.add(1);// 女装
|
| | | int sort = getCommonSort(cid);
|
| | | result = DaTaoKeApiUtil.search("内衣 女", cidList, null, null, page, pageSize, sort);
|
| | | result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | |
|
| | | List<TLJBuyGoods> list = tljBuyGoodsService
|
| | | .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | |
|
| | | if (list.size() > 30)
|
| | | list = list.subList(0, 30);
|
| | | List<TaoBaoGoodsBrief> finalList = new ArrayList<>();
|
| | | Map<Long, TLJBuyGoods> map = new ConcurrentHashMap<>();
|
| | | if (list != null)
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.hongbao;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.hongbao.HongBaoV2SettleTempMapper;
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | |
|
| | | @Service
|
| | | public class HongBaoV2SettleTempServiceImpl implements HongBaoV2SettleTempService {
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempMapper hongBaoV2SettleTempMapper;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addTemp(List<Long> hongBaoIdList, String taskKey) {
|
| | | for (Long hbId : hongBaoIdList) {
|
| | | HongBaoV2SettleTemp temp = new HongBaoV2SettleTemp();
|
| | | temp.setCreateTime(new Date());
|
| | | temp.setHongBaoId(hbId);
|
| | | temp.setTaskKey(taskKey);
|
| | | hongBaoV2SettleTempMapper.insertSelective(temp);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoV2SettleTemp> listByKey(String key) {
|
| | | return hongBaoV2SettleTempMapper.listByKey(key);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByKey(String key) {
|
| | | return hongBaoV2SettleTempMapper.countByKey(key);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.money.InviteOrderSubsidyDebtMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.InviteOrderSubsidyDebtRepayHistoryMapper;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | |
|
| | | @Service
|
| | | public class InviteOrderSubsidyDebtServiceImpl implements InviteOrderSubsidyDebtService {
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtMapper inviteOrderSubsidyDebtMapper;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtRepayHistoryMapper inviteOrderSubsidyDebtRepayHistoryMapper;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addDebt(InviteOrderSubsidyDebt debt) throws InviteOrderSubsidyDebtException {
|
| | | if (debt == null || debt.getOriginMoney() == null || debt.getOriginMoney() == null || debt.getUid() == null) {
|
| | | throw new InviteOrderSubsidyDebtException(1, "数据不完整");
|
| | | }
|
| | | if (debt.getCreateTime() == null)
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setLeftMoney(debt.getOriginMoney());
|
| | | inviteOrderSubsidyDebtMapper.insertSelective(debt);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void repayDebt(Long debtId, BigDecimal money) throws InviteOrderSubsidyDebtException {
|
| | | InviteOrderSubsidyDebt debt = inviteOrderSubsidyDebtMapper.selectByPrimaryKeyForUpdate(debtId);
|
| | | if (debt == null)
|
| | | throw new InviteOrderSubsidyDebtException(1, "债务ID不存在");
|
| | | if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
|
| | | throw new InviteOrderSubsidyDebtException(3, "还钱必须大于0");
|
| | | if (debt.getLeftMoney().compareTo(money) < 0)
|
| | | throw new InviteOrderSubsidyDebtException(2, "还钱过多");
|
| | | // 还钱
|
| | | InviteOrderSubsidyDebt update = new InviteOrderSubsidyDebt();
|
| | | update.setId(debt.getId());
|
| | | update.setLeftMoney(debt.getLeftMoney().subtract(money));
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyDebtMapper.updateByPrimaryKeySelective(update);
|
| | | // 加入还钱记录
|
| | | InviteOrderSubsidyDebtRepayHistory record = new InviteOrderSubsidyDebtRepayHistory();
|
| | | record.setCreateTime(new Date());
|
| | | record.setDebt(debt);
|
| | | record.setMoney(money);
|
| | | record.setUid(debt.getUid());
|
| | | inviteOrderSubsidyDebtRepayHistoryMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws InviteOrderSubsidyDebtException {
|
| | | // 还钱
|
| | | long count = countNeedRepayDebt(uid);
|
| | | int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
|
| | | List<InviteOrderSubsidyDebt> totalList = new ArrayList<>();
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<InviteOrderSubsidyDebt> tempList = listNeedRepayDebt(uid, i + 1, 200);
|
| | | if (tempList != null && tempList.size() > 0) {
|
| | | totalList.addAll(tempList);
|
| | | }
|
| | | }
|
| | |
|
| | | // 剩余资金
|
| | | BigDecimal leftMoney = new BigDecimal(money.toString());
|
| | |
|
| | | for (InviteOrderSubsidyDebt debt : totalList) {
|
| | | if (leftMoney.compareTo(new BigDecimal(0)) <= 0)// 余额不足扣款
|
| | | break;
|
| | | BigDecimal repayMoney = null;
|
| | | if (debt.getLeftMoney().compareTo(leftMoney) >= 0)
|
| | | repayMoney = new BigDecimal(leftMoney.toString());
|
| | | else
|
| | | repayMoney = debt.getLeftMoney();
|
| | | try {
|
| | | repayDebt(debt.getId(), repayMoney);
|
| | | leftMoney = leftMoney.subtract(repayMoney);
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | // 上笔还款未成功,继续下一笔还款
|
| | | }
|
| | | }
|
| | |
|
| | | return leftMoney;//返回剩余的资金
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid, int page, int count) {
|
| | | return inviteOrderSubsidyDebtMapper.listByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid, (page - 1) * count,
|
| | | count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countNeedRepayDebt(Long uid) {
|
| | | return inviteOrderSubsidyDebtMapper.countByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTotalDebtMoney(Long uid) {
|
| | | BigDecimal money = inviteOrderSubsidyDebtMapper.sumLeftMoneyByUid(uid);
|
| | | if (money == null)
|
| | | money = new BigDecimal(0);
|
| | | return money;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanDrawBackMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDebtException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
|
| | | @Override
|
| | | public void addWeiQuanDrawBack(TaoBaoWeiQuanDrawBack taoBaoWeiQuanDrawBack) {
|
| | |
| | | weiQuanDrawBack.setUser(child.getUserInfo());
|
| | | taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 加入返还记录
|
| | |
|
| | | // 加入邀请补贴返还记录
|
| | | doInviteOrderSubsidy(orderId, Constant.SOURCE_TYPE_TAOBAO, uid, settleMent, wqMoney);
|
| | |
|
| | | // 如果资金大于0才扣除
|
| | |
|
| | | if (drawBackMoney != null && drawBackMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请订单补贴维权处理
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | private void doInviteOrderSubsidy(String orderId, int sourceType, Long uid, BigDecimal settleMent,
|
| | | BigDecimal weiQuanMoney) throws TaoBaoWeiQuanException {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderId, sourceType);
|
| | | if (subSidy != null)// 添加借贷关系
|
| | | {
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(settleMent, weiQuanMoney, subSidy.getOriginalMoney());
|
| | | if (drawBackMoney.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | InviteOrderSubsidyDebt debt = new InviteOrderSubsidyDebt();
|
| | | debt.setBeiZhu("订单维权:" + orderId + "-" + sourceType);
|
| | | debt.setOriginMoney(drawBackMoney);
|
| | | debt.setUid(uid);
|
| | | debt.setCreateTime(new Date());
|
| | | try {
|
| | | inviteOrderSubsidyDebtService.addDebt(debt);
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new TaoBaoWeiQuanException(101, "邀请订单补贴异常");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoWeiQuanDrawBack selectByOrderItemId(String orderItemId) {
|
| | | List<TaoBaoWeiQuanDrawBack> list = taoBaoWeiQuanDrawBackMapper.selectByOrderItemId(orderItemId);
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.mq;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.mq.MQUnSendInfoMapper;
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | | import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class MQUnSendInfoServiceImpl implements MQUnSendInfoService {
|
| | |
|
| | | @Resource
|
| | | private MQUnSendInfoMapper mqUnSendInfoMapper;
|
| | |
|
| | | @Override
|
| | | public void addMQUnSendInfo(MQUnSendInfo info) throws MQUnSendInfoException {
|
| | | if (StringUtil.isNullOrEmpty(info.getTag()) || StringUtil.isNullOrEmpty(info.getTopic())
|
| | | || StringUtil.isNullOrEmpty(info.getBody()) || StringUtil.isNullOrEmpty(info.getKey())) {
|
| | | throw new MQUnSendInfoException(1, "信息不完整");
|
| | | }
|
| | | MQUnSendInfo oldInfo = mqUnSendInfoMapper.selectByTopicTagAndKey(info.getTopic(), info.getTag(), info.getKey());
|
| | | if (oldInfo != null)
|
| | | return;
|
| | | if (info.getLastSendTime() == null)
|
| | | info.setLastSendTime(new Date());
|
| | | mqUnSendInfoMapper.insertSelective(info);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MQUnSendInfo> listByMaxSendTime(Date maxSendTime, int page, int pageSize) {
|
| | | return mqUnSendInfoMapper.listByMaxSendTime(maxSendTime, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByPrimaryKey(Long id) {
|
| | | mqUnSendInfoMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateSendTime(Long id, Date sendTime) {
|
| | | MQUnSendInfo info = new MQUnSendInfo();
|
| | | info.setId(id);
|
| | | info.setLastSendTime(sendTime);
|
| | | mqUnSendInfoMapper.updateByPrimaryKeySelective(info);
|
| | | }
|
| | | }
|
| | |
| | | return hongBaoOrderMapper.selectByHongBaoId(hongBaoId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoOrder> listByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | return hongBaoOrderMapper.listByOrderIdAndSourceType(orderId, sourceType);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | firstHongbao.setType(HongBaoV2.TYPE_YIJI);
|
| | | firstHongbao.setVersion(2);
|
| | | firstHongbao.setState(hongBao.getState());
|
| | | firstHongbao.setOrderType(commonOrder.getSourceType());
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | |
| | | secondHongbao.setType(HongBaoV2.TYPE_ERJI);
|
| | | secondHongbao.setVersion(2);
|
| | | secondHongbao.setState(hongBao.getState());
|
| | | secondHongbao.setOrderType(commonOrder.getSourceType());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | |
| | |
|
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | | hongBaoV2Mapper.insertSelective(hongBao);
|
| | | // 添加红包与订单的映射
|
| | | HongBaoOrder hongBaoOrder = new HongBaoOrder();
|
| | |
| | | firstHongbao.setType(HongBaoV2.TYPE_YIJI);
|
| | | firstHongbao.setVersion(2);
|
| | | firstHongbao.setState(hongBao.getState());
|
| | | firstHongbao.setOrderType(commonOrder.getSourceType());
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | |
| | | secondHongbao.setType(HongBaoV2.TYPE_ERJI);
|
| | | secondHongbao.setVersion(2);
|
| | | secondHongbao.setState(hongBao.getState());
|
| | | secondHongbao.setOrderType(commonOrder.getSourceType());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | secondHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
|
| | |
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setUserInfo(user);
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | | hongBaoV2Mapper.insertSelective(hongBao);
|
| | | // 插入红包与订单映射
|
| | | HongBaoOrder hongBaoOrder = new HongBaoOrder();
|
| | |
| | | child.setUrank(boss.getRank());
|
| | | child.setVersion(2);
|
| | | child.setCreateTime(new Date());
|
| | | child.setOrderType(commonOrder.getSourceType());
|
| | | if (child.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | hongBaoV2Mapper.insertSelective(child);
|
| | | // 添加通知
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoV2> listChildrenByIds(List<Long> idList) {
|
| | | if (idList == null || idList.size() == 0)
|
| | | return null;
|
| | | return hongBaoV2Mapper.listChildrenByIds(idList);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> getUidByNear30DayShareSucceed() {
|
| | | return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
|
| | | }
|
| | |
| | | return hongBaoV2List.get(0);
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoV2> listByIds(List<Long> idList) {
|
| | | return hongBaoV2Mapper.listByIds(idList);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.InviteOrderSubsidyMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | @Resource
|
| | | private InviteOrderSubsidyMapper inviteOrderSubsidyMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMapService orderHongBaoMapService;
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Override
|
| | | public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.getByOrderNoAndType(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public InviteOrderSubsidy getByOrderNoAndTypeForUpdate(Long uid, String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.getByOrderNoAndTypeForUpdate(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | |
| | | InviteOrderSubsidy old = getByOrderNoAndType(orderSubsidy.getUid(), orderSubsidy.getOrderNo(),
|
| | | orderSubsidy.getSourceType());
|
| | | if (old != null) {// 修改
|
| | | if (old.getState() == InviteOrderSubsidy.STATE_INVALID
|
| | | || old.getState() == InviteOrderSubsidy.STATE_SUBSIDIZED)
|
| | | return;
|
| | |
|
| | | // 修改状态
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(old.getId());
|
| | | update.setMoney(orderSubsidy.getMoney());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType) throws InviteOrderSubsidyException {
|
| | | List<HongBaoOrder> list = hongBaoOrderService.listByOrderIdAndSourceType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0) {
|
| | | // 必须是自购订单才返利
|
| | | HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId());
|
| | | if (parent != null && parent.getType() == HongBaoV2.TYPE_ZIGOU) {
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderId, sourceType);
|
| | | List<Long> idList = new ArrayList<>();
|
| | | for (HongBaoOrder ho : list)
|
| | | if (ho.getHongBaoV2() != null)
|
| | | idList.add(ho.getHongBaoV2().getId());
|
| | | // 查询子红包
|
| | | List<HongBaoV2> children = hongBaoV2Service.listChildrenByIds(idList);
|
| | | if (children != null && children.size() > 0) {
|
| | | Map<Long, Integer> uidHongBaoMap = new ConcurrentHashMap<>();
|
| | | for (HongBaoV2 v2 : children) {// 按用户ID统计红包
|
| | | Long uid = v2.getUserInfo().getId();
|
| | | if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | uidHongBaoMap.put(uid, v2.getType());
|
| | | }
|
| | | }
|
| | |
|
| | | List<HongBaoV2> hbList = hongBaoV2Service.listByIds(idList);
|
| | | int state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | | // 确定是否使用了奖励券
|
| | | if (orderHongBaoMapService.selectByOrderIdAndSourceType(orderId, sourceType) != null) {
|
| | | state = InviteOrderSubsidy.STATE_INVALID;
|
| | | } else {
|
| | | // 确定是否返利到账5天后
|
| | | if (recieveMoneyMoreThan(hbList, 5)) {
|
| | | state = InviteOrderSubsidy.STATE_VALID;
|
| | | } else {
|
| | | state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | // 计算总返利
|
| | | for (HongBaoV2 v2 : hbList) {
|
| | | if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | totalMoney = totalMoney.add(v2.getMoney());
|
| | | }
|
| | |
|
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getInviteFirstLevelSubsidyRate(order.getThirdCreateTime().getTime());
|
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getInviteSecondLevelSubsidyRate(order.getThirdCreateTime().getTime());
|
| | |
|
| | | // 计算奖励金
|
| | | for (Iterator<Long> its = uidHongBaoMap.keySet().iterator(); its.hasNext();) {
|
| | | Long uid = its.next();
|
| | | int type = uidHongBaoMap.get(uid);
|
| | | if (type == HongBaoV2.TYPE_YIJI || type == HongBaoV2.TYPE_ERJI) {
|
| | | BigDecimal rate = null;
|
| | | if (type == HongBaoV2.TYPE_YIJI)
|
| | | rate = firstRate;
|
| | | else
|
| | | rate = secondRate;
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(totalMoney, rate),
|
| | | new BigDecimal(100));
|
| | | InviteOrderSubsidy orderSubsidy = new InviteOrderSubsidy();
|
| | | orderSubsidy.setMoney(money);
|
| | | orderSubsidy.setUid(uid);
|
| | | orderSubsidy.setOrderNo(orderId);
|
| | | orderSubsidy.setSourceType(sourceType);
|
| | | orderSubsidy.setState(state);
|
| | | addOrderSubsidy(orderSubsidy);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private boolean recieveMoneyMoreThan(List<HongBaoV2> hbList, int day) {
|
| | | // 是否全部是到账状态或失效状态
|
| | | int invalidCount = 0;// 失效个数
|
| | | int recieveCount = 0;// 到账的个数
|
| | | long maxGetTime = 0;
|
| | | for (HongBaoV2 v2 : hbList) {
|
| | | if (v2.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | invalidCount++;
|
| | | else if (v2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | recieveCount++;
|
| | | if (v2.getGetTime() != null && v2.getGetTime().getTime() > maxGetTime)
|
| | | maxGetTime = v2.getGetTime().getTime();
|
| | |
|
| | | }
|
| | | }
|
| | | if (invalidCount + recieveCount == hbList.size() && recieveCount > 0 && maxGetTime > 0) {// 全部已到账
|
| | | // 查询到账时间距离当前时间是否超过指定天
|
| | | if (System.currentTimeMillis() - maxGetTime > 1000 * 60 * 60 * 24L * day)
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | return inviteOrderSubsidyMapper.countByOrderNoAndType(orderId, sourceType);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void invalidByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | List<InviteOrderSubsidy> list = inviteOrderSubsidyMapper.listByOrderNoAndType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0)
|
| | | for (InviteOrderSubsidy subsidy : list) {
|
| | | if (subsidy.getState() == InviteOrderSubsidy.STATE_UNKNOWN
|
| | | || subsidy.getState() == InviteOrderSubsidy.STATE_VALID) {
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId());
|
| | | update.setState(InviteOrderSubsidy.STATE_INVALID);
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void validByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | List<InviteOrderSubsidy> list = inviteOrderSubsidyMapper.listByOrderNoAndType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0)
|
| | | for (InviteOrderSubsidy subsidy : list) {
|
| | | if (subsidy.getState() == InviteOrderSubsidy.STATE_UNKNOWN) {
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId());
|
| | | update.setState(InviteOrderSubsidy.STATE_VALID);
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void settleById(Long id, BigDecimal money) {
|
| | | InviteOrderSubsidy orderSubsidy = new InviteOrderSubsidy(id);
|
| | | orderSubsidy.setMoney(money);
|
| | | orderSubsidy.setState(InviteOrderSubsidy.STATE_SUBSIDIZED);
|
| | | orderSubsidy.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(orderSubsidy);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.order.OrderHongBaoMap;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | |
|
| | | @Service
|
| | | public class OrderHongBaoMapServiceImpl implements OrderHongBaoMapService {
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMapMapper orderHongBaoMapMapper;
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | |
|
| | | @Override
|
| | | public void addOrderHongBaoMap(HongBaoV2 hongBao, Order order) {
|
| | |
| | | map.setOrder(order);
|
| | | orderHongBaoMapMapper.insertSelective(map);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public BigDecimal getCouponHongbaoByOrderNo(String orderNo, Long uid) {
|
| | | return orderHongBaoMapMapper.getCouponHongbaoByOrderNo(orderNo, uid);
|
| | | return orderHongBaoMapMapper.getCouponHongbaoByOrderNo(orderNo, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public OrderHongBaoMap selectByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderId, sourceType);
|
| | | if (order != null) {
|
| | | List<OrderHongBaoMap> mapList = orderHongBaoMapMapper.listByOrderId(order.getId());
|
| | | if (mapList != null && mapList.size() > 0)
|
| | | return mapList.get(0);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.math.RoundingMode;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
|
| | |
|
| | | @Service
|
| | | public class OrderMoneySettleServiceImpl implements OrderMoneySettleService {
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Mapper hongBaoV2Mapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanDrawBackService taoBaoWeiQuanDrawBackService;
|
| | |
|
| | | @Resource
|
| | | private AccountDetailsHongBaoMapService accountDetailsHongBaoMapService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | // 邀请补贴
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSettleTB(Long uid) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | 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);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item != null && item.getParent() != null) {
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getParent().getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanliInviteTB(hongBaoList, uid, taskKey);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSettleJD(Long uid) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_JD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | 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);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item != null && item.getParent() != null) {
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getParent().getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanliInviteOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSettlePDD(Long uid) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_PDD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | 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);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item != null && item.getParent() != null) {
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getParent().getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanliInviteOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void shareSettleTB(Long uid) throws OrderMoneySettleException {
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | | int sourceType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | 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);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanLiShareTB(hongBaoList, uid, taskKey);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void shareSettleJD(Long uid) throws OrderMoneySettleException {
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | | int sourceType = Constant.SOURCE_TYPE_JD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | 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);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void shareSettlePDD(Long uid) throws OrderMoneySettleException {
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | | int sourceType = Constant.SOURCE_TYPE_PDD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | 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);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void ziGouSettle(String orderId, int sourceType,String taskKey) throws OrderMoneySettleException {
|
| | | // 查询同一订单号的红包
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | Map<Long, BigDecimal> userMoney = new HashMap<>();
|
| | | Map<Long, List<HongBaoV2>> userHongBao = new HashMap<>();
|
| | | Map<Long, Integer> userGoodsCount = new HashMap<>();
|
| | | for (CommonOrder co : orderList) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
|
| | | hongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | Long uid = co.getUserInfo().getId();
|
| | | if (userGoodsCount.get(uid) == null)
|
| | | userGoodsCount.put(uid, co.getCount());
|
| | | else
|
| | | userGoodsCount.put(uid, Integer.valueOf(co.getCount() + userGoodsCount.get(uid)));
|
| | | }
|
| | |
|
| | | for (HongBaoV2 hb : hongBaoList) {
|
| | | long currentTimeMillis = System.currentTimeMillis();
|
| | | if (hb.getState() != HongBao.STATE_SHIXIAO) {
|
| | | // 设置为已返利
|
| | | // 处理主红包
|
| | | if (hb.getState() != HongBaoV2.STATE_SHIXIAO && hb.getState() != HongBaoV2.STATE_YILINGQU
|
| | | && hb.getType() == HongBaoV2.TYPE_ZIGOU) {
|
| | | // 如果红包没被领取
|
| | | Long uid = hb.getUserInfo().getId();
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hb.getId());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setGetTime(new Date(currentTimeMillis));
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | if (userMoney.get(uid) == null)
|
| | | userMoney.put(uid, hb.getMoney());
|
| | | else
|
| | | userMoney.put(uid, userMoney.get(uid).add(hb.getMoney()));
|
| | |
|
| | | // 添加红包到用户
|
| | | if (userHongBao.get(uid) == null)
|
| | | userHongBao.put(uid, new ArrayList<>());
|
| | | userHongBao.get(uid).add(hb);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Iterator<Long> its = userMoney.keySet().iterator();
|
| | |
|
| | | while (its.hasNext()) {
|
| | | // 将自己添加到用户
|
| | | Long uid = its.next();
|
| | | BigDecimal money = userMoney.get(uid);
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | // 插入新版资金明细
|
| | | try {
|
| | | // 此处不用订单号做唯一性索引
|
| | | userMoneyDetail = UserMoneyDetailFactory.createFanLi(uid, orderId, sourceType, null, money);
|
| | | } catch (UserMoneyDetailException e1) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e1, "订单号:" + orderId, "");
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | userMoneyService.addUserMoney(uid, money, userMoneyDetail);
|
| | | |
| | | List<Long> hbIdList=new ArrayList<>();
|
| | | // 添加资金明细与红包的映射关系
|
| | | for (HongBaoV2 v2 : userHongBao.get(uid)) {
|
| | | hbIdList.add(v2.getId());
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId());
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(v2.getId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | //添加结算映射
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, taskKey);
|
| | |
|
| | | // 站内信+推送
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderReceived(uid, orderId, sourceType, userGoodsCount.get(uid), money,
|
| | | user.getMyHongBao());
|
| | | }
|
| | | // 通知免单到账
|
| | | try {
|
| | | userSystemCouponService.updateStateByArrivalAccount(orderId);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 维权扣款(2018-08-05后开始实行)
|
| | |
|
| | | try {
|
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(orderId);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | if (e.getCode() == TaoBaoWeiQuanException.CODE_NEDD_UPDATE_ORDER) {
|
| | | List<TaoBaoOrder> olist = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
|
| | | if (olist != null && olist.size() > 0) {
|
| | | long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
|
| | | olist = TaoKeOrderApiUtil.getTaoBaoCommonOrderList(time, time + 1000 * 2L, 1);
|
| | | if (olist != null && olist.size() > 0) {
|
| | | for (int i = 0; i < olist.size(); i++) {
|
| | | if (!olist.get(i).getOrderId().equalsIgnoreCase(orderId)) {// 删除无关订单
|
| | | olist.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | taoBaoOrderService.addTaoBaoOrderList(olist);
|
| | | }
|
| | | }
|
| | | } else
|
| | | throw new OrderMoneySettleException(e.getCode(), "维权处理出错:" + e.getMsg());
|
| | | }
|
| | | |
| | | //添加结算映射
|
| | | |
| | | |
| | | }
|
| | |
|
| | | private HongBaoV2 filterWeiQuanINGHongBao(HongBaoV2 hongBao) {
|
| | |
|
| | | long hbId = hongBao.getId();
|
| | | if (hongBao.getParent() != null) {
|
| | | hbId = hongBao.getParent().getId();
|
| | | }
|
| | |
|
| | | HongBaoOrder hongbaoOrder = hongBaoOrderMapper.selectByHongBaoId(hbId);
|
| | |
|
| | | if (hongbaoOrder == null)
|
| | | return null;
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "维权创建");
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList1 = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "等待处理");
|
| | | if ((taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | || (taoBaoWeiQuanList1 != null && taoBaoWeiQuanList1.size() > 0)) {
|
| | | return null;
|
| | | }
|
| | | return hongBao;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void fanliInviteTB(List<HongBaoV2> hongBaoList, Long uid, String key) throws TaoBaoWeiQuanException {
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | Date balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | if (!StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getOrderNo()))
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
|
| | | }
|
| | |
|
| | | try {
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, key);
|
| | | } catch (Exception e1) {
|
| | | throw new TaoBaoWeiQuanException(200, "插入返利临时表出错");
|
| | | }
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : hbIdList) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void fanliInviteOther(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key) {
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | |
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, sourceType, (int) validCount,
|
| | | (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, sourceType, inviteOrders.size(), inviteGoodsCount,
|
| | | invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, key);
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : hbIdList) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝分享赚返利
|
| | | * |
| | | * @param hongBaoList
|
| | | * @param uid
|
| | | * @throws TaoBaoWeiQuanException
|
| | | */
|
| | | private void fanLiShareTB(List<HongBaoV2> hongBaoList, Long uid, String key) throws TaoBaoWeiQuanException {
|
| | | BigDecimal sharemoney = new BigDecimal(0);
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | | List<Long> recieveHongBaoIds = new ArrayList<>();
|
| | | int shareGoodsCount = 0;
|
| | | Set<String> shareOrders = new HashSet<>();
|
| | |
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | sharemoney = sharemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBao.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | | Date balanceTime = null;
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (hongBaoOrder != null) {
|
| | | balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | shareGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | }
|
| | | shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享赚到账
|
| | | */
|
| | |
|
| | | if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 计算本月的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | |
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, sharemoney, new Date());
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
|
| | |
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(recieveHongBaoIds, key);
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : recieveHongBaoIds) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 其他平台分享赚返利
|
| | | * |
| | | * @param hongBaoList
|
| | | * @param uid
|
| | | * @param sourceType
|
| | | */
|
| | | private void fanLiShareOther(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key) {
|
| | | BigDecimal sharemoney = new BigDecimal(0);
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | List<Long> recieveHongBaoIds = new ArrayList<>();
|
| | | int shareGoodsCount = 0;
|
| | | Set<String> shareOrders = new HashSet<>();
|
| | |
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | sharemoney = sharemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBao.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (hongBaoOrder != null) {
|
| | | shareGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | }
|
| | | shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享赚到账
|
| | | */
|
| | |
|
| | | if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 计算本月的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | |
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, sharemoney, new Date());
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
|
| | |
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(recieveHongBaoIds, key);
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : recieveHongBaoIds) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请补贴结算
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSubsidySettle(Long uid, String taskKey) throws OrderMoneySettleException {
|
| | | // 查询key
|
| | | List<HongBaoV2SettleTemp> list = hongBaoV2SettleTempService.listByKey(taskKey);
|
| | | if (list != null && list.size() > 0) {
|
| | |
|
| | | Integer sourceType = null;
|
| | | List<InviteOrderSubsidy> subsidyList = new ArrayList<>();
|
| | | for (HongBaoV2SettleTemp temp : list) {
|
| | | Long hongBaoId = temp.getHongBaoId();
|
| | | HongBaoV2 hongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoId);
|
| | | if (sourceType != null)
|
| | | sourceType = hongBao.getOrderType();
|
| | | if (hongBao.getParent() != null)
|
| | | hongBao = hongBao.getParent();
|
| | | HongBaoOrder order = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (order != null && order.getCommonOrder() != null) {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndTypeForUpdate(uid,
|
| | | order.getCommonOrder().getOrderNo(), order.getCommonOrder().getSourceType());
|
| | | if (subSidy != null && subSidy.getState() == InviteOrderSubsidy.STATE_VALID) {
|
| | | subsidyList.add(subSidy);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (sourceType == null)
|
| | | throw new OrderMoneySettleException(1, "订单类型未获取到");
|
| | |
|
| | | if (subsidyList.size() > 0) {
|
| | | BigDecimal debtMoney = inviteOrderSubsidyDebtService.getTotalDebtMoney(uid);
|
| | | BigDecimal originalDebtMoney = new BigDecimal(debtMoney.toString());// 总的欠款
|
| | | List<InviteOrderSubsidy> copySubsidyList = new ArrayList<>();
|
| | | copySubsidyList.addAll(subsidyList);
|
| | | while (debtMoney.compareTo(new BigDecimal(0)) > 0 && copySubsidyList.size() > 0) {// 有欠款,还有还的
|
| | | debtMoney = kouKuan(copySubsidyList, debtMoney);
|
| | | }
|
| | | // 还款
|
| | | BigDecimal repayMoney = originalDebtMoney.subtract(debtMoney);
|
| | | BigDecimal bannce = null;
|
| | | if (repayMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | try {
|
| | | bannce = inviteOrderSubsidyDebtService.repayDebtByUid(uid, repayMoney);
|
| | | // 剩余的补贴金额
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new OrderMoneySettleException(2, "还款异常");
|
| | | }
|
| | | }
|
| | | if (bannce != null && bannce.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 如果有还剩下的钱就加到第一个上面
|
| | | subsidyList.get(0).setMoney(subsidyList.get(0).getMoney().add(bannce));
|
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | for (InviteOrderSubsidy subsidy : subsidyList) {
|
| | | inviteOrderSubsidyService.settleById(subsidy.getId(), subsidy.getMoney());
|
| | | totalMoney = totalMoney.add(subsidy.getMoney());
|
| | | }
|
| | |
|
| | | // 到账
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | try {
|
| | | userMoneyDetail = UserMoneyDetailFactory.createInviteSubsidy(uid, sourceType, totalMoney,
|
| | | new Date());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new OrderMoneySettleException(1, "账户明细构建出错");
|
| | | }
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, totalMoney, userMoneyDetail);
|
| | | // TODO 添加消息
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private String getTaskKey(Long uid) {
|
| | | return uid + "-" + UUID.randomUUID().toString();
|
| | | }
|
| | |
|
| | | private BigDecimal kouKuan(List<InviteOrderSubsidy> subsidyList, BigDecimal debtMoney) {
|
| | | BigDecimal average = debtMoney.divide(new BigDecimal(subsidyList.size()), 2, RoundingMode.UP);
|
| | | for (int i = 0; i < subsidyList.size(); i++) {
|
| | | InviteOrderSubsidy sidy = subsidyList.get(i);
|
| | | BigDecimal subMoney = null;
|
| | | if (average.compareTo(sidy.getMoney()) >= 0) {
|
| | | subMoney = sidy.getMoney();
|
| | | } else {
|
| | | subMoney = average;
|
| | | }
|
| | | if (subMoney.compareTo(debtMoney) > 0)
|
| | | subMoney = debtMoney;
|
| | | debtMoney = debtMoney.subtract(subMoney);
|
| | | sidy.setMoney(sidy.getMoney().subtract(subMoney));
|
| | |
|
| | | if (sidy.getMoney().compareTo(new BigDecimal(0)) == 0) {
|
| | | subsidyList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | return debtMoney;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | | public class OrderProcessServiceImpl implements OrderProcessService {
|
| | |
| | |
|
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | @Resource
|
| | | private OrderMoneySettleService orderMoneySettleService;
|
| | |
|
| | | /**
|
| | | * 是否是分享订单
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (hongBaoOrder.getCommonOrder() == null) {// ||
|
| | | // hongBaoOrder.getCommonOrder().getSourceType()
|
| | | // ==
|
| | | // Constant.SOURCE_TYPE_JD
|
| | | // || hongBaoOrder.getCommonOrder().getSourceType() ==
|
| | | // Constant.SOURCE_TYPE_PDD
|
| | | if (hongBaoOrder.getCommonOrder() == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // 查询同一订单号的红包
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | Map<Long, BigDecimal> userMoney = new HashMap<>();
|
| | | Map<Long, List<HongBaoV2>> userHongBao = new HashMap<>();
|
| | | Map<Long, Integer> userGoodsCount = new HashMap<>();
|
| | | // Map<Long, BigDecimal> userPayMent = new HashMap<>();
|
| | | for (CommonOrder co : orderList) {
|
| | | hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
|
| | | hongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | Long uid = co.getUserInfo().getId();
|
| | | if (userGoodsCount.get(uid) == null)
|
| | | userGoodsCount.put(uid, co.getCount());
|
| | | else
|
| | | userGoodsCount.put(uid, Integer.valueOf(co.getCount() + userGoodsCount.get(uid)));
|
| | | // if (userPayMent.get(uid) == null)
|
| | | // userPayMent.put(uid, new BigDecimal(0));
|
| | | // if (co.getState() == CommonOrder.STATE_JS)
|
| | | // userPayMent.put(uid,
|
| | | // userPayMent.get(uid).add(co.getSettlement()));
|
| | | // else
|
| | | // userPayMent.put(uid, userPayMent.get(uid).add(co.getPayment()));
|
| | | }
|
| | |
|
| | | for (HongBaoV2 hb : hongBaoList) {
|
| | | long currentTimeMillis = System.currentTimeMillis();
|
| | | if (hb.getState() != HongBao.STATE_SHIXIAO) {
|
| | | // 设置为已返利
|
| | | // 处理主红包
|
| | | if (hb.getState() != HongBaoV2.STATE_SHIXIAO && hb.getState() != HongBaoV2.STATE_YILINGQU
|
| | | && hb.getType() == HongBaoV2.TYPE_ZIGOU) {
|
| | | // 如果红包没被领取
|
| | | Long uid = hb.getUserInfo().getId();
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hb.getId());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setGetTime(new Date(currentTimeMillis));
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | if (userMoney.get(uid) == null)
|
| | | userMoney.put(uid, hb.getMoney());
|
| | | else
|
| | | userMoney.put(uid, userMoney.get(uid).add(hb.getMoney()));
|
| | |
|
| | | // 添加红包到用户
|
| | | if (userHongBao.get(uid) == null)
|
| | | userHongBao.put(uid, new ArrayList<>());
|
| | | userHongBao.get(uid).add(hb);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Iterator<Long> its = userMoney.keySet().iterator();
|
| | |
|
| | | while (its.hasNext()) {
|
| | | // 将自己添加到用户
|
| | | Long uid = its.next();
|
| | | BigDecimal money = userMoney.get(uid);
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | // 插入新版资金明细
|
| | | try {
|
| | | // 此处不用订单号做唯一性索引
|
| | | userMoneyDetail = UserMoneyDetailFactory.createFanLi(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), null, money);
|
| | | } catch (UserMoneyDetailException e1) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e1, "订单号:" + hongBaoOrder.getCommonOrder().getOrderNo(), "");
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | userMoneyService.addUserMoney(uid, money, userMoneyDetail);
|
| | | // 添加资金明细与红包的映射关系
|
| | | for (HongBaoV2 v2 : userHongBao.get(uid)) {
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId());
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(v2.getId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | // 站内信+推送
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderReceived(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), userGoodsCount.get(uid), money, user.getMyHongBao());
|
| | | }
|
| | | // 通知免单到账
|
| | | // 自购到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU,
|
| | | mainUser.getId(), hongBaoOrder.getCommonOrder().getSourceType(),
|
| | | hongBaoOrder.getCommonOrder().getOrderNo(), null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String key = mainUser.getId() + "-" + UUID.randomUUID().toString();
|
| | | msg.setKey(key);
|
| | | try {
|
| | | userSystemCouponService.updateStateByArrivalAccount(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 维权扣款(2018-08-05后开始实行)
|
| | | if (hongBaoOrder.getCommonOrder().getSettleTime() != null && hongBaoOrder.getCommonOrder().getSettleTime()
|
| | | .getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | try {
|
| | | if (hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_TAOBAO)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | if (e.getCode() == TaoBaoWeiQuanException.CODE_NEDD_UPDATE_ORDER) {
|
| | | List<TaoBaoOrder> olist = taoBaoOrderService
|
| | | .getTaoBaoOrderByOrderId(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | if (olist != null && olist.size() > 0) {
|
| | | long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
|
| | | olist = TaoKeOrderApiUtil.getTaoBaoCommonOrderList(time, time + 1000 * 2L, 1);
|
| | | if (olist != null && olist.size() > 0) {
|
| | | for (int i = 0; i < olist.size(); i++) {
|
| | | if (!olist.get(i).getOrderId()
|
| | | .equalsIgnoreCase(hongBaoOrder.getCommonOrder().getOrderNo())) {// 删除无关订单
|
| | | olist.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | |
|
| | | taoBaoOrderService.addTaoBaoOrderList(olist);
|
| | | }
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), key);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | } catch (Exception e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | } else
|
| | | throw new TaoBaoWeiQuanException(e.getCode(), e.getMsg());
|
| | | }
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private HongBaoV2 filterWeiQuanINGHongBao(HongBaoV2 hongBao) {
|
| | |
|
| | | long hbId = hongBao.getId();
|
| | | if (hongBao.getParent() != null) {
|
| | | hbId = hongBao.getParent().getId();
|
| | | }
|
| | |
|
| | | HongBaoOrder hongbaoOrder = hongBaoOrderMapper.selectByHongBaoId(hbId);
|
| | |
|
| | | if (hongbaoOrder == null)
|
| | | return null;
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "维权创建");
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList1 = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "等待处理");
|
| | | if ((taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | || (taoBaoWeiQuanList1 != null && taoBaoWeiQuanList1.size() > 0)) {
|
| | | return null;
|
| | | }
|
| | | return hongBao;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException {
|
| | | List<Long> recieveHongBaoIds = new ArrayList<>();
|
| | | /**
|
| | | * 处理邀请赚订单
|
| | | */
|
| | | // 查询UID的邀请赚订单
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid);
|
| | | 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, i * 1000,
|
| | | 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | | // 灰度测试中,京东/拼多多订单分享/邀请订单不返利
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item.getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | } else {
|
| | | item = item.getParent();
|
| | | }
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | |
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | |
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | Date balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | if (!StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getOrderNo()))
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理一级二级分享赚(属于邀请赚类型)
|
| | | */
|
| | |
|
| | | List<HongBaoV2> totalHongBaoList = new ArrayList<>();
|
| | | // 查询UID的二级或者三级分享赚订单
|
| | | // TODO 暂时查询10000条数据,后面再做分页
|
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | // TODO 需要处理超过1w条数据的订单
|
| | | List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000);
|
| | |
|
| | | if (hbList != null && hbList.size() > 0)
|
| | | totalHongBaoList.addAll(hbList);
|
| | |
|
| | | for (HongBaoV2 hb : totalHongBaoList) {
|
| | | if (hb.getState() == HongBaoV2.STATE_BUKELINGQU || hb.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | hb = filterWeiQuanINGHongBao(hb);
|
| | | if (hb == null)
|
| | | continue;
|
| | | invitemoney = invitemoney.add(hb.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hb.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hb.getId());
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hb.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | if (!StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getOrderNo()))
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
|
| | | }
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | hbIdList.clear();
|
| | | drawBackOrders.clear();
|
| | |
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | |
|
| | | int shareGoodsCount = 0;
|
| | | Set<String> shareOrders = new HashSet<>();
|
| | | BigDecimal sharemoney = new BigDecimal(0);
|
| | | // 查询UID的分享赚订单
|
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | // TODO 需要处理超过10000条数据的订单
|
| | | List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000);
|
| | | for (HongBaoV2 hongBao : hongBaoShareList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | sharemoney = sharemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBao.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | | Date balanceTime = null;
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (hongBaoOrder != null) {
|
| | | balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | shareGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | }
|
| | | shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleTB(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享赚到账
|
| | | */
|
| | |
|
| | | if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 计算本月的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | |
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | | long invalidCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_SX,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, sharemoney, new Date());
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
|
| | |
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleJD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : recieveHongBaoIds) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.inviteSettlePDD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 分享赚到账
|
| | | try {
|
| | | orderMoneySettleService.shareSettleTB(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.shareSettleJD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.shareSettlePDD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
| | |
| | | // 原来不存在订单
|
| | | Long uid = null;
|
| | | if (oldOrder == null) {
|
| | | PidUser pidUser = null;// pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null) {
|
| | | uid = pidUser.getUid();
|
| | | Long targetUid = null;
|
| | | if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
|
| | | targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
|
| | |
|
| | | } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | | if (info != null && info.getUser() != null)
|
| | | targetUid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | if (targetUid != null) {
|
| | | uid = targetUid;
|
| | | // 插入到Order中
|
| | | // 添加到订单中去
|
| | | Order order = new Order();
|
| | |
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | oldOrder = order;
|
| | | } else {
|
| | | Long targetUid = null;
|
| | | if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
|
| | | targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
|
| | |
|
| | | } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | | if (info != null && info.getUser() != null)
|
| | | targetUid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | if (targetUid != null) {
|
| | | uid = targetUid;
|
| | | // 插入到Order中
|
| | | // 添加到订单中去
|
| | | Order order = new Order();
|
| | | order.setBeizhu("PID返利订单");
|
| | | order.setCreatetime(System.currentTimeMillis());
|
| | | order.setOrderId(orderId);
|
| | | order.setOrderType(1);
|
| | | order.setState(Order.STATE_YIZHIFU);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | order.setVersion(2);
|
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | oldOrder = order;
|
| | | }
|
| | | }
|
| | |
|
| | | } else {
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | public void processShareGoodsOrderNew(String orderId, List<TaoBaoOrder> orderList) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | | if (orderList != null && orderList.size() > 0) {
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
|
| | | orderList.get(0).getSourceMediaId(), orderList.get(0).getAdPositionId());
|
| | | // 原来不存在订单
|
| | | Long uid = null;
|
| | | PidUser pidUser = null; // pidUserMapper.selectByPid(pid);-PID机制移除
|
| | | if (pidUser != null)
|
| | | uid = pidUser.getUid();
|
| | | else {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId());
|
| | | if (info != null && info.getUser() != null)
|
| | | uid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId());
|
| | | if (info != null && info.getUser() != null)
|
| | | uid = info.getUser().getId();
|
| | | // 尚未找到和PID对应的用户
|
| | | if (uid == null) {
|
| | | // 通过红包查询
|
| | |
| | | public List<HongBaoV2> getCanBalanceElmeFanliHongBao() {
|
| | | List<Integer> list = new ArrayList<>();
|
| | | list.add(HongBaoV2.TYPE_ELME);
|
| | | return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, 0, 1000);
|
| | | return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, 0, 1000);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | // 返利到账
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加红包与事务消息
|
| | | * |
| | | * @param commonOrderList
|
| | | * @param orderId
|
| | | * @param uid
|
| | | * @param sourceType
|
| | | * @param hongBaoType
|
| | | */
|
| | | private void addHongBaoWithMQ(List<CommonOrderAddResultDTO> commonOrderList, String orderId, Long uid,
|
| | | int sourceType, int hongBaoType) {
|
| | | final List<CommonOrder> coList = convertCommonOrder(commonOrderList);
|
| | | OrderMQMsgDTO mqMsg = new OrderMQMsgDTO(orderId, sourceType, uid);
|
| | | Message msg = new Message("TOPIC_ORDER", String.format("orderhongbao-%s-%s", sourceType, hongBaoType),
|
| | | Message msg = new Message(MQTopicName.TOPIC_ORDER.name(),
|
| | | String.format(MQTagConstant.TAG_ORDER_STATISTIC_PREFIX + "%s-%s", sourceType, hongBaoType),
|
| | | new Gson().toJson(mqMsg).getBytes());
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | |
| | | }
|
| | | }, null);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getInviteFirstLevelSubsidyRate(Long time) {
|
| | | String key = "invite_subsidy_6";
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getInviteSecondLevelSubsidyRate(Long time) {
|
| | | String key = "invite_subsidy_7";
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.TransactionStatus;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.transaction.support.DefaultTransactionDefinition;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderTradeMapMapper;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderTradeMapMapper taoBaoOrderTradeMapMapper;
|
| | |
|
| | | @Resource(name = "transactionManager")
|
| | | private DataSourceTransactionManager transactionManager;
|
| | |
|
| | | /**
|
| | | * 获取订单的哈希值
|
| | |
| | | @Transactional
|
| | | @Override
|
| | | public void addTaoBaoOrder(String orderId, List<TaoBaoOrder> list) {
|
| | | LogHelper.test("订单号与订单数量:" + orderId + "-" + list.size());
|
| | | // 验证orderby是否正确
|
| | | if (list != null && list.size() > 0) {
|
| | | int maxOrderBy = list.get(0).getOrderBy();
|
| | | if (list.size() > 1)
|
| | | for (TaoBaoOrder order : list) {
|
| | | if (order.getOrderBy() > maxOrderBy)
|
| | | maxOrderBy = order.getOrderBy();
|
| | | TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
| | | try {
|
| | |
|
| | | LogHelper.test("订单号与订单数量:" + orderId + "-" + list.size());
|
| | | |
| | | // 验证orderby是否正确
|
| | | if (list != null && list.size() > 0) {
|
| | | int maxOrderBy = list.get(0).getOrderBy();
|
| | | if (list.size() > 1)
|
| | | for (TaoBaoOrder order : list) {
|
| | | if (order.getOrderBy() > maxOrderBy)
|
| | | maxOrderBy = order.getOrderBy();
|
| | | }
|
| | |
|
| | | if (list.size() != maxOrderBy) {
|
| | | LogHelper.test("捕捉到排序值错误:" + orderId);
|
| | | throw new Exception();
|
| | | }
|
| | |
|
| | | if (list.size() != maxOrderBy) {
|
| | | LogHelper.test("捕捉到排序值错误:" + orderId);
|
| | | return;
|
| | | }
|
| | | }
|
| | | // 验证tradeId问题
|
| | | Set<String> tradesIds = new HashSet<>();
|
| | | for (TaoBaoOrder order : list) {
|
| | | tradesIds.add(order.getTradeId());
|
| | | }
|
| | |
|
| | | // 有重复的交易ID不处理
|
| | | if (tradesIds.size() != list.size()) {
|
| | | LogHelper.test("检测到交易ID重复问题:" + orderId);
|
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoOrder> oldOrderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | | if (oldOrderList == null || oldOrderList.size() == 0) {
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | // 验证tradeId问题
|
| | | Set<String> tradesIds = new HashSet<>();
|
| | | for (TaoBaoOrder order : list) {
|
| | | tradesIds.add(order.getTradeId());
|
| | | }
|
| | | } else {
|
| | | if (StringUtil.isNullOrEmpty(oldOrderList.get(0).getTradeId())) {
|
| | | taoBaoOrderMapper.deleteByOrderId(orderId);
|
| | |
|
| | | // 有重复的交易ID不处理
|
| | | if (tradesIds.size() != list.size()) {
|
| | | LogHelper.test("检测到交易ID重复问题:" + orderId);
|
| | | throw new Exception();
|
| | | }
|
| | |
|
| | | List<TaoBaoOrder> oldOrderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | | if (oldOrderList == null || oldOrderList.size() == 0) {
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | }
|
| | | } else {
|
| | | // 按tradeId更新
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | TaoBaoOrder order = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(taoBaoOrder.getTradeId());
|
| | | if (order == null) {
|
| | | if (StringUtil.isNullOrEmpty(oldOrderList.get(0).getTradeId())) {
|
| | | taoBaoOrderMapper.deleteByOrderId(orderId);
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | } else {
|
| | | taoBaoOrder.setId(order.getId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getRelationId()))
|
| | | taoBaoOrder.setRelationId(order.getRelationId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getSpecialId()))
|
| | | taoBaoOrder.setSpecialId(order.getSpecialId());
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.updateByPrimaryKeySelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | }
|
| | | } else {
|
| | | // 按tradeId更新
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | TaoBaoOrder order = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(taoBaoOrder.getTradeId());
|
| | | if (order == null) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | } else {
|
| | | taoBaoOrder.setId(order.getId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getRelationId()))
|
| | | taoBaoOrder.setRelationId(order.getRelationId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getSpecialId()))
|
| | | taoBaoOrder.setSpecialId(order.getSpecialId());
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.updateByPrimaryKeySelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | // 提交事务
|
| | | transactionManager.commit(transactionStatus);
|
| | | } catch (Exception e) {
|
| | | transactionManager.rollback(transactionStatus);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.entity.DateInfo;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherCouponActivateDTO;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
|
| | | import com.yeshi.fanli.dto.user.coupon.UserSystemCouponUseMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | |
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.exception.user.UserSystemCouponException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.factory.msg.MsgOtherSystemGiveDTOFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private TokenRecordService tokenRecordService;
|
| | |
|
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | @Override
|
| | | public int insertSelective(UserSystemCoupon record) {
|
| | |
| | | if (systemCoupon == null)
|
| | | throw new UserSystemCouponException(1, "券已不存在");
|
| | | }
|
| | | |
| | |
|
| | | if (systemCoupon.getType() != CouponTypeEnum.rebatePercentCoupon)
|
| | | throw new UserSystemCouponException(1, "券类型不匹配");
|
| | |
|
| | |
| | | sourceType);
|
| | | if (orderVO == null)
|
| | | throw new UserSystemCouponException(1, "订单信息获取失败");
|
| | | |
| | |
|
| | | // 版本区分:2.0.2
|
| | | if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | Date thirdCreateTime = orderVO.getThirdCreateTime();
|
| | | if (thirdCreateTime != null) {
|
| | | long downOrderTime = thirdCreateTime.getTime();
|
| | | long limitDate = Long.parseLong("1573315200000"); // TODO 日期待确定2019-11-10
|
| | | long limitDate = Long.parseLong("1573315200000"); // TODO
|
| | | // 日期待确定2019-11-10
|
| | | if (downOrderTime > limitDate) {
|
| | | Date endDay = DateUtil.plusDayDate(4, thirdCreateTime);
|
| | | long currentTime = java.lang.System.currentTimeMillis();
|
| | |
| | | boolean valid = false;
|
| | | DateInfo dateInfo = DateUtil.dateDiff3(currentTime, endDay.getTime());
|
| | | if (dateInfo != null) {
|
| | | if (dateInfo.getDay() > 0) |
| | | if (dateInfo.getDay() > 0)
|
| | | valid = true;
|
| | |
|
| | | if (!valid && dateInfo.getHour() > 0)
|
| | | valid = true;
|
| | | |
| | |
|
| | | if (!valid && dateInfo.getMinute() > 0) |
| | | if (!valid && dateInfo.getMinute() > 0)
|
| | | valid = true;
|
| | | |
| | |
|
| | | if (!valid && dateInfo.getSecond() >= 0)
|
| | | valid = true;
|
| | | }
|
| | | |
| | | if (!valid) |
| | |
|
| | | if (!valid)
|
| | | throw new UserSystemCouponException(1, "该订单已不能使用使用奖励券,详情请咨询客服");
|
| | | }
|
| | | }
|
| | |
| | | // 提成金额
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(hongBao, percent);
|
| | |
|
| | | // 1、插入红包数据
|
| | | HongBaoV2 hongBaoV2 = new HongBaoV2();
|
| | | hongBaoV2.setMoney(money);
|
| | | hongBaoV2.setType(HongBaoV2.TYPE_COUPON);
|
| | | hongBaoV2.setState(HongBaoV2.STATE_YILINGQU);
|
| | | hongBaoV2.setVersion(2);
|
| | | hongBaoV2.setCreateTime(new Date());
|
| | | hongBaoV2.setUpdateTime(new Date());
|
| | | hongBaoV2.setUserInfo(new UserInfo(uid));
|
| | | hongBaoV2.setPreGetTime(new Date());
|
| | | hongBaoV2.setGetTime(new Date());
|
| | | UserSystemCouponUseMQMsgDTO mqMsg = new UserSystemCouponUseMQMsgDTO(userSystemCoupon.getId(),
|
| | | order.getOrderId(), sourceType);
|
| | | // 事务消息
|
| | | Message msg = new Message(MQTopicName.TOPIC_SYSTEM_COUPON_USE.name(),systemCoupon.getType().name(),
|
| | | new Gson().toJson(mqMsg).getBytes());
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | useRewardCouponCore(userSystemCoupon, money, hongBao, uid, order);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | } catch (UserMoneyDetailException e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | | }, null);
|
| | |
|
| | | hongBaoV2Service.insertSelective(hongBaoV2);
|
| | | }
|
| | | }
|
| | |
|
| | | // 2.插入关联
|
| | | orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
|
| | | @Transactional
|
| | | private void useRewardCouponCore(UserSystemCoupon userSystemCoupon, BigDecimal money, BigDecimal hongBao, Long uid,
|
| | | Order order) throws UserMoneyDetailException {
|
| | | // 1、插入红包数据
|
| | | HongBaoV2 hongBaoV2 = new HongBaoV2();
|
| | | hongBaoV2.setMoney(money);
|
| | | hongBaoV2.setType(HongBaoV2.TYPE_COUPON);
|
| | | hongBaoV2.setState(HongBaoV2.STATE_YILINGQU);
|
| | | hongBaoV2.setVersion(2);
|
| | | hongBaoV2.setCreateTime(new Date());
|
| | | hongBaoV2.setUpdateTime(new Date());
|
| | | hongBaoV2.setUserInfo(new UserInfo(uid));
|
| | | hongBaoV2.setPreGetTime(new Date());
|
| | | hongBaoV2.setGetTime(new Date());
|
| | |
|
| | | // 3.插入资金明细,用户余额
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo, sourceType, money,
|
| | | new UserInfo(uid));
|
| | | userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
|
| | | userInfoService.addMoney(new UserInfo(uid), money);
|
| | | hongBaoV2Service.insertSelective(hongBaoV2);
|
| | |
|
| | | // 插入资金通知
|
| | | userMoneyMsgNotificationService.orderReward(uid, orderNo, sourceType, money,
|
| | | userInfoService.selectByPKey(uid).getMyHongBao());
|
| | | // 2.插入关联
|
| | | orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
|
| | |
|
| | | /* 用户券信息状态及记录处理 */
|
| | | // 3.插入资金明细,用户余额
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(order.getOrderId(),
|
| | | order.getOrderType(), money, new UserInfo(uid));
|
| | | userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
|
| | | userInfoService.addMoney(new UserInfo(uid), money);
|
| | |
|
| | | Date date = new Date();
|
| | | // 更新券状态:已使用
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_END_USE);
|
| | | userSystemCoupon.setUseTime(date);
|
| | | userSystemCoupon.setUpdateTime(date);
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
|
| | | // 插入资金通知
|
| | | userMoneyMsgNotificationService.orderReward(uid, order.getOrderId(), order.getOrderType(), money,
|
| | | userInfoService.selectByPKey(uid).getMyHongBao());
|
| | |
|
| | | // 插入使用券记录
|
| | | UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
|
| | | couponRecord.setGoodSource(sourceType);
|
| | | couponRecord.setOrderNo(orderNo);
|
| | | couponRecord.setUserSystemCoupon(userSystemCoupon);
|
| | | couponRecord.setCouponType(systemCoupon.getType().name());
|
| | | couponRecord.setCreateTime(date);
|
| | | couponRecord.setUpdateTime(date);
|
| | | userSystemCouponRecordService.insertSelective(couponRecord);
|
| | | /* 用户券信息状态及记录处理 */
|
| | |
|
| | | // 消息推送
|
| | | try {
|
| | | userOtherMsgNotificationService.rewardCouponUsed(userSystemCoupon, hongBao, money, orderNo);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | Date date = new Date();
|
| | | // 更新券状态:已使用
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_END_USE);
|
| | | userSystemCoupon.setUseTime(date);
|
| | | userSystemCoupon.setUpdateTime(date);
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
|
| | |
|
| | | // 插入使用券记录
|
| | | UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
|
| | | couponRecord.setGoodSource(order.getOrderType());
|
| | | couponRecord.setOrderNo(order.getOrderId());
|
| | | couponRecord.setUserSystemCoupon(userSystemCoupon);
|
| | | couponRecord.setCouponType(userSystemCoupon.getSystemCoupon().getType().name());
|
| | | couponRecord.setCreateTime(date);
|
| | | couponRecord.setUpdateTime(date);
|
| | | userSystemCouponRecordService.insertSelective(couponRecord);
|
| | |
|
| | | // 消息推送
|
| | | try {
|
| | | userOtherMsgNotificationService.rewardCouponUsed(userSystemCoupon, hongBao, money, order.getOrderId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void systemGiveRewardCoupon(Long uid, int num, String orderId, Integer orderType, String reason)
|
| | | throws Exception {
|
| | | // 添加奖励券
|
| | | insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), "系统赠送",
|
| | | new BigDecimal(configService.get("exchange_rebate_percent")),false);
|
| | | new BigDecimal(configService.get("exchange_rebate_percent")), false);
|
| | | // 添加奖励券消息
|
| | | userOtherMsgNotificationService.systemGiveRewardCoupon(uid, null, MsgOtherSystemGiveDTOFactory
|
| | | .createRewardCouponGive(num, "请按照返利奖励券规则使用", "返利奖励券", orderId, orderType, reason));
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.hongbao;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | |
|
| | | public interface HongBaoV2SettleTempService {
|
| | |
|
| | | /**
|
| | | * 添加
|
| | | * @param hongBaoList
|
| | | * @param taskKey
|
| | | * @throws Exception
|
| | | */
|
| | | public void addTemp(List<Long> hongBaoIdList, String taskKey);
|
| | | |
| | | |
| | | /**
|
| | | * 根据key检索
|
| | | * @param key
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoV2SettleTemp> listByKey(String key);
|
| | | |
| | | |
| | | public long countByKey(String key);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | |
|
| | | public interface InviteOrderSubsidyDebtService {
|
| | |
|
| | | /**
|
| | | * 添加债务
|
| | | * |
| | | * @param debt
|
| | | * @throws InviteOrderSubsidyDebtException
|
| | | */
|
| | | public void addDebt(InviteOrderSubsidyDebt debt) throws InviteOrderSubsidyDebtException;
|
| | |
|
| | | /**
|
| | | * 偿还债务
|
| | | * |
| | | * @param debtId
|
| | | * @param money
|
| | | */
|
| | | public void repayDebt(Long debtId, BigDecimal money) throws InviteOrderSubsidyDebtException;
|
| | |
|
| | | /**
|
| | | * 还款
|
| | | * |
| | | * @param uid
|
| | | * @param money
|
| | | * @return 还剩下的资金
|
| | | * @throws InviteOrderSubsidyDebtException
|
| | | */
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws InviteOrderSubsidyDebtException;
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | | * |
| | | * @param uid
|
| | | * @param page
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid, int page, int count);
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countNeedRepayDebt(Long uid);
|
| | |
|
| | | /**
|
| | | * 获取总共欠钱金额
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getTotalDebtMoney(Long uid);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.mq;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | |
|
| | | /**
|
| | | * 消息队列消息未发送成功服务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface MQUnSendInfoService {
|
| | |
|
| | | public void addMQUnSendInfo(MQUnSendInfo info) throws MQUnSendInfoException;
|
| | |
|
| | | /**
|
| | | * 根据最大发送时间检索
|
| | | * |
| | | * @param maxSendTime
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | | public List<MQUnSendInfo> listByMaxSendTime(Date maxSendTime, int page, int pageSize);
|
| | |
|
| | | public void deleteByPrimaryKey(Long id);
|
| | |
|
| | | /**
|
| | | * 更新发送时间
|
| | | * |
| | | * @param id
|
| | | * @param sendTime
|
| | | */
|
| | | public void updateSendTime(Long id, Date sendTime);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | |
|
| | | public interface HongBaoOrderService {
|
| | |
| | | * @return
|
| | | */
|
| | | public long countByOrderNoAndHongBaoType(String orderNo, int hongBaotype, int sourceType);
|
| | | |
| | |
|
| | | /**
|
| | | * 获取详情
|
| | | * |
| | | * @param commonOrderId
|
| | | * @return
|
| | | */
|
| | | public HongBaoOrder selectDetailByCommonOrderId(Long commonOrderId);
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 获取详情
|
| | | * |
| | | * @param hongBaoId
|
| | | * @return
|
| | | */
|
| | | public HongBaoOrder selectDetailByHongBaoId(Long hongBaoId);
|
| | |
|
| | | /**
|
| | | * 根据订单号和来源类型查询
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoOrder> listByOrderIdAndSourceType(@Param("orderId") String orderId,
|
| | | @Param("sourceType") int sourceType);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | /**
|
| | | * 添加红包
|
| | | * @param commonOrder 订单对象
|
| | | * @param type 类型
|
| | | * @return 0-未添加也未更新 1-只添加 2-只更新 12-有添加也有更新
|
| | | * |
| | | * @param commonOrder
|
| | | * 订单对象
|
| | | * @param type
|
| | | * 类型
|
| | | * @return 0-未添加也未更新 1-只添加 2-只更新 12-有添加也有更新
|
| | | * @throws HongBaoException
|
| | | */
|
| | | public int addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException;
|
| | |
| | | public List<HongBaoV2> listChildrenById(Long id);
|
| | |
|
| | | /**
|
| | | * 查询子红包
|
| | | * |
| | | * @param idList
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoV2> listChildrenByIds(List<Long> idList);
|
| | |
|
| | | /**
|
| | | * 最近30天内产生过分享订单的用户
|
| | | *
|
| | | * @return
|
| | |
| | | */
|
| | | public HongBaoV2 getFirstValidHongBaoByTypeAndUid(List<Integer> typeList, Long uid);
|
| | |
|
| | | /**
|
| | | * 根据ID批量查询
|
| | | * |
| | | * @param idList
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoV2> listByIds(List<Long> idList);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | |
|
| | |
| | | public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type);
|
| | |
|
| | | /**
|
| | | * 查询补贴(加锁)
|
| | | * @param uid
|
| | | * @param orderNo
|
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | public InviteOrderSubsidy getByOrderNoAndTypeForUpdate(Long uid, String orderNo, Integer type);
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 添加订单补贴
|
| | | *
|
| | | * @param orderSubsidy
|
| | |
| | | */
|
| | | public void addOrderSubsidy(InviteOrderSubsidy orderSubsidy) throws InviteOrderSubsidyException;
|
| | |
|
| | | /**
|
| | | * 添加或修改(按照订单号与来源)
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType) throws InviteOrderSubsidyException;
|
| | |
|
| | | /**
|
| | | * 根据订单号与来源查询
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @return
|
| | | */
|
| | | public long countByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | /**
|
| | | * 使订单号对应的数据失效
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void invalidByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | |
| | | /**
|
| | | * 使订单号对应的数据有效
|
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void validByOrderIdAndSourceType(String orderId, int sourceType);
|
| | | |
| | | |
| | | /**
|
| | | * 结算金额
|
| | | * @param id
|
| | | * @param money
|
| | | */
|
| | | public void settleById(Long id,BigDecimal money);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.order.OrderHongBaoMap;
|
| | |
|
| | | /**
|
| | | * 订单红包对应表用于活动)
|
| | |
| | |
|
| | | /**
|
| | | * 查找奖励金额
|
| | | * |
| | | * @param orderNo
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getCouponHongbaoByOrderNo(String orderNo, Long uid);
|
| | |
|
| | | /**
|
| | | * 根据订单ID与sourceType查询
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @return
|
| | | */
|
| | | public OrderHongBaoMap selectByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 订单资金结算服务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface OrderMoneySettleService {
|
| | |
|
| | | /**
|
| | | * 邀请赚结算
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void inviteSettleTB(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void inviteSettleJD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void inviteSettlePDD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 分享赚结算
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void shareSettleTB(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void shareSettleJD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void shareSettlePDD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 自购结算
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void ziGouSettle(String orderId, int sourceType,String taskKey) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 邀请补贴结算
|
| | | * @param uid
|
| | | * @param taskKey
|
| | | * @throws OrderMoneySettleException
|
| | | */
|
| | | public void inviteSubsidySettle(Long uid, String taskKey) throws OrderMoneySettleException;
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | public BigDecimal getTLJShareRate(long time);
|
| | |
|
| | | /**
|
| | | * 获取邀请一级补贴比例
|
| | | * |
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getInviteFirstLevelSubsidyRate(Long time);
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取邀请二级补贴比例
|
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getInviteSecondLevelSubsidyRate(Long time);
|
| | |
|
| | | }
|
| | |
| | | HongBaoV2 hongBaoV2 = hongBaoV2Service.selectByPrimaryKey(hongBaoId);
|
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
|
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | // 到账送金币
|
| | | fanliGetIntegral(hongBaoV2);
|
| | | HongBaoRecieveCMQManager.getInstance()
|
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
|
| | | |
| | | //返利不足0.01元送金币
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购
|
| | | // 判断是否为该用户的首笔红包
|
| | | List<Integer> typeList = new ArrayList<>();
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | HongBaoRecieveCMQManager.getInstance()
|
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
|
| | |
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | private void fanliGetIntegral(HongBaoV2 hongBaoV2) {
|
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
|
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购订单
|
| | | integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享订单
|
| | | integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请
|
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请
|
| | | integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) {
|
| | | CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
|
| | | if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId)
|
| | |
| | | return detail;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请奖金到账
|
| | | * |
| | | * @param uid
|
| | | * @param validCount
|
| | | * @param weiQuanCount
|
| | | * @param invalidCount
|
| | | * @param money
|
| | | * @param time
|
| | | * @return
|
| | | * @throws UserMoneyDetailException
|
| | | */
|
| | | public static UserMoneyDetail createInviteSubsidy(Long uid, int orderType, BigDecimal money, Date time)
|
| | | throws UserMoneyDetailException {
|
| | | if (money == null)
|
| | | throw new UserMoneyDetailException(1, "返利金额为空");
|
| | |
|
| | | if (uid == null)
|
| | | throw new UserMoneyDetailException(1, "UID为空");
|
| | |
|
| | | if (time == null)
|
| | | throw new UserMoneyDetailException(1, "发生时间为空");
|
| | |
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(time);
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy.M");
|
| | |
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setIdentifyCode(
|
| | | StringUtil.Md5(UserMoneyDetailTypeEnum.subsidy.name() + "-" + orderType + "-" + uid + "-" + timeF));
|
| | | detail.setMoney(money);
|
| | | detail.setTitle(timeF + UserMoneyDetailTypeEnum.subsidy.getDesc()+"["+Constant.getSourceName(orderType)+"]");
|
| | | detail.setType(UserMoneyDetailTypeEnum.subsidy);
|
| | | detail.setDescInfo("邀请订单补贴");
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(uid));
|
| | | detail.setOrderType(orderType);
|
| | | return detail;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq;
|
| | |
|
| | | public class MQTagConstant {
|
| | | public final static String TAG_ORDER_STATISTIC_PREFIX = "orderhongbao-";// 订单统计
|
| | | public final static String TAG_ORDER_FANLI_PREFIX = "orderhongbaofanli-";// 订单到账
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq;
|
| | |
|
| | | public enum MQTopicName {
|
| | | TOPIC_ORDER("订单"), TOPIC_FANLI("返利到账"), TOPIC_SYSTEM_COUPON_USE("券使用");
|
| | | private final String desc;
|
| | |
|
| | | private MQTopicName(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.SendResult;
|
| | | import com.aliyun.openservices.ons.api.bean.TransactionProducerBean;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | |
|
| | | public class MyTransactionProducer extends TransactionProducerBean {
|
| | |
|
| | | public SendResult sendMsg(Message message, LocalTransactionExecuter executer, Object arg) {
|
| | | return super.send(message, executer, arg);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.order;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Action;
|
| | | import com.aliyun.openservices.ons.api.ConsumeContext;
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.MessageListener;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.aliyun.openservices.ons.api.SendResult;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.order.OrderMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.user.coupon.UserSystemCouponUseMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | | * 邀请订单补贴消息消费
|
| | |
| | | */
|
| | | @Component
|
| | | public class InviteOrderSubsidyMessageListener implements MessageListener {
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponRecordService userSystemCouponRecordService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private MQUnSendInfoService mqUnSendInfoService;
|
| | |
|
| | | @Resource
|
| | | private OrderMoneySettleService orderMoneySettleService;
|
| | |
|
| | | public InviteOrderSubsidyMessageListener() {
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | | if (message.getTag().startsWith("")) {
|
| | |
|
| | | if (!Constant.IS_TASK) {// 非任务服务器不能消费消息
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | |
|
| | | if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | // 查询上级红包
|
| | | OrderMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()), OrderMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(dto.getOrderId(), dto.getType());
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | | } else if (MQTopicName.TOPIC_FANLI.name().equalsIgnoreCase(message.getTopic())) {
|
| | | if (message.getTag().equalsIgnoreCase("actual")) {
|
| | | OrderMoneyRecievedMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU) {// 自购到账
|
| | | // 判断订单号是否在补贴中
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {// 延时消息发送
|
| | | sendOrderSubsidyUpdateLater(dto, 5);
|
| | | }
|
| | | } else if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_INVITE) {// 邀请到账
|
| | | // 补贴到账
|
| | | try {
|
| | | orderMoneySettleService.inviteSubsidySettle(dto.getUid(), message.getKey());
|
| | | return Action.CommitMessage;
|
| | | } catch (OrderMoneySettleException e) {
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | | }
|
| | | } else if (message.getTag().equalsIgnoreCase("delay")) {
|
| | | OrderMoneyRecievedMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU) {// 延时时间已到
|
| | | // 判断订单号是否在补贴中
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {
|
| | | // 判断是否要使用奖励券
|
| | | UserSystemCouponRecord record = userSystemCouponRecordService
|
| | | .getRecordByOrderNo(dto.getOrderId(), UserSystemCouponRecord.STATE_SUCCESS);
|
| | | if (record != null
|
| | | && record.getCouponType()
|
| | | .equalsIgnoreCase(SystemCoupon.CouponTypeEnum.rebatePercentCoupon.name())
|
| | | && record.getGoodSource() == dto.getSourceType()) {// 成功使用了奖励券
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else {
|
| | | // 使数据有效
|
| | | inviteOrderSubsidyService.validByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | } else if (MQTopicName.TOPIC_SYSTEM_COUPON_USE.name().equalsIgnoreCase(message.getTopic())) {// 奖励券使用成功
|
| | | UserSystemCouponUseMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()),
|
| | | UserSystemCouponUseMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {
|
| | | // 使相关订单失效
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(), dto.getSourceType());
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 发送订单延时消息
|
| | | * |
| | | * @param day
|
| | | */
|
| | | private boolean sendOrderSubsidyUpdateLater(OrderMoneyRecievedMQMsgDTO dto, int day) {
|
| | |
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "delay", new Gson().toJson(dto).getBytes());
|
| | | msg.setKey(dto.getSourceType() + "_" + dto.getOrderId());
|
| | | long delayTime = System.currentTimeMillis() + 1000 * 60 * 60 * 24L * day;
|
| | | msg.setStartDeliverTime(delayTime);
|
| | | SendResult sendResult = producer.send(msg);
|
| | | if (sendResult != null) {
|
| | | return true;
|
| | | } else {
|
| | | MQUnSendInfo info = new MQUnSendInfo();
|
| | | info.setBody(new String(msg.getBody()));
|
| | | if (msg.getStartDeliverTime() > 0)
|
| | | info.setDeliverTime(new Date(msg.getStartDeliverTime()));
|
| | | info.setKey(msg.getKey());
|
| | | info.setTag(msg.getTag());
|
| | | info.setTopic(msg.getTopic());
|
| | | try {
|
| | | mqUnSendInfoService.addMQUnSendInfo(info);
|
| | | } catch (MQUnSendInfoException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.order;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Component
|
| | | public class MQLocalTransactionChecker implements LocalTransactionChecker {
|
| | |
|
| | | @Resource
|
| | | private MQLocalUserCouponUsedTransactionChecker mqLocalUserCouponUsedTransactionChecker;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | public MQLocalTransactionChecker() {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TransactionStatus check(Message msg) {
|
| | |
|
| | | if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_ORDER.name())) {
|
| | | if (msg.getTag().startsWith(MQTagConstant.TAG_ORDER_STATISTIC_PREFIX)) {// 订单加入红包标识
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | } else if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_FANLI.name())) {
|
| | | if (msg.getTag().equalsIgnoreCase("actual")) {// 查询key值是否在
|
| | | if (hongBaoV2SettleTempService.countByKey(msg.getKey()) > 0)
|
| | | return TransactionStatus.CommitTransaction;
|
| | | else
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | } else if (msg.getTag().equalsIgnoreCase("delay")) {
|
| | | OrderMoneyRecievedMQMsgDTO dto = new Gson().fromJson(new String(msg.getBody()),
|
| | | OrderMoneyRecievedMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU) {
|
| | | // TODO 尚未处理一个订单部分到账的状况
|
| | | // 返利是否到账
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(dto.getSourceType(),
|
| | | dto.getOrderId());
|
| | | for (CommonOrder order : orderList) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService.selectDetailByCommonOrderId(order.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
|
| | | && hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | |
|
| | | // 其他未知条件暂时处理为回滚
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | } else if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_SYSTEM_COUPON_USE.name())) {
|
| | | return mqLocalUserCouponUsedTransactionChecker.check(msg);
|
| | | }
|
| | |
|
| | | return TransactionStatus.Unknow;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.order;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.user.coupon.UserSystemCouponUseMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | | * 券使用事务检查
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class MQLocalUserCouponUsedTransactionChecker {
|
| | | @Resource
|
| | | private UserSystemCouponRecordService userSystemCouponRecordService;
|
| | |
|
| | | public MQLocalUserCouponUsedTransactionChecker() {
|
| | |
|
| | | }
|
| | |
|
| | | public TransactionStatus check(Message msg) {
|
| | | if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_SYSTEM_COUPON_USE.name())) {
|
| | | if (msg.getTag().equalsIgnoreCase(SystemCoupon.CouponTypeEnum.rebatePercentCoupon.name())) {// 返利奖励券
|
| | | // 查询是否使用成功
|
| | | UserSystemCouponUseMQMsgDTO dto = new Gson().fromJson(new String(msg.getBody()),
|
| | | UserSystemCouponUseMQMsgDTO.class);
|
| | | UserSystemCouponRecord record = userSystemCouponRecordService
|
| | | .getNearByUserCouponId(dto.getUserSystemCouponId());
|
| | | if (record != null) {
|
| | | if (record.getOrderNo().equalsIgnoreCase(dto.getOrderId())
|
| | | && dto.getSourceType().intValue() == record.getGoodSource()) {
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | | return TransactionStatus.Unknow;
|
| | | }
|
| | | }
|
| | |
| | | log4j.appender.jobLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
|
| | |
|
| | |
|
| | | log4j.logger.mqLog=ALL,mqLog
|
| | | log4j.appender.mqLog=org.apache.log4j.DailyRollingFileAppender
|
| | | log4j.appender.mqLog.File=logs/mq/mqLog.log
|
| | | log4j.appender.mqLog.MaxFileSize=20MB
|
| | | log4j.appender.mqLog.MaxBackupIndex=100
|
| | | log4j.appender.mqLog.layout=org.apache.log4j.PatternLayout
|
| | | log4j.appender.mqLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
|
| | |
|
| | |
|
| | |
|
| | | log4j.appender.mongodb=org.apache.log4j.ConsoleAppender
|
| | | log4j.appender.mongodb.Target=System.out
|
| | | log4j.appender.mongodb.Threshold=DEBUG
|
| | |
| | | <beans xmlns="http://www.springframework.org/schema/beans"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
| | | <bean id="msgListener" class="com.yeshi.fanli.util.rocketmq.consumer.order.InviteOrderSubsidyMessageListener"></bean> <!--Listener 配置 -->
|
| | | <bean id="inviteOrderSubsidyMsgListener" class="com.yeshi.fanli.util.rocketmq.consumer.order.InviteOrderSubsidyMessageListener"></bean> <!--Listener 配置 -->
|
| | | <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean -->
|
| | | <bean id="orderTransactionConsumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | |
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <entry value-ref="msgListener">
|
| | | <!-- 订单补贴订阅 -->
|
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value=TOPIC_ORDER />
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression" value="*" /><!--expression 即
|
| | | Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 -->
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | |
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_FANLI" />
|
| | | <property name="expression" value="*" /><!--expression 即 |
| | | Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 -->
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | |
| | | |
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_SYSTEM_COUPON_USE" />
|
| | | <property name="expression" value="rebatePercentCoupon" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | |
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
| | | <!-- 事务消息生产 -->
|
| | | <bean id="localOrderTransactionChecker" class="com.yeshi.fanli.util.rocketmq.order.RocketMQLocalOrderTransactionChecker"></bean>
|
| | | <bean id="localTransactionChecker" class="com.yeshi.fanli.util.rocketmq.order.MQLocalTransactionChecker"></bean>
|
| | | <bean id="orderTransactionProducer"
|
| | | class="com.aliyun.openservices.ons.api.bean.TransactionProducerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | |
| | | </prop>
|
| | | </props>
|
| | | </property>
|
| | | <property name="localTransactionChecker" ref="localOrderTransactionChecker"></property>
|
| | | <property name="localTransactionChecker" ref="localTransactionChecker"></property>
|
| | | </bean>
|
| | | |
| | | |
| | | |
| | | </beans> |