admin
2019-07-11 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
@@ -4,9 +4,9 @@
import java.util.Calendar;
import java.util.Date;
import com.yeshi.fanli.dto.HongBao;
import com.yeshi.fanli.entity.bus.user.AlipayAccountValidNormalHistory;
import com.yeshi.fanli.entity.bus.user.Extract;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
@@ -23,10 +23,12 @@
    * @param hongBaoList
    * @return
    */
   public static UserMoneyDetail createFanLi(Long uid, String orderId, BigDecimal money)
   public static UserMoneyDetail createFanLi(Long uid, String orderId, int orderType, String hbIds, BigDecimal money)
         throws UserMoneyDetailException {
      if (StringUtil.isNullOrEmpty(orderId))
         throw new UserMoneyDetailException(1, "订单号为空");
      if (money == null)
         throw new UserMoneyDetailException(1, "返利金额为空");
@@ -35,7 +37,8 @@
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.fanli.name() + ":" + orderId));
      detail.setIdentifyCode(StringUtil
            .Md5(UserMoneyDetailTypeEnum.fanli.name() + "-" + uid + "-" + orderType + "-" + orderId + "-" + hbIds));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.fanli.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.fanli);
@@ -121,7 +124,8 @@
      detail.setMoney(money);
      detail.setTitle(timeF + UserMoneyDetailTypeEnum.invite.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.invite);
      detail.setDescInfo(String.format("有效订单:%s笔   维权订单:%s笔   失效订单:%s笔", validCount, weiQuanCount, invalidCount));
      if (validCount != 0 || weiQuanCount != 0 || invalidCount != 0)
         detail.setDescInfo(String.format("有效订单:%s笔   维权订单:%s笔   失效订单:%s笔", validCount, weiQuanCount, invalidCount));
      detail.setUpdateTime(new Date());
      detail.setUserInfo(new UserInfo(uid));
      return detail;
@@ -323,6 +327,7 @@
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractReject.name() + ":" + extract.getId()));
      detail.setMoney(extract.getMoney());
      detail.setSourceIdentifyId(extract.getId());
      detail.setSubTitle("原路退回");
      detail.setTitle(UserMoneyDetailTypeEnum.extractReject.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.extractReject);
      detail.setUpdateTime(new Date());
@@ -346,12 +351,33 @@
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.hongbao.name() + ":" + hb.getId()));
      detail.setIdentifyCode(
            StringUtil.Md5(UserMoneyDetailTypeEnum.hongbao.name() + "-" + subTitle + "-" + hb.getId()));
      detail.setMoney(hb.getMoney());
      detail.setSourceIdentifyId(hb.getId());
      detail.setTitle(UserMoneyDetailTypeEnum.hongbao.getDesc());
      detail.setSubTitle(subTitle);
      detail.setType(UserMoneyDetailTypeEnum.hongbao);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(hb.getUserInfo());
      return detail;
   }
   private static UserMoneyDetail createHongBaoDeduct(HongBao hb, String subTitle) throws UserMoneyDetailException {
      if (hb == null)
         throw new UserMoneyDetailException(1, "红包不能为空");
      if (hb.getUserInfo() == null)
         throw new UserMoneyDetailException(1, "用户不能为空");
      UserMoneyDetail detail = new UserMoneyDetail();
      detail.setCreateTime(new Date());
      detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.hongbaoDeduct.name() + "-" + subTitle + "-"
            + hb.getBeizhu() + "-" + hb.getId()));
      detail.setMoney(hb.getMoney());
      detail.setSourceIdentifyId(hb.getId());
      detail.setTitle(UserMoneyDetailTypeEnum.hongbaoDeduct.getDesc());
      detail.setSubTitle(subTitle);
      detail.setType(UserMoneyDetailTypeEnum.hongbaoDeduct);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(hb.getUserInfo());
      return detail;
@@ -370,13 +396,75 @@
   /**
    * 新人红包扣除
    *
    * @param hb
    * @return
    * @throws UserMoneyDetailException
    */
   public static UserMoneyDetail createNewerHongBaoDeduct(HongBao hb) throws UserMoneyDetailException {
      return createHongBao(hb, "新人红包扣除");
      return createHongBaoDeduct(hb, "新人红包扣除");
   }
   /**
    * 返利奖励
    *
    * @param orderId
    * @param money
    * @param user
    * @return
    * @throws UserMoneyDetailException
    */
   public static UserMoneyDetail createOrderReward(String orderId, BigDecimal money, UserInfo user)
         throws UserMoneyDetailException {
      if (StringUtil.isNullOrEmpty(orderId))
         throw new UserMoneyDetailException(1, "订单号不能为空");
      if (user == 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(UserMoneyDetailTypeEnum.hongbao.name() + "-" + "老版本" + "-" + orderId));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.orderReward.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.orderReward);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(user);
      // detail.setDescInfo("订单号:" + orderId);
      return detail;
   }
   /**
    * 订单重复统计退款
    *
    * @param orderId
    * @param money
    * @param user
    * @return
    * @throws UserMoneyDetailException
    */
   public static UserMoneyDetail createRepeatStatistic(String orderId, BigDecimal money, UserInfo user)
         throws UserMoneyDetailException {
      if (StringUtil.isNullOrEmpty(orderId))
         throw new UserMoneyDetailException(1, "订单号不能为空");
      if (user == 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(UserMoneyDetailTypeEnum.repeatStatistic.name() + "-" + orderId + "-" + user.getId()));
      detail.setMoney(money);
      detail.setTitle(UserMoneyDetailTypeEnum.repeatStatistic.getDesc());
      detail.setType(UserMoneyDetailTypeEnum.repeatStatistic);
      detail.setUpdateTime(new Date());
      detail.setUserInfo(user);
      detail.setDescInfo("订单号:" + orderId);
      return detail;
   }
}