yujian
2019-11-01 c94492d53f390fe3143689d0641a2786afe83adf
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
@@ -7,6 +7,7 @@
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
import com.yeshi.fanli.exception.redpack.RedPackDetailException;
import com.yeshi.fanli.util.StringUtil;
@@ -84,21 +85,181 @@
   
   
   
   public static RedPackDetail createGiveOthers(RedPackGiveRecord giveRecord, String desc, RedPackDetailTypeEnum type) throws RedPackDetailException {
      if (giveRecord == null || type == null)
         throw new RedPackDetailException(1, "提现记录、类型不能为空");
      // 红包明细- 退回红包
   /**
    * 赠送好友明细
    * @param giveRecord
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createGiveOthers(RedPackGiveRecord giveRecord) throws RedPackDetailException {
      if (giveRecord == null)
         throw new RedPackDetailException(1, "赠送记录不能为空");
      RedPackDetail detail = new RedPackDetail();
      detail.setDisplay(true);
      detail.setUid(giveRecord.getGiveUid());
      detail.setMoney(new BigDecimal("-" + giveRecord.getAmount()));
      detail.setType(RedPackDetailTypeEnum.giveOthers);
      detail.setTitle(RedPackDetailTypeEnum.giveOthers.getDesc());
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.giveOthers.name() + ":" + giveRecord.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
   /**
    * 赠送成功
    * @param id
    * @param giveRecord
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createGiveOthersSucceed(Long id, RedPackGiveRecord giveRecord) throws RedPackDetailException {
      if (giveRecord == null)
         throw new RedPackDetailException(1, "赠送记录不能为空");
      RedPackDetail detail = new RedPackDetail();
      detail.setId(id);
      detail.setDisplay(true);
      detail.setType(RedPackDetailTypeEnum.giveOthersSucceed);
      detail.setTitle(RedPackDetailTypeEnum.giveOthersSucceed.getDesc());
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.giveOthersSucceed.name() + ":" + giveRecord.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
   /**
    * 赠送失败
    * @param giveRecord
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createGiveOthersFail(RedPackGiveRecord giveRecord) throws RedPackDetailException {
      if (giveRecord == null)
         throw new RedPackDetailException(1, "赠送记录不能为空");
      RedPackDetail detail = new RedPackDetail();
      detail.setDisplay(true);
      detail.setUid(giveRecord.getGiveUid());
      detail.setMoney(giveRecord.getAmount());
      detail.setDesc(desc);
      detail.setType(type);
      detail.setTitle(type.getDesc());
      detail.setIdentifyCode(StringUtil.Md5(type.name() + ":" + giveRecord.getId()));
      detail.setType(RedPackDetailTypeEnum.giveOthersFail);
      detail.setTitle(RedPackDetailTypeEnum.giveOthersFail.getDesc());
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.giveOthersFail.name() + ":" + giveRecord.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
   /**
    * 赠送失败
    * @param giveRecord
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createGiveOthersReceive(RedPackGiveRecord giveRecord) throws RedPackDetailException {
      if (giveRecord == null)
         throw new RedPackDetailException(1, "赠送记录不能为空");
      RedPackDetail detail = new RedPackDetail();
      detail.setDisplay(true);
      detail.setUid(giveRecord.getReceiveUid());
      detail.setMoney(giveRecord.getAmount());
      detail.setType(RedPackDetailTypeEnum.giveOthersReceive);
      detail.setTitle(RedPackDetailTypeEnum.giveOthersReceive.getDesc());
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.giveOthersReceive.name() + ":" + giveRecord.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
   /**
    *  新人奖励
    * @param winInvite
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createNewUserReward(RedPackWinInvite winInvite) throws RedPackDetailException {
      if (winInvite == null)
         throw new RedPackDetailException(1, "获得记录不能为空");
      // 红包明细- 退回红包
      RedPackDetail detail = new RedPackDetail();
      detail.setDisplay(true);
      detail.setUid(winInvite.getUid());
      detail.setMoney(winInvite.getMoney());
      detail.setDesc("完成首笔订单");
      detail.setTitle(RedPackDetailTypeEnum.newUserReward.getDesc());
      detail.setType(RedPackDetailTypeEnum.newUserReward);
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.newUserReward.name() + ":" + winInvite.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
   /**
    * 立得现金
    * @param winInvite
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createInvite(RedPackWinInvite winInvite) throws RedPackDetailException {
      if (winInvite == null)
         throw new RedPackDetailException(1, "获得记录不能为空");
      // 红包明细- 退回红包
      RedPackDetail detail = new RedPackDetail();
      detail.setDisplay(true);
      detail.setUid(winInvite.getUid());
      detail.setMoney(winInvite.getMoney());
      detail.setDesc("成功邀请好友");
      detail.setTitle(RedPackDetailTypeEnum.invite.getDesc());
      detail.setType(RedPackDetailTypeEnum.invite);
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.invite.name() + ":" + winInvite.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
   /**
    * 递增奖励 + 好友完成分享订单
    * @param winInvite
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createIncreaseReward(RedPackWinInvite winInvite) throws RedPackDetailException {
      if (winInvite == null)
         throw new RedPackDetailException(1, "获得记录不能为空");
      // 红包明细- 退回红包
      RedPackDetail detail = new RedPackDetail();
      detail.setDisplay(true);
      detail.setUid(winInvite.getUid());
      detail.setMoney(winInvite.getMoney());
      detail.setDesc("好友完成订单");
      detail.setTitle(RedPackDetailTypeEnum.increaseReward.getDesc());
      detail.setType(RedPackDetailTypeEnum.increaseReward);
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.increaseReward.name() + ":" + winInvite.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
   /**
    * 连续奖励 + 好友完成分享订单
    * @param winInvite
    * @return
    * @throws RedPackDetailException
    */
   public static RedPackDetail createSeriesReward(RedPackWinInvite winInvite) throws RedPackDetailException {
      if (winInvite == null)
         throw new RedPackDetailException(1, "获得记录不能为空");
      // 红包明细- 退回红包
      RedPackDetail detail = new RedPackDetail();
      detail.setDisplay(true);
      detail.setUid(winInvite.getUid());
      detail.setMoney(winInvite.getMoney());
      detail.setDesc("好友完成订单");
      detail.setTitle(RedPackDetailTypeEnum.seriesReward.getDesc());
      detail.setType(RedPackDetailTypeEnum.seriesReward);
      detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.seriesReward.name() + ":" + winInvite.getId()));
      detail.setCreateTime(new Date());
      return detail;
   }
}