| | |
| | | package com.yeshi.fanli.util.factory;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | 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.RedPackForbidRecord;
|
| | | 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;
|
| | |
|
| | | 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.setDescInfo("等待人工审核");
|
| | | 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.setDescInfo("请到账户余额中查看");
|
| | | 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.setDescInfo("红包产生过程中涉嫌违规");
|
| | | detail.setTitle(RedPackDetailTypeEnum.redExchangeReject.getDesc());
|
| | | detail.setType(RedPackDetailTypeEnum.redExchangeReject);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangeReject.name() + ":" + exchange.getId()));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 红包封禁
|
| | | * |
| | | * @param extract
|
| | | * @return
|
| | | */
|
| | | public static RedPackDetail createForbid(RedPackForbidRecord record) throws RedPackDetailException {
|
| | | if (record == null)
|
| | | throw new RedPackDetailException(1, "提现记录不能为空");
|
| | |
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | | detail.setUid(record.getUid());
|
| | | detail.setDescInfo(record.getReason());
|
| | | detail.setMoney(new BigDecimal("-" + record.getMoney()));
|
| | | detail.setType(RedPackDetailTypeEnum.forbid);
|
| | | detail.setTitle(RedPackDetailTypeEnum.forbid.getDesc());
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.forbid.name() + ":" + record.getId()));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 红包扣除
|
| | | * |
| | | * @param extract
|
| | | * @return
|
| | | */
|
| | | public static RedPackDetail createDeduct(RedPackForbidRecord record) throws RedPackDetailException {
|
| | | if (record == null)
|
| | | throw new RedPackDetailException(1, "提现记录不能为空");
|
| | |
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | | detail.setUid(record.getUid());
|
| | | detail.setDescInfo(record.getReason());
|
| | | detail.setMoney(new BigDecimal("-" + record.getMoney()));
|
| | | detail.setType(RedPackDetailTypeEnum.deduct);
|
| | | detail.setTitle(RedPackDetailTypeEnum.deduct.getDesc());
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.deduct.name() + ":" + record.getUid() + format.format(new Date())));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | /**
|
| | | * 赠送好友明细
|
| | | * |
| | | * @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.setRemark("领取人ID:" + giveRecord.getReceiveUid());
|
| | | 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.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 giveRecord
|
| | | * @return
|
| | | * @throws RedPackDetailException
|
| | | */
|
| | | public static RedPackDetail createUseByShopOrder(Long orderId, Long uid, String title, String setName,
|
| | | BigDecimal money) throws RedPackDetailException {
|
| | | if (orderId == null)
|
| | | throw new RedPackDetailException(1, "订单ID不能为空");
|
| | | if (uid == null)
|
| | | throw new RedPackDetailException(1, "用户ID不能为空");
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(false);
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(new BigDecimal(0).subtract(money));
|
| | | detail.setType(RedPackDetailTypeEnum.useByShopOrder);
|
| | | detail.setTitle(title);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.useByShopOrder.name() + "-" + orderId));
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setDescInfo(setName);
|
| | | return detail;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新人奖励
|
| | | * |
| | | * @param winInvite
|
| | | * @return
|
| | | * @throws RedPackDetailException
|
| | | */
|
| | | public static RedPackDetail createNewUserReward(Long uid, Integer num, BigDecimal money) throws RedPackDetailException {
|
| | | if (uid == null || num == null || money == null)
|
| | | throw new RedPackDetailException(1, "获得记录不能为空");
|
| | | // 红包明细- 退回红包
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(money);
|
| | | detail.setDescInfo("签到红包");
|
| | | detail.setTitle(RedPackDetailTypeEnum.newUserReward.getDesc());
|
| | | detail.setType(RedPackDetailTypeEnum.newUserReward);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.newUserReward.name() + ":" + uid +"_" + num));
|
| | | 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.setDescInfo("成功邀请好友");
|
| | | 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.setDescInfo("好友完成订单");
|
| | | 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.setDescInfo("好友完成订单");
|
| | | detail.setTitle(RedPackDetailTypeEnum.seriesReward.getDesc());
|
| | | detail.setType(RedPackDetailTypeEnum.seriesReward);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.seriesReward.name() + ":" + winInvite.getId()));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | |
|
| | | public static RedPackDetail createShopOrderDrawBack(Long orderId, Long uid, String title, String setName,
|
| | | BigDecimal money) throws RedPackDetailException {
|
| | | if (orderId == null)
|
| | | throw new RedPackDetailException(1, "订单ID不能为空");
|
| | | if (uid == null)
|
| | | throw new RedPackDetailException(1, "用户ID不能为空");
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(false);
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(money);
|
| | | detail.setType(RedPackDetailTypeEnum.shopOrderDrawBack);
|
| | | detail.setTitle(title);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.shopOrderDrawBack.name() + "-" + orderId));
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setDescInfo(setName);
|
| | | return detail;
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @param uid
|
| | | * @param money
|
| | | * @param date
|
| | | * @return
|
| | | * @throws RedPackDetailException
|
| | | */
|
| | | public static RedPackDetail createByMonth(Long uid, BigDecimal money, Date date) throws RedPackDetailException {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | String time = sdf.format(date);
|
| | | |
| | | String title = sdf.format(date) + "邀请红包";
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(money);
|
| | | detail.setTitle(title);
|
| | | detail.setType(RedPackDetailTypeEnum.redMonthly);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redMonthly.name() + ":" + time));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.util.factory; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | 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.RedPackForbidRecord; |
| | | 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; |
| | | |
| | | 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.setDescInfo("等待人工审核"); |
| | | 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.setDescInfo("请到账户余额中查看"); |
| | | 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.setDescInfo("红包产生过程中涉嫌违规"); |
| | | detail.setTitle(RedPackDetailTypeEnum.redExchangeReject.getDesc()); |
| | | detail.setType(RedPackDetailTypeEnum.redExchangeReject); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangeReject.name() + ":" + exchange.getId())); |
| | | detail.setCreateTime(new Date()); |
| | | return detail; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 红包封禁 |
| | | * |
| | | * @param extract |
| | | * @return |
| | | */ |
| | | public static RedPackDetail createForbid(RedPackForbidRecord record) throws RedPackDetailException { |
| | | if (record == null) |
| | | throw new RedPackDetailException(1, "提现记录不能为空"); |
| | | |
| | | RedPackDetail detail = new RedPackDetail(); |
| | | detail.setDisplay(true); |
| | | detail.setUid(record.getUid()); |
| | | detail.setDescInfo(record.getReason()); |
| | | detail.setMoney(new BigDecimal("-" + record.getMoney())); |
| | | detail.setType(RedPackDetailTypeEnum.forbid); |
| | | detail.setTitle(RedPackDetailTypeEnum.forbid.getDesc()); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.forbid.name() + ":" + record.getId())); |
| | | detail.setCreateTime(new Date()); |
| | | return detail; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 红包扣除 |
| | | * |
| | | * @param extract |
| | | * @return |
| | | */ |
| | | public static RedPackDetail createDeduct(RedPackForbidRecord record) throws RedPackDetailException { |
| | | if (record == null) |
| | | throw new RedPackDetailException(1, "提现记录不能为空"); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | RedPackDetail detail = new RedPackDetail(); |
| | | detail.setDisplay(true); |
| | | detail.setUid(record.getUid()); |
| | | detail.setDescInfo(record.getReason()); |
| | | detail.setMoney(new BigDecimal("-" + record.getMoney())); |
| | | detail.setType(RedPackDetailTypeEnum.deduct); |
| | | detail.setTitle(RedPackDetailTypeEnum.deduct.getDesc()); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.deduct.name() + ":" + record.getUid() + format.format(new Date()))); |
| | | detail.setCreateTime(new Date()); |
| | | return detail; |
| | | } |
| | | /** |
| | | * 赠送好友明细 |
| | | * |
| | | * @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.setRemark("领取人ID:" + giveRecord.getReceiveUid()); |
| | | 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.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 giveRecord |
| | | * @return |
| | | * @throws RedPackDetailException |
| | | */ |
| | | public static RedPackDetail createUseByShopOrder(Long orderId, Long uid, String title, String setName, |
| | | BigDecimal money) throws RedPackDetailException { |
| | | if (orderId == null) |
| | | throw new RedPackDetailException(1, "订单ID不能为空"); |
| | | if (uid == null) |
| | | throw new RedPackDetailException(1, "用户ID不能为空"); |
| | | RedPackDetail detail = new RedPackDetail(); |
| | | detail.setDisplay(false); |
| | | detail.setUid(uid); |
| | | detail.setMoney(new BigDecimal(0).subtract(money)); |
| | | detail.setType(RedPackDetailTypeEnum.useByShopOrder); |
| | | detail.setTitle(title); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.useByShopOrder.name() + "-" + orderId)); |
| | | detail.setCreateTime(new Date()); |
| | | detail.setDescInfo(setName); |
| | | return detail; |
| | | } |
| | | |
| | | /** |
| | | * 新人奖励 |
| | | * |
| | | * @param winInvite |
| | | * @return |
| | | * @throws RedPackDetailException |
| | | */ |
| | | public static RedPackDetail createNewUserReward(Long uid, Integer num, BigDecimal money) throws RedPackDetailException { |
| | | if (uid == null || num == null || money == null) |
| | | throw new RedPackDetailException(1, "获得记录不能为空"); |
| | | // 红包明细- 退回红包 |
| | | RedPackDetail detail = new RedPackDetail(); |
| | | detail.setDisplay(true); |
| | | detail.setUid(uid); |
| | | detail.setMoney(money); |
| | | detail.setDescInfo("签到红包"); |
| | | detail.setTitle(RedPackDetailTypeEnum.newUserReward.getDesc()); |
| | | detail.setType(RedPackDetailTypeEnum.newUserReward); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.newUserReward.name() + ":" + uid +"_" + num)); |
| | | 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.setDescInfo("成功邀请好友"); |
| | | 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.setDescInfo("好友完成订单"); |
| | | 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.setDescInfo("好友完成订单"); |
| | | detail.setTitle(RedPackDetailTypeEnum.seriesReward.getDesc()); |
| | | detail.setType(RedPackDetailTypeEnum.seriesReward); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.seriesReward.name() + ":" + winInvite.getId())); |
| | | detail.setCreateTime(new Date()); |
| | | return detail; |
| | | } |
| | | |
| | | public static RedPackDetail createShopOrderDrawBack(Long orderId, Long uid, String title, String setName, |
| | | BigDecimal money) throws RedPackDetailException { |
| | | if (orderId == null) |
| | | throw new RedPackDetailException(1, "订单ID不能为空"); |
| | | if (uid == null) |
| | | throw new RedPackDetailException(1, "用户ID不能为空"); |
| | | RedPackDetail detail = new RedPackDetail(); |
| | | detail.setDisplay(false); |
| | | detail.setUid(uid); |
| | | detail.setMoney(money); |
| | | detail.setType(RedPackDetailTypeEnum.shopOrderDrawBack); |
| | | detail.setTitle(title); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.shopOrderDrawBack.name() + "-" + orderId)); |
| | | detail.setCreateTime(new Date()); |
| | | detail.setDescInfo(setName); |
| | | return detail; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param uid |
| | | * @param money |
| | | * @param date |
| | | * @return |
| | | * @throws RedPackDetailException |
| | | */ |
| | | public static RedPackDetail createByMonth(Long uid, BigDecimal money, Date date) throws RedPackDetailException { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); |
| | | String time = sdf.format(date); |
| | | |
| | | String title = sdf.format(date) + "邀请红包"; |
| | | RedPackDetail detail = new RedPackDetail(); |
| | | detail.setDisplay(true); |
| | | detail.setUid(uid); |
| | | detail.setMoney(money); |
| | | detail.setTitle(title); |
| | | detail.setType(RedPackDetailTypeEnum.redMonthly); |
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redMonthly.name() + ":" + time)); |
| | | detail.setCreateTime(new Date()); |
| | | return detail; |
| | | } |
| | | } |