From bdc1aeac75e7c794a770f854950822641083adf7 Mon Sep 17 00:00:00 2001 From: oddfar Date: Sat, 25 May 2024 23:52:51 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=AD=E6=B2=A1=E7=94=A8=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campus/business/service/IMTService.java | 14 ++----- .../campus/business/service/IShopService.java | 2 + .../business/service/impl/IMTServiceImpl.java | 42 +++++++++---------- .../campus/business/task/CampusIMTTask.java | 10 ++--- 4 files changed, 29 insertions(+), 39 deletions(-) diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTService.java b/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTService.java index d18dafe..105a93d 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTService.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/service/IMTService.java @@ -2,11 +2,13 @@ import com.oddfar.campus.business.entity.IUser; +/** + * i茅台接口请求服务 + */ public interface IMTService { + /** * 获取i茅台app版本号 - * - * @return */ String getMTVersion(); @@ -29,7 +31,6 @@ public interface IMTService { * @param mobile 手机号 * @param code 验证码 * @param deviceId 设备id - * @return */ boolean login(String mobile, String code, String deviceId); @@ -47,15 +48,8 @@ public interface IMTService { * 获得旅行奖励 * * @param iUser - * @return */ void getTravelReward(IUser iUser); -// -// /** -// * 获取累计申购奖励 -// * @param iUser -// */ -// void getCumulatively(IUser iUser); /** * 批量预约 diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/service/IShopService.java b/campus-modular/src/main/java/com/oddfar/campus/business/service/IShopService.java index 8140f66..9dcf8d5 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/service/IShopService.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/service/IShopService.java @@ -47,6 +47,8 @@ public interface IShopService extends IService { List getShopsByProvince(String province, String itemId); /** + * 获取合适的shopId + * * @param shopType 1:预约本市出货量最大的门店,2:预约你的位置附近门店 * @param itemId 项目id即预约项目code * @param province 省份,例如:河北省,北京市 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 20c6b5e..e799e80 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 @@ -23,8 +23,7 @@ import com.oddfar.campus.common.core.RedisCache; import com.oddfar.campus.common.exception.ServiceException; import com.oddfar.campus.common.utils.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -33,21 +32,18 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.Random; +/** + * i茅台接口请求服务 实现类 + */ @Service +@Slf4j public class IMTServiceImpl implements IMTService { - private static final Logger logger = LoggerFactory.getLogger(IMTServiceImpl.class); - @Autowired private IUserMapper iUserMapper; @@ -127,11 +123,11 @@ public Boolean sendCode(String mobile, String deviceId) { HttpResponse execute = request.body(JSONObject.toJSONString(data)).execute(); JSONObject jsonObject = JSONObject.parseObject(execute.body()); //成功返回 {"code":2000} - logger.info("「发送验证码返回」:" + jsonObject.toJSONString()); + log.info("「发送验证码返回」:" + jsonObject.toJSONString()); if (jsonObject.getString("code").equals("2000")) { return Boolean.TRUE; } else { - logger.error("「发送验证码-失败」:" + jsonObject.toJSONString()); + log.error("「发送验证码-失败」:" + jsonObject.toJSONString()); throw new ServiceException("发送验证码错误"); // return false; } @@ -166,11 +162,11 @@ public boolean login(String mobile, String code, String deviceId) { JSONObject body = JSONObject.parseObject(execute.body()); if (body.getString("code").equals("2000")) { -// logger.info("「登录请求-成功」" + body.toJSONString()); +// log.info("「登录请求-成功」" + body.toJSONString()); iUserService.insertIUser(Long.parseLong(mobile), deviceId, body); return true; } else { - logger.error("「登录请求-失败」" + body.toJSONString()); + log.error("「登录请求-失败」" + body.toJSONString()); throw new ServiceException("登录失败,本地错误日志已记录"); // return false; } @@ -265,7 +261,7 @@ public void receiveReward(IUser iUser) { } public void shareReward(IUser iUser) { - logger.info("「领取每日首次分享获取耐力」:" + iUser.getMobile()); + log.info("「领取每日首次分享获取耐力」:" + iUser.getMobile()); String url = "https://h5.moutai519.com.cn/game/xmTravel/shareReward"; HttpRequest request = HttpUtil.createRequest(Method.POST, url); @@ -505,7 +501,7 @@ public void reservationBatch() { List iUsers = iUserService.selectReservationUserByMinute(minute); for (IUser iUser : iUsers) { - logger.info("「开始预约用户」" + iUser.getMobile()); + log.info("「开始预约用户」" + iUser.getMobile()); //预约 reservation(iUser); //延时3秒 @@ -527,7 +523,7 @@ public void getTravelRewardBatch() { // List iUsers = iUserService.selectReservationUser(); for (IUser iUser : iUsers) { - logger.info("「开始获得旅行奖励」" + iUser.getMobile()); + log.info("「开始获得旅行奖励」" + iUser.getMobile()); getTravelReward(iUser); //延时3秒 TimeUnit.SECONDS.sleep(3); @@ -546,7 +542,7 @@ public void refreshAll() { @Override public void appointmentResults() { - logger.info("申购结果查询开始========================="); + log.info("申购结果查询开始========================="); List iUsers = iUserService.selectReservationUser(); for (IUser iUser : iUsers) { try { @@ -557,14 +553,14 @@ public void appointmentResults() { .header("MT-Token", iUser.getToken()) .header("User-Agent", "iOS;16.3;Apple;?unrecognized?").execute().body(); JSONObject jsonObject = JSONObject.parseObject(body); - logger.info("查询申购结果回调: user->{},response->{}", iUser.getMobile(), body); + log.info("查询申购结果回调: user->{},response->{}", iUser.getMobile(), body); if (jsonObject.getInteger("code") != 2000) { String message = jsonObject.getString("message"); throw new ServiceException(message); } JSONArray itemVOs = jsonObject.getJSONObject("data").getJSONArray("reservationItemVOS"); if (Objects.isNull(itemVOs) || itemVOs.isEmpty()) { - logger.info("申购记录为空: user->{}", iUser.getMobile()); + log.info("申购记录为空: user->{}", iUser.getMobile()); continue; } for (Object itemVO : itemVOs) { @@ -576,11 +572,11 @@ public void appointmentResults() { } } } catch (Exception e) { - logger.error("查询申购结果失败:失败原因->{}", e.getMessage(), e); + log.error("查询申购结果失败:失败原因->{}", e.getMessage(), e); } } - logger.info("申购结果查询结束========================="); + log.info("申购结果查询结束========================="); } public JSONObject reservation(IUser iUser, String itemId, String shopId) { @@ -621,7 +617,7 @@ public JSONObject reservation(IUser iUser, String itemId, String shopId) { String message = body.getString("message"); throw new ServiceException(message); } -// logger.info(body.toJSONString()); +// log.info(body.toJSONString()); return body; } diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/task/CampusIMTTask.java b/campus-modular/src/main/java/com/oddfar/campus/business/task/CampusIMTTask.java index adfdaff..cda0845 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/task/CampusIMTTask.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/task/CampusIMTTask.java @@ -3,9 +3,7 @@ import com.oddfar.campus.business.service.IMTService; import com.oddfar.campus.business.service.IUserService; import lombok.RequiredArgsConstructor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.EnableScheduling; @@ -17,8 +15,8 @@ @Configuration @EnableScheduling @RequiredArgsConstructor +@Slf4j public class CampusIMTTask { - private static final Logger logger = LoggerFactory.getLogger(CampusIMTTask.class); private final IMTService imtService; @@ -59,11 +57,11 @@ public void reservationBatchTask() { @Async @Scheduled(cron = "0 10,55 7,8 ? * * ") public void refresh() { - logger.info("「刷新数据」开始刷新版本号,预约item,门店shop列表 "); + log.info("「刷新数据」开始刷新版本号,预约item,门店shop列表 "); try { imtService.refreshAll(); } catch (Exception e) { - logger.info("「刷新数据执行报错」%s", e.getMessage()); + log.info("「刷新数据执行报错」%s", e.getMessage()); } }