From 56bcbcf230f4ce53376c7ccc99b91990d3375f9d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 01 十一月 2019 17:06:02 +0800 Subject: [PATCH] 板栗商城 --- fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java | 136 +++++++++++++++++++++++++++++++++++++------- 1 files changed, 113 insertions(+), 23 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 b30dce7..d3d7268 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 @@ -13,7 +13,7 @@ public class RedPackDetailFactory { /** - * 绾㈠寘鎻愮幇 + * 绾㈠寘鎻愮幇 * * @param extract * @return @@ -21,10 +21,10 @@ 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.setDesc("绛夊緟浜哄伐瀹℃牳"); detail.setUid(exchange.getUid()); detail.setMoney(new BigDecimal("-" + exchange.getMoney())); detail.setType(RedPackDetailTypeEnum.redExchange); @@ -34,9 +34,8 @@ return detail; } - /** - * 绾㈠寘鎻愮幇閫氳繃 + * 绾㈠寘鎻愮幇閫氳繃 * * @param extract * @return @@ -44,10 +43,10 @@ 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); @@ -57,10 +56,9 @@ detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + exchange.getId())); return detail; } - - + /** - * 绾㈠寘鎻愮幇鎷掔粷 + * 绾㈠寘鎻愮幇鎷掔粷 * * @param extract * @return @@ -68,7 +66,7 @@ public static RedPackDetail createExchangeReject(RedPackExchange exchange) throws RedPackDetailException { if (exchange == null) throw new RedPackDetailException(1, "鎻愮幇璁板綍涓嶈兘涓虹┖"); - + // 绾㈠寘鏄庣粏- 閫�鍥炵孩鍖� RedPackDetail detail = new RedPackDetail(); detail.setDisplay(false); @@ -81,24 +79,116 @@ 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, "鎻愮幇璁板綍銆佺被鍨嬩笉鑳戒负绌�"); - - // 绾㈠寘鏄庣粏- 閫�鍥炵孩鍖� + + /** + * 璧犻�佸ソ鍙嬫槑缁� + * + * @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 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(money); + detail.setType(RedPackDetailTypeEnum.useByShopOrder); + detail.setTitle(title); + detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.useByShopOrder.name() + "-" + orderId)); + detail.setCreateTime(new Date()); + detail.setDesc(setName); + return detail; + } + } -- Gitblit v1.8.0