From b3d001c65da02bdc83e92308cd23ed1525c98070 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 19 三月 2019 17:29:05 +0800 Subject: [PATCH] 删除 RecommendSectionGoods相关+推送版本调整 --- fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java | 180 ++++++++++------------------------------------------------- 1 files changed, 31 insertions(+), 149 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 67c3a1b..1dc1acb 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 @@ -1,20 +1,14 @@ package com.yeshi.fanli.service.impl.push; -import java.util.List; - -import javax.annotation.Resource; - +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import com.yeshi.fanli.dao.mybatis.AppVersionInfoMapper; -import com.yeshi.fanli.entity.AppVersionInfo; import com.yeshi.fanli.entity.bus.user.AccountMessage; import com.yeshi.fanli.entity.system.SystemZnx; import com.yeshi.fanli.entity.xinge.MessageInfo; 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; @@ -24,27 +18,10 @@ @Service public class XMPushServiceImpl implements XMPushService { - @Resource - private AppVersionInfoMapper appVersionInfoMapper; - - @Resource - private AppVersionService appVersionService; - + @Async("pushExecutor") @Override - public void pushGoods(Long uid, Long auctionId, String title, String content, List<String> listVersion) throws PushException { + public void pushGoods(Long uid, Long auctionId, String title, String content, String versions) 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浣跨敤 @@ -52,9 +29,10 @@ 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); + if (versions != null && versions.trim().length() > 0) { + json.put("app_version", versions); } MessageInfo info = new MessageInfo(); @@ -80,19 +58,9 @@ } } + @Async("pushExecutor") @Override - 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); - } + public void pushUrl(Long uid, String url, String title, String content, String versions) throws PushException { JSONObject json = new JSONObject(); json.put("url", url); @@ -102,8 +70,8 @@ Constant.systemCommonConfig.getAndroidBaseactivityName())); // 鐗堟湰鎺ㄩ�� - if (appVersion != null && appVersion.trim().length() > 0) { - json.put("app_version", appVersion); + if (versions != null && versions.trim().length() > 0) { + json.put("app_version", versions); } MessageInfo info = new MessageInfo(); @@ -128,23 +96,11 @@ info.setAlias(uid + ""); PushUtils.singlePushXiaoMi(info, json, pushRecord); } - } + @Async("pushExecutor") @Override - 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); - } + public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX, String versions) throws PushException { MessageInfo info = new MessageInfo(); info.setPackageName(Constant.systemCommonConfig.getAndroidPackageName()); @@ -169,9 +125,10 @@ 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); + if (versions != null && versions.trim().length() > 0) { + json.put("app_version", versions); } PushRecord pushRecord = new PushRecord(); @@ -204,8 +161,8 @@ Constant.systemCommonConfig.getAndroidBaseactivityName())); // 鐗堟湰鎺ㄩ�� - if (appVersion != null && appVersion.trim().length() > 0) { - json.put("app_version", appVersion); + if (versions != null && versions.trim().length() > 0) { + json.put("app_version", versions); } // 灏忕背 鍗曟帹 @@ -217,27 +174,17 @@ } } + @Async("pushExecutor") @Override - public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listVersion) throws PushException { + public void pushWEEX(Long uid, String title, String content, String weexUrl, String versions) 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"); + // 鐗堟湰鎺ㄩ�� - if (appVersion != null && appVersion.trim().length() > 0) { - json.put("app_version", appVersion); + if (versions != null && versions.trim().length() > 0) { + json.put("app_version", versions); } MessageInfo info = new MessageInfo(); @@ -264,72 +211,19 @@ } } - private String getVersionByMinVersionCode(int versionCode) { - List<AppVersionInfo> list = appVersionInfoMapper - .listByPlatformAndMinVersionCode(AppVersionInfo.PLATFORM_ANDROID, versionCode); - String versions = ""; - if (list != null) - for (AppVersionInfo appVersion : list) { - versions += appVersion.getVersion() + ","; - } - if (versions.endsWith(",")) - versions = versions.substring(0, versions.length() - 1); - - 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; - } - + @Async("pushExecutor") @Override - public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listVersion) throws PushException { + public void pushBaiChuanUrl(Long uid, String title, String content, String url, String versions) 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"); // 鐗堟湰鎺ㄩ�� - if (appVersion != null && appVersion.trim().length() > 0) { - json.put("app_version", appVersion); + if (versions != null && versions.trim().length() > 0) { + json.put("app_version", versions); } + MessageInfo info = new MessageInfo(); info.setTitle(title); @@ -351,31 +245,19 @@ info.setAlias(uid + ""); PushUtils.singlePushXiaoMi(info, json, pushRecord); } - } + @Async("pushExecutor") @Override - 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); - } + public void pushWelfareCenter(Long uid, String title, String content, String versions) throws PushException { 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); + if (versions != null && versions.trim().length() > 0) { + json.put("app_version", versions); } MessageInfo info = new MessageInfo(); -- Gitblit v1.8.0