admin
2024-04-26 5e7b0ed4a154ad067cbcf4aa1a1c7cce32f9864c
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java
@@ -7,12 +7,14 @@
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum;
import com.yeshi.fanli.entity.config.SystemConfigKeyEnum;
import com.yeshi.fanli.entity.push.DeviceTokenHW;
import com.yeshi.fanli.exception.push.PushException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.LogManager;
import com.yeshi.fanli.log.PushLogHelper;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.config.SystemConfigService;
import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
import com.yeshi.fanli.service.inter.push.HWPushService;
import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
@@ -37,7 +39,10 @@
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    private List<Integer> getVersionCodeList(List<Integer> versionCodeList, SystemEnum system) {
    @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", 46, system);
@@ -57,7 +62,7 @@
    }
    @Override
    public void pushGoods(Long uid, Long auctionId, PushBaseContent baseContent)
    public void pushGoods(Long uid, String auctionId, PushBaseContent baseContent)
            throws PushException {
        addPushQueue(PushTypeEnum.goodsdetail, uid, null, null, auctionId, baseContent);
    }
@@ -130,7 +135,7 @@
    //添加到推送队列
    private void addPushQueue(PushTypeEnum type, Long uid, String url, String webUrl,
                              Long goodsId, PushBaseContent content) {
                              String goodsId, PushBaseContent content) {
        //添加到推送队列
        PushContentDetailDTO dto = new PushContentDetailDTO(type, uid, url, webUrl, goodsId, content);
        PushCMQManager.getInstance().addHWPush(dto);
@@ -159,7 +164,7 @@
            for (int p = 1; p <= page; p++) {
                List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenList(p, 100, newVersionList, minUpdateTime);
                hwDeviceList = filterDeviceToken(hwDeviceList, hour);
                LogHelper.pushHW(String.format("全推:设备数%s",hwDeviceList.size()));
                LogHelper.pushHW(String.format("全推:设备数%s", hwDeviceList.size()));
                List<String> tokenList = new ArrayList<>();
                for (DeviceTokenHW token : hwDeviceList)
                    tokenList.add(token.getDeviceToken());
@@ -167,25 +172,25 @@
                    if (dto.getType() == PushTypeEnum.goodsdetail) {// 商品详情
                        if (dto.getGoodsId() == null)
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushGoods(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), 1, dto.getGoodsId());
                        HWPushUtil.pushGoods(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), 1, dto.getGoodsId(),getAndroidBaseActivity( dto.getContent().getSystem()));
                    } else if (dto.getType() == PushTypeEnum.url) {// 链接
                        if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                        HWPushUtil.pushUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl(),getAndroidBaseActivity(dto.getContent().getSystem()));
                    } else if (dto.getType() == PushTypeEnum.ZNX) {// 站内信
                        HWPushUtil.pushZNX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                    } else if (dto.getType() == PushTypeEnum.weex) {// weex
                        if (StringUtil.isNullOrEmpty(dto.getUrl()))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushWEEX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getUrl());
                        HWPushUtil.pushWEEX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getUrl(),getAndroidBaseActivity(dto.getContent().getSystem()));
                    } else if (dto.getType() == PushTypeEnum.baichuan) {// 百川链接
                        if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushBaiChuanUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                    } else if (dto.getType() == PushTypeEnum.welfare) {// 福利中心
                        HWPushUtil.pushWelfareCenter(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                        HWPushUtil.pushWelfareCenter(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(),getAndroidBaseActivity(dto.getContent().getSystem()));
                    } else if (dto.getType() == PushTypeEnum.signin) {// 签到
                        HWPushUtil.pushUserSignInNotification(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                        HWPushUtil.pushUserSignInNotification(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(),getAndroidBaseActivity(dto.getContent().getSystem()));
                    }
                } catch (Exception e) {
                    PushLogHelper.hwError(e);
@@ -203,7 +208,7 @@
                    tokenList.add(token.getDeviceToken());
            }
            LogHelper.pushHW(String.format("单推:设备数%s 用户:%s",hwDeviceList.size(),dto.getUid()+""));
            LogHelper.pushHW(String.format("单推:设备数%s 用户:%s", hwDeviceList.size(), dto.getUid() + ""));
            if (tokenList.size() == 0)
                return;
@@ -212,25 +217,25 @@
                if (dto.getType() == PushTypeEnum.goodsdetail) {// 商品详情
                    if (dto.getGoodsId() == null)
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushGoods(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), 1, dto.getGoodsId());
                    HWPushUtil.pushGoods(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), 1, dto.getGoodsId(),getAndroidBaseActivity(dto.getContent().getSystem()));
                } else if (dto.getType() == PushTypeEnum.url) {// 链接
                    if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                    HWPushUtil.pushUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl(),getAndroidBaseActivity(dto.getContent().getSystem()));
                } else if (dto.getType() == PushTypeEnum.ZNX) {// 站内信
                    HWPushUtil.pushZNX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                } else if (dto.getType() == PushTypeEnum.weex) {// weex
                    if (StringUtil.isNullOrEmpty(dto.getUrl()))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushWEEX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getUrl());
                    HWPushUtil.pushWEEX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getUrl(),getAndroidBaseActivity(dto.getContent().getSystem()));
                } else if (dto.getType() == PushTypeEnum.baichuan) {// 百川链接
                    if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushBaiChuanUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                } else if (dto.getType() == PushTypeEnum.welfare) {// 福利中心
                    HWPushUtil.pushWelfareCenter(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                    HWPushUtil.pushWelfareCenter(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(),getAndroidBaseActivity(dto.getContent().getSystem()));
                } else if (dto.getType() == PushTypeEnum.signin) {// 签到
                    HWPushUtil.pushUserSignInNotification(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                    HWPushUtil.pushUserSignInNotification(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(),getAndroidBaseActivity(dto.getContent().getSystem()));
                }
            } catch (Exception e) {
                PushLogHelper.hwError(e);
@@ -238,4 +243,10 @@
        }
    }
    private String getAndroidBaseActivity(SystemEnum system) {
        return systemConfigService.getValueCache(SystemConfigKeyEnum.androidBaseActivityName, system);
    }
}