From a489609934155d3a9417ebfd315afbadd1d9b95f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 19 三月 2019 12:21:32 +0800
Subject: [PATCH] 删除ExtractRecordDao

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java |  165 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 150 insertions(+), 15 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java
index e15f552..67c3a1b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java
@@ -14,6 +14,7 @@
 import com.yeshi.fanli.entity.xinge.PushRecord;
 import com.yeshi.fanli.exception.PushException;
 import com.yeshi.fanli.log.PushLogHelper;
+import com.yeshi.fanli.service.inter.config.AppVersionService;
 import com.yeshi.fanli.service.inter.push.XMPushService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.push.PushUtils;
@@ -25,9 +26,25 @@
 
 	@Resource
 	private AppVersionInfoMapper appVersionInfoMapper;
+	
+	@Resource
+	private AppVersionService appVersionService;
 
 	@Override
-	public void pushGoods(Long uid, Long auctionId, String title, String content) throws PushException {
+	public void pushGoods(Long uid, Long auctionId, String title, String content, List<String> listVersion) throws PushException {
+	
+		// 鏃犳渶浣庣増鏈檺鍒�
+		int minVersionCode = 0;
+		String appVersion = null;
+		if (listVersion != null && listVersion.size() > 0) {
+			appVersion = getCanPushVersions(minVersionCode, listVersion);
+			if (appVersion == null || appVersion.trim().length() ==0) {
+				throw new PushException(1, "灏忕背鎺ㄩ�佸け璐ワ紝鎺ㄩ�佺殑鐗堟湰杩囦綆锛�");
+			}
+		} else if (minVersionCode > 0) {
+			appVersion = getVersionByMinVersionCode(minVersionCode);
+		}
+
 		String gid = auctionId + "";
 		JSONObject json = new JSONObject();
 		// json.put("url", "http://item.taobao.com/item.htm?id=" + gid);// IOS浣跨敤
@@ -35,7 +52,11 @@
 		json.put("type", "goodsdetail");
 		json.put("miPushUrl", String.format("%s.ui.recommend.GoodsBrowserActivity",
 				Constant.systemCommonConfig.getAndroidBaseactivityName()));
-
+		// 鐗堟湰鎺ㄩ��
+		if (appVersion != null && appVersion.trim().length() > 0) {
+			json.put("app_version", appVersion);
+		}
+		
 		MessageInfo info = new MessageInfo();
 		info.setTitle(title);
 		info.setContent(content);
@@ -60,13 +81,30 @@
 	}
 
 	@Override
-	public void pushUrl(Long uid, String url, String title, String content) throws PushException {
+	public void pushUrl(Long uid, String url, String title, String content, List<String> listVersion) throws PushException {
+		// 鏃犳渶浣庣増鏈檺鍒�
+		int minVersionCode = 0;
+		String appVersion = null;
+		if (listVersion != null && listVersion.size() > 0) {
+			appVersion = getCanPushVersions(minVersionCode, listVersion);
+			if (appVersion == null || appVersion.trim().length() ==0) {
+				throw new PushException(1, "灏忕背鎺ㄩ�佸け璐ワ紝鎺ㄩ�佺殑鐗堟湰杩囦綆锛�");
+			}
+		} else if (minVersionCode > 0) {
+			appVersion = getVersionByMinVersionCode(minVersionCode);
+		}
+		
 		JSONObject json = new JSONObject();
 		json.put("url", url);
 		json.put("type", "url");
 		json.put("webUrl", url);
 		json.put("miPushUrl", String.format("%s.ui.invite.ShareBrowserActivity",
 				Constant.systemCommonConfig.getAndroidBaseactivityName()));
+		
+		// 鐗堟湰鎺ㄩ��
+		if (appVersion != null && appVersion.trim().length() > 0) {
+			json.put("app_version", appVersion);
+		}
 
 		MessageInfo info = new MessageInfo();
 		info.setTitle(title);
@@ -94,13 +132,24 @@
 	}
 
 	@Override
-	public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX) throws PushException {
+	public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX, List<String> listVersion) throws PushException {
+		
+		// 鏃犳渶浣庣増鏈檺鍒�
+		int minVersionCode = 0;
+		String appVersion = null;
+		if (listVersion != null && listVersion.size() > 0) {
+			appVersion = getCanPushVersions(minVersionCode, listVersion);
+			if (appVersion == null || appVersion.trim().length() == 0) {
+				throw new PushException(1, "灏忕背鎺ㄩ�佸け璐ワ紝鎺ㄩ�佺殑鐗堟湰杩囦綆锛�");
+			}
+		} else if (minVersionCode > 0) {
+			appVersion = getVersionByMinVersionCode(minVersionCode);
+		}
+		
 		MessageInfo info = new MessageInfo();
-
 		info.setPackageName(Constant.systemCommonConfig.getAndroidPackageName());
 
 		JSONObject contentJson = new JSONObject();
-
 		contentJson.put("isOpen", 0);
 		contentJson.put("createTime", java.lang.System.currentTimeMillis());
 
@@ -120,7 +169,11 @@
 			json.put("content", contentJson);
 			json.put("miPushUrl", String.format("%s.ui.mine.AppMailDetailActivity",
 					Constant.systemCommonConfig.getAndroidBaseactivityName()));
-
+			// 鐗堟湰鎺ㄩ��
+			if (appVersion != null && appVersion.trim().length() > 0) {
+				json.put("app_version", appVersion);
+			}
+			
 			PushRecord pushRecord = new PushRecord();
 
 			// 灏忕背 鍏ㄦ帹
@@ -149,6 +202,12 @@
 			json.put("content", contentJson);
 			json.put("miPushUrl", String.format("%s.ui.mine.AppMailDetailActivity",
 					Constant.systemCommonConfig.getAndroidBaseactivityName()));
+			
+			// 鐗堟湰鎺ㄩ��
+			if (appVersion != null && appVersion.trim().length() > 0) {
+				json.put("app_version", appVersion);
+			}
+			
 			// 灏忕背 鍗曟帹
 			try {
 				PushUtils.singlePushXiaoMi(info, json, pushRecord);
@@ -159,13 +218,28 @@
 	}
 
 	@Override
-	public void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException {
-		// TODO 鎺ㄩ�亀eex椤甸潰
+	public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listVersion) throws PushException {
+
+		// 璁剧疆鍙帹閫佺増鏈�,1.4.8浠ュ悗鐨勭増鏈彲鎺ㄩ��
+		int minVersionCode = 31;
+		String appVersion = null;
+		if (listVersion != null && listVersion.size() > 0) {
+			appVersion = getCanPushVersions(minVersionCode, listVersion);
+			if (appVersion == null || appVersion.trim().length() == 0) {
+				throw new PushException(1, "灏忕背鎺ㄩ�佸け璐ワ紝鎺ㄩ�佺殑鐗堟湰涓嶈兘浣庝簬1.4.8");
+			}
+		} else if (minVersionCode > 0) {
+			appVersion = getVersionByMinVersionCode(minVersionCode);
+		}
+				
 		JSONObject json = new JSONObject();
 		json.put("url", weexUrl);
 		json.put("type", "weex");
-		// 璁剧疆鍙帹閫佺増鏈�,1.4.8浠ュ悗鐨勭増鏈彲鎺ㄩ��
-		json.put("app_version", getVersionByMinVersionCode(31));
+		// 鐗堟湰鎺ㄩ��
+		if (appVersion != null && appVersion.trim().length() > 0) {
+			json.put("app_version", appVersion);
+		}
+		
 		MessageInfo info = new MessageInfo();
 		info.setTitle(title);
 		info.setContent(content);
@@ -204,14 +278,58 @@
 
 		return versions;
 	}
+	
+	/**
+	 * 鏌ヨ鑳芥帹閫佺増鏈彿
+	 * @param versionCode
+	 * @param listVersion
+	 * @return
+	 */
+	private String getCanPushVersions(int versionCode, List<String> listVersion) throws PushException{
+		List<AppVersionInfo> list = appVersionService.listByVersions(AppVersionInfo.PLATFORM_ANDROID, listVersion);
+		String versions = "";
+		
+		if (list != null) {
+			for (AppVersionInfo appVersion : list) {
+				Integer code =	appVersion.getVersionCode();
+				if (code != null && code >= versionCode) {
+					versions += appVersion.getVersion() + ",";
+				}
+			}
+		} else {
+			throw new PushException(1, "鎺ㄩ�佺殑鐗堟湰涓嶅瓨鍦紝璇锋牳瀹炵増鏈俊鎭�");
+		}
+		
+		if (versions.endsWith(",")) {
+			versions = versions.substring(0, versions.length() - 1);
+		}
+		
+		return versions;
+	}
 
 	@Override
-	public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
+	public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listVersion) throws PushException {
+	
+		// 璁剧疆鍙帹閫佺増鏈�,1.4.8浠ュ悗鐨勭増鏈彲鎺ㄩ��
+		int minVersionCode = 31;
+		String appVersion = null;
+		if (listVersion != null && listVersion.size() > 0) {
+			appVersion = getCanPushVersions(minVersionCode, listVersion);
+			if (appVersion == null || appVersion.trim().length() ==0) {
+				throw new PushException(1, "灏忕背鎺ㄩ�佸け璐ワ紝鎺ㄩ�佺殑鐗堟湰涓嶈兘浣庝簬1.4.8");
+			}
+			
+		} else if (minVersionCode > 0){
+			appVersion = getVersionByMinVersionCode(minVersionCode);
+		}
+		
 		JSONObject json = new JSONObject();
 		json.put("url", url);
 		json.put("type", "baichuan");
-		// 璁剧疆鍙帹閫佺増鏈�,1.4.8浠ュ悗鐨勭増鏈彲鎺ㄩ��
-		json.put("app_version", getVersionByMinVersionCode(31));
+		// 鐗堟湰鎺ㄩ��
+		if (appVersion != null && appVersion.trim().length() > 0) {
+			json.put("app_version", appVersion);
+		}
 
 		MessageInfo info = new MessageInfo();
 		info.setTitle(title);
@@ -237,11 +355,28 @@
 	}
 
 	@Override
-	public void pushWelfareCenter(Long uid, String title, String content) throws PushException {
+	public void pushWelfareCenter(Long uid, String title, String content, List<String> listVersion) throws PushException {
+		
+		// 1.5.1涔嬪悗鐨勭増鏈彲鎺ㄩ��
+		int minVersionCode = 36;
+		String appVersion = null;
+		if (listVersion != null && listVersion.size() > 0) {
+			appVersion = getCanPushVersions(minVersionCode, listVersion);
+			if (appVersion == null || appVersion.trim().length() ==0) {
+				throw new PushException(1, "灏忕背鎺ㄩ�佸け璐ワ紝鎺ㄩ�佺殑鐗堟湰涓嶈兘浣庝簬1.5.1");
+			}
+		} else if (minVersionCode > 0){
+			appVersion = getVersionByMinVersionCode(minVersionCode);
+		}
+		
 		JSONObject json = new JSONObject();
 		json.put("type", "welfare");
 		json.put("miPushUrl", String.format("%s.ui.mine.WelfareCenterActivity",
 				Constant.systemCommonConfig.getAndroidBaseactivityName()));
+		// 鐗堟湰鎺ㄩ��
+		if (appVersion != null && appVersion.trim().length() > 0) {
+			json.put("app_version", appVersion);
+		}
 
 		MessageInfo info = new MessageInfo();
 		info.setTitle(title);

--
Gitblit v1.8.0