admin
2019-10-31 f59fd6755fe615bf88d8a4950cbdadfaaf1e876a
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
@@ -84,21 +84,88 @@
   
   
   
   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;
   }
}