From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java |  489 +++++++++++++++++++++++++++--------------------------
 1 files changed, 250 insertions(+), 239 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java
index 43b3af9..88da675 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java
@@ -1,239 +1,250 @@
-package com.yeshi.fanli.service.impl.push;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.Resource;
-
-import com.yeshi.fanli.dto.push.PushBaseContent;
-import com.yeshi.fanli.entity.SystemEnum;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-
-import com.yeshi.fanli.dto.push.PushTypeEnum;
-import com.yeshi.fanli.entity.AppVersionInfo;
-import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
-import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum;
-import com.yeshi.fanli.entity.push.DeviceTokenVIVO;
-import com.yeshi.fanli.exception.push.PushException;
-import com.yeshi.fanli.log.PushLogHelper;
-import com.yeshi.fanli.service.inter.config.AppVersionService;
-import com.yeshi.fanli.service.inter.push.DeviceTokenVIVOService;
-import com.yeshi.fanli.service.inter.push.VIVOPushService;
-import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.push.VIVOPushUtil;
-
-@Service
-public class VIVOPushServiceImpl implements VIVOPushService {
-
-	@Resource
-	private DeviceTokenVIVOService deviceTokenVIVOService;
-
-	@Resource
-	private AppVersionService appVersionService;
-
-	@Resource
-	private UserCustomSettingsService userCustomSettingsService;
-
-	private List<Integer> getVersionCodeList(List<Integer> versionCodeList, SystemEnum system) {
-		List<Integer> versionList = new ArrayList<>();
-		if (versionCodeList == null) {// 鍏ㄦ帹
-			List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 51,system);
-			if (appInfoList != null)
-				for (AppVersionInfo version : appInfoList) {
-					versionList.add(version.getVersionCode());
-				}
-
-		} else {// 鎸夌増鏈帹閫�
-			for (Integer versionCode : versionCodeList) {
-				if (versionCode.intValue() >= 51) {// 2.0.1寮�濮嬫敮鎸�
-					versionList.add(versionCode);
-				}
-			}
-		}
-		return versionList;
-	}
-
-	@Async("pushExecutor")
-	@Override
-	public void pushGoods(Long uid, Long auctionId, PushBaseContent content)
-			throws PushException {
-		push(PushTypeEnum.goodsdetail, uid,  null, null, auctionId, content);
-	}
-
-	@Async("pushExecutor")
-	@Override
-	public void pushUrl(Long uid, String url, PushBaseContent content)
-			throws PushException {
-		push(PushTypeEnum.url, uid, null, url, null, content);
-	}
-
-	@Async("pushExecutor")
-	@Override
-	public void pushZNX(Long uid, PushBaseContent content) throws PushException {
-		push(PushTypeEnum.ZNX, uid,  null, null, null, content);
-	}
-
-	@Async("pushExecutor")
-	@Override
-	public void pushWEEX(Long uid,  String weexUrl, PushBaseContent content)
-			throws PushException {
-		push(PushTypeEnum.weex, uid,  weexUrl, null, null, content);
-	}
-
-	@Async("pushExecutor")
-	@Override
-	public void pushBaiChuanUrl(Long uid, String url, PushBaseContent content)
-			throws PushException {
-
-		push(PushTypeEnum.baichuan, uid,  null, url, null, content);
-	}
-
-	@Async("pushExecutor")
-	@Override
-	public void pushWelfareCenter(Long uid, PushBaseContent content)
-			throws PushException {
-		push(PushTypeEnum.welfare, uid,  null, null, null, content);
-	}
-
-	@Override
-	public void pushUserSignInNotification(Long uid, PushBaseContent content)
-			throws PushException {
-		push(PushTypeEnum.signin, uid, null, null, null, content);
-	}
-
-	private List<DeviceTokenVIVO> filterDeviceToken(List<DeviceTokenVIVO> deviceList, int hour) {
-		// TODO 娑堟伅鍏嶆墦鎵板叧闂�
-		if (1 > 0)
-			return deviceList;
-		// 澶勭悊娑堟伅鍏嶆墦鎵�
-		if (hour >= 20 || hour < 8) {
-			Set<Long> uidSets = new HashSet<>();
-			for (DeviceTokenVIVO dt : deviceList)
-				if (dt.getUid() != null)
-					uidSets.add(dt.getUid());
-			List<Long> uidList = new ArrayList<>();
-			uidList.addAll(uidSets);
-			List<UserCustomSettings> settingList = userCustomSettingsService.listByUidListAndTypeAndState(uidList,
-					UserSettingTypeEnum.cancelNotice.name(), UserCustomSettings.STATE_VALID);
-			uidSets.clear();
-			if (settingList != null) {
-				for (UserCustomSettings seeting : settingList)
-					uidSets.add(seeting.getUserInfo().getId());
-			}
-			if (uidSets.size() > 0)
-				for (int i = 0; i < deviceList.size(); i++) {
-					if (deviceList.get(i).getUid() != null && uidSets.contains(deviceList.get(i).getUid())) {
-						deviceList.remove(i--);
-					}
-				}
-		}
-		return deviceList;
-	}
-
-	/**
-	 * 鎺ㄩ��
-	 * 
-	 * @param type
-	 * @param uid
-	 * @param content
-	 * @param url
-	 * @param webUrl
-	 */
-	private void push(PushTypeEnum type, Long uid, String url, String webUrl,
-			Long goodsId, PushBaseContent content) throws PushException {
-		int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
-		List<Integer> newVersionList = getVersionCodeList(content.getVersionCodeList(),content.getSystem());
-		// 2.0.1鍚庡紑濮嬫帹閫�
-		for (int i = 0; i < newVersionList.size(); i++) {
-			if (newVersionList.get(i) < 51)
-				newVersionList.remove(i--);
-		}
-
-		if (uid == null || uid == 0) {
-			int pageSize = 200;
-			long deviceCount = deviceTokenVIVOService.countDeviceToken(newVersionList);
-			int page = (int) (deviceCount % pageSize == 0 ? deviceCount / pageSize : deviceCount / pageSize + 1);
-			for (int p = 1; p <= page; p++) {
-				List<DeviceTokenVIVO> deviceList = deviceTokenVIVOService.listDeviceToken(p, pageSize, newVersionList);
-				deviceList = filterDeviceToken(deviceList, hour);
-
-				List<String> tokenList = new ArrayList<>();
-				for (DeviceTokenVIVO token : deviceList)
-					tokenList.add(token.getRegisterId());
-				try {
-					if (type == PushTypeEnum.goodsdetail) {// 鍟嗗搧璇︽儏
-						if (goodsId == null)
-							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-						VIVOPushUtil.pushGoods(tokenList, content.getTitle(),content.getContent(), 1, goodsId);
-					} else if (type == PushTypeEnum.url) {// 閾炬帴
-						if (StringUtil.isNullOrEmpty(webUrl))
-							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-						VIVOPushUtil.pushUrl(tokenList,  content.getTitle(),content.getContent(),  webUrl);
-					} else if (type == PushTypeEnum.ZNX) {// 绔欏唴淇�
-						VIVOPushUtil.pushZNX(tokenList,  content.getTitle(),content.getContent());
-					} else if (type == PushTypeEnum.weex) {// weex
-						if (StringUtil.isNullOrEmpty(url))
-							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-						VIVOPushUtil.pushWEEX(tokenList,  content.getTitle(),content.getContent(),  url);
-					} else if (type == PushTypeEnum.baichuan) {// 鐧惧窛閾炬帴
-						if (StringUtil.isNullOrEmpty(webUrl))
-							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-						VIVOPushUtil.pushBaiChuanUrl(tokenList,  content.getTitle(),content.getContent(),  webUrl);
-					} else if (type == PushTypeEnum.welfare) {// 绂忓埄涓績
-						VIVOPushUtil.pushWelfareCenter(tokenList,  content.getTitle(),content.getContent());
-					} else if (type == PushTypeEnum.signin) {// 绛惧埌
-						VIVOPushUtil.pushUserSignInNotification(tokenList,  content.getTitle(),content.getContent());
-					}
-				} catch (Exception e) {
-					PushLogHelper.hwError(e);
-				}
-
-			}
-		} else {
-			// 鍗曟帹
-			List<DeviceTokenVIVO> deviceList = deviceTokenVIVOService.listByUid(uid, newVersionList);
-			List<String> tokenList = new ArrayList<>();
-			if (deviceList != null) {
-				deviceList = filterDeviceToken(deviceList, hour);
-				for (DeviceTokenVIVO token : deviceList)
-					tokenList.add(token.getRegisterId());
-			}
-			if (tokenList.size() == 0)
-				return;
-
-			try {
-				if (type == PushTypeEnum.goodsdetail) {// 鍟嗗搧璇︽儏
-					if (goodsId == null)
-						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-					VIVOPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
-				} else if (type == PushTypeEnum.url) {// 閾炬帴
-					if (StringUtil.isNullOrEmpty(webUrl))
-						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-					VIVOPushUtil.pushUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
-				} else if (type == PushTypeEnum.ZNX) {// 绔欏唴淇�
-					VIVOPushUtil.pushZNX(tokenList, content.getTitle(), content.getContent());
-				} else if (type == PushTypeEnum.weex) {// weex
-					if (StringUtil.isNullOrEmpty(url))
-						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-					VIVOPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url);
-				} else if (type == PushTypeEnum.baichuan) {// 鐧惧窛閾炬帴
-					if (StringUtil.isNullOrEmpty(webUrl))
-						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
-					VIVOPushUtil.pushBaiChuanUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
-				} else if (type == PushTypeEnum.welfare) {// 绂忓埄涓績
-					VIVOPushUtil.pushWelfareCenter(tokenList, content.getTitle(), content.getContent());
-				} else if (type == PushTypeEnum.signin) {// 绛惧埌
-					VIVOPushUtil.pushUserSignInNotification(tokenList,content.getTitle(), content.getContent());
-				}
-			} catch (Exception e) {
-				PushLogHelper.vivoError(e);
-			}
-
-		}
-	}
-}
+package com.yeshi.fanli.service.impl.push;
+
+import java.util.*;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.dto.push.PushBaseContent;
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.config.SystemConfigKeyEnum;
+import com.yeshi.fanli.service.inter.config.SystemConfigService;
+import com.yeshi.fanli.util.Constant;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import com.yeshi.fanli.dto.push.PushTypeEnum;
+import com.yeshi.fanli.entity.AppVersionInfo;
+import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
+import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum;
+import com.yeshi.fanli.entity.push.DeviceTokenVIVO;
+import com.yeshi.fanli.exception.push.PushException;
+import com.yeshi.fanli.log.PushLogHelper;
+import com.yeshi.fanli.service.inter.config.AppVersionService;
+import com.yeshi.fanli.service.inter.push.DeviceTokenVIVOService;
+import com.yeshi.fanli.service.inter.push.VIVOPushService;
+import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.push.VIVOPushUtil;
+
+@Service
+public class VIVOPushServiceImpl implements VIVOPushService {
+
+	@Resource
+	private DeviceTokenVIVOService deviceTokenVIVOService;
+
+	@Resource
+	private AppVersionService appVersionService;
+
+	@Resource
+	private UserCustomSettingsService userCustomSettingsService;
+
+	@Resource
+	private SystemConfigService systemConfigService;
+
+	private List<Integer> getVersionCodeList(List<Integer> versionCodeList,SystemEnum system) {
+		List<Integer> versionList = new ArrayList<>();
+		if (versionCodeList == null) {// 鍏ㄦ帹
+			List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 51,system);
+			if (appInfoList != null)
+				for (AppVersionInfo version : appInfoList) {
+					versionList.add(version.getVersionCode());
+				}
+
+		} else {// 鎸夌増鏈帹閫�
+			for (Integer versionCode : versionCodeList) {
+				if (versionCode.intValue() >= 51) {// 2.0.1寮�濮嬫敮鎸�
+					versionList.add(versionCode);
+				}
+			}
+		}
+		return versionList;
+	}
+
+	@Async("pushExecutor")
+	@Override
+	public void pushGoods(Long uid, String auctionId, PushBaseContent content)
+			throws PushException {
+		push(PushTypeEnum.goodsdetail, uid,  null, null, auctionId, content);
+	}
+
+	@Async("pushExecutor")
+	@Override
+	public void pushUrl(Long uid, String url, PushBaseContent content)
+			throws PushException {
+		push(PushTypeEnum.url, uid, null, url, null, content);
+	}
+
+	@Async("pushExecutor")
+	@Override
+	public void pushZNX(Long uid, PushBaseContent content) throws PushException {
+		push(PushTypeEnum.ZNX, uid,  null, null, null, content);
+	}
+
+	@Async("pushExecutor")
+	@Override
+	public void pushWEEX(Long uid,  String weexUrl, PushBaseContent content)
+			throws PushException {
+		push(PushTypeEnum.weex, uid,  weexUrl, null, null, content);
+	}
+
+	@Async("pushExecutor")
+	@Override
+	public void pushBaiChuanUrl(Long uid, String url, PushBaseContent content)
+			throws PushException {
+
+		push(PushTypeEnum.baichuan, uid,  null, url, null, content);
+	}
+
+	@Async("pushExecutor")
+	@Override
+	public void pushWelfareCenter(Long uid, PushBaseContent content)
+			throws PushException {
+		push(PushTypeEnum.welfare, uid,  null, null, null, content);
+	}
+
+	@Override
+	public void pushUserSignInNotification(Long uid, PushBaseContent content)
+			throws PushException {
+		push(PushTypeEnum.signin, uid, null, null, null, content);
+	}
+
+	private List<DeviceTokenVIVO> filterDeviceToken(List<DeviceTokenVIVO> deviceList, int hour) {
+		// TODO 娑堟伅鍏嶆墦鎵板叧闂�
+		if (1 > 0)
+			return deviceList;
+		// 澶勭悊娑堟伅鍏嶆墦鎵�
+		if (hour >= 20 || hour < 8) {
+			Set<Long> uidSets = new HashSet<>();
+			for (DeviceTokenVIVO dt : deviceList)
+				if (dt.getUid() != null)
+					uidSets.add(dt.getUid());
+			List<Long> uidList = new ArrayList<>();
+			uidList.addAll(uidSets);
+			List<UserCustomSettings> settingList = userCustomSettingsService.listByUidListAndTypeAndState(uidList,
+					UserSettingTypeEnum.cancelNotice.name(), UserCustomSettings.STATE_VALID);
+			uidSets.clear();
+			if (settingList != null) {
+				for (UserCustomSettings seeting : settingList)
+					uidSets.add(seeting.getUserInfo().getId());
+			}
+			if (uidSets.size() > 0)
+				for (int i = 0; i < deviceList.size(); i++) {
+					if (deviceList.get(i).getUid() != null && uidSets.contains(deviceList.get(i).getUid())) {
+						deviceList.remove(i--);
+					}
+				}
+		}
+		return deviceList;
+	}
+
+	/**
+	 * 鎺ㄩ��
+	 * 
+	 * @param type
+	 * @param uid
+	 * @param content
+	 * @param url
+	 * @param webUrl
+	 */
+	private void push(PushTypeEnum type, Long uid, String url, String webUrl,
+			String goodsId, PushBaseContent content) throws PushException {
+
+		String androidBaseActivity=getAndroidBaseActivity(content.getSystem());
+		int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
+		List<Integer> newVersionList = getVersionCodeList(content.getVersionCodeList(),content.getSystem());
+		// 2.0.1鍚庡紑濮嬫帹閫�
+		for (int i = 0; i < newVersionList.size(); i++) {
+			if (newVersionList.get(i) < 51)
+				newVersionList.remove(i--);
+		}
+
+		if (uid == null || uid == 0) {
+			Date minUpdatetime=new Date(System.currentTimeMillis()- Constant.PUSH_MIN_TIME);
+			int pageSize = 200;
+			long deviceCount = deviceTokenVIVOService.countDeviceToken(newVersionList,minUpdatetime);
+			int page = (int) (deviceCount % pageSize == 0 ? deviceCount / pageSize : deviceCount / pageSize + 1);
+			for (int p = 1; p <= page; p++) {
+				List<DeviceTokenVIVO> deviceList = deviceTokenVIVOService.listDeviceToken(p, pageSize, newVersionList,minUpdatetime);
+				deviceList = filterDeviceToken(deviceList, hour);
+
+				List<String> tokenList = new ArrayList<>();
+				for (DeviceTokenVIVO token : deviceList)
+					tokenList.add(token.getRegisterId());
+				try {
+					if (type == PushTypeEnum.goodsdetail) {// 鍟嗗搧璇︽儏
+						if (goodsId == null)
+							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+						VIVOPushUtil.pushGoods(tokenList, content.getTitle(),content.getContent(), 1, goodsId,androidBaseActivity);
+					} else if (type == PushTypeEnum.url) {// 閾炬帴
+						if (StringUtil.isNullOrEmpty(webUrl))
+							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+						VIVOPushUtil.pushUrl(tokenList,  content.getTitle(),content.getContent(),  webUrl,androidBaseActivity);
+					} else if (type == PushTypeEnum.ZNX) {// 绔欏唴淇�
+						VIVOPushUtil.pushZNX(tokenList,  content.getTitle(),content.getContent());
+					} else if (type == PushTypeEnum.weex) {// weex
+						if (StringUtil.isNullOrEmpty(url))
+							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+						VIVOPushUtil.pushWEEX(tokenList,  content.getTitle(),content.getContent(),  url,androidBaseActivity);
+					} else if (type == PushTypeEnum.baichuan) {// 鐧惧窛閾炬帴
+						if (StringUtil.isNullOrEmpty(webUrl))
+							throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+						VIVOPushUtil.pushBaiChuanUrl(tokenList,  content.getTitle(),content.getContent(),  webUrl);
+					} else if (type == PushTypeEnum.welfare) {// 绂忓埄涓績
+						VIVOPushUtil.pushWelfareCenter(tokenList,  content.getTitle(),content.getContent(),androidBaseActivity);
+					} else if (type == PushTypeEnum.signin) {// 绛惧埌
+						VIVOPushUtil.pushUserSignInNotification(tokenList,  content.getTitle(),content.getContent(),androidBaseActivity);
+					}
+				} catch (Exception e) {
+					PushLogHelper.hwError(e);
+				}
+
+			}
+		} else {
+			// 鍗曟帹
+			List<DeviceTokenVIVO> deviceList = deviceTokenVIVOService.listByUid(uid, newVersionList);
+			List<String> tokenList = new ArrayList<>();
+			if (deviceList != null) {
+				deviceList = filterDeviceToken(deviceList, hour);
+				for (DeviceTokenVIVO token : deviceList)
+					tokenList.add(token.getRegisterId());
+			}
+			if (tokenList.size() == 0)
+				return;
+
+			try {
+				if (type == PushTypeEnum.goodsdetail) {// 鍟嗗搧璇︽儏
+					if (goodsId == null)
+						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+					VIVOPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId,androidBaseActivity);
+				} else if (type == PushTypeEnum.url) {// 閾炬帴
+					if (StringUtil.isNullOrEmpty(webUrl))
+						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+					VIVOPushUtil.pushUrl(tokenList, content.getTitle(), content.getContent(), webUrl,androidBaseActivity);
+				} else if (type == PushTypeEnum.ZNX) {// 绔欏唴淇�
+					VIVOPushUtil.pushZNX(tokenList, content.getTitle(), content.getContent());
+				} else if (type == PushTypeEnum.weex) {// weex
+					if (StringUtil.isNullOrEmpty(url))
+						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+					VIVOPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url,androidBaseActivity);
+				} else if (type == PushTypeEnum.baichuan) {// 鐧惧窛閾炬帴
+					if (StringUtil.isNullOrEmpty(webUrl))
+						throw new PushException(2, "鍙傛暟涓嶅畬鏁�");
+					VIVOPushUtil.pushBaiChuanUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
+				} else if (type == PushTypeEnum.welfare) {// 绂忓埄涓績
+					VIVOPushUtil.pushWelfareCenter(tokenList, content.getTitle(), content.getContent(),androidBaseActivity);
+				} else if (type == PushTypeEnum.signin) {// 绛惧埌
+					VIVOPushUtil.pushUserSignInNotification(tokenList,content.getTitle(), content.getContent(),androidBaseActivity);
+				}
+			} catch (Exception e) {
+				PushLogHelper.vivoError(e);
+			}
+
+		}
+	}
+
+	private String getAndroidBaseActivity(SystemEnum system) {
+
+		return systemConfigService.getValueCache(SystemConfigKeyEnum.androidBaseActivityName, system);
+
+	}
+}

--
Gitblit v1.8.0