From 9f56a3478708633de7e5f013901a4539b01b638c Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 30 六月 2020 12:05:50 +0800
Subject: [PATCH] 订单结算时的红包
---
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java | 88 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 80 insertions(+), 8 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java b/fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
index 0966a61..2a8a23a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
@@ -1,15 +1,18 @@
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;
+import com.yeshi.fanli.util.TimeUtil;
public class RedPackDetailFactory {
@@ -80,7 +83,53 @@
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;
+ }
+
+
+ /**
+ * 绾㈠寘鎵i櫎
+ *
+ * @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;
+ }
/**
* 璧犻�佸ソ鍙嬫槑缁�
*
@@ -117,6 +166,7 @@
RedPackDetail detail = new RedPackDetail();
detail.setId(id);
detail.setDisplay(true);
+ detail.setRemark("棰嗗彇浜篒D:" + giveRecord.getReceiveUid());
detail.setType(RedPackDetailTypeEnum.giveOthersSucceed);
detail.setTitle(RedPackDetailTypeEnum.giveOthersSucceed.getDesc());
detail.setIdentifyCode(
@@ -200,19 +250,18 @@
* @return
* @throws RedPackDetailException
*/
- public static RedPackDetail createNewUserReward(RedPackWinInvite winInvite) throws RedPackDetailException {
- if (winInvite == null)
+ 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(winInvite.getUid());
- detail.setMoney(winInvite.getMoney());
- detail.setDescInfo("瀹屾垚棣栫瑪璁㈠崟");
+ detail.setUid(uid);
+ detail.setMoney(money);
+ detail.setDescInfo("绛惧埌绾㈠寘");
detail.setTitle(RedPackDetailTypeEnum.newUserReward.getDesc());
detail.setType(RedPackDetailTypeEnum.newUserReward);
- detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.newUserReward.name() + ":" + winInvite.getId()));
+ detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.newUserReward.name() + ":" + uid +"_" + num));
detail.setCreateTime(new Date());
return detail;
}
@@ -307,4 +356,27 @@
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;
+ }
}
--
Gitblit v1.8.0