From 7384fd794b9bcb38cef7853cb55e56e810775678 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 09 八月 2019 14:27:02 +0800 Subject: [PATCH] 动态/品牌商品添加到重要商品更新库,推荐记录列表返回结果跳转任意更改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java | 230 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 130 insertions(+), 100 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java index e8d1a16..3451cf8 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java @@ -60,13 +60,12 @@ @Resource private AccountMessageMapper accountMessageMapper; - + @Resource private AppVersionService appVersionService; - - + @Override - public void pushGoods(Long uid, String title, String content, String url, List<String> listIOS, + public void pushGoods(Long uid, String title, String content, String url, List<String> listIOS, List<String> listAndroid) throws PushException { String gids = url.split("id=")[1]; String gid = gids.split("&")[0]; @@ -75,28 +74,33 @@ if (StringUtil.isNullOrEmpty(title)) throw new PushException(1, "璇峰~鍐欐帹閫佹爣棰�"); if (StringUtil.isNullOrEmpty(content)) - throw new PushException(1, "璇峰~鍐欐帹閫佸唴瀹�"); - - - /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + throw new PushException(1, "璇峰~鍐欐帹閫佸唴瀹�"); + + /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listIOS == null || listIOS.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); - if(listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { + String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); + if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { iosPushService.pushGoods(uid, Long.parseLong(gid), title, content, codes); } } - - /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listAndroid == null || listAndroid.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); - if(listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { + String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); + if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { xmPushService.pushGoods(uid, Long.parseLong(gid), title, content, versions); } + // 鍗庝负鎺ㄩ�� + if (listAndroid == null || listAndroid.size() > 0) { + List<Integer> versionCodeList = null; + if (listAndroid != null) + versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid); + hwPushService.pushGoods(uid, Long.parseLong(gid), title, content, versionCodeList); + } } - - + PushRecord pushRecord = new PushRecord(); pushRecord.setUid(uid); pushRecord.setState(1); @@ -109,7 +113,6 @@ pushRecordMapper.insertSelective(pushRecord); } - @Override public void pushUrl(Long uid, String title, String content, String url, List<String> listIOS, List<String> listAndroid) throws PushException { @@ -120,27 +123,33 @@ throw new PushException(1, "鏃犳帹閫佹爣棰�"); if (StringUtil.isNullOrEmpty(content)) throw new PushException(1, "鏃犳帹閫佸唴瀹�"); - - - /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listIOS == null || listIOS.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); - if(listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { + String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); + if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { iosPushService.pushUrl(uid, url, title, content, codes); } } - - /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listAndroid == null || listAndroid.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); - if(listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { + String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); + if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { xmPushService.pushUrl(uid, url, title, content, versions); } + + // 鍗庝负鎺ㄩ�� + if (listAndroid == null || listAndroid.size() > 0) { + List<Integer> versionCodeList = null; + if (listAndroid != null) + versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid); + hwPushService.pushUrl(uid, url, title, content, versionCodeList); + } } - - + PushRecord pushRecord = new PushRecord(); pushRecord.setUid(uid); pushRecord.setState(1); @@ -152,10 +161,9 @@ pushRecordMapper.insertSelective(pushRecord); } - @Override - public void pushZNX(Long uId, String title, String content, List<String> listIOS, - List<String> listAndroid) throws PushException { + public void pushZNX(Long uId, String title, String content, List<String> listIOS, List<String> listAndroid) + throws PushException { if (StringUtil.isNullOrEmpty(title)) throw new PushException(1, "鏃犳帹閫佹爣棰�"); if (StringUtil.isNullOrEmpty(content)) @@ -163,7 +171,7 @@ SystemZnx systemZnx = null; AccountMessage accountMessage = null; - + /* 鏃爑id , 骞挎挱 鏁版嵁鎻掑叆绯荤粺琛� */ if (uId == null || uId == 0) { // 鎻掑叆鏁版嵁搴擄紙绯荤粺绔欏唴淇℃暟鎹級 @@ -181,27 +189,33 @@ accountMessage.setContent(content); accountMessageMapper.insertSelective(accountMessage); } - - - /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listIOS == null || listIOS.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); - if(listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { + String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); + if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { iosPushService.pushZNX(uId, accountMessage, systemZnx, codes); } } - - /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listAndroid == null || listAndroid.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); - if(listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { + String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); + if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { xmPushService.pushZNX(uId, accountMessage, systemZnx, versions); } + + // 鍗庝负鎺ㄩ�� + if (listAndroid == null || listAndroid.size() > 0) { + List<Integer> versionCodeList = null; + if (listAndroid != null) + versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid); + hwPushService.pushZNX(uId, title, content, versionCodeList); + } } - - + // 鎻掑叆鎺ㄩ�佽褰� PushRecord pushRecord = new PushRecord(); pushRecord.setUid(uId); @@ -213,7 +227,6 @@ pushRecordMapper.insertSelective(pushRecord); } - @Override public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listIOS, List<String> listAndroid) throws PushException { @@ -221,28 +234,35 @@ throw new PushException(1, "鏃犳帹閫佹爣棰�"); if (StringUtil.isNullOrEmpty(content)) throw new PushException(1, "鏃犳帹閫佸唴瀹�"); - + // 閫傜敤鐗堟湰 1.4.8鍙婁互鍚� 鎺ㄩ�亀eex椤甸潰 - - /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listIOS == null || listIOS.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); - if(listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { + String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); + if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { iosPushService.pushWEEX(uid, title, content, weexUrl, codes); } } - - /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listAndroid == null || listAndroid.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�31 - String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); - if(listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { + String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid); + if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { xmPushService.pushWEEX(uid, title, content, weexUrl, versions); } } - - + + // 鍗庝负鎺ㄩ�� + if (listAndroid == null || listAndroid.size() > 0) { + List<Integer> versionCodeList = null; + if (listAndroid != null) + versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid); + hwPushService.pushWEEX(uid, title, content, weexUrl, versionCodeList); + } + // 鎻掑叆鎺ㄩ�佽褰� PushRecord pushRecord = new PushRecord(); pushRecord.setTitle(title); @@ -254,37 +274,43 @@ pushRecordMapper.insertSelective(pushRecord); } - @Override public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listIOS, List<String> listAndroid) throws PushException { - + if (StringUtil.isNullOrEmpty(title)) throw new PushException(1, "鏃犳帹閫佹爣棰�"); if (StringUtil.isNullOrEmpty(content)) throw new PushException(1, "鏃犳帹閫佸唴瀹�"); - + // 閫傜敤鐗堟湰 1.4.8鍙婁互鍚� 鎺ㄩ�佺櫨宸濈綉椤� - - /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listIOS == null || listIOS.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); - if(listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { + String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); + if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { iosPushService.pushBaiChuanUrl(uid, title, content, url, codes); } } - - /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listAndroid == null || listAndroid.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�31 - String versions = getEffectiveVersions(31, AppVersionInfo.PLATFORM_ANDROID, listAndroid); - if(listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { + String versions = getEffectiveVersions(31, AppVersionInfo.PLATFORM_ANDROID, listAndroid); + if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { xmPushService.pushBaiChuanUrl(uid, title, content, url, versions); } } - - + + // 鍗庝负鎺ㄩ�� + if (listAndroid == null || listAndroid.size() > 0) { + List<Integer> versionCodeList = null; + if (listAndroid != null) + versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid); + hwPushService.pushBaiChuanUrl(uid, title, content, url, versionCodeList); + } + // 鎻掑叆鎺ㄩ�佽褰� PushRecord pushRecord = new PushRecord(); pushRecord.setUrl(url); @@ -297,36 +323,41 @@ pushRecordMapper.insertSelective(pushRecord); } - @Override public void pushWelfareCenter(Long uid, String title, String content, List<String> listIOS, List<String> listAndroid) throws PushException { - + if (StringUtil.isNullOrEmpty(title)) throw new PushException(1, "鏃犳帹閫佹爣棰�"); if (StringUtil.isNullOrEmpty(content)) throw new PushException(1, "鏃犳帹閫佸唴瀹�"); - - - /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* IOS绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listIOS == null || listIOS.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�0 - String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); - if(listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { + String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS); + if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { iosPushService.pushWelfareCenter(uid, title, content, codes); } } - - /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ + + /* Android绔帹閫� (娉ㄦ槑锛歭ist绛変簬 'null' 鏃跺叏鎺紝 size绛変簬0 涓嶅仛鎺ㄩ��) */ if (listAndroid == null || listAndroid.size() > 0) { // 闄愬埗鎺ㄩ�佺増鏈彿锛�36 - String versions = getEffectiveVersions(36, AppVersionInfo.PLATFORM_ANDROID, listAndroid); - if(listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { + String versions = getEffectiveVersions(36, AppVersionInfo.PLATFORM_ANDROID, listAndroid); + if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { xmPushService.pushWelfareCenter(uid, title, content, versions); } } - - + + // 鍗庝负鎺ㄩ�� + if (listAndroid == null || listAndroid.size() > 0) { + List<Integer> versionCodeList = null; + if (listAndroid != null) + versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid); + hwPushService.pushWelfareCenter(uid, title, content, versionCodeList); + } + // 鎻掑叆鎺ㄩ�佽褰� PushRecord pushRecord = new PushRecord(); pushRecord.setTitle(title); @@ -338,20 +369,19 @@ pushRecordMapper.insertSelective(pushRecord); } - - /** * 鏌ヨ鑳芥帹閫佺増鏈彿 + * * @param versionCode * @param listVersion * @return */ - private String getEffectiveVersions(int minCode, String type, List<String> listVersion) throws PushException{ - + private String getEffectiveVersions(int minCode, String type, List<String> listVersion) throws PushException { + if (minCode == 0 && listVersion == null) { return null; } - + String versions = ""; if (listVersion == null) { List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode); @@ -364,34 +394,34 @@ List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion); if (list != null) { for (AppVersionInfo appVersion : list) { - Integer code = appVersion.getVersionCode(); + Integer code = appVersion.getVersionCode(); if (code != null && code >= minCode) { versions += appVersion.getVersion() + ","; } } - } + } } - + if (versions.endsWith(",")) { versions = versions.substring(0, versions.length() - 1); } - + return versions; } - - + /** * 鏌ヨ鑳芥帹閫佺増鏈彿code + * * @param versionCode * @param listVersion * @return */ - private String getEffectiveVersionCodes(int minCode, String type, List<String> listVersion) throws PushException{ - + private String getEffectiveVersionCodes(int minCode, String type, List<String> listVersion) throws PushException { + if (minCode == 0 && listVersion == null) { return null; } - + String versionCodes = ""; if (listVersion == null) { List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode); @@ -404,19 +434,19 @@ List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion); if (list != null) { for (AppVersionInfo appVersion : list) { - Integer code = appVersion.getVersionCode(); + Integer code = appVersion.getVersionCode(); if (code != null && code >= minCode) { versionCodes += appVersion.getVersionCode() + ","; } } - } + } } - + if (versionCodes.endsWith(",")) { versionCodes = versionCodes.substring(0, versionCodes.length() - 1); } - + return versionCodes; } - + } -- Gitblit v1.8.0