| | |
| | | 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.controller.admin.PushController;
|
| | | import com.yeshi.fanli.dao.mybatis.AccountMessageMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.push.PushRecordMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.system.SystemZnx;
|
| | | import com.yeshi.fanli.entity.xinge.PushRecord;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
|
| | | import com.yeshi.fanli.service.inter.push.HWPushService;
|
| | | import com.yeshi.fanli.service.inter.push.IOSPushService;
|
| | | import com.yeshi.fanli.service.inter.push.PushRecordService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.push.XMPushService;
|
| | | import com.yeshi.fanli.service.inter.user.AccountMessageService;
|
| | | import com.yeshi.fanli.service.inter.user.SystemZnxService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class PushServiceImpl implements PushService {
|
| | |
|
| | | static String IOSBundleId = "";
|
| | | static String PROJECT_NAME = "";
|
| | |
|
| | | static {
|
| | | IOSBundleId = Constant.systemCommonConfig.getIosBundleId();
|
| | | PROJECT_NAME = Constant.systemCommonConfig.getProjectChineseName();
|
| | | }
|
| | |
|
| | | @Resource
|
| | | private PushRecordService pushRecordService;
|
| | |
|
| | | @Resource
|
| | | private SystemZnxService systemZnxService;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageService accountMessageService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenHWService deviceTokenHWService;
|
| | |
|
| | | @Resource
|
| | | private IOSPushService iosPushService;
|
| | |
|
| | | @Resource
|
| | | private HWPushService hwPushService;
|
| | |
|
| | | @Resource
|
| | | private XMPushService xmPushService;
|
| | |
|
| | | @Resource
|
| | | private PushRecordMapper pushRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageMapper accountMessageMapper;
|
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushGoods(Long uid, String url, String title, String content, List<String> listVersion) throws PushException {
|
| | | String gids = url.split("id=")[1];
|
| | | String gid = gids.split("&")[0];
|
| | | if (StringUtil.isNullOrEmpty(gid))
|
| | | throw new PushException(1, "商品解析失败");
|
| | | if (StringUtil.isNullOrEmpty(title))
|
| | | throw new PushException(1, "请填写推送标题");
|
| | | if (StringUtil.isNullOrEmpty(content))
|
| | | throw new PushException(1, "请填写推送内容"); |
| | |
|
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setState(1);
|
| | | pushRecord.setType(PushController.GOODS); // 都成功
|
| | | pushRecord.setUrl(url);
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setAccount(1);
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | |
|
| | | xmPushService.pushGoods(uid, Long.parseLong(gid), title, content, listVersion);
|
| | | iosPushService.pushGoods(uid, Long.parseLong(gid), title, content, listVersion);
|
| | | // hwPushService.pushGoods(uid, Long.parseLong(gid), title, content);
|
| | |
|
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | | }
|
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushUrl(Long uid, String url, String title, String content, List<String> listVersion) throws PushException {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(url))
|
| | | throw new PushException(1, "无推送链接");
|
| | | if (StringUtil.isNullOrEmpty(title))
|
| | | throw new PushException(1, "无推送标题");
|
| | | if (StringUtil.isNullOrEmpty(content))
|
| | | throw new PushException(1, "无推送内容");
|
| | |
|
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setState(1);
|
| | | pushRecord.setType(PushController.URL);
|
| | | pushRecord.setUrl(url);
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | |
|
| | | xmPushService.pushUrl(uid, url, title, content, listVersion);
|
| | | iosPushService.pushUrl(uid, url, title, content, listVersion);
|
| | | hwPushService.pushUrl(uid, url, title, content, listVersion);
|
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | | }
|
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushZNX(Long uId, String title, String content, List<String> listVersion) throws PushException {
|
| | | if (StringUtil.isNullOrEmpty(title))
|
| | | throw new PushException(1, "无推送标题");
|
| | | if (StringUtil.isNullOrEmpty(content))
|
| | | throw new PushException(1, "无推送内容");
|
| | |
|
| | | /* 无uid , 广播 数据插入系统表 */
|
| | | if (uId == null || uId == 0) {
|
| | | // 插入数据库(系统站内信数据)
|
| | | SystemZnx systemZnx = new SystemZnx();
|
| | | systemZnx.setTitle(title);
|
| | | systemZnx.setContent(content);
|
| | | systemZnx.setCreateTime(System.currentTimeMillis());
|
| | | systemZnxService.save(systemZnx);
|
| | |
|
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setState(1); // 成功
|
| | | pushRecord.setType(4); // 类型:站内信
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | |
| | | xmPushService.pushZNX(uId, null, systemZnx, listVersion);
|
| | | iosPushService.pushZNX(uId, null, systemZnx, listVersion);
|
| | | hwPushService.pushZNX(uId, null, systemZnx, listVersion);
|
| | | // 插入推送记录
|
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | | } else {
|
| | | AccountMessage accountMessage = new AccountMessage();
|
| | | accountMessage.setCreateTime(System.currentTimeMillis());
|
| | | accountMessage.setIsOpen(false);
|
| | | accountMessage.setUserInfo(new UserInfo(uId));
|
| | | accountMessage.setTitle(title);
|
| | | accountMessage.setContent(content);
|
| | | accountMessageMapper.insertSelective(accountMessage);
|
| | |
|
| | | xmPushService.pushZNX(uId, accountMessage, null, listVersion);
|
| | | iosPushService.pushZNX(uId, accountMessage, null, listVersion);
|
| | | hwPushService.pushZNX(uId, accountMessage, null, listVersion);
|
| | |
|
| | | // 插入推送记录
|
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setUid(uId);
|
| | | pushRecord.setState(1); // 成功
|
| | | pushRecord.setType(PushController.ZNX); // 类型:站内信
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | |
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listVersion) throws PushException {
|
| | | if (StringUtil.isNullOrEmpty(title))
|
| | | throw new PushException(1, "无推送标题");
|
| | | if (StringUtil.isNullOrEmpty(content))
|
| | | throw new PushException(1, "无推送内容");
|
| | | iosPushService.pushWEEX(uid, title, content, weexUrl, listVersion);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listVersion) throws PushException {
|
| | | iosPushService.pushBaiChuanUrl(uid, title, content, url, listVersion);
|
| | | xmPushService.pushBaiChuanUrl(uid, title, content, url, listVersion);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWelfareCenter(Long uid, String title, String content, List<String> listVersion) throws PushException {
|
| | | iosPushService.pushWelfareCenter(uid, title, content, listVersion);
|
| | | xmPushService.pushWelfareCenter(uid, title, content, listVersion);
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.push; |
| | | |
| | | import com.ks.push.exception.BPushTaskException; |
| | | import com.ks.push.pojo.DO.BPushFilter; |
| | | import com.ks.push.pojo.DO.BPushMessage; |
| | | import com.ks.push.pojo.DO.BPushTask; |
| | | import com.ks.push.service.BPushTaskService; |
| | | import com.yeshi.fanli.dao.mybatis.AccountMessageMapper; |
| | | import com.yeshi.fanli.dao.mybatis.push.PushRecordMapper; |
| | | import com.yeshi.fanli.dto.push.PushBaseContent; |
| | | import com.yeshi.fanli.dto.push.PushTypeEnum; |
| | | import com.yeshi.fanli.entity.AppVersionInfo; |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.common.JumpDetailV2; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.entity.system.SystemZnx; |
| | | import com.yeshi.fanli.entity.xinge.PushRecord; |
| | | import com.yeshi.fanli.exception.push.PushException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; |
| | | import com.yeshi.fanli.service.inter.config.AppVersionService; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService; |
| | | import com.yeshi.fanli.service.inter.push.*; |
| | | import com.yeshi.fanli.service.inter.user.SystemZnxService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class PushServiceImpl implements PushService { |
| | | Logger logger = LoggerFactory.getLogger(PushService.class); |
| | | |
| | | static String PROJECT_NAME = ""; |
| | | |
| | | static { |
| | | PROJECT_NAME = Constant.systemCommonConfig.getProjectChineseName(); |
| | | } |
| | | |
| | | @Resource |
| | | private SystemZnxService systemZnxService; |
| | | |
| | | @Resource |
| | | private IOSPushService iosPushService; |
| | | |
| | | @Resource |
| | | private HWPushService hwPushService; |
| | | |
| | | @Resource |
| | | private XMPushService xmPushService; |
| | | |
| | | @Resource |
| | | private OPPOPushService oPPOPushService; |
| | | |
| | | @Resource |
| | | private VIVOPushService vIVOPushService; |
| | | |
| | | @Resource |
| | | private PushRecordMapper pushRecordMapper; |
| | | |
| | | @Resource |
| | | private AccountMessageMapper accountMessageMapper; |
| | | |
| | | @Resource |
| | | private AppVersionService appVersionService; |
| | | |
| | | @Reference(version = "1.0", check = false) |
| | | private BPushTaskService bPushTaskService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private JumpDetailV2Service jumpDetailV2Service; |
| | | |
| | | @Override |
| | | public void pushGoods(Long uid, String title, String content, String url, List<String> listIOS, |
| | | List<String> listAndroid, SystemEnum system) throws PushException { |
| | | String gids = url.split("id=")[1]; |
| | | String gid = gids.split("&")[0]; |
| | | if (StringUtil.isNullOrEmpty(gid)) |
| | | throw new PushException(1, "商品解析失败"); |
| | | if (StringUtil.isNullOrEmpty(title)) |
| | | throw new PushException(1, "请填写推送标题"); |
| | | if (StringUtil.isNullOrEmpty(content)) |
| | | throw new PushException(1, "请填写推送内容"); |
| | | |
| | | if (system.isNewPush()) { |
| | | List<Long> uidList = null; |
| | | if (uid != null) { |
| | | uidList = new ArrayList<>(); |
| | | uidList.add(uid); |
| | | } |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | } |
| | | try { |
| | | newPush(system, uidList, versionCodeList, null, title, content, NewPushExtraParamsFactory.createGoods(jumpDetailV2Service.getByTypeCache("goodsdetail", system), gid, Constant.SOURCE_TYPE_TAOBAO)); |
| | | } catch (BPushTaskException e) { |
| | | logger.error("推送-商品:{}", gid, e); |
| | | } |
| | | } else { |
| | | /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listIOS == null || listIOS.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system); |
| | | if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { |
| | | iosPushService.pushGoods(uid, Long.parseLong(gid), title, content, codes, system); |
| | | } |
| | | } |
| | | |
| | | /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system); |
| | | if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { |
| | | xmPushService.pushGoods(uid, Long.parseLong(gid), title, content, versions, system); |
| | | } |
| | | // 华为推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | hwPushService.pushGoods(uid, Long.parseLong(gid), new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // OPPO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | oPPOPushService.pushGoods(uid, Long.parseLong(gid), new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | // VIVO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | vIVOPushService.pushGoods(uid, Long.parseLong(gid), new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | PushRecord pushRecord = new PushRecord(); |
| | | pushRecord.setUid(uid); |
| | | pushRecord.setState(1); |
| | | pushRecord.setType(PushTypeEnum.goodsdetail.getCode()); // 都成功 |
| | | pushRecord.setUrl(url); |
| | | pushRecord.setTitle(title); |
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName()); |
| | | pushRecord.setAccount(1); |
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | pushRecordMapper.insertSelective(pushRecord); |
| | | } |
| | | |
| | | @Override |
| | | public void pushUrl(Long uid, String title, String content, String url, List<String> listIOS, |
| | | List<String> listAndroid, SystemEnum system) throws PushException { |
| | | |
| | | if (StringUtil.isNullOrEmpty(url)) |
| | | throw new PushException(1, "无推送链接"); |
| | | if (StringUtil.isNullOrEmpty(title)) |
| | | throw new PushException(1, "无推送标题"); |
| | | if (StringUtil.isNullOrEmpty(content)) |
| | | throw new PushException(1, "无推送内容"); |
| | | |
| | | |
| | | if (system.isNewPush()) { |
| | | List<Long> uidList = null; |
| | | if (uid != null) { |
| | | uidList = new ArrayList<>(); |
| | | uidList.add(uid); |
| | | } |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | } |
| | | try { |
| | | newPush(system, uidList, versionCodeList, null, title, content, NewPushExtraParamsFactory.createUrl(jumpDetailV2Service.getByTypeCache("web", system), url)); |
| | | } catch (BPushTaskException e) { |
| | | logger.error("推送-链接:{}", url, e); |
| | | } |
| | | } else { |
| | | |
| | | /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listIOS == null || listIOS.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system); |
| | | if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { |
| | | iosPushService.pushUrl(uid, url, title, content, codes, system); |
| | | } |
| | | } |
| | | |
| | | /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system); |
| | | if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { |
| | | xmPushService.pushUrl(uid, url, title, content, versions, system); |
| | | } |
| | | |
| | | // 华为推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | hwPushService.pushUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // OPPO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | oPPOPushService.pushUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // VIVO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | vIVOPushService.pushUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | PushRecord pushRecord = new PushRecord(); |
| | | pushRecord.setUid(uid); |
| | | pushRecord.setState(1); |
| | | pushRecord.setType(PushTypeEnum.url.getCode()); |
| | | pushRecord.setUrl(url); |
| | | pushRecord.setTitle(title); |
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName()); |
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | pushRecordMapper.insertSelective(pushRecord); |
| | | } |
| | | |
| | | @Override |
| | | public void pushZNX(Long uId, String title, String content, List<String> listIOS, List<String> listAndroid, SystemEnum system) |
| | | throws PushException { |
| | | if (StringUtil.isNullOrEmpty(title)) |
| | | throw new PushException(1, "无推送标题"); |
| | | if (StringUtil.isNullOrEmpty(content)) |
| | | throw new PushException(1, "无推送内容"); |
| | | |
| | | SystemZnx systemZnx = null; |
| | | AccountMessage accountMessage = null; |
| | | |
| | | /* 无uid , 广播 数据插入系统表 */ |
| | | if (uId == null || uId == 0) { |
| | | // 插入数据库(系统站内信数据) |
| | | systemZnx = new SystemZnx(); |
| | | systemZnx.setTitle(title); |
| | | systemZnx.setContent(content); |
| | | systemZnx.setCreateTime(System.currentTimeMillis()); |
| | | systemZnxService.save(systemZnx); |
| | | } else { |
| | | accountMessage = new AccountMessage(); |
| | | accountMessage.setCreateTime(System.currentTimeMillis()); |
| | | accountMessage.setIsOpen(false); |
| | | accountMessage.setUserInfo(new UserInfo(uId)); |
| | | accountMessage.setTitle(title); |
| | | accountMessage.setContent(content); |
| | | accountMessageMapper.insertSelective(accountMessage); |
| | | } |
| | | |
| | | if (system.isNewPush()) { |
| | | logger.debug("新版站内信推送开始:uid-{} title-{} content-{}", new Object[]{uId, title, content}); |
| | | List<Long> uidList = null; |
| | | if (uId != null) { |
| | | uidList = new ArrayList<>(); |
| | | uidList.add(uId); |
| | | } |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | } |
| | | try { |
| | | newPush(system, uidList, versionCodeList, null, title, content, NewPushExtraParamsFactory.createZNX(jumpDetailV2Service.getByTypeCache("system_msg", system))); |
| | | } catch (BPushTaskException e) { |
| | | logger.error("推送-站内信:{}", uId + "", e); |
| | | } |
| | | } else { |
| | | /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listIOS == null || listIOS.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system); |
| | | if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { |
| | | iosPushService.pushZNX(uId, accountMessage, systemZnx, codes, system); |
| | | } |
| | | } |
| | | |
| | | /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system); |
| | | if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { |
| | | xmPushService.pushZNX(uId, accountMessage, systemZnx, versions, system); |
| | | } |
| | | |
| | | // 华为推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | hwPushService.pushZNX(uId, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // OPPO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | oPPOPushService.pushZNX(uId, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // VIVO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | vIVOPushService.pushZNX(uId, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 插入推送记录 |
| | | PushRecord pushRecord = new PushRecord(); |
| | | pushRecord.setUid(uId); |
| | | pushRecord.setTitle(title); |
| | | pushRecord.setState(1); // 成功 |
| | | pushRecord.setType(PushTypeEnum.ZNX.getCode()); // 类型:站内信 |
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName()); |
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | pushRecordMapper.insertSelective(pushRecord); |
| | | } |
| | | |
| | | @Override |
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listIOS, |
| | | List<String> listAndroid, SystemEnum system) throws PushException { |
| | | if (StringUtil.isNullOrEmpty(title)) |
| | | throw new PushException(1, "无推送标题"); |
| | | if (StringUtil.isNullOrEmpty(content)) |
| | | throw new PushException(1, "无推送内容"); |
| | | |
| | | // 适用版本 1.4.8及以后 推送weex页面 |
| | | |
| | | /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listIOS == null || listIOS.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system); |
| | | if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { |
| | | iosPushService.pushWEEX(uid, title, content, weexUrl, codes, system); |
| | | } |
| | | } |
| | | |
| | | /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | // 限制推送版本号:31 |
| | | String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system); |
| | | if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { |
| | | xmPushService.pushWEEX(uid, title, content, weexUrl, versions, system); |
| | | } |
| | | } |
| | | |
| | | // 华为推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | hwPushService.pushWEEX(uid, weexUrl, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // OPPO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | oPPOPushService.pushWEEX(uid, weexUrl, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // VIVO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | vIVOPushService.pushWEEX(uid, weexUrl, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // 插入推送记录 |
| | | PushRecord pushRecord = new PushRecord(); |
| | | pushRecord.setTitle(title); |
| | | pushRecord.setUid(uid); |
| | | pushRecord.setState(1); // 成功 |
| | | pushRecord.setType(PushTypeEnum.weex.getCode()); // 类型:WEEX |
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName()); |
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | pushRecordMapper.insertSelective(pushRecord); |
| | | } |
| | | |
| | | @Override |
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listIOS, |
| | | List<String> listAndroid, SystemEnum system) throws PushException { |
| | | |
| | | if (StringUtil.isNullOrEmpty(title)) |
| | | throw new PushException(1, "无推送标题"); |
| | | if (StringUtil.isNullOrEmpty(content)) |
| | | throw new PushException(1, "无推送内容"); |
| | | |
| | | if (system.isNewPush()) { |
| | | List<Long> uidList = null; |
| | | if (uid != null) { |
| | | uidList = new ArrayList<>(); |
| | | uidList.add(uid); |
| | | } |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | } |
| | | try { |
| | | newPush(system, uidList, versionCodeList, null, title, content, NewPushExtraParamsFactory.createBaichuan(jumpDetailV2Service.getByTypeCache("baichuan", system), url)); |
| | | } catch (BPushTaskException e) { |
| | | logger.error("推送-百川:{}", url, e); |
| | | } |
| | | } else { |
| | | |
| | | // 适用版本 1.4.8及以后 推送百川网页 |
| | | |
| | | /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listIOS == null || listIOS.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system); |
| | | if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { |
| | | iosPushService.pushBaiChuanUrl(uid, title, content, url, codes, system); |
| | | } |
| | | } |
| | | |
| | | /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | // 限制推送版本号:31 |
| | | String versions = getEffectiveVersions(31, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system); |
| | | if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { |
| | | xmPushService.pushBaiChuanUrl(uid, title, content, url, versions, system); |
| | | } |
| | | } |
| | | |
| | | // 华为推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | hwPushService.pushBaiChuanUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // OPPO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | oPPOPushService.pushBaiChuanUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // VIVO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | vIVOPushService.pushBaiChuanUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | } |
| | | |
| | | // 插入推送记录 |
| | | PushRecord pushRecord = new PushRecord(); |
| | | pushRecord.setUrl(url); |
| | | pushRecord.setTitle(title); |
| | | pushRecord.setUid(uid); |
| | | pushRecord.setState(1); // 成功 |
| | | pushRecord.setType(PushTypeEnum.baichuan.getCode()); // 类型:百川 |
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName()); |
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | pushRecordMapper.insertSelective(pushRecord); |
| | | } |
| | | |
| | | @Override |
| | | public void pushWelfareCenter(Long uid, String title, String content, List<String> listIOS, |
| | | List<String> listAndroid, SystemEnum system) throws PushException { |
| | | |
| | | if (StringUtil.isNullOrEmpty(title)) |
| | | throw new PushException(1, "无推送标题"); |
| | | if (StringUtil.isNullOrEmpty(content)) |
| | | throw new PushException(1, "无推送内容"); |
| | | |
| | | /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listIOS == null || listIOS.size() > 0) { |
| | | // 限制推送版本号:0 |
| | | String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system); |
| | | if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { |
| | | iosPushService.pushWelfareCenter(uid, title, content, codes, system); |
| | | } |
| | | } |
| | | |
| | | /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | // 限制推送版本号:36 |
| | | String versions = getEffectiveVersions(36, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system); |
| | | if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { |
| | | xmPushService.pushWelfareCenter(uid, title, content, versions, system); |
| | | } |
| | | } |
| | | |
| | | // 华为推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | hwPushService.pushWelfareCenter(uid, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // OPPO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | oPPOPushService.pushWelfareCenter(uid, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // VIVO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | vIVOPushService.pushWelfareCenter(uid, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // 插入推送记录 |
| | | PushRecord pushRecord = new PushRecord(); |
| | | pushRecord.setTitle(title); |
| | | pushRecord.setUid(uid); |
| | | pushRecord.setState(1); // 成功 |
| | | pushRecord.setType(PushTypeEnum.welfare.getCode()); // 类型:百川 |
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName()); |
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | pushRecordMapper.insertSelective(pushRecord); |
| | | } |
| | | |
| | | /** |
| | | * 查询能推送版本号 |
| | | * |
| | | * @param listVersion |
| | | * @return |
| | | */ |
| | | private String getEffectiveVersions(int minCode, String type, List<String> listVersion, SystemEnum system) throws PushException { |
| | | |
| | | if (minCode == 0 && listVersion == null) { |
| | | return null; |
| | | } |
| | | |
| | | String versions = ""; |
| | | if (listVersion == null) { |
| | | List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode, system); |
| | | if (list != null) { |
| | | for (AppVersionInfo appVersion : list) { |
| | | versions += appVersion.getVersion() + ","; |
| | | } |
| | | } |
| | | } else { |
| | | List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion, system); |
| | | if (list != null) { |
| | | for (AppVersionInfo appVersion : list) { |
| | | 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 listVersion |
| | | * @return |
| | | */ |
| | | private String getEffectiveVersionCodes(int minCode, String type, List<String> listVersion, SystemEnum system) throws PushException { |
| | | |
| | | if (minCode == 0 && listVersion == null) { |
| | | return null; |
| | | } |
| | | |
| | | String versionCodes = ""; |
| | | if (listVersion == null) { |
| | | List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode, system); |
| | | if (list != null) { |
| | | for (AppVersionInfo appVersion : list) { |
| | | versionCodes += appVersion.getVersionCode() + ","; |
| | | } |
| | | } |
| | | } else { |
| | | List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion, system); |
| | | if (list != null) { |
| | | for (AppVersionInfo appVersion : list) { |
| | | Integer code = appVersion.getVersionCode(); |
| | | if (code != null && code >= minCode) { |
| | | versionCodes += appVersion.getVersionCode() + ","; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (versionCodes.endsWith(",")) { |
| | | versionCodes = versionCodes.substring(0, versionCodes.length() - 1); |
| | | } |
| | | |
| | | return versionCodes; |
| | | } |
| | | |
| | | @Override |
| | | public void pushUserSignInNotification(Long uid, String title, String content, List<String> listIOS, |
| | | List<String> listAndroid, SystemEnum system) throws PushException { |
| | | if (StringUtil.isNullOrEmpty(title)) |
| | | throw new PushException(1, "无推送标题"); |
| | | if (StringUtil.isNullOrEmpty(content)) |
| | | throw new PushException(1, "无推送内容"); |
| | | |
| | | /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listIOS == null || listIOS.size() > 0) { |
| | | // 限制推送版本号:1.6.5以后 |
| | | String codes = getEffectiveVersionCodes(60, AppVersionInfo.PLATFORM_IOS, listIOS, system); |
| | | if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) { |
| | | iosPushService.pushUserSignInNotification(uid, title, content, codes, system); |
| | | } |
| | | } |
| | | |
| | | /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */ |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | // 限制推送版本号:1.6.5以后 |
| | | String versions = getEffectiveVersions(47, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system); |
| | | if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) { |
| | | xmPushService.pushUserSignInNotification(uid, title, content, versions, system); |
| | | } |
| | | } |
| | | |
| | | // 华为推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | hwPushService.pushUserSignInNotification(uid, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // OPPO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | oPPOPushService.pushUserSignInNotification(uid, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // VIVO推送 |
| | | if (listAndroid == null || listAndroid.size() > 0) { |
| | | List<Integer> versionCodeList = null; |
| | | if (listAndroid != null) |
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system); |
| | | vIVOPushService.pushUserSignInNotification(uid, new PushBaseContent(title, content, versionCodeList, system)); |
| | | } |
| | | |
| | | // 插入推送记录 |
| | | PushRecord pushRecord = new PushRecord(); |
| | | pushRecord.setTitle(title); |
| | | pushRecord.setUid(uid); |
| | | pushRecord.setState(1); // 成功 |
| | | pushRecord.setType(PushTypeEnum.signin.getCode()); // 类型:百川 |
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName()); |
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | pushRecordMapper.insertSelective(pushRecord); |
| | | } |
| | | |
| | | private void newPush(SystemEnum system, List<Long> uidList, List<Integer> versionCodeList, Date startPushTime, String title, String content, Map<String, String> params) throws BPushTaskException { |
| | | |
| | | logger.debug("新版推送开始:title-{} content-{}", new Object[]{title, content}); |
| | | //灰度测试 |
| | | // if (uidList == null || uidList.size() == 0 || uidList.size() > 1) |
| | | // return; |
| | | |
| | | |
| | | BPushFilter filter = new BPushFilter(); |
| | | //设置用户信息 |
| | | List<String> uidStrList = null; |
| | | if (uidList != null && uidList.size() > 0) { |
| | | uidStrList = new ArrayList<>(); |
| | | for (Long uid : uidList) { |
| | | uidStrList.add(uid + ""); |
| | | } |
| | | } |
| | | filter.setUidList(uidStrList); |
| | | filter.setVersionCodeList(versionCodeList); |
| | | //默认推送最近两个月的活跃用户 |
| | | filter.setMinActiveTime(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 60)); |
| | | filter.setStartPushTime(startPushTime); |
| | | |
| | | BPushMessage message = new BPushMessage(); |
| | | message.setAndroidActivityScheme(configService.getValue(ConfigKeyEnum.pushAndroidActivityScheme, system)); |
| | | message.setAndroidActivity(configService.getValue(ConfigKeyEnum.pushAndroidActivity, system)); |
| | | message.setAndroidHostPath(configService.getValue(ConfigKeyEnum.pushAndroidHostPath, system)); |
| | | message.setTitle(title); |
| | | message.setContent(content); |
| | | |
| | | message.setExtras(params); |
| | | BPushTask pushTask = new BPushTask(); |
| | | pushTask.setFilter(filter); |
| | | pushTask.setAppCode(system.name()); |
| | | pushTask.setMessage(message); |
| | | String taskId = bPushTaskService.createTask(pushTask); |
| | | if (startPushTime == null) { |
| | | bPushTaskService.startPush(taskId); |
| | | } |
| | | |
| | | logger.debug("新版推送灰度测试结束:title-{} content-{}", new Object[]{title, content}); |
| | | } |
| | | |
| | | private static class NewPushExtraParamsFactory { |
| | | |
| | | public static Map<String, String> createCommon(JumpDetailV2 jumpDetail, JSONObject cps) { |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("activity", jumpDetail.getActivity()); |
| | | params.put("type", jumpDetail.getType()); |
| | | params.put("controller", jumpDetail.getController()); |
| | | if (cps != null) |
| | | params.put("params", cps.toString()); |
| | | return params; |
| | | } |
| | | |
| | | //单品推送 |
| | | public static Map<String, String> createGoods(JumpDetailV2 jumpDetail, String goodsId, Integer goodsType) { |
| | | JSONObject cps = new JSONObject(); |
| | | cps.put("goodsId", goodsId); |
| | | cps.put("goodsType", goodsType); |
| | | cps.put("from", "push"); |
| | | return createCommon(jumpDetail, cps); |
| | | } |
| | | |
| | | //站内信 |
| | | public static Map<String, String> createZNX(JumpDetailV2 jumpDetail) { |
| | | return createCommon(jumpDetail, null); |
| | | } |
| | | |
| | | //推送链接 |
| | | public static Map<String, String> createUrl(JumpDetailV2 jumpDetail, String url) { |
| | | JSONObject cps = new JSONObject(); |
| | | cps.put("url", url); |
| | | cps.put("from", "push"); |
| | | return createCommon(jumpDetail, cps); |
| | | } |
| | | |
| | | //推送百川链接 |
| | | public static Map<String, String> createBaichuan(JumpDetailV2 jumpDetail, String url) { |
| | | JSONObject cps = new JSONObject(); |
| | | cps.put("url", url); |
| | | cps.put("from", "push"); |
| | | return createCommon(jumpDetail, cps); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |