From 4fb61ca224acdf33865a609606678309bf688d6a Mon Sep 17 00:00:00 2001 From: admin <2780501319@qq.com> Date: 星期一, 23 九月 2019 23:27:06 +0800 Subject: [PATCH] OPPO推送,提现优化 --- fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java | 76 +++++++++++++++++++------------------ 1 files changed, 39 insertions(+), 37 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java index 4712110..d31cd66 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java @@ -16,20 +16,22 @@ import com.yeshi.fanli.entity.bus.user.UserCustomSettings; import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum; import com.yeshi.fanli.entity.push.DeviceTokenHW; +import com.yeshi.fanli.entity.push.DeviceTokenOPPO; 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.DeviceTokenHWService; +import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService; import com.yeshi.fanli.service.inter.push.OPPOPushService; import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.push.HWPushUtil; +import com.yeshi.fanli.util.push.OPPOPushUtil; @Service public class OPPOPushServiceImpl implements OPPOPushService { @Resource - private DeviceTokenHWService deviceTokenHWService; + private DeviceTokenOPPOService deviceTokenOPPOService; @Resource private AppVersionService appVersionService; @@ -104,13 +106,13 @@ push(PushTypeEnum.signin, uid, title, content, null, null, null, versionCodeList); } - private List<DeviceTokenHW> filterDeviceToken(List<DeviceTokenHW> hwDeviceList, int hour) { + private List<DeviceTokenOPPO> filterDeviceToken(List<DeviceTokenOPPO> deviceList, int hour) { // 澶勭悊娑堟伅鍏嶆墦鎵� if (hour >= 20 || hour < 8) { Set<Long> uidSets = new HashSet<>(); - for (DeviceTokenHW dt : hwDeviceList) - if (dt.getUser() != null) - uidSets.add(dt.getUser().getId()); + for (DeviceTokenOPPO dt : deviceList) + if (dt.getUid() != null) + uidSets.add(dt.getUid()); List<Long> uidList = new ArrayList<>(); uidList.addAll(uidSets); List<UserCustomSettings> settingList = userCustomSettingsService.listByUidListAndTypeAndState(uidList, @@ -121,14 +123,13 @@ uidSets.add(seeting.getUserInfo().getId()); } if (uidSets.size() > 0) - for (int i = 0; i < hwDeviceList.size(); i++) { - if (hwDeviceList.get(i).getUser() != null - && uidSets.contains(hwDeviceList.get(i).getUser().getId())) { - hwDeviceList.remove(i--); + for (int i = 0; i < deviceList.size(); i++) { + if (deviceList.get(i).getUid() != null && uidSets.contains(deviceList.get(i).getUid())) { + deviceList.remove(i--); } } } - return hwDeviceList; + return deviceList; } /** @@ -153,38 +154,39 @@ } if (uid == null || uid == 0) { - long deviceCount = deviceTokenHWService.countDeviceToken(newVersionList); - int page = (int) (deviceCount % 100 == 0 ? deviceCount / 100 : deviceCount / 100 + 1); + int pageSize = 200; + long deviceCount = deviceTokenOPPOService.countDeviceToken(newVersionList); + int page = (int) (deviceCount % pageSize == 0 ? deviceCount / pageSize : deviceCount / pageSize + 1); for (int p = 1; p <= page; p++) { - List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenList(p, 100, newVersionList); - hwDeviceList = filterDeviceToken(hwDeviceList, hour); + List<DeviceTokenOPPO> deviceList = deviceTokenOPPOService.listDeviceToken(p, pageSize, newVersionList); + deviceList = filterDeviceToken(deviceList, hour); List<String> tokenList = new ArrayList<>(); - for (DeviceTokenHW token : hwDeviceList) - tokenList.add(token.getDeviceToken()); + for (DeviceTokenOPPO token : deviceList) + tokenList.add(token.getRegisterId()); try { if (type == PushTypeEnum.goodsdetail) {// 鍟嗗搧璇︽儏 if (goodsId == null) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId); + OPPOPushUtil.pushGoods(tokenList, title, content, 1, goodsId); } else if (type == PushTypeEnum.url) {// 閾炬帴 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushUrl(tokenList, title, content, webUrl); + OPPOPushUtil.pushUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.ZNX) {// 绔欏唴淇� - HWPushUtil.pushZNX(tokenList, title, content); + OPPOPushUtil.pushZNX(tokenList, title, content); } else if (type == PushTypeEnum.weex) {// weex if (StringUtil.isNullOrEmpty(url)) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushWEEX(tokenList, title, content, url); + OPPOPushUtil.pushWEEX(tokenList, title, content, url); } else if (type == PushTypeEnum.baichuan) {// 鐧惧窛閾炬帴 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); + OPPOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.welfare) {// 绂忓埄涓績 - HWPushUtil.pushWelfareCenter(tokenList, title, content); + OPPOPushUtil.pushWelfareCenter(tokenList, title, content); } else if (type == PushTypeEnum.signin) {// 绛惧埌 - HWPushUtil.pushUserSignInNotification(tokenList, title, content); + OPPOPushUtil.pushUserSignInNotification(tokenList, title, content); } } catch (Exception e) { PushLogHelper.hwError(e); @@ -193,12 +195,12 @@ } } else { // 鍗庝负鍗曟帹 - List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenByUid(uid, newVersionList); + List<DeviceTokenOPPO> deviceList = deviceTokenOPPOService.listByUid(uid, newVersionList); List<String> tokenList = new ArrayList<>(); - if (hwDeviceList != null) { - hwDeviceList = filterDeviceToken(hwDeviceList, hour); - for (DeviceTokenHW token : hwDeviceList) - tokenList.add(token.getDeviceToken()); + if (deviceList != null) { + deviceList = filterDeviceToken(deviceList, hour); + for (DeviceTokenOPPO token : deviceList) + tokenList.add(token.getRegisterId()); } if (tokenList.size() == 0) return; @@ -207,28 +209,28 @@ if (type == PushTypeEnum.goodsdetail) {// 鍟嗗搧璇︽儏 if (goodsId == null) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId); + OPPOPushUtil.pushGoods(tokenList, title, content, 1, goodsId); } else if (type == PushTypeEnum.url) {// 閾炬帴 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushUrl(tokenList, title, content, webUrl); + OPPOPushUtil.pushUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.ZNX) {// 绔欏唴淇� - HWPushUtil.pushZNX(tokenList, title, content); + OPPOPushUtil.pushZNX(tokenList, title, content); } else if (type == PushTypeEnum.weex) {// weex if (StringUtil.isNullOrEmpty(url)) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushWEEX(tokenList, title, content, url); + OPPOPushUtil.pushWEEX(tokenList, title, content, url); } else if (type == PushTypeEnum.baichuan) {// 鐧惧窛閾炬帴 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "鍙傛暟涓嶅畬鏁�"); - HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); + OPPOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.welfare) {// 绂忓埄涓績 - HWPushUtil.pushWelfareCenter(tokenList, title, content); + OPPOPushUtil.pushWelfareCenter(tokenList, title, content); } else if (type == PushTypeEnum.signin) {// 绛惧埌 - HWPushUtil.pushUserSignInNotification(tokenList, title, content); + OPPOPushUtil.pushUserSignInNotification(tokenList, title, content); } } catch (Exception e) { - PushLogHelper.hwError(e); + PushLogHelper.oppoError(e); } } -- Gitblit v1.8.0