From d960fdbfe07a65cb80ccb764bfb15ce78ebfd84a Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 10 四月 2020 18:21:04 +0800
Subject: [PATCH] 消息修改

---
 fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOrderDetailFactory.java |  368 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 368 insertions(+), 0 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOrderDetailFactory.java b/fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOrderDetailFactory.java
index 96588be..f6cd80f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOrderDetailFactory.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOrderDetailFactory.java
@@ -1,5 +1,373 @@
 package com.yeshi.fanli.util.factory.msg;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.transaction.annotation.Transactional;
+
+import com.google.gson.Gson;
+import com.yeshi.fanli.entity.bus.msg.MsgExtra;
+import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
+import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail.MsgTypeOrderTypeEnum;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.exception.msg.MsgOrderDetailException;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
+import com.yeshi.fanli.vo.msg.CommonMsgItemVO;
+import com.yeshi.fanli.vo.msg.CommonMsgItemVOFactory;
+
 public class MsgOrderDetailFactory {
 
+	/**
+	 * 杩斿埄璁㈠崟
+	 * 
+	 * @param uid
+	 * @param orderId
+	 * @param goodsCount
+	 * @param orderState
+	 * @param payMoney
+	 * @param money
+	 * @param state
+	 * @param beiZhu
+	 * @return
+	 */
+	public static MsgOrderDetail createFanLiOrder(Long uid, String orderId, int orderType, int goodsCount,
+			int orderState, BigDecimal payMoney, BigDecimal money, String beiZhu) {
+		if (uid == null)
+			return null;
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setBeiZhu(beiZhu);
+		detail.setCreateTime(new Date());
+		detail.setGoodsCount(goodsCount);
+		detail.setHongBaoMoney(money);
+		detail.setOrderId(orderId);
+		detail.setOrderType(orderType);
+		detail.setPayMoney(payMoney);
+		detail.setRead(false);
+		detail.setState(orderState);
+		detail.setType(MsgTypeOrderTypeEnum.fanli);
+		detail.setUser(new UserInfo(uid));
+		return detail;
+	}
+
+	/**
+	 * 閭�璇疯鍗�
+	 * 
+	 * @param uid
+	 * @param orderId
+	 * @param goodsCount
+	 * @param orderState
+	 * @param payMoney
+	 * @param money
+	 * @param state
+	 * @param beiZhu
+	 * @return
+	 */
+	public static MsgOrderDetail createInviteOrder(Long uid, String orderId, int orderType, int goodsCount,
+			int orderState, BigDecimal payMoney, BigDecimal money, String beiZhu) {
+		if (payMoney == null || money == null || uid == null)
+			return null;
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setBeiZhu(beiZhu);
+		detail.setCreateTime(new Date());
+		detail.setGoodsCount(goodsCount);
+		detail.setHongBaoMoney(money);
+		detail.setOrderId(orderId);
+		detail.setOrderType(orderType);
+		detail.setPayMoney(payMoney);
+		detail.setRead(false);
+		detail.setState(orderState);
+		detail.setType(MsgTypeOrderTypeEnum.invite);
+		detail.setUser(new UserInfo(uid));
+		return detail;
+	}
+
+	/**
+	 * 鍒嗕韩璁㈠崟
+	 * 
+	 * @param uid
+	 * @param orderId
+	 * @param goodsCount
+	 * @param orderState
+	 * @param payMoney
+	 * @param money
+	 * @param state
+	 * @param beiZhu
+	 * @return
+	 */
+	public static MsgOrderDetail createShareOrder(Long uid, String orderId, int orderType, int goodsCount,
+			int orderState, BigDecimal payMoney, BigDecimal money, String beiZhu) {
+		if (payMoney == null || money == null || uid == null)
+			return null;
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setBeiZhu(beiZhu);
+		detail.setCreateTime(new Date());
+		detail.setGoodsCount(goodsCount);
+		detail.setHongBaoMoney(money);
+		detail.setOrderId(orderId);
+		detail.setOrderType(orderType);
+		detail.setPayMoney(payMoney);
+		detail.setRead(false);
+		detail.setState(orderState);
+		detail.setType(MsgTypeOrderTypeEnum.share);
+		detail.setUser(new UserInfo(uid));
+		return detail;
+	}
+
+	/**
+	 * 璁㈠崟鎵惧洖
+	 * 
+	 * @param uid
+	 * @param orderId
+	 *            -璁㈠崟鍙�
+	 * @param isSuccess-鏄惁鎵惧洖鎴愬姛
+	 * @param payMoney
+	 * @param orderType
+	 *            1-娣樺疂璁㈠崟 3-鎷煎澶氳鍗� 4-浜笢璁㈠崟
+	 * @param beiZhu
+	 * @return
+	 */
+	public static MsgOrderDetail createFoundOrder(Long uid, String orderId, boolean isSuccess, BigDecimal payMoney,
+			int orderType, Date happendDate, String beiZhu) {
+		if (orderId == null || uid == null)
+			return null;
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setBeiZhu(beiZhu);
+		detail.setCreateTime(new Date());
+		detail.setOrderType(orderType);
+		detail.setPayMoney(payMoney);
+		detail.setRead(false);
+		detail.setState(isSuccess ? 1 : 0);
+		detail.setType(MsgTypeOrderTypeEnum.found);
+		detail.setUser(new UserInfo(uid));
+		detail.setHappendDate(happendDate);
+		return detail;
+	}
+	
+	/**
+	 * 楗夸簡涔堣鍗曟秷鎭�
+	 * @param uid
+	 * @param orderId
+	 * @param orderType
+	 * @param orderState
+	 * @param payMoney
+	 * @param money
+	 * @param beiZhu
+	 * @return
+	 */
+	public static MsgOrderDetail createElmeOrder(Long uid, String orderId, int orderType,
+			int orderState, BigDecimal payMoney, BigDecimal money, String beiZhu) {
+		if (uid == null)
+			return null;
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setBeiZhu(beiZhu);
+		detail.setCreateTime(new Date());
+		detail.setHongBaoMoney(money);
+		detail.setOrderId(orderId);
+		detail.setOrderType(orderType);
+		detail.setPayMoney(payMoney);
+		detail.setRead(false);
+		detail.setState(orderState);
+		detail.setType(MsgTypeOrderTypeEnum.elme);
+		detail.setUser(new UserInfo(uid));
+		return detail;
+	}
+	
+	
+
+	/**
+	 * 鍒涘缓璁㈠崟琚粺璁℃秷鎭�
+	 * @param uid
+	 * @param orderId 璁㈠崟鍙�
+	 * @param source  璁㈠崟鏉ユ簮锛氭窐瀹濄�佷含涓溿�佸ぉ鐚�
+	 * @param type    璁㈠崟绫诲瀷锛氳嚜璐�佸垎浜�佸洟闃�
+	 * @param goodsCount 鍟嗗搧鏁伴噺
+	 * @param payMoney  浠樻閲戦
+	 * @param money     杩斿埄閲戦
+	 * @param downTime  涓嬪崟鏃堕棿
+	 * @param beiZhu 澶囨敞淇℃伅 - 闈炲繀濉�
+	 * @return
+	 */
+	@Transactional
+	public static MsgOrderDetail  createOrderStatistics(Long uid, String orderId, int source, int type, int goodsCount,
+			BigDecimal payMoney, BigDecimal money, Date downTime, String beiZhu) {
+		if (uid == null || StringUtil.isNullOrEmpty(orderId) || downTime == null)
+			return null;
+
+		String fanliName = "";
+		MsgTypeOrderTypeEnum typeEnum = null;
+		String sourceName = Constant.getSourceName(source);
+		if (Constant.TYPE_REBATE == type) {
+			fanliName = "杩斿埄锛�";
+			sourceName += "-杩斿埄璁㈠崟";
+			typeEnum = MsgTypeOrderTypeEnum.fanli;
+		} else if (Constant.TYPE_SHAER == type) {
+			fanliName = "濂栭噾锛�";
+			sourceName += "-鍒嗕韩璁㈠崟";
+			typeEnum = MsgTypeOrderTypeEnum.share;
+		} else if (Constant.TYPE_INVITE == type) {
+			fanliName = "鏀剁泭锛�";
+			sourceName += "-鍥㈤槦璁㈠崟";
+			typeEnum = MsgTypeOrderTypeEnum.invite;
+		}
+
+		// 娣诲姞鍐呭
+		List<CommonMsgItemVO> listMsg = new ArrayList<>();
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("璁㈠崟璇︽儏", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(sourceName, ClientTextStyleVO.COLOR_CONTENT)));
+		// 璁㈠崟鍙峰彲鐐瑰嚮
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("璁㈠崟鍙�", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(orderId, ClientTextStyleVO.COLOR_CONTENT), true));
+
+		List<ClientTextStyleVO> contentList = new ArrayList<>();
+		contentList
+				.add(new ClientTextStyleVO("涓嬪崟鏃堕棿锛�" + TimeUtil.formatDate(downTime), ClientTextStyleVO.COLOR_CONTENT));
+		contentList.add(new ClientTextStyleVO("-鍟嗗搧鏁伴噺锛氬叡", ClientTextStyleVO.COLOR_CONTENT));
+		contentList.add(new ClientTextStyleVO(goodsCount + "", ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));
+		contentList.add(new ClientTextStyleVO("浠跺晢鍝�", ClientTextStyleVO.COLOR_CONTENT));
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("璁㈠崟鐩稿叧", ClientTextStyleVO.COLOR_TITLE),
+				contentList));
+
+		List<ClientTextStyleVO> contentList2 = new ArrayList<>();
+		contentList2.add(new ClientTextStyleVO("瀹炰粯娆撅細", ClientTextStyleVO.COLOR_CONTENT));
+		contentList2.add(new ClientTextStyleVO("楼" + filterMoney(payMoney), ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));
+		contentList2.add(new ClientTextStyleVO("&" + fanliName, ClientTextStyleVO.COLOR_CONTENT));
+		contentList2.add(new ClientTextStyleVO("楼" + filterMoney(money), ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("閲戦", ClientTextStyleVO.COLOR_TITLE),
+				contentList2));
+
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("澶囨敞", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(StringUtil.isNullOrEmpty(beiZhu) ? "鏃�" : beiZhu,
+						ClientTextStyleVO.COLOR_CONTENT)));
+
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setBeiZhu(beiZhu);
+		detail.setCreateTime(new Date());
+		detail.setGoodsCount(goodsCount);
+		detail.setHongBaoMoney(money);
+		detail.setOrderId(orderId);
+		detail.setOrderType(source);
+		detail.setPayMoney(payMoney);
+		detail.setRead(false);
+		detail.setType(typeEnum);
+		detail.setUser(new UserInfo(uid));
+		detail.setExtraInfo(new Gson().toJson(listMsg));
+		return detail;
+	}
+	
+	private static BigDecimal filterMoney(BigDecimal money) {
+		if (money == null)
+			return BigDecimal.valueOf(0.00) ;
+		else
+			return money.setScale(2);
+	}
+	
+	
+	/**
+	 * 璁㈠崟鎵惧洖鎴愬姛
+	 * @param uid
+	 * @param orderId 璁㈠崟鍙�
+	 * @param source  璁㈠崟鏉ユ簮锛氭窐瀹濄�佷含涓溿�佸ぉ鐚�
+	 * @param type    璁㈠崟绫诲瀷锛氳嚜璐�佸垎浜�佸洟闃�
+	 * @param goodsCount 鍟嗗搧鏁伴噺
+	 * @param payMoney  浠樻閲戦
+	 * @param money     杩斿埄閲戦
+	 * @param submitTime  鎻愪氦鏃堕棿
+	 * @param beiZhu 澶囨敞淇℃伅 - 闈炲繀濉�
+	 * @return
+	 */
+	public static MsgOrderDetail createOrderFoundSuccess(Long uid, String orderId, int source, int type, int goodsCount,
+		BigDecimal payMoney, BigDecimal money, Date submitTime, String beiZhu) {
+		if (uid == null || StringUtil.isNullOrEmpty(orderId) || submitTime == null)
+			return null;
+		
+		String fanliName = "";
+		String sourceName = Constant.getSourceName(source);
+		if (Constant.TYPE_REBATE == type) {
+			fanliName = "杩斿埄锛�";
+			sourceName +=  "-杩斿埄璁㈠崟";
+		} else if (Constant.TYPE_SHAER == type) {
+			fanliName = "濂栭噾锛�";
+			sourceName +=  "-鍒嗕韩璁㈠崟";
+		}
+		
+		List<CommonMsgItemVO> listMsg = new ArrayList<>();
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("鎵惧洖鐘舵��", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO("璁㈠崟鎵惧洖鎴愬姛", ClientTextStyleVO.COLOR_CONTENT)));
+		
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("璁㈠崟璇︽儏", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(sourceName, ClientTextStyleVO.COLOR_CONTENT)));
+		
+		// 璁㈠崟鍙峰彲鐐瑰嚮
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("璁㈠崟鍙�", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(orderId, ClientTextStyleVO.COLOR_CONTENT), true));
+		
+		List<ClientTextStyleVO> contentList = new ArrayList<>();
+		contentList.add(new ClientTextStyleVO("鎻愪氦鏃堕棿锛�" + TimeUtil.formatDate(submitTime), ClientTextStyleVO.COLOR_CONTENT));
+		contentList.add(new ClientTextStyleVO("-鍟嗗搧鏁伴噺锛氬叡", ClientTextStyleVO.COLOR_CONTENT));
+		contentList.add(new ClientTextStyleVO(goodsCount + "", ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));
+		contentList.add(new ClientTextStyleVO("浠跺晢鍝�", ClientTextStyleVO.COLOR_CONTENT));
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("璁㈠崟鐩稿叧", ClientTextStyleVO.COLOR_TITLE),contentList));
+		
+		List<ClientTextStyleVO> contentList2 = new ArrayList<>();
+		contentList2.add(new ClientTextStyleVO("瀹炰粯娆撅細", ClientTextStyleVO.COLOR_CONTENT));
+		contentList2.add(new ClientTextStyleVO("楼" + filterMoney(payMoney), ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));
+		contentList2.add(new ClientTextStyleVO("&" + fanliName, ClientTextStyleVO.COLOR_CONTENT));
+		contentList2.add(new ClientTextStyleVO("楼" + filterMoney(money), ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("閲戦", ClientTextStyleVO.COLOR_TITLE),contentList2));
+		
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("澶囨敞", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(StringUtil.isNullOrEmpty(beiZhu)?"鏃�" : beiZhu, ClientTextStyleVO.COLOR_CONTENT)));
+		
+		
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setBeiZhu(beiZhu);
+		detail.setCreateTime(new Date());
+		detail.setOrderType(source);
+		detail.setPayMoney(payMoney);
+		detail.setRead(false);
+		detail.setType(MsgTypeOrderTypeEnum.foundSucceed);
+		detail.setUser(new UserInfo(uid));
+		detail.setExtraInfo(new Gson().toJson(listMsg));
+		
+		return detail;
+	}
+	
+	
+
+	/**
+	 * 璁㈠崟鎵惧洖澶辫触
+	 * @param uid
+	 * @param orderId
+	 * @param beiZhu
+	 * @return
+	 */
+	public static MsgOrderDetail createOrderFoundFail(Long uid, String orderId, String beiZhu) {
+		if (uid == null || StringUtil.isNullOrEmpty(orderId))
+			return null;
+		
+		List<CommonMsgItemVO> listMsg = new ArrayList<>();
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("鎵惧洖鐘舵��", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO("璁㈠崟鎵惧洖澶辫触", ClientTextStyleVO.COLOR_CONTENT)));
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("璁㈠崟鍙�", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(orderId, ClientTextStyleVO.COLOR_CONTENT)));
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("鍘熷洜", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO("璇蜂粩缁嗘牳瀵硅鍗曞彿鏄惁杈撳叆閿欒锛屽鏈夌枒闂鑱旂郴浜哄伐瀹㈡湇", ClientTextStyleVO.COLOR_CONTENT)));
+		listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("澶囨敞", ClientTextStyleVO.COLOR_TITLE),
+				new ClientTextStyleVO(StringUtil.isNullOrEmpty(beiZhu)?"鏃�" : beiZhu, ClientTextStyleVO.COLOR_CONTENT)));
+		
+		MsgOrderDetail detail = new MsgOrderDetail();
+		detail.setOrderId(orderId);
+		detail.setType(MsgTypeOrderTypeEnum.foundFail);
+		detail.setUser(new UserInfo(uid));
+		detail.setRead(false);
+		detail.setCreateTime(new Date());
+		detail.setExtraInfo(new Gson().toJson(listMsg));
+		return detail;
+	}
+	
 }

--
Gitblit v1.8.0