| | |
| | | @RequestMapping("admin/new/api/v1/push")
|
| | | public class PushController {
|
| | |
|
| | | public final static int GOODS = 1; // 商品推送
|
| | | public final static int URL = 2; // 网页推送
|
| | | public final static int DETAIL = 3; // 详情推送
|
| | | public final static int ZNX = 4; // 站内推送
|
| | | public final static int WEEX = 5; // 站内推送
|
| | | public final static int BAICHUAN = 6; // 站内推送
|
| | | public final static int WELFARE_CENTER = 7; // 福利中心
|
| | |
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.dto.push;
|
| | |
|
| | | public enum PushTypeEnum {
|
| | | goodsdetail(1, "淘宝商品详情"), url(2, "网页"), ZNX(4, "站内信"), weex(5, "weex"), baichuan(6, "百川链接"), welfare(7,
|
| | | "福利中心"), signin(8, "签到");
|
| | | private final String desc;
|
| | | private final int code;
|
| | |
|
| | | private PushTypeEnum(int code, String desc) {
|
| | | this.code = code;
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | |
|
| | | public int getCode() {
|
| | | return code;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.checkerframework.checker.units.qual.h;
|
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.push.PushTypeEnum;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
|
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum;
|
| | |
| | | @Override
|
| | | public void pushGoods(Long uid, Long auctionId, String title, String content, List<Integer> versionCodeList)
|
| | | throws PushException {
|
| | | push("goodsdetail", uid, title, content, null, null, auctionId, versionCodeList);
|
| | | push(PushTypeEnum.goodsdetail, uid, title, content, null, null, auctionId, versionCodeList);
|
| | | }
|
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushUrl(Long uid, String url, String title, String content, List<Integer> versionCodeList)
|
| | | throws PushException {
|
| | | push("url", uid, title, content, null, url, null, versionCodeList);
|
| | | push(PushTypeEnum.url, uid, title, content, null, url, null, versionCodeList);
|
| | | }
|
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushZNX(Long uid, String title, String content, List<Integer> versionCodeList) throws PushException {
|
| | | push("ZNX", uid, title, content, null, null, null, versionCodeList);
|
| | | push(PushTypeEnum.ZNX, uid, title, content, null, null, null, versionCodeList);
|
| | | }
|
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl, List<Integer> versionCodeList)
|
| | | throws PushException {
|
| | | push("weex", uid, title, content, weexUrl, null, null, versionCodeList);
|
| | | push(PushTypeEnum.weex, uid, title, content, weexUrl, null, null, versionCodeList);
|
| | | }
|
| | |
|
| | | @Async("pushExecutor")
|
| | |
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<Integer> versionCodeList)
|
| | | throws PushException {
|
| | |
|
| | | push("baichuan", uid, title, content, null, url, null, versionCodeList);
|
| | | push(PushTypeEnum.baichuan, uid, title, content, null, url, null, versionCodeList);
|
| | | }
|
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushWelfareCenter(Long uid, String title, String content, List<Integer> versionCodeList)
|
| | | throws PushException {
|
| | | push("welfare", uid, title, content, null, null, null, versionCodeList);
|
| | | push(PushTypeEnum.welfare, uid, title, content, null, null, null, versionCodeList);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushUserSignInNotification(Long uid, String title, String content, List<Integer> versionCodeList)
|
| | | throws PushException {
|
| | | push(PushTypeEnum.signin, uid, title, content, null, null, null, versionCodeList);
|
| | | }
|
| | |
|
| | | private List<DeviceTokenHW> filterDeviceToken(List<DeviceTokenHW> hwDeviceList, int hour) {
|
| | |
| | | * @param webUrl
|
| | | * @param versionCodeList
|
| | | */
|
| | | private void push(String type, Long uid, String title, String content, String url, String webUrl, Long goodsId,
|
| | | private void push(PushTypeEnum type, Long uid, String title, String content, String url, String webUrl, Long goodsId,
|
| | | List<Integer> versionCodeList) throws PushException {
|
| | | int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
|
| | | List<Integer> newVersionList = getVersionCodeList(versionCodeList);
|
| | |
| | | for (DeviceTokenHW token : hwDeviceList)
|
| | | tokenList.add(token.getDeviceToken());
|
| | | try {
|
| | | if (type.equalsIgnoreCase("goodsdetail")) {// 商品详情
|
| | | if (type==PushTypeEnum.goodsdetail) {// 商品详情
|
| | | if (goodsId == null)
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
|
| | | } else if (type.equalsIgnoreCase("url")) {// 链接
|
| | | } else if (type==PushTypeEnum.url) {// 链接
|
| | | if (StringUtil.isNullOrEmpty(webUrl))
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushUrl(tokenList, title, content, webUrl);
|
| | | } else if (type.equalsIgnoreCase("ZNX")) {// 站内信
|
| | | } else if (type==PushTypeEnum.ZNX) {// 站内信
|
| | | HWPushUtil.pushZNX(tokenList, title, content);
|
| | | } else if (type.equalsIgnoreCase("weex")) {// weex
|
| | | } else if (type==PushTypeEnum.weex) {// weex
|
| | | if (StringUtil.isNullOrEmpty(url))
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushWEEX(tokenList, title, content, url);
|
| | | } else if (type.equalsIgnoreCase("baichuan")) {// 百川链接
|
| | | } else if (type==PushTypeEnum.baichuan) {// 百川链接
|
| | | if (StringUtil.isNullOrEmpty(webUrl))
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
|
| | | } else if (type.equalsIgnoreCase("welfare")) {// 福利中心
|
| | | } else if (type==PushTypeEnum.welfare) {// 福利中心
|
| | | HWPushUtil.pushWelfareCenter(tokenList, title, content);
|
| | | }else if (type==PushTypeEnum.signin) {// 签到
|
| | | HWPushUtil.pushUserSignInNotification(tokenList, title, content);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.hwError(e);
|
| | |
| | | return;
|
| | |
|
| | | try {
|
| | | if (type.equalsIgnoreCase("goodsdetail")) {// 商品详情
|
| | | if (type==PushTypeEnum.goodsdetail) {// 商品详情
|
| | | if (goodsId == null)
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
|
| | | } else if (type.equalsIgnoreCase("url")) {// 链接
|
| | | } else if (type==PushTypeEnum.url) {// 链接
|
| | | if (StringUtil.isNullOrEmpty(webUrl))
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushUrl(tokenList, title, content, webUrl);
|
| | | } else if (type.equalsIgnoreCase("ZNX")) {// 站内信
|
| | | } else if (type==PushTypeEnum.ZNX) {// 站内信
|
| | | HWPushUtil.pushZNX(tokenList, title, content);
|
| | | } else if (type.equalsIgnoreCase("weex")) {// weex
|
| | | } else if (type==PushTypeEnum.weex) {// weex
|
| | | if (StringUtil.isNullOrEmpty(url))
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushWEEX(tokenList, title, content, url);
|
| | | } else if (type.equalsIgnoreCase("baichuan")) {// 百川链接
|
| | | } else if (type==PushTypeEnum.baichuan) {// 百川链接
|
| | | if (StringUtil.isNullOrEmpty(webUrl))
|
| | | throw new PushException(2, "参数不完整");
|
| | | HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
|
| | | } else if (type.equalsIgnoreCase("welfare")) {// 福利中心
|
| | | } else if (type==PushTypeEnum.welfare) {// 福利中心
|
| | | HWPushUtil.pushWelfareCenter(tokenList, title, content);
|
| | | } else if (type==PushTypeEnum.signin) {// 签到
|
| | | HWPushUtil.pushUserSignInNotification(tokenList, title, content);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.hwError(e);
|
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.controller.admin.PushController;
|
| | | import com.yeshi.fanli.dao.mybatis.push.DeviceTokenIOSMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.push.PushQueueRecordMapper;
|
| | | import com.yeshi.fanli.dto.push.PushTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenIOS;
|
| | | import com.yeshi.fanli.entity.push.PushQueueRecord;
|
| | |
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushGoods(Long uid, Long auctionId, String title, String content, String versionCodes) throws PushException {
|
| | | public void pushGoods(Long uid, Long auctionId, String title, String content, String versionCodes)
|
| | | throws PushException {
|
| | |
|
| | | String url = "https://item.taobao.com/item.htm?id=" + auctionId;
|
| | | JSONObject json = new JSONObject();
|
| | |
| | |
|
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setState(1);
|
| | | pushRecord.setType(PushController.GOODS); // 都成功
|
| | | pushRecord.setType(PushTypeEnum.goodsdetail.getCode()); // 都成功
|
| | | pushRecord.setUrl(url);
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | |
|
| | | if (uid == null || uid == 0) {
|
| | |
|
| | | addPushIOSQueue(info, url, PushController.GOODS, versionCodes);
|
| | | addPushIOSQueue(info, url, PushTypeEnum.goodsdetail.getCode(), versionCodes);
|
| | |
|
| | | /*
|
| | | * // 查询IOS所有设备号 // TODO 需要全推 List<String> deviceTokenList =
|
| | |
| | | if (!validateNotDisturbSingle(uid)) {
|
| | | return; // 通知免打扰(20:00-24:00 / 00:00 -08:00)
|
| | | }
|
| | | |
| | |
|
| | | // IOS 单推
|
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, versionCodes);
|
| | | |
| | |
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | | if (deviceTokenIosList != null)
|
| | | for (DeviceTokenIOS ios : deviceTokenIosList) {
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.GOODS);
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushTypeEnum.goodsdetail.getCode());
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | |
| | | if (uid == null || uid == 0) {
|
| | | // TODO 需要全推
|
| | |
|
| | | addPushIOSQueue(info, url, PushController.URL, versionCodes);
|
| | | addPushIOSQueue(info, url, PushTypeEnum.url.getCode(), versionCodes);
|
| | |
|
| | | /*
|
| | | * List<String> deviceTokenList = getDeviceTokenList(1, 1000);
|
| | |
| | | deviceTokenList.add(ios.getDeviceToken());
|
| | | }
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.URL);
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushTypeEnum.url.getCode());
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX, String versionCodes) throws PushException {
|
| | |
| | |
|
| | | // TODO 需要全推
|
| | |
|
| | | addPushIOSQueue(info, id + "", PushController.ZNX, versionCodes);
|
| | | addPushIOSQueue(info, id + "", PushTypeEnum.ZNX.getCode(), versionCodes);
|
| | |
|
| | | /*
|
| | | * List<String> deviceTokenList = getDeviceTokenList(1, 1000);
|
| | |
| | |
|
| | | // IOS 单推
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, "0", PushController.ZNX);
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, "0", PushTypeEnum.ZNX.getCode());
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | |
| | | */
|
| | | @Transactional
|
| | | public void addPushIOSQueue(MessageInfo info, String url, int type, String versionCodes) throws PushException {
|
| | | |
| | | if(Constant.IS_TEST)
|
| | |
|
| | | if (Constant.IS_TEST)
|
| | | return;
|
| | |
|
| | | try {
|
| | |
| | |
|
| | | // 每次执行条目
|
| | | int pushNum = 50;
|
| | | |
| | |
|
| | | for (long i = 0; i < tokenCount + totalCount;) {
|
| | |
|
| | | PushQueueRecord pushQueueRecord = new PushQueueRecord();
|
| | |
| | | pushQueueRecord.setType(1);
|
| | | // 版本号
|
| | | pushQueueRecord.setVersions(versionCodes);
|
| | | |
| | |
|
| | | if (tokenCount - i < totalCount) {
|
| | | // 起始游标
|
| | |
| | | Long startCursor = pushQueueRecord.getStartCursor();
|
| | | // 结束位置
|
| | | Long endCursor = pushQueueRecord.getEndCursor();
|
| | | |
| | |
|
| | | if (startCursor == null && endCursor == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | // 推送的版本号
|
| | | String versions = pushQueueRecord.getVersions();
|
| | | List<Integer> listCode = convertVersionType(versions);
|
| | | |
| | | |
| | |
|
| | | int total = (int) (endCursor - startCursor);
|
| | |
|
| | | // 每次推送总条数
|
| | |
| | | long recordCursor = startCursor;
|
| | |
|
| | | for (int i = 0; i < count; i++) {
|
| | | |
| | |
|
| | | // 不足50个数据
|
| | | if (moveNum > total) {
|
| | | moveNum = (int) (endCursor - startCursor);
|
| | |
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl,String versionCodes) throws PushException {
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl, String versionCodes)
|
| | | throws PushException {
|
| | | MessageInfo info = new MessageInfo();
|
| | | info.setTitle(title);
|
| | | info.setContent(content);
|
| | | info.setDescription(content);
|
| | | // IOS 全推
|
| | | if (uid == null || uid == 0) {
|
| | | addPushIOSQueue(info, weexUrl, PushController.WEEX, versionCodes);
|
| | | addPushIOSQueue(info, weexUrl, PushTypeEnum.weex.getCode(), versionCodes);
|
| | | } else {
|
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, versionCodes);
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | |
| | | deviceTokenList.add(ios.getDeviceToken());
|
| | | }
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, weexUrl, PushController.WEEX);
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, weexUrl, PushTypeEnum.weex.getCode());
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | |
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, String versionCodes) throws PushException {
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, String versionCodes)
|
| | | throws PushException {
|
| | | MessageInfo info = new MessageInfo();
|
| | | info.setTitle(title);
|
| | | info.setContent(content);
|
| | | info.setDescription(content);
|
| | | // IOS 全推
|
| | | if (uid == null || uid == 0) {
|
| | | addPushIOSQueue(info, url, PushController.BAICHUAN, versionCodes);
|
| | | addPushIOSQueue(info, url, PushTypeEnum.baichuan.getCode(), versionCodes);
|
| | | } else {
|
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, versionCodes);
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | |
| | | deviceTokenList.add(ios.getDeviceToken());
|
| | | }
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.BAICHUAN);
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushTypeEnum.baichuan.getCode());
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | |
| | | info.setDescription(content);
|
| | | // IOS 全推
|
| | | if (uid == null || uid == 0) {
|
| | | addPushIOSQueue(info, "", PushController.WELFARE_CENTER, versionCodes);
|
| | | addPushIOSQueue(info, "", PushTypeEnum.welfare.getCode(), versionCodes);
|
| | | } else {
|
| | | if (!validateNotDisturbSingle(uid)) {
|
| | | return;
|
| | |
| | | deviceTokenList.add(ios.getDeviceToken());
|
| | | }
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, "", PushController.WELFARE_CENTER);
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, "", PushTypeEnum.welfare.getCode());
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | |
| | | }
|
| | | return listVersionCode;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void pushUserSignInNotification(Long uid, String title, String content, String versions)
|
| | | throws PushException {
|
| | | MessageInfo info = new MessageInfo();
|
| | | info.setTitle(title);
|
| | | info.setContent(content);
|
| | | info.setDescription(content);
|
| | | // IOS 全推
|
| | | if (uid == null || uid == 0) {
|
| | | addPushIOSQueue(info, "", PushTypeEnum.signin.getCode(), versions);
|
| | | } else {
|
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, versions);
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | | if (deviceTokenIosList != null)
|
| | | for (DeviceTokenIOS ios : deviceTokenIosList) {
|
| | | deviceTokenList.add(ios.getDeviceToken());
|
| | | }
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, "", PushTypeEnum.signin.getCode());
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | 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.dto.push.PushTypeEnum;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setUid(uid);
|
| | | pushRecord.setState(1);
|
| | | pushRecord.setType(PushController.GOODS); // 都成功
|
| | | pushRecord.setType(PushTypeEnum.goodsdetail.getCode()); // 都成功
|
| | | pushRecord.setUrl(url);
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | |
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setUid(uid);
|
| | | pushRecord.setState(1);
|
| | | pushRecord.setType(PushController.URL);
|
| | | pushRecord.setType(PushTypeEnum.url.getCode());
|
| | | pushRecord.setUrl(url);
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | |
| | | pushRecord.setUid(uId);
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setState(1); // 成功
|
| | | pushRecord.setType(PushController.ZNX); // 类型:站内信
|
| | | pushRecord.setType(PushTypeEnum.ZNX.getCode()); // 类型:站内信
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | |
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setUid(uid);
|
| | | pushRecord.setState(1); // 成功
|
| | | pushRecord.setType(PushController.WEEX); // 类型:WEEX
|
| | | pushRecord.setType(PushTypeEnum.weex.getCode()); // 类型:WEEX
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | |
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setUid(uid);
|
| | | pushRecord.setState(1); // 成功
|
| | | pushRecord.setType(PushController.BAICHUAN); // 类型:百川
|
| | | pushRecord.setType(PushTypeEnum.baichuan.getCode()); // 类型:百川
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | |
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setUid(uid);
|
| | | pushRecord.setState(1); // 成功
|
| | | pushRecord.setType(PushController.WELFARE_CENTER); // 类型:百川
|
| | | pushRecord.setType(PushTypeEnum.welfare.getCode()); // 类型:百川
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | |
| | | return versionCodes;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushUserSignInNotification(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端推送 (注明:list等于 '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)) {
|
| | | iosPushService.pushUserSignInNotification(uid, title, content, codes);
|
| | | }
|
| | | }
|
| | |
|
| | | /* Android端推送 (注明:list等于 '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)) {
|
| | | xmPushService.pushUserSignInNotification(uid, title, content, versions);
|
| | | }
|
| | | }
|
| | |
|
| | | // 华为推送
|
| | | if (listAndroid == null || listAndroid.size() > 0) {
|
| | | List<Integer> versionCodeList = null;
|
| | | if (listAndroid != null)
|
| | | versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid);
|
| | | hwPushService.pushUserSignInNotification(uid, title, content, versionCodeList);
|
| | | }
|
| | |
|
| | | // 插入推送记录
|
| | | 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);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.push.PushTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.system.SystemZnx;
|
| | | import com.yeshi.fanli.entity.xinge.MessageInfo;
|
| | |
| | | JSONObject json = new JSONObject();
|
| | | // json.put("url", "http://item.taobao.com/item.htm?id=" + gid);// IOS使用
|
| | | json.put("id", gid);
|
| | | json.put("type", "goodsdetail");
|
| | | json.put("type", PushTypeEnum.goodsdetail.name());
|
| | | json.put("miPushUrl", String.format("%s.ui.recommend.GoodsBrowserActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | |
|
| | |
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("url", url);
|
| | | json.put("type", "url");
|
| | | json.put("type", PushTypeEnum.url.name());
|
| | | json.put("webUrl", url);
|
| | | json.put("miPushUrl", String.format("%s.ui.invite.ShareBrowserActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | |
| | | contentJson.put("id", id);
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("type", "ZNX");
|
| | | json.put("type",PushTypeEnum.ZNX.name());
|
| | | json.put("content", contentJson);
|
| | | json.put("miPushUrl", String.format("%s.ui.main.MainActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | |
| | | contentJson.put("id", msg.getId() + "");
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("type", "ZNX");
|
| | | json.put("type", PushTypeEnum.ZNX.name());
|
| | | json.put("content", contentJson);
|
| | | json.put("miPushUrl", String.format("%s.ui.main.MainActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | |
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("url", weexUrl);
|
| | | json.put("type", "weex");
|
| | | json.put("type", PushTypeEnum.weex.name());
|
| | |
|
| | | // 版本推送
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | |
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("url", url);
|
| | | json.put("type", "baichuan");
|
| | | json.put("type", PushTypeEnum.baichuan.name());
|
| | | // 版本推送
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | json.put("app_version", versions);
|
| | |
| | | public void pushWelfareCenter(Long uid, String title, String content, String versions) throws PushException {
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("type", "welfare");
|
| | | json.put("type", PushTypeEnum.welfare.name());
|
| | | json.put("miPushUrl", String.format("%s.ui.mine.WelfareCenterActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | | // 版本推送
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushUserSignInNotification(Long uid, String title, String content, String versions)
|
| | | throws PushException {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("type", PushTypeEnum.signin.name());
|
| | | json.put("miPushUrl", String.format("%s.ui.goldtask.GoldTaskActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | | // 版本推送
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | json.put("app_version", versions);
|
| | | }
|
| | |
|
| | | MessageInfo info = new MessageInfo();
|
| | | info.setTitle(title);
|
| | | info.setContent(content);
|
| | | info.setDescription(content);
|
| | | // 小米推送网页
|
| | | info.setPackageName(Constant.systemCommonConfig.getAndroidPackageName());
|
| | | info.setActivty(String.format("%s.ui.goldtask.GoldTaskActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | |
|
| | | PushRecord pushRecord = new PushRecord();
|
| | |
|
| | | // 小米 全推
|
| | | if (uid == null || uid == 0) {
|
| | | try {
|
| | | PushUtils.allPushXiaoMi(info, json, pushRecord);
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.xmError(e);
|
| | | }
|
| | | } else {
|
| | | info.setAlias(uid + "");
|
| | | PushUtils.singlePushXiaoMi(info, json, pushRecord);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | * @throws PushException
|
| | | */
|
| | | void pushWelfareCenter(Long uid, String title, String content, String versions) throws PushException;
|
| | |
|
| | | /**
|
| | | * 推送用户签到
|
| | | * |
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | | * @param versions
|
| | | * @throws PushException
|
| | | */
|
| | | void pushUserSignInNotification(Long uid, String title, String content, String versions) throws PushException;
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.system.SystemZnx;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | |
|
| | | /**
|
| | |
| | | * @param content
|
| | | * @throws PushException
|
| | | */
|
| | | void pushZNX(Long uId, String title,String content, List<Integer> versionCodeList) throws PushException;
|
| | | void pushZNX(Long uId, String title, String content, List<Integer> versionCodeList) throws PushException;
|
| | |
|
| | | /**
|
| | | * 适用版本 1.4.8及以后 推送weex页面
|
| | |
| | | */
|
| | | void pushWelfareCenter(Long uid, String title, String content, List<Integer> versionCodeList) throws PushException;
|
| | |
|
| | | /**
|
| | | * 推送签到提醒
|
| | | * |
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | | * @param versions
|
| | | * @throws PushException
|
| | | */
|
| | | void pushUserSignInNotification(Long uid, String title, String content, List<Integer> versionCodeList) throws PushException;
|
| | |
|
| | | }
|
| | |
| | | public interface PushService {
|
| | | /**
|
| | | * 推送商品
|
| | | * |
| | | * @param uid
|
| | | * @param url
|
| | | * @param title
|
| | |
| | | * @param listAndroid
|
| | | * @throws PushException
|
| | | */
|
| | | void pushGoods(Long uid, String title, String content, String url, List<String> listIOS,
|
| | | List<String> listAndroid) throws PushException;
|
| | | void pushGoods(Long uid, String title, String content, String url, List<String> listIOS, List<String> listAndroid)
|
| | | throws PushException;
|
| | |
|
| | | /**
|
| | | * 推送链接
|
| | | * |
| | | * @param uid
|
| | | * @param url
|
| | | * @param title
|
| | |
| | | * @param listAndroid
|
| | | * @throws PushException
|
| | | */
|
| | | void pushUrl(Long uid, String title, String content, String url, List<String> listIOS,
|
| | | List<String> listAndroid) throws PushException;
|
| | | void pushUrl(Long uid, String title, String content, String url, List<String> listIOS, List<String> listAndroid)
|
| | | throws PushException;
|
| | |
|
| | | /**
|
| | | * 推送站内信
|
| | | * |
| | | * @param uId
|
| | | * @param title
|
| | | * @param content
|
| | |
| | | * @param listAndroid
|
| | | * @throws PushException
|
| | | */
|
| | | void pushZNX(Long uId, String title, String content, List<String> listIOS,
|
| | | List<String> listAndroid) throws PushException;
|
| | | void pushZNX(Long uId, String title, String content, List<String> listIOS, List<String> listAndroid)
|
| | | throws PushException;
|
| | |
|
| | | /**
|
| | | * 适用版本 1.4.8及以后 推送weex页面
|
| | | * |
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | |
| | |
|
| | | /**
|
| | | * 适用版本 1.4.8及以后 推送百川网页
|
| | | * |
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | |
| | |
|
| | | /**
|
| | | * 推送福利中心
|
| | | * |
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | |
| | | * @param listAndroid
|
| | | * @throws PushException
|
| | | */
|
| | | void pushWelfareCenter(Long uid, String title, String content,List<String> listIOS,
|
| | | void pushWelfareCenter(Long uid, String title, String content, List<String> listIOS, List<String> listAndroid)
|
| | | throws PushException;
|
| | |
|
| | | /**
|
| | | * 推送签到通知
|
| | | * |
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | | * @param listIOS
|
| | | * @param listAndroid
|
| | | * @throws PushException
|
| | | */
|
| | | void pushUserSignInNotification(Long uid, String title, String content, List<String> listIOS,
|
| | | List<String> listAndroid) throws PushException;
|
| | | }
|
| | |
| | |
|
| | | import java.io.UnsupportedEncodingException;
|
| | |
|
| | | import com.yeshi.fanli.controller.admin.PushController;
|
| | | import com.yeshi.fanli.dto.push.PushTypeEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | alert.put("badge", "1");
|
| | | alert.put("sound", "default");
|
| | | alert.put("url", "http://id=" + auctionId);
|
| | | alert.put("type", PushController.GOODS);
|
| | | alert.put("type",PushTypeEnum.goodsdetail.getCode());
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | | aps.put("alert", alert);
|
| | |
| | | alert.put("body", body);
|
| | | alert.put("badge", "1");
|
| | | alert.put("sound", "default");
|
| | | alert.put("type", PushController.ZNX);
|
| | | alert.put("type", PushTypeEnum.ZNX.getCode());
|
| | | JSONObject aps = new JSONObject();
|
| | | aps.put("alert", alert);
|
| | | //aps.put("badge", 1);
|
| | |
| | | alert.put("body", body);
|
| | | alert.put("badge", "1");
|
| | | alert.put("sound", "default");
|
| | | alert.put("type", PushController.URL);
|
| | | alert.put("type",PushTypeEnum.url.getCode());
|
| | | alert.put("url", shortUrl);
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | |
| | | alert.put("body", body);
|
| | | alert.put("badge", "1");
|
| | | alert.put("sound", "default");
|
| | | alert.put("type", PushController.WEEX);
|
| | | alert.put("type", PushTypeEnum.weex.getCode());
|
| | | alert.put("url", shortUrl);
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | |
| | | alert.put("body", body);
|
| | | alert.put("badge", "1");
|
| | | alert.put("sound", "default");
|
| | | alert.put("type", PushController.BAICHUAN);
|
| | | alert.put("type", PushTypeEnum.baichuan.getCode());
|
| | | alert.put("url", shortUrl);
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | |
| | | alert.put("body", body);
|
| | | alert.put("badge", "1");
|
| | | alert.put("sound", "default");
|
| | | alert.put("type", PushController.WELFARE_CENTER);
|
| | | alert.put("type", PushTypeEnum.welfare.getCode());
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | | aps.put("alert", alert);
|
| | |
| | | return filterPushContent(json);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 用户签到
|
| | | * @param title
|
| | | * @param body
|
| | | * @return
|
| | | */
|
| | | public static JSONObject createUserSignInPush( String title, String body) {
|
| | | JSONObject alert = new JSONObject();
|
| | | alert.put("title", title);
|
| | | alert.put("body", body);
|
| | | alert.put("badge", "1");
|
| | | alert.put("sound", "default");
|
| | | alert.put("type", PushTypeEnum.signin.getCode());
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | | aps.put("alert", alert);
|
| | | //aps.put("badge", 1);
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("aps", aps);
|
| | | return filterPushContent(json);
|
| | | }
|
| | | |
| | | }
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | |
|
| | | public class UserMoneyDetailFactory {
|
| | |
|
| | |
| | | * @return
|
| | | * @throws UserMoneyDetailException
|
| | | */
|
| | | public static UserMoneyDetail createShare(Long uid,int orderType, int validCount, int weiQuanCount, int invalidCount,
|
| | | BigDecimal money, Date time) throws UserMoneyDetailException {
|
| | | public static UserMoneyDetail createShare(Long uid, int orderType, int validCount, int weiQuanCount,
|
| | | int invalidCount, BigDecimal money, Date time) throws UserMoneyDetailException {
|
| | | if (money == null)
|
| | | throw new UserMoneyDetailException(1, "返利金额为空");
|
| | |
|
| | |
| | | * @return
|
| | | * @throws UserMoneyDetailException
|
| | | */
|
| | | public static UserMoneyDetail createInvite(Long uid,int orderType, int validCount, int weiQuanCount, int invalidCount,
|
| | | BigDecimal money, Date time) throws UserMoneyDetailException {
|
| | | public static UserMoneyDetail createInvite(Long uid, int orderType, int validCount, int weiQuanCount,
|
| | | int invalidCount, BigDecimal money, Date time) throws UserMoneyDetailException {
|
| | | if (money == null)
|
| | | throw new UserMoneyDetailException(1, "返利金额为空");
|
| | |
|
| | |
| | | detail.setSubTitle("订单维权");
|
| | | detail.setType(UserMoneyDetailTypeEnum.shareWeiQuan);
|
| | | detail.setSourceIdentifyId(drawBack.getId());
|
| | | detail.setDescInfo("订单号:" + drawBack.getOrderId());
|
| | | detail.setDescInfo("订单号:" + UserUtil.filterOrderId(drawBack.getOrderId()));
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(uid));
|
| | | detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | |
| | | detail.setSubTitle("订单维权");
|
| | | detail.setType(UserMoneyDetailTypeEnum.inviteWeiQuan);
|
| | | detail.setSourceIdentifyId(drawBack.getId());
|
| | | detail.setDescInfo("订单号:" + drawBack.getOrderId());
|
| | | detail.setDescInfo("订单号:" + UserUtil.filterOrderId(drawBack.getOrderId()));
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(uid));
|
| | | detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | |
| | | * @return
|
| | | * @throws UserMoneyDetailException
|
| | | */
|
| | | public static UserMoneyDetail createOrderReward(String orderId,int orderType, BigDecimal money, UserInfo user)
|
| | | public static UserMoneyDetail createOrderReward(String orderId, int orderType, BigDecimal money, UserInfo user)
|
| | | throws UserMoneyDetailException {
|
| | | if (StringUtil.isNullOrEmpty(orderId))
|
| | | throw new UserMoneyDetailException(1, "订单号不能为空");
|
| | |
| | | * @return
|
| | | * @throws UserMoneyDetailException
|
| | | */
|
| | | public static UserMoneyDetail createRepeatStatistic(String orderId,int orderType, BigDecimal money, UserInfo user)
|
| | | public static UserMoneyDetail createRepeatStatistic(String orderId, int orderType, BigDecimal money, UserInfo user)
|
| | | throws UserMoneyDetailException {
|
| | | if (StringUtil.isNullOrEmpty(orderId))
|
| | | throw new UserMoneyDetailException(1, "订单号不能为空");
|
| | |
| | | }
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | | public static UserMoneyDetail createScoreConvert(BigDecimal money, UserInfo user)
|
| | | throws UserMoneyDetailException {
|
| | |
|
| | | public static UserMoneyDetail createScoreConvert(BigDecimal money, UserInfo user) throws UserMoneyDetailException {
|
| | | if (user == null)
|
| | | throw new UserMoneyDetailException(1, "UID不能为空");
|
| | | if (money == null)
|
| | |
| | | detail.setType(UserMoneyDetailTypeEnum.scoreConvert);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(user);
|
| | | |
| | |
|
| | | return detail;
|
| | | }
|
| | |
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | public static void pushUserSignInNotification(List<String> deviceTokens, String title, String content) throws PushException {
|
| | | String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.goldtask.GoldTaskActivity";
|
| | | String intent = getIntent("signin", activity, null, null, null);
|
| | | if (intent == null)
|
| | | return;
|
| | |
|
| | | try {
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent);
|
| | | net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | throw new PushException(2, result);
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 推送设备消息
|
| | |
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.controller.admin.PushController;
|
| | | import com.yeshi.fanli.dto.push.PushTypeEnum;
|
| | | import com.yeshi.fanli.entity.xinge.MessageInfo;
|
| | | import com.yeshi.fanli.entity.xinge.PushRecord;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | // json自定义传值
|
| | |
|
| | | JSONObject json = null;
|
| | | if (type == PushController.GOODS) {
|
| | | if (type == PushTypeEnum.goodsdetail.getCode()) {
|
| | | Long auctionId = null;
|
| | | if (url.contains("id=")) {
|
| | | String[] sts = url.split("\\?")[1].split("&");
|
| | |
| | | if (auctionId == null)
|
| | | throw new Exception("淘宝商品ID提取出错");
|
| | | json = IOSPushFactory.createGoodsPush(auctionId, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.URL) {
|
| | | } else if (type == PushTypeEnum.url.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createURLPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.ZNX) {
|
| | | } else if (type == PushTypeEnum.ZNX.getCode()) {
|
| | | json = IOSPushFactory.createZNXPush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WEEX) {
|
| | | } else if (type == PushTypeEnum.weex.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createWEEXPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.BAICHUAN) {
|
| | | } else if (type == PushTypeEnum.baichuan.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WELFARE_CENTER) {
|
| | | } else if (type == PushTypeEnum.welfare.getCode()) {
|
| | | json = IOSPushFactory.createWelfarePush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushTypeEnum.signin.getCode()) {
|
| | | json = IOSPushFactory.createUserSignInPush(info.getTitle(), info.getContent());
|
| | | }
|
| | |
|
| | | // 分组推送 每50个设备为一组
|
| | |
|
| | | InputStream certificate = IOSPushUtil.class.getClassLoader()
|
| | |
| | |
|
| | | // json自定义传值
|
| | | JSONObject json = null;
|
| | | if (type == PushController.GOODS) {
|
| | | if (type == PushTypeEnum.goodsdetail.getCode()) {
|
| | | Long auctionId = null;
|
| | | if (url.contains("id=")) {
|
| | | String[] sts = url.split("\\?")[1].split("&");
|
| | |
| | | if (auctionId == null)
|
| | | throw new Exception("淘宝商品ID提取出错");
|
| | | json = IOSPushFactory.createGoodsPush(auctionId, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.URL) {
|
| | | } else if (type == PushTypeEnum.url.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createURLPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.ZNX) {
|
| | | } else if (type == PushTypeEnum.ZNX.getCode()) {
|
| | | json = IOSPushFactory.createZNXPush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WEEX) {
|
| | | } else if (type == PushTypeEnum.weex.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | shortUrl = url;
|
| | | json = IOSPushFactory.createWEEXPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.BAICHUAN) {
|
| | | } else if (type == PushTypeEnum.baichuan.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | shortUrl = url;
|
| | | json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushTypeEnum.signin.getCode()) {
|
| | | json = IOSPushFactory.createUserSignInPush(info.getTitle(), info.getContent());
|
| | | }
|
| | |
|
| | | return json;
|