admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
@@ -42,12 +42,47 @@
      detail.setIdentifyCode(StringUtil
            .Md5(UserMoneyDetailTypeEnum.fanli.name() + "-" + uid + "-" + orderType + "-" + orderId + "-" + hbIds));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.fanli.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.fanli);
      detail.setDescInfo("订单号:" + orderId);
      detail.setTitle(UserMoneyDetailTypeEnum.fanliNew.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.fanliNew);
      detail.setDescInfo(Constant.getSourceName(orderType) + ":" + orderId);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      detail.setOrderType(orderType);
      return detail;
   }
   /**
    * 饿了么返利
    *
    * @param uid
    * @param orderId
    * @param hbId
    * @param money
    * @return
    * @throws UserMoneyDetailException
    */
   public static UserMoneyDetail createElmeFanLi(Long uid, String orderId, Long hbId, BigDecimal money)
         throws UserMoneyDetailException {
      if (StringUtil.isNullOrEmpty(orderId))
         throw new UserMoneyDetailException(1, "订单号为空");
      if (money == null)
         throw new UserMoneyDetailException(1, "返利金额为空");
      if (uid == null)
         throw new UserMoneyDetailException(1, "UID为空");
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.elmeFanli.name() + "-" + hbId));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.elmeFanli.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.elmeFanli);
      detail.setDescInfo("订单号:" + orderId);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      detail.setOrderType(Constant.SOURCE_TYPE_ELME);
      return detail;
   }
@@ -63,7 +98,8 @@
    * @return
    * @throws UserMoneyDetailException
    */
   public static UserMoneyDetail createShare(Long uid, int orderType, int validCount, int weiQuanCount, BigDecimal money, Date time) throws UserMoneyDetailException {
   public static UserMoneyDetail createShare(Long uid, int orderType, BigDecimal money, Date time)
         throws UserMoneyDetailException {
      if (money == null)
         throw new UserMoneyDetailException(1, "返利金额为空");
@@ -77,15 +113,16 @@
      ca.setTime(time);
      ca.add(Calendar.MONTH, -1);
      String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy.M");
      String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy年M月");
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.share.name() + "-" + uid + "-" + timeF));
      detail.setIdentifyCode(
            StringUtil.Md5(UserMoneyDetailTypeEnum.share.name() + "-" + orderType + "-" + uid + "-" + timeF));
      detail.setMoney(money);
      detail.setTitle(timeF + UserMoneyDetailTypeEnum.share.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.share);
      detail.setDescInfo(String.format("有效订单:%s笔  维权订单:%s笔", validCount, weiQuanCount));
      detail.setTitle(UserMoneyDetailTypeEnum.shareNew.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.shareNew);
      detail.setDescInfo(Constant.getSourceName(orderType) + ":" + timeF);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      detail.setOrderType(orderType);
@@ -104,7 +141,8 @@
    * @return
    * @throws UserMoneyDetailException
    */
   public static UserMoneyDetail createInvite(Long uid, int orderType, int validCount, int weiQuanCount, BigDecimal money, Date time) throws UserMoneyDetailException {
   public static UserMoneyDetail createInvite(Long uid, int orderType, int validCount, int weiQuanCount,
         BigDecimal money, Date time) throws UserMoneyDetailException {
      if (money == null)
         throw new UserMoneyDetailException(1, "返利金额为空");
@@ -122,7 +160,8 @@
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.invite.name() + "-" + uid + "-" + timeF));
      detail.setIdentifyCode(
            StringUtil.Md5(UserMoneyDetailTypeEnum.invite.name() + "-" + orderType + "-" + uid + "-" + timeF));
      detail.setMoney(money);
      detail.setTitle(timeF + UserMoneyDetailTypeEnum.invite.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.invite);
@@ -163,11 +202,11 @@
      detail.setIdentifyCode(StringUtil
            .Md5(UserMoneyDetailTypeEnum.fanliWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
      detail.setMoney(new BigDecimal("0").subtract(money));
      detail.setTitle(UserMoneyDetailTypeEnum.fanliWeiQuan.getDesc());
      detail.setSubTitle("订单维权");
      detail.setType(UserMoneyDetailTypeEnum.fanliWeiQuan);
      detail.setTitle(UserMoneyDetailTypeEnum.fanliWeiQuanNew.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.fanliWeiQuanNew);
      detail.setSourceIdentifyId(drawBack.getId());
      detail.setDescInfo("订单号:" + drawBack.getOrderId());
      detail.setDescInfo(
            Constant.getSourceName(Constant.SOURCE_TYPE_TAOBAO) + ":" + drawBack.getOrderId() + "-部分商品售后");
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
@@ -204,10 +243,10 @@
            .Md5(UserMoneyDetailTypeEnum.shareWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
      detail.setMoney(new BigDecimal("0").subtract(money));
      detail.setTitle(UserMoneyDetailTypeEnum.shareWeiQuan.getDesc());
      detail.setSubTitle("订单维权");
      detail.setSubTitle("订单售后");
      detail.setType(UserMoneyDetailTypeEnum.shareWeiQuan);
      detail.setSourceIdentifyId(drawBack.getId());
      detail.setDescInfo("订单号:" + UserUtil.filterOrderId(drawBack.getOrderId()));
      detail.setDescInfo("订单号:" + drawBack.getOrderId());
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
@@ -244,7 +283,7 @@
            .Md5(UserMoneyDetailTypeEnum.inviteWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
      detail.setMoney(new BigDecimal("0").subtract(money));
      detail.setTitle(UserMoneyDetailTypeEnum.inviteWeiQuan.getDesc());
      detail.setSubTitle("订单维权");
      detail.setSubTitle("订单售后");
      detail.setType(UserMoneyDetailTypeEnum.inviteWeiQuan);
      detail.setSourceIdentifyId(drawBack.getId());
      detail.setDescInfo("订单号:" + UserUtil.filterOrderId(drawBack.getOrderId()));
@@ -260,7 +299,7 @@
    * @param extract
    * @return
    */
   public static UserMoneyDetail createExtract(Extract extract) throws UserMoneyDetailException {
   public static UserMoneyDetail createExtract(Extract extract, String alipayNo) throws UserMoneyDetailException {
      if (extract == null)
         throw new UserMoneyDetailException(1, "提现记录不能为空");
      if (extract.getId() == null)
@@ -270,15 +309,20 @@
      if (extract.getUserInfo() == null || extract.getUserInfo().getId() == null)
         throw new UserMoneyDetailException(1, "提现用户不能为空");
      if (alipayNo != null && alipayNo.length() > 10)
         alipayNo = "*" + alipayNo.substring(alipayNo.length() - 10, alipayNo.length());
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extract.name() + ":" + extract.getId()));
      detail.setMoney(new BigDecimal("0").subtract(extract.getMoney()));
      detail.setSourceIdentifyId(extract.getId());
      detail.setTitle(UserMoneyDetailTypeEnum.extract.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.extract);
      detail.setTitle(UserMoneyDetailTypeEnum.extractNew.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.extractNew);
      detail.setUpdateTime(new Date());
      detail.setDescInfo("支付宝订单号:" + alipayNo);
      detail.setUserInfo(extract.getUserInfo());
      detail.setShow(false);
      return detail;
   }
@@ -304,10 +348,44 @@
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractVerify.name() + ":" + aa.getId()));
      detail.setMoney(new BigDecimal("0").subtract(money));
      detail.setSourceIdentifyId(aa.getId());
      detail.setTitle(UserMoneyDetailTypeEnum.extractVerify.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.extractVerify);
      detail.setTitle(UserMoneyDetailTypeEnum.extractVerifyNew.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.extractVerifyNew);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(aa.getUid()));
      detail.setDescInfo(String.format("支付宝:%s -姓名-%s", UserUtil.filterAlipayAccount(aa.getAccount()),
            UserUtil.filterAlipayName(aa.getName())));
      return detail;
   }
   /**
    * 系统扣除
    * @Title: createSystemTakeOff
    * @Description:
    * @param uid
    * @param money
    * @param desc
    * @return
    * @throws UserMoneyDetailException
    * UserMoneyDetail 返回类型
    * @throws
    */
   public static UserMoneyDetail createSystemTakeOff(Long uid, BigDecimal money, String desc)
         throws UserMoneyDetailException {
      if (uid == null)
         throw new UserMoneyDetailException(1, "UID不能为空");
      if (money == null)
         throw new UserMoneyDetailException(1, "金额不能为空");
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(
            StringUtil.Md5(uid + "-" + UserMoneyDetailTypeEnum.systemTakeOff.name() + System.currentTimeMillis()));
      detail.setMoney(new BigDecimal("0").subtract(money));
      detail.setTitle(UserMoneyDetailTypeEnum.systemTakeOff.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.systemTakeOff);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      detail.setDescInfo(desc);
      return detail;
   }
@@ -338,6 +416,7 @@
      detail.setType(UserMoneyDetailTypeEnum.extractReject);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(extract.getUserInfo());
      detail.setShow(false);// 隐藏提现失败记录
      return detail;
   }
@@ -421,8 +500,8 @@
    * @return
    * @throws UserMoneyDetailException
    */
   public static UserMoneyDetail createOrderReward(String orderId, int orderType, BigDecimal money, UserInfo user)
         throws UserMoneyDetailException {
   public static UserMoneyDetail createOrderReward(String orderId, int orderType, BigDecimal money,
         BigDecimal originalMoney, UserInfo user) throws UserMoneyDetailException {
      if (StringUtil.isNullOrEmpty(orderId))
         throw new UserMoneyDetailException(1, "订单号不能为空");
      if (user == null)
@@ -434,12 +513,12 @@
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.hongbao.name() + "-" + "老版本" + "-" + orderId));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.orderReward.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.orderReward);
      detail.setTitle(UserMoneyDetailTypeEnum.orderRewardNew.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.orderRewardNew);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(user);
      detail.setOrderType(orderType);
      // detail.setDescInfo("订单号:" + orderId);
      detail.setDescInfo(Constant.getSourceName(orderType) + ":" + orderId + "-原返利:" + originalMoney);
      return detail;
   }
@@ -487,8 +566,8 @@
      detail.setIdentifyCode(StringUtil.Md5(
            UserMoneyDetailTypeEnum.systemEqualize.name() + "-" + System.currentTimeMillis() + "-" + user.getId()));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.systemEqualize.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.systemEqualize);
      detail.setTitle(UserMoneyDetailTypeEnum.systemEqualizeNew.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.systemEqualizeNew);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(user);
      if (!StringUtil.isNullOrEmpty(desc)) {
@@ -516,4 +595,132 @@
      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;
   }
   /**
    * 团队收益
    * @Title: createTeamReward
    * @Description:
    * @param uid
    * @param money
    * @param time
    * @return
    * @throws UserMoneyDetailException
    * UserMoneyDetail 返回类型
    * @throws
    */
   public static UserMoneyDetail createTeamReward(Long uid, 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.teamReward.name() + "-" + uid + "-" + timeF));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.teamReward.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.teamReward);
      detail.setDescInfo(timeF);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      return detail;
   }
   /**
    * 团队分红
    * @Title: createTeamDividents
    * @Description:
    * @param uid
    * @param money
    * @param time
    * @return
    * @throws UserMoneyDetailException
    * UserMoneyDetail 返回类型
    * @throws
    */
   public static UserMoneyDetail createTeamDividents(Long uid, 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.teamDividents.name() + "-" + uid + "-" + timeF));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.teamDividents.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.teamDividents);
      detail.setDescInfo(timeF);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      return detail;
   }
}