| | |
| | | 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;
|
| | |
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserSystemMsgService userSystemMsgService;
|
| | |
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("转链数据不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | String shortLink = org.yeshi.utils.HttpUtil.getShortLink(url);
|
| | |
|
| | |
| | | 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 可为空
|
| | |
| | | * @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("&");
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 网页推送 -(新后台)
|
| | | *
|
| | |
| | | */
|
| | | @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;
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("标题或内容过长,请删减后再试"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | pushService.pushUrl(null, url, title, content);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | *
|
| | | * 方法说明: 站内信推送 -(新后台)
|
| | |
| | | */
|
| | | @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 {
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | *
|
| | | * 方法说明: 百川推送 -(新后台)
|
| | |
| | | * @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 {
|
| | |
| | | }
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
|
| | | |
| | |
|
| | | } catch (PushException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @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, "创建用户失败");
|
| | | // 保存关系
|
| | |
| | | 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) {
|
| | |
| | | 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);
|
| | |
| | | // 用户未登录,又不存在邀请关系,不做处理
|
| | | }
|
| | | } 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));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void pushWelfareCenter(Long uid, String title, String content) throws PushException {
|
| | | // TODO Auto-generated method stub
|
| | | |
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | | |
| | |
|
| | | @Override
|
| | | public void pushGoods(Long uid, Long auctionId, String title, String content) throws PushException {
|
| | |
|
| | |
| | | */
|
| | | } 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<>();
|
| | |
| | | */
|
| | | } 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)
|
| | |
| | | * } });
|
| | | */
|
| | | } 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());
|
| | |
| | |
|
| | | 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());
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 通知免打扰(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();
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @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);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | * @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
|
| | |
| | | * @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
|
| | |
| | | * @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;
|
| | | }
|
| | |
| | | void pushZNX(Long uId, String title, String content) throws PushException;
|
| | |
|
| | | /**
|
| | | * 适用版本 1.4.8及以后
|
| | | * 推送weex页面
|
| | | * 适用版本 1.4.8及以后 推送weex页面
|
| | | * |
| | | * @param uid
|
| | | * @param title
|
| | | * @param content
|
| | |
| | | * @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
|
| | |
| | | * @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;
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | 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个设备为一组
|
| | |
|