| | |
| | |
|
| | | if ((acceptData.getPlatform() != null && acceptData.getPlatform().equalsIgnoreCase("android")
|
| | | && acceptData.getVersion() != null && Integer.parseInt(acceptData.getVersion()) > 21)
|
| | | || (acceptData.getPlatform().equalsIgnoreCase("ios") && acceptData.getVersion() != null
|
| | | || (acceptData.getPlatform()!=null&&acceptData.getPlatform().equalsIgnoreCase("ios") && acceptData.getVersion() != null
|
| | | && Integer.parseInt(acceptData.getVersion()) > 24)) {
|
| | | isRight = signIsRight(request);
|
| | | } else if (acceptData.getPackages().startsWith("com.haicaojie")) {
|
| | |
| | | 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; // 站内推送
|
| | |
|
| | | @Resource
|
| | | private PushRecordService pushRecordService;
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEXUrl(Long uid, String weexUrl, String title, String content) throws PushException {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushZNX(Long uid, AccountMessage msg, SystemZnx systemZNX) throws PushException {
|
| | |
|
| | | JSONObject contentJson = new JSONObject();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException {
|
| | | // TODO 推送weex页面
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
|
| | | // TODO 推送淘客百川链接
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEXUrl(Long uid, String weexUrl, String title, String content) throws PushException {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX) throws PushException {
|
| | | MessageInfo info = new MessageInfo();
|
| | | info.setPackageName(Constant.systemCommonConfig.getAndroidPackageName());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl) 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);
|
| | | } else {
|
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | | if (deviceTokenIosList != null)
|
| | | for (DeviceTokenIOS ios : deviceTokenIosList) {
|
| | | deviceTokenList.add(ios.getDeviceToken());
|
| | | }
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, weexUrl, PushController.WEEX);
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url) 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);
|
| | | } else {
|
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | | if (deviceTokenIosList != null)
|
| | | for (DeviceTokenIOS ios : deviceTokenIosList) {
|
| | | deviceTokenList.add(ios.getDeviceToken());
|
| | | }
|
| | | try {
|
| | | IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.BAICHUAN);
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.iosError(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException {
|
| | | if (StringUtil.isNullOrEmpty(title))
|
| | | throw new PushException(1, "无推送标题");
|
| | | if (StringUtil.isNullOrEmpty(content))
|
| | | throw new PushException(1, "无推送内容");
|
| | | iosPushService.pushWEEX(uid, title, content, weexUrl);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
|
| | | iosPushService.pushBaiChuanUrl(uid, title, content, url);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEXUrl(Long uid, String weexUrl, String title, String content) throws PushException {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX) throws PushException {
|
| | | MessageInfo info = new MessageInfo();
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException {
|
| | | // TODO 推送weex页面
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
|
| | | // TODO 推送百川的链接
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | void pushUrl(Long uid, String url, String title, String content) throws PushException;
|
| | |
|
| | | /**
|
| | | * 推送WEEX的页面(暂时不做)
|
| | | * |
| | | * @param uid
|
| | | * @param weexUrl
|
| | | * @param title
|
| | | * @param content
|
| | | * @throws PushException
|
| | | */
|
| | | void pushWEEXUrl(Long uid, String weexUrl, String title, String content) throws PushException;
|
| | |
|
| | | /**
|
| | | * 推送站内信
|
| | | *
|
| | | * @param uId
|
| | |
| | | * @throws PushException
|
| | | */
|
| | | void pushZNX(Long uId, AccountMessage msg,SystemZnx systemZNX) throws PushException;
|
| | | |
| | | /**
|
| | | * 适用版本 1.4.8及以后
|
| | | * 推送weex页面
|
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | | * @param weexUrl
|
| | | * @throws PushException
|
| | | */
|
| | | void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException;
|
| | | |
| | | |
| | | /**
|
| | | * 适用版本 1.4.8及以后
|
| | | * 推送百川网页
|
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | | * @param url
|
| | | * @throws PushException
|
| | | */
|
| | | void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException;
|
| | | }
|
| | |
| | | * @throws PushException
|
| | | */
|
| | | void pushZNX(Long uId, String title, String content) throws PushException;
|
| | |
|
| | | /**
|
| | | * 适用版本 1.4.8及以后
|
| | | * 推送weex页面
|
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | | * @param weexUrl
|
| | | * @throws PushException
|
| | | */
|
| | | void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException;
|
| | | |
| | | |
| | | /**
|
| | | * 适用版本 1.4.8及以后
|
| | | * 推送百川网页
|
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | | * @param url
|
| | | * @throws PushException
|
| | | */
|
| | | void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException;
|
| | | }
|
| | |
| | | private static JSONObject filterPushContent(JSONObject json) {
|
| | | if (json != null)
|
| | | try {
|
| | | boolean ischange= false;
|
| | | boolean ischange = false;
|
| | | while (json.toString().getBytes("UTF-8").length > 253) {
|
| | | // 首先削减内容,然后削减标题
|
| | | String title = json.optJSONObject("aps").optJSONObject("alert").optString("title");
|
| | |
| | | }
|
| | | } else {
|
| | | ischange = true;
|
| | | json.optJSONObject("aps").optJSONObject("alert").put("body", body.substring(0, body.length() - 1));
|
| | | json.optJSONObject("aps").optJSONObject("alert").put("body",
|
| | | body.substring(0, body.length() - 1));
|
| | | continue;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (ischange) {
|
| | | String body = json.optJSONObject("aps").optJSONObject("alert").optString("body");
|
| | | json.optJSONObject("aps").optJSONObject("alert").put("body", body + "...");
|
| | | }
|
| | | |
| | |
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | return filterPushContent(json);
|
| | | }
|
| | |
|
| | | /**
|
| | | * WEEX页面推送
|
| | | * |
| | | * @param shortUrl
|
| | | * @param title
|
| | | * @param body
|
| | | * @return
|
| | | */
|
| | | public static JSONObject createWEEXPush(String shortUrl, 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", PushController.WEEX);
|
| | | alert.put("url", shortUrl);
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | | aps.put("alert", alert);
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("aps", aps);
|
| | | return filterPushContent(json);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 百川网页推送
|
| | | * |
| | | * @param shortUrl
|
| | | * @param title
|
| | | * @param body
|
| | | * @return
|
| | | */
|
| | | public static JSONObject createBaiChuanPush(String shortUrl, 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", PushController.BAICHUAN);
|
| | | alert.put("url", shortUrl);
|
| | |
|
| | | JSONObject aps = new JSONObject();
|
| | | aps.put("alert", alert);
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("aps", aps);
|
| | | return filterPushContent(json);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | json = IOSPushFactory.createURLPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.ZNX) {
|
| | | json = IOSPushFactory.createZNXPush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WEEX) {
|
| | | 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) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
|
| | | }
|
| | | // 分组推送 每50个设备为一组
|
| | |
|
| | |
| | |
|
| | | PushNotificationManager pushManager = new PushNotificationManager();
|
| | | // true:表示的是产品线上发布推送服务 false:表示的是产品测试推送服务
|
| | | if(Constant.IS_TEST)
|
| | | pushManager.initializeConnection(new AppleNotificationServerBasicImpl(certificate, certificatePassword, false));
|
| | | if (Constant.IS_TEST)
|
| | | pushManager.initializeConnection(
|
| | | new AppleNotificationServerBasicImpl(certificate, certificatePassword, false));
|
| | | else
|
| | | pushManager.initializeConnection(new AppleNotificationServerBasicImpl(certificate, certificatePassword, true));
|
| | | pushManager
|
| | | .initializeConnection(new AppleNotificationServerBasicImpl(certificate, certificatePassword, true));
|
| | |
|
| | | List<Device> deviceList = new ArrayList<Device>();
|
| | | for (String token : tokenList) {
|
| | |
| | | return 4;
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 执行推送
|
| | | * |
| | | * @param tokenList
|
| | | * @param json
|
| | | * @throws Exception
|
| | | */
|
| | | public static void executePushIOS(List<String> tokenList, JSONObject json) throws Exception{
|
| | | public static void executePushIOS(List<String> tokenList, JSONObject json) throws Exception {
|
| | | pushIOS(tokenList, json);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | *
|
| | | * 方法说明: IOS 多推
|
| | |
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public static JSONObject getJSONObject(MessageInfo info, String url, int type)
|
| | | throws Exception {
|
| | | public static JSONObject getJSONObject(MessageInfo info, String url, int type) throws Exception {
|
| | |
|
| | | // json自定义传值
|
| | | JSONObject json = null;
|
| | |
| | | json = IOSPushFactory.createURLPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.ZNX) {
|
| | | json = IOSPushFactory.createZNXPush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WEEX) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | shortUrl = url;
|
| | | json = IOSPushFactory.createWEEXPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.BAICHUAN) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | shortUrl = url;
|
| | | json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
|
| | | }
|
| | |
|
| | | return json;
|
| | |
| | |
|
| | | long startTime = System.currentTimeMillis();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("itemNumId", auctionId + "");
|
| | | data.put("id", auctionId + "");
|
| | | String url = "";
|
| | | try {
|
| | | url = String.format(
|
| | | "https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%s&qq-pf-to=pcqq.group",
|
| | | URLEncoder.encode(data.toString(), "UTF-8"));
|
| | | "https://h5api.m.taobao.com/h5/mtop.taobao.detail.getdesc/6.0/?data=%s&callback=GoodsLogic.showTuwen&_=%s",
|
| | | URLEncoder.encode(data.toString(), "UTF-8"), System.currentTimeMillis() + "");
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | String result = HttpUtil.get(url);
|
| | | result = result.replace("GoodsLogic.showTuwen(", "").replace(")", "");
|
| | | data = JSONObject.fromObject(result);
|
| | | String moduleDescUrl = data.optJSONObject("data").optJSONObject("item").optString("moduleDescUrl");
|
| | | if (!StringUtil.isNullOrEmpty(moduleDescUrl)) {
|
| | | String pcDescContent = data.optJSONObject("data").optString("pcDescContent");
|
| | | System.out.println(pcDescContent);
|
| | | if (!StringUtil.isNullOrEmpty(pcDescContent)) {
|
| | | try {
|
| | | result = HttpUtil.get("http:" + moduleDescUrl);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | JSONArray itemsArray = resultJSON.optJSONObject("data").optJSONArray("children");
|
| | | for (int i = 0; i < itemsArray.size(); i++) {
|
| | | // picUrl
|
| | | JSONObject params = itemsArray.optJSONObject(i).optJSONObject("params");
|
| | | if (params.keySet().contains("picUrl")) {
|
| | | String pictureUrl = params.optString("picUrl");
|
| | | JSONObject sizeJSON = params.optJSONObject("size");
|
| | | int width = sizeJSON.optInt("width");
|
| | | int height = sizeJSON.optInt("height");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(pictureUrl))
|
| | | imgList.add(new ImageInfo(pictureUrl, width, height));
|
| | | Document doc = Jsoup.parse(pcDescContent);
|
| | | Elements eles = doc.getElementsByTag("img");
|
| | | for (int i = 0; i < eles.size(); i++) {
|
| | | String imgSrc = eles.get(i).attr("src");
|
| | | if (imgSrc.endsWith(".jpg")) {
|
| | | if (!imgSrc.startsWith("http"))
|
| | | imgSrc = "https:" + imgSrc;
|
| | | imgList.add(new ImageInfo(imgSrc, 0, 0));
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
| | |
|
| | | if (filter.getEndTkRate() > 0)
|
| | | map.put("end_tk_rate", filter.getEndTkRate() + "");
|
| | | |
| | |
|
| | | if (filter.getStartKaTkRate() > 0)
|
| | | map.put("start_ka_tk_rate", filter.getStartKaTkRate() + "");
|
| | |
| | | * @return
|
| | | */
|
| | | public static String getTKToken(String logo, String text, String url) {
|
| | | if (text == null)
|
| | | return null;
|
| | | if (text.length() < 5)
|
| | | text = "好货:" + text;
|
| | |
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.tpwd.create");
|
| | | map.put("url", url);
|