From fc320897a91331bd0f43d377d3d45338b57609af Mon Sep 17 00:00:00 2001 From: zhangdepeng <576200531@qq.com> Date: Mon, 27 May 2024 23:57:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E4=BD=BF=E6=9B=B4=E7=9B=B4=E8=A7=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campus/business/api/PushPlusApi.java | 19 ++-------- .../business/service/IMTLogFactory.java | 10 +++--- .../business/service/impl/IMTServiceImpl.java | 35 ++++++++++++------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/api/PushPlusApi.java b/campus-modular/src/main/java/com/oddfar/campus/business/api/PushPlusApi.java index 479e438b..77d6e474 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/api/PushPlusApi.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/api/PushPlusApi.java @@ -15,26 +15,13 @@ */ public class PushPlusApi { - - public static void sendNotice(IUser iUser, ILog operLog) { + public static void sendNotice(IUser iUser, ILog operLog, String title) { String token = iUser.getPushPlusToken(); if (StringUtils.isEmpty(token)) { return; } - String title, content; - if (operLog.getStatus() == 0) { - //预约成功 - title = iUser.getRemark() + "-i茅台执行成功"; - content = iUser.getMobile() + System.lineSeparator() + operLog.getLogContent(); - AsyncManager.me().execute(sendNotice(token, title, content, "txt")); - } else { - //预约失败 - title = iUser.getRemark() + "-i茅台执行失败"; - content = iUser.getMobile() + System.lineSeparator() + operLog.getLogContent(); - AsyncManager.me().execute(sendNotice(token, title, content, "txt")); - } - - + String content = iUser.getMobile() + System.lineSeparator() + operLog.getLogContent(); + AsyncManager.me().execute(sendNotice(token, title, content, "txt")); } /** diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTLogFactory.java b/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTLogFactory.java index 3eb49b31..427c9167 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTLogFactory.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTLogFactory.java @@ -15,12 +15,10 @@ public class IMTLogFactory { - public static void reservation(IUser iUser, String logContent) { + public static void reservation(IUser iUser, String logContent, String title) { //{"code":2000,"data":{"successDesc":"申购完成,请于7月6日18:00查看预约申购结果","reservationList":[{"reservationId":17053404357,"sessionId":678,"shopId":"233331084001","reservationTime":1688608601720,"itemId":"10214","count":1}],"reservationDetail":{"desc":"申购成功后将以短信形式通知您,请您在申购成功次日18:00前确认支付方式,并在7天内完成提货。","lotteryTime":1688637600000,"cacheValidTime":1688637600000}}} ILog operLog = new ILog(); - operLog.setOperTime(new Date()); - if (logContent.contains("报错")) { //失败 operLog.setStatus(1); @@ -30,10 +28,10 @@ public static void reservation(IUser iUser, String logContent) { operLog.setMobile(iUser.getMobile()); operLog.setCreateUser(iUser.getCreateUser()); operLog.setLogContent(logContent); - + // 日志记录 AsyncManager.me().execute(recordOper(operLog)); - //推送 - PushPlusApi.sendNotice(iUser, operLog); + // 消息推送 + PushPlusApi.sendNotice(iUser, operLog, title); } /** diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java index 20c6b5e5..9ccc9d99 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java @@ -186,12 +186,14 @@ public void reservation(IUser iUser) { String[] items = iUser.getItemCode().split("@"); String logContent = ""; + String title = ""; for (String itemId : items) { try { String shopId = iShopService.getShopId(iUser.getShopType(), itemId, iUser.getProvinceName(), iUser.getCityName(), iUser.getLat(), iUser.getLng()); //预约 JSONObject json = reservation(iUser, itemId, shopId); + title = "i茅台预约申购: 成功"; logContent += String.format("[预约项目]:%s\n[shopId]:%s\n[结果返回]:%s\n\n", itemId, shopId, json.toString()); //随机延迟3~5秒 @@ -199,19 +201,13 @@ public void reservation(IUser iUser) { int sleepTime = random.nextInt(3) + 3; Thread.sleep(sleepTime * 1000); } catch (Exception e) { + title = "i茅台预约申购: 失败"; logContent += String.format("执行报错--[预约项目]:%s\n[结果返回]:%s\n\n", itemId, e.getMessage()); } } -// try { -// //预约后领取耐力值 -// String energyAward = getEnergyAward(iUser); -// logContent += "[申购耐力值]:" + energyAward; -// } catch (Exception e) { -// logContent += "执行报错--[申购耐力值]:" + e.getMessage(); -// } //日志记录 - IMTLogFactory.reservation(iUser, logContent); + IMTLogFactory.reservation(iUser, logContent, title); //预约后延迟领取耐力值 getEnergyAwardDelay(iUser); } @@ -226,17 +222,20 @@ public void getEnergyAwardDelay(IUser iUser) { @Override public void run() { String logContent = ""; + String title = ""; //sleep 10秒 try { Thread.sleep(10000); //预约后领取耐力值 String energyAward = getEnergyAward(iUser); logContent += "[申购耐力值]:" + energyAward; + title = "i茅台申购领耐力: 成功"; } catch (Exception e) { logContent += "执行报错--[申购耐力值]:" + e.getMessage(); + title = "i茅台申购领耐力: 失败"; } //日志记录 - IMTLogFactory.reservation(iUser, logContent); + IMTLogFactory.reservation(iUser, logContent, title); } }; new Thread(runnable).start(); @@ -312,15 +311,18 @@ public String getEnergyAward(IUser iUser) { @Override public void getTravelReward(IUser iUser) { String logContent = ""; + String title = ""; try { String s = travelReward(iUser); logContent += "[获得旅行奖励]:" + s; + title = "i茅台旅行活动执行: 成功"; } catch (Exception e) { // e.printStackTrace(); logContent += "执行报错--[获得旅行奖励]:" + e.getMessage(); + title = "i茅台旅行活动执行: 失败"; } //日志记录 - IMTLogFactory.reservation(iUser, logContent); + IMTLogFactory.reservation(iUser, logContent, title); } /** @@ -569,11 +571,20 @@ public void appointmentResults() { } for (Object itemVO : itemVOs) { JSONObject item = JSON.parseObject(itemVO.toString()); - // 预约时间在24小时内的 + // 预约时间在24小时内的 成功 if (item.getInteger("status") == 2 && DateUtil.between(item.getDate("reservationTime"), new Date(), DateUnit.HOUR) < 24) { String logContent = DateUtil.formatDate(item.getDate("reservationTime")) + " 申购" + item.getString("itemName") + "成功"; - IMTLogFactory.reservation(iUser, logContent); + String title = "申购结果查询成功: 申购成功!!!"; + IMTLogFactory.reservation(iUser, logContent, title); } + + // 预约时间在24小时内的 失败 + if (item.getInteger("status") == 1 && DateUtil.between(item.getDate("reservationTime"), new Date(), DateUnit.HOUR) < 24) { + String logContent = DateUtil.formatDate(item.getDate("reservationTime")) + " 申购" + item.getString("itemName") + "失败"; + String title = "申购结果查询成功: 申购失败"; + IMTLogFactory.reservation(iUser, logContent, title); + } + } } catch (Exception e) { logger.error("查询申购结果失败:失败原因->{}", e.getMessage(), e); From 497fdf16ed4b102be975307b39ce5ddc5579e7e2 Mon Sep 17 00:00:00 2001 From: zhangdepeng <576200531@qq.com> Date: Tue, 28 May 2024 19:54:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E4=BD=BF=E6=9B=B4=E7=9B=B4=E8=A7=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campus/business/service/impl/IMTServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java index 9ccc9d99..345118b6 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java @@ -315,11 +315,11 @@ public void getTravelReward(IUser iUser) { try { String s = travelReward(iUser); logContent += "[获得旅行奖励]:" + s; - title = "i茅台旅行活动执行: 成功"; + title = "i茅台小茅运旅行: 成功"; } catch (Exception e) { // e.printStackTrace(); logContent += "执行报错--[获得旅行奖励]:" + e.getMessage(); - title = "i茅台旅行活动执行: 失败"; + title = "i茅台小茅运旅行: 失败"; } //日志记录 IMTLogFactory.reservation(iUser, logContent, title); @@ -574,14 +574,14 @@ public void appointmentResults() { // 预约时间在24小时内的 成功 if (item.getInteger("status") == 2 && DateUtil.between(item.getDate("reservationTime"), new Date(), DateUnit.HOUR) < 24) { String logContent = DateUtil.formatDate(item.getDate("reservationTime")) + " 申购" + item.getString("itemName") + "成功"; - String title = "申购结果查询成功: 申购成功!!!"; + String title = "i茅台今日申购: 成功!!!"; IMTLogFactory.reservation(iUser, logContent, title); } // 预约时间在24小时内的 失败 if (item.getInteger("status") == 1 && DateUtil.between(item.getDate("reservationTime"), new Date(), DateUnit.HOUR) < 24) { String logContent = DateUtil.formatDate(item.getDate("reservationTime")) + " 申购" + item.getString("itemName") + "失败"; - String title = "申购结果查询成功: 申购失败"; + String title = "i茅台今日申购: 失败"; IMTLogFactory.reservation(iUser, logContent, title); }