package com.yeshi.fanli.util.factory;
|
|
import java.math.BigDecimal;
|
import java.util.Date;
|
|
import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
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.exception.redpack.RedPackDetailException;
|
import com.yeshi.fanli.util.StringUtil;
|
|
public class RedPackDetailFactory {
|
|
/**
|
* 红包提现
|
*
|
* @param extract
|
* @return
|
*/
|
public static RedPackDetail createExchange(RedPackExchange exchange) throws RedPackDetailException {
|
if (exchange == null)
|
throw new RedPackDetailException(1, "提现记录不能为空");
|
|
RedPackDetail detail = new RedPackDetail();
|
detail.setDisplay(false);
|
detail.setDesc( "等待人工审核");
|
detail.setUid(exchange.getUid());
|
detail.setMoney(new BigDecimal("-" + exchange.getMoney()));
|
detail.setType(RedPackDetailTypeEnum.redExchange);
|
detail.setTitle(RedPackDetailTypeEnum.redExchange.getDesc());
|
detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchange.name() + ":" + exchange.getId()));
|
detail.setCreateTime(new Date());
|
return detail;
|
}
|
|
|
/**
|
* 红包提现通过
|
*
|
* @param extract
|
* @return
|
*/
|
public static RedPackDetail updateExchangePass(Long id, RedPackExchange exchange) throws RedPackDetailException {
|
if (id == null)
|
throw new RedPackDetailException(1, "明细ID不能为空");
|
|
if (exchange == null)
|
throw new RedPackDetailException(1, "提现记录不能为空");
|
|
RedPackDetail detail = new RedPackDetail();
|
detail.setId(id);
|
detail.setDisplay(true);
|
detail.setDesc("请到账户余额中查看");
|
detail.setType(RedPackDetailTypeEnum.redExchangePass);
|
detail.setTitle(RedPackDetailTypeEnum.redExchangePass.getDesc());
|
detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + exchange.getId()));
|
return detail;
|
}
|
|
|
/**
|
* 红包提现拒绝
|
*
|
* @param extract
|
* @return
|
*/
|
public static RedPackDetail createExchangeReject(RedPackExchange exchange) throws RedPackDetailException {
|
if (exchange == null)
|
throw new RedPackDetailException(1, "提现记录不能为空");
|
|
// 红包明细- 退回红包
|
RedPackDetail detail = new RedPackDetail();
|
detail.setDisplay(false);
|
detail.setUid(exchange.getUid());
|
detail.setMoney(exchange.getMoney());
|
detail.setDesc("红包产生过程中涉嫌违规");
|
detail.setTitle(RedPackDetailTypeEnum.redExchangeReject.getDesc());
|
detail.setType(RedPackDetailTypeEnum.redExchangeReject);
|
detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangeReject.name() + ":" + exchange.getId()));
|
detail.setCreateTime(new Date());
|
return detail;
|
}
|
|
|
|
public static RedPackDetail createGiveOthers(RedPackGiveRecord giveRecord, String desc, RedPackDetailTypeEnum type) throws RedPackDetailException {
|
if (giveRecord == null || type == 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.setCreateTime(new Date());
|
return detail;
|
}
|
|
}
|