admin
2018-12-15 6a4d58a65e916323b1ea11b36b27e47943482f18
添加IOS的weex,百川推送支持
2个文件已删除
12个文件已修改
297 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/SignValidateAspect.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/BasePushService.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/push/IOSPushUtil.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/certificate/old_kaifa.p12 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/certificate/old_shengchan.p12 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/aspect/SignValidateAspect.java
@@ -64,7 +64,7 @@
        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")) {
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
@@ -31,6 +31,8 @@
    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;
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java
@@ -152,11 +152,6 @@
    }
    @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();
@@ -208,4 +203,16 @@
        }
    }
    @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 推送淘客百川链接
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
@@ -148,11 +148,6 @@
    }
    @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());
@@ -487,4 +482,52 @@
        }
    }
    @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);
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java
@@ -164,4 +164,18 @@
        }
    }
    @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);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java
@@ -85,11 +85,6 @@
    }
    @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();
@@ -154,4 +149,14 @@
        }
    }
    @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 推送百川的链接
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/BasePushService.java
@@ -28,17 +28,6 @@
    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
@@ -47,4 +36,27 @@
     * @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;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushService.java
@@ -34,4 +34,27 @@
     * @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;
}
fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java
@@ -12,7 +12,7 @@
    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");
@@ -26,16 +26,17 @@
                        }
                    } 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();
            }
@@ -113,4 +114,52 @@
        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);
    }
}
fanli/src/main/java/com/yeshi/fanli/util/push/IOSPushUtil.java
@@ -88,6 +88,16 @@
            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个设备为一组
@@ -138,10 +148,12 @@
        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) {
@@ -196,19 +208,18 @@
            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 多推
@@ -220,8 +231,7 @@
     * @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;
@@ -245,6 +255,16 @@
            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;
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -1550,34 +1550,30 @@
        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) {
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -626,7 +626,6 @@
        if (filter.getEndTkRate() > 0)
            map.put("end_tk_rate", filter.getEndTkRate() + "");
        if (filter.getStartKaTkRate() > 0)
            map.put("start_ka_tk_rate", filter.getStartKaTkRate() + "");
@@ -960,6 +959,11 @@
     * @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);
fanli/src/main/resource/certificate/old_kaifa.p12
Binary files differ
fanli/src/main/resource/certificate/old_shengchan.p12
Binary files differ