admin
2019-08-26 aad0425e6a103b633aab4c36642cdd34e95ace62
推送类型优化
12个文件已修改
1个文件已添加
439 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/push/PushTypeEnum.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/BasePushService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/HWPushService.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushService.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/push/HWPushUtil.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/push/IOSPushUtil.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
@@ -28,15 +28,6 @@
@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;
fanli/src/main/java/com/yeshi/fanli/dto/push/PushTypeEnum.java
New file
@@ -0,0 +1,21 @@
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;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java
@@ -8,10 +8,10 @@
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;
@@ -60,27 +60,27 @@
    @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")
@@ -88,14 +88,20 @@
    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) {
@@ -136,7 +142,7 @@
     * @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);
@@ -151,26 +157,28 @@
                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);
@@ -190,26 +198,28 @@
                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);
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
@@ -12,9 +12,9 @@
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;
@@ -46,7 +46,8 @@
    @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();
@@ -65,14 +66,14 @@
        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 =
@@ -90,10 +91,10 @@
            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) {
@@ -101,7 +102,7 @@
                }
            try {
                IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.GOODS);
                IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushTypeEnum.goodsdetail.getCode());
            } catch (Exception e) {
                PushLogHelper.iosError(e);
            }
@@ -133,7 +134,7 @@
        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);
@@ -158,14 +159,13 @@
                    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 {
@@ -198,7 +198,7 @@
            // TODO 需要全推
            addPushIOSQueue(info, id + "", PushController.ZNX, versionCodes);
            addPushIOSQueue(info, id + "", PushTypeEnum.ZNX.getCode(), versionCodes);
            /*
             * List<String> deviceTokenList = getDeviceTokenList(1, 1000);
@@ -250,7 +250,7 @@
            // IOS 单推
            try {
                IOSPushUtil.allPushIOS(deviceTokenList, info, "0", PushController.ZNX);
                IOSPushUtil.allPushIOS(deviceTokenList, info, "0", PushTypeEnum.ZNX.getCode());
            } catch (Exception e) {
                PushLogHelper.iosError(e);
            }
@@ -328,8 +328,8 @@
     */
    @Transactional
    public void addPushIOSQueue(MessageInfo info, String url, int type, String versionCodes) throws PushException {
        if(Constant.IS_TEST)
        if (Constant.IS_TEST)
            return;
        try {
@@ -344,7 +344,7 @@
            // 每次执行条目
            int pushNum = 50;
            for (long i = 0; i < tokenCount + totalCount;) {
                PushQueueRecord pushQueueRecord = new PushQueueRecord();
@@ -360,7 +360,6 @@
                pushQueueRecord.setType(1);
                // 版本号
                pushQueueRecord.setVersions(versionCodes);
                if (tokenCount - i < totalCount) {
                    // 起始游标
@@ -411,17 +410,15 @@
        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);
        // 每次推送总条数
@@ -436,7 +433,7 @@
        long recordCursor = startCursor;
        for (int i = 0; i < count; i++) {
            // 不足50个数据
            if (moveNum > total) {
                moveNum = (int) (endCursor - startCursor);
@@ -535,14 +532,15 @@
    @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<>();
@@ -551,7 +549,7 @@
                    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);
            }
@@ -560,14 +558,15 @@
    @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<>();
@@ -576,7 +575,7 @@
                    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);
            }
@@ -616,7 +615,7 @@
        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;
@@ -628,7 +627,7 @@
                    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);
            }
@@ -653,5 +652,30 @@
        }
        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);
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java
@@ -9,6 +9,7 @@
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;
@@ -104,7 +105,7 @@
        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());
@@ -153,7 +154,7 @@
        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());
@@ -221,7 +222,7 @@
        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);
@@ -268,7 +269,7 @@
        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);
@@ -317,7 +318,7 @@
        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);
@@ -363,7 +364,7 @@
        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);
@@ -449,4 +450,49 @@
        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);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java
@@ -3,6 +3,7 @@
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;
@@ -27,7 +28,7 @@
        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()));
@@ -65,7 +66,7 @@
        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()));
@@ -122,7 +123,7 @@
            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()));
@@ -156,7 +157,7 @@
            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()));
@@ -181,7 +182,7 @@
        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) {
@@ -219,7 +220,7 @@
        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);
@@ -252,7 +253,7 @@
    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()));
        // 版本推送
@@ -284,4 +285,40 @@
        }
    }
    @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);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/BasePushService.java
@@ -68,4 +68,15 @@
     * @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;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/HWPushService.java
@@ -2,8 +2,6 @@
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;
/**
@@ -46,7 +44,7 @@
     * @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页面
@@ -82,4 +80,15 @@
     */
    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;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushService.java
@@ -7,6 +7,7 @@
public interface PushService {
    /**
     * 推送商品
     *
     * @param uid
     * @param url
     * @param title
@@ -15,11 +16,12 @@
     * @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
@@ -28,11 +30,12 @@
     * @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
@@ -40,11 +43,12 @@
     * @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
@@ -58,6 +62,7 @@
    /**
     * 适用版本 1.4.8及以后 推送百川网页
     *
     * @param uid
     * @param title
     * @param content
@@ -71,6 +76,7 @@
    /**
     * 推送福利中心
     *
     * @param uid
     * @param title
     * @param content
@@ -78,6 +84,19 @@
     * @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;
}
fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java
@@ -2,7 +2,7 @@
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;
@@ -59,7 +59,7 @@
        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);
@@ -82,7 +82,7 @@
        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);
@@ -106,7 +106,7 @@
        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();
@@ -131,7 +131,7 @@
        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();
@@ -156,7 +156,7 @@
        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();
@@ -179,7 +179,7 @@
        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);
@@ -189,4 +189,27 @@
        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);
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
@@ -15,6 +15,7 @@
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 {
@@ -62,8 +63,8 @@
     * @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, "返利金额为空");
@@ -104,8 +105,8 @@
     * @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, "返利金额为空");
@@ -208,7 +209,7 @@
        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);
@@ -248,7 +249,7 @@
        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);
@@ -422,7 +423,7 @@
     * @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, "订单号不能为空");
@@ -453,7 +454,7 @@
     * @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, "订单号不能为空");
@@ -497,10 +498,8 @@
        }
        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)
@@ -515,7 +514,7 @@
        detail.setType(UserMoneyDetailTypeEnum.scoreConvert);
        detail.setUpdateTime(new Date());
        detail.setUserInfo(user);
        return detail;
    }
fanli/src/main/java/com/yeshi/fanli/util/push/HWPushUtil.java
@@ -214,6 +214,23 @@
            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();
        }
    }
    /**
     * 推送设备消息
fanli/src/main/java/com/yeshi/fanli/util/push/IOSPushUtil.java
@@ -12,6 +12,7 @@
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;
@@ -70,7 +71,7 @@
        // 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("&");
@@ -83,26 +84,29 @@
            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()
@@ -241,7 +245,7 @@
        // 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("&");
@@ -254,23 +258,25 @@
            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;