admin
2019-03-05 ca20ce6afc5abe164767c87b5332df223c3b8063
增加福利中心推送
二维码识别邀请关系修改
10个文件已修改
297 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/BasePushService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushService.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/push/IOSPushUtil.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
@@ -36,6 +36,7 @@
    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 PushRecordService pushRecordService;
@@ -54,7 +55,7 @@
    @Resource
    private PushService pushService;
    @Resource
    private UserSystemMsgService userSystemMsgService;
@@ -153,7 +154,7 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("转链数据不能为空"));
            return;
        }
        try {
            String shortLink = org.yeshi.utils.HttpUtil.getShortLink(url);
@@ -161,17 +162,15 @@
            jsonData.put("url", url);
            jsonData.put("shortLink", shortLink);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonData));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("转换失败"));
            e.printStackTrace();
        }
    }
    /**
     * 商品推送  -(新后台)
     * 商品推送 -(新后台)
     * 
     * @param uId
     *            -用户ID 可为空
@@ -185,8 +184,9 @@
     * @throws Exception
     */
    @RequestMapping(value = "newPushGoodsAll")
    public void newPushGoodsAll(String callback, Long uid, String url, String title, String content, PrintWriter out) throws Exception {
    public void newPushGoodsAll(String callback, Long uid, String url, String title, String content, PrintWriter out)
            throws Exception {
        String auctionId = null;
        if (!StringUtil.isNullOrEmpty(url) && url.contains("id=")) {
            String[] sts = url.split("\\?")[1].split("&");
@@ -215,7 +215,7 @@
            e.printStackTrace();
        }
    }
    /**
     * 网页推送 -(新后台)
     * 
@@ -227,7 +227,7 @@
     */
    @RequestMapping(value = "newPushUrlAll")
    public void newPushUrlAll(String callback, String url, String title, String content, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写链接,标题与内容"));
            return;
@@ -238,7 +238,7 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("标题或内容过长,请删减后再试"));
            return;
        }
        try {
            pushService.pushUrl(null, url, title, content);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
@@ -247,7 +247,7 @@
            e.printStackTrace();
        }
    }
    /**
     * 
     * 方法说明: 站内信推送 -(新后台)
@@ -259,19 +259,19 @@
     */
    @RequestMapping(value = "newPushFanZNX")
    public void newPushFanZNX(String callback, String uids, String title, String content, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写标题与内容"));
            return;
        }
        try {
            String[] uidArray = null;
            if (uids != null) {
                uidArray = uids.split(",");
            }
            if (uidArray == null) {
                pushService.pushZNX(null, title, content);
            } else {
@@ -279,10 +279,9 @@
                    String str_uid = uidArray[i];
                    if (str_uid != null && str_uid.trim().length() > 0) {
                        pushService.pushZNX(Long.parseLong(str_uid), title, content);
                        userSystemMsgService.addUserSystemMsg(Long.parseLong(str_uid),
                                UserSystemMsgTypeEnum.question, title, content,
                                UserSystemMsg.TIME_TAG_EMERGENT, null);
                        userSystemMsgService.addUserSystemMsg(Long.parseLong(str_uid), UserSystemMsgTypeEnum.question,
                                title, content, UserSystemMsg.TIME_TAG_EMERGENT, null);
                    }
                }
            }
@@ -295,7 +294,6 @@
        }
    }
    /**
     * 
     * 方法说明: 百川推送 -(新后台)
@@ -306,21 +304,20 @@
     * @throws Exception
     */
    @RequestMapping(value = "pushBaiChuan")
    public void pushBaiChuan(String callback, String uids, String title, String content, String url,
            PrintWriter out) {
    public void pushBaiChuan(String callback, String uids, String title, String content, String url, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写标题与内容"));
            return;
        }
        try {
            String[] uidArray = null;
            if (uids != null) {
                uidArray = uids.split(",");
            }
            if (uidArray == null) {
                pushService.pushBaiChuanUrl(null, title, content, url);
            } else {
@@ -332,7 +329,7 @@
                }
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
        } catch (PushException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
@@ -340,5 +337,5 @@
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -99,13 +99,13 @@
    }
    @Transactional
    public void bind(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
        if (invitee == null || inviter == null)
    public void bind(UserInfo worker, UserInfo inviter) throws ThreeSaleException {
        if (worker == null || inviter == null)
            throw new ThreeSaleException(1, "用户信息为空");
        if (invitee.getId() == null)// 该用户还不存在
        if (worker.getId() == null)// 该用户还不存在
        {
            // 保存用户
            UserInfo inviteeUser = userInfoService.addUser(invitee, Constant.APPID);
            UserInfo inviteeUser = userInfoService.addUser(worker, Constant.APPID);
            if (inviteeUser == null)
                throw new ThreeSaleException(2, "创建用户失败");
            // 保存关系
@@ -132,13 +132,14 @@
            userInviteMsgNotificationService.inviteScan(inviter.getId(), threeSale);
        } else {// 是已经存在的用户
            worker = userInfoService.selectByPKey(worker.getId());
            // 用户已经存在我们的用户库中
            if (invitee.getLastLoginTime() == null || invitee.getLastLoginTime() == 0L) {
            if (worker.getLastLoginTime() == null || worker.getLastLoginTime() == 0L) {
                // 用户未登录
                int outOfDateCount = 0;// 过期数量
                // 查询邀请关系
                List<ThreeSale> list = listByWorkerId(invitee.getId());
                List<ThreeSale> list = listByWorkerId(worker.getId());
                if (list != null && list.size() > 0) {
                    for (ThreeSale ts : list) {
                        if (!ts.getState() && ts.getExpire() == ThreeSale.EXPIRE_OUTOFDATE) {
@@ -154,20 +155,20 @@
                        threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
                        threeSale.setState(false);
                        threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
                        threeSale.setWorker(invitee);
                        threeSale.setWorker(worker);
                        threeSaleMapper.insertSelective(threeSale);
                        // 删除已失效关系
                        threeSaleMapper.deleteExpireRecord(inviter.getId(), invitee.getId());
                        threeSaleMapper.deleteExpireRecord(inviter.getId(), worker.getId());
                        List<ThreeSale> listExpire = threeSaleMapper.getExpireRecord(inviter.getId(), invitee.getId());
                        List<ThreeSale> listExpire = threeSaleMapper.getExpireRecord(inviter.getId(), worker.getId());
                        if (listExpire != null && listExpire.size() > 0) {
                            // 删除历史通知
                            for (ThreeSale saleExpire : listExpire) {
                                msgInviteDetailService.deleteByThreeSale(saleExpire);
                            }
                            // 删除已失效关系
                            threeSaleMapper.deleteExpireRecord(inviter.getId(), invitee.getId());
                            threeSaleMapper.deleteExpireRecord(inviter.getId(), worker.getId());
                        }
                        userInviteMsgNotificationService.inviteScan(inviter.getId(), threeSale);
@@ -180,7 +181,41 @@
                    // 用户未登录,又不存在邀请关系,不做处理
                }
            } else {
                // 已经登录,不做处理
                // 已经登录,而且没有上下级关系或者上下级关系未生效,则绑定关系
                List<ThreeSale> list = threeSaleMapper.listByWorkerId(worker.getId());
                // 删除无效的
                if (list != null)
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).getState() != null && list.get(i).getState() == false
                                && list.get(i).getExpire() == ThreeSale.EXPIRE_OUTOFDATE) {// 过期的
                            list.remove(i);
                            i--;
                        }
                    }
                // 查询上级是否有和现在上级一样的
                if (list == null || list.size() == 0)// 尚未确立关系,建立关系
                {
                    ThreeSale ts = new ThreeSale();
                    ts.setBoss(inviter);
                    ts.setCreateTime(System.currentTimeMillis());
                    ts.setExpire(ThreeSale.EXPIRE_NORMAL);
                    ts.setState(true);
                    ts.setSucceedTime(System.currentTimeMillis());
                    ts.setWorker(worker);
                    threeSaleMapper.insertSelective(ts);
                    ThreeSaleCMQManager.getInstance().addThreeSaleMsg(ts);
                    userInviteMsgNotificationService.inviteSuccess(inviter.getId(), ts);
                } else {
                    if (!list.get(0).getState() && list.get(0).getExpire() == ThreeSale.EXPIRE_NORMAL
                            && list.get(0).getBoss().getId() == inviter.getId().longValue()) {// 未生效的上级和现在上级一样就生效
                        ThreeSale update = new ThreeSale(list.get(0).getId());
                        update.setState(true);
                        update.setSucceedTime(System.currentTimeMillis());
                        threeSaleMapper.updateByPrimaryKeySelective(update);
                        ThreeSaleCMQManager.getInstance().addThreeSaleMsg(list.get(0));//添加通知
                        userInviteMsgNotificationService.inviteSuccess(inviter.getId(), list.get(0));
                    }
                }
            }
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java
@@ -215,4 +215,10 @@
    }
    @Override
    public void pushWelfareCenter(Long uid, String title, String content) throws PushException {
        // TODO Auto-generated method stub
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
@@ -41,7 +41,7 @@
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    @Override
    public void pushGoods(Long uid, Long auctionId, String title, String content) throws PushException {
@@ -85,9 +85,9 @@
             */
        } else {
            if (!validateNotDisturbSingle(uid)) {
                return; //通知免打扰(20:00-24:00 / 00:00 -08:00)
                return; // 通知免打扰(20:00-24:00 / 00:00 -08:00)
            }
            // IOS 单推
            List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
            List<String> deviceTokenList = new ArrayList<>();
@@ -143,9 +143,9 @@
             */
        } else {
            if (!validateNotDisturbSingle(uid)) {
                return; //通知免打扰(20:00-24:00 / 00:00 -08:00)
                return; // 通知免打扰(20:00-24:00 / 00:00 -08:00)
            }
            List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
            List<String> deviceTokenList = new ArrayList<>();
            if (deviceTokenIosList != null)
@@ -206,13 +206,13 @@
             * } });
             */
        } else if (msg != null) {
            if (uId !=null) {
            if (uId != null) {
                if (!validateNotDisturbSingle(uId)) {
                    return; //通知免打扰(20:00-24:00 / 00:00 -08:00)
                    return; // 通知免打扰(20:00-24:00 / 00:00 -08:00)
                }
            }
            // 插入推送记录
            PushRecord pushRecord = new PushRecord();
            info.setTitle(msg.getTitle());
@@ -462,27 +462,27 @@
        String jsonContent = pushQueueRecord.getJsonContent();
        JSONObject json = JSONObject.fromObject(jsonContent);
        List<String> tokenList = new ArrayList<>();
        boolean ispush = false;
        List<Long> listNotPushId = null;
        Calendar now = Calendar.getInstance();
        int hour = now.get(Calendar.HOUR_OF_DAY);
        if (hour >= 8 && hour < 20) {
            ispush = true; // 可推送
        }  else {
        } else {
            listNotPushId = validateNotDisturb();
        }
        for (DeviceTokenIOS ios : list) {
            if (!StringUtil.isNullOrEmpty(ios.getDeviceToken())) {
                if (!ispush && listNotPushId != null && listNotPushId.size() > 0) {
                    Long uid = ios.getUid();
                    if (uid != null && listNotPushId.contains(uid)) {
                        continue;  // 通知免打扰(20:00-24:00 / 00:00 -08:00)
                        continue; // 通知免打扰(20:00-24:00 / 00:00 -08:00)
                    }
                }
                tokenList.add(ios.getDeviceToken());
@@ -564,16 +564,16 @@
            }
        }
    }
    /**
     *  通知免打扰(20:00-8:00)
     * 通知免打扰(20:00-8:00)
     */
    public List<Long> validateNotDisturb() {
        return userCustomSettingsService.getCancelNoticeUsers();
    }
    /**
     *  通知免打扰(20:00-8:00)
     * 通知免打扰(20:00-8:00)
     */
    public boolean validateNotDisturbSingle(Long uid) {
        Calendar now = Calendar.getInstance();
@@ -582,12 +582,38 @@
        if (hour >= 8 && hour < 20) {
            ispush = true; // 可推送
        } else {
            // 自定义设置  通知免打扰(20:00-24:00 / 00:00 -08:00)
            // 自定义设置 通知免打扰(20:00-24:00 / 00:00 -08:00)
            ispush = userCustomSettingsService.validateCancelNoticeByUid(uid);
        }
        return ispush;
    }
    @Override
    public void pushWelfareCenter(Long uid, String title, String content) throws PushException {
        MessageInfo info = new MessageInfo();
        info.setTitle(title);
        info.setContent(content);
        info.setDescription(content);
        // IOS 全推
        if (uid == null || uid == 0) {
            addPushIOSQueue(info, "", PushController.WELFARE_CENTER);
        } else {
            if (!validateNotDisturbSingle(uid)) {
                return;
            }
            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, "", PushController.WELFARE_CENTER);
            } catch (Exception e) {
                PushLogHelper.iosError(e);
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java
@@ -185,4 +185,10 @@
        xmPushService.pushBaiChuanUrl(uid, title, content, url);
    }
    @Override
    public void pushWelfareCenter(Long uid, String title, String content) throws PushException {
        iosPushService.pushWelfareCenter(uid, title, content);
        xmPushService.pushWelfareCenter(uid, title, content);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java
@@ -236,4 +236,35 @@
    }
    @Override
    public void pushWelfareCenter(Long uid, String title, String content) throws PushException {
        JSONObject json = new JSONObject();
        json.put("type", "welfare");
        json.put("miPushUrl", String.format("%s.ui.mine.WelfareCenterActivity",
                Constant.systemCommonConfig.getAndroidBaseactivityName()));
        MessageInfo info = new MessageInfo();
        info.setTitle(title);
        info.setContent(content);
        info.setDescription(content);
        // 小米推送网页
        info.setPackageName(Constant.systemCommonConfig.getAndroidPackageName());
        info.setActivty(String.format("%s.ui.mine.WelfareCenterActivity",
                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
@@ -35,11 +35,11 @@
     * @param content
     * @throws PushException
     */
    void pushZNX(Long uId, AccountMessage msg,SystemZnx systemZNX) throws PushException;
    void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX) throws PushException;
    /**
     * 适用版本 1.4.8及以后
     * 推送weex页面
     * 适用版本 1.4.8及以后 推送weex页面
     *
     * @param uid
     * @param title
     * @param content
@@ -47,11 +47,10 @@
     * @throws PushException
     */
    void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException;
    /**
     * 适用版本 1.4.8及以后
     * 推送百川网页
     * 适用版本 1.4.8及以后 推送百川网页
     *
     * @param uid
     * @param title
     * @param content
@@ -59,4 +58,14 @@
     * @throws PushException
     */
    void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException;
    /**
     * 推送福利中心(版本号:1.5.1后)
     *
     * @param uid
     * @param title
     * @param content
     * @throws PushException
     */
    void pushWelfareCenter(Long uid, String title, String content) throws PushException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushService.java
@@ -36,8 +36,8 @@
    void pushZNX(Long uId, String title, String content) throws PushException;
    /**
     * 适用版本 1.4.8及以后
     * 推送weex页面
     * 适用版本 1.4.8及以后 推送weex页面
     *
     * @param uid
     * @param title
     * @param content
@@ -45,11 +45,10 @@
     * @throws PushException
     */
    void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException;
    /**
     * 适用版本 1.4.8及以后
     * 推送百川网页
     * 适用版本 1.4.8及以后 推送百川网页
     *
     * @param uid
     * @param title
     * @param content
@@ -57,4 +56,14 @@
     * @throws PushException
     */
    void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException;
    /**
     * 推送福利中心
     *
     * @param uid
     * @param title
     * @param content
     * @throws PushException
     */
    void pushWelfareCenter(Long uid, String title, String content) throws PushException;
}
fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java
@@ -166,5 +166,27 @@
        json.put("aps", aps);
        return filterPushContent(json);
    }
    /**
     * 福利中心推送
     * @param title
     * @param body
     * @return
     */
    public static JSONObject createWelfarePush( 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.WELFARE_CENTER);
        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/push/IOSPushUtil.java
@@ -98,6 +98,8 @@
            if (StringUtil.isNullOrEmpty(shortUrl))
                throw new Exception("获取短链出错");
            json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
        } else if (type == PushController.WELFARE_CENTER) {
            json = IOSPushFactory.createWelfarePush(info.getTitle(), info.getContent());
        }
        // 分组推送 每50个设备为一组