package com.oddfar.campus.business.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.oddfar.campus.business.entity.IUser;
import com.oddfar.campus.business.mapper.IUserMapper;
import com.oddfar.campus.business.service.IMTLogFactory;
import com.oddfar.campus.business.service.IMTService;
import com.oddfar.campus.business.service.IShopService;
import com.oddfar.campus.business.service.IUserService;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
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.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
public class IMTServiceImpl implements IMTService {
private static final Logger logger = LoggerFactory.getLogger(IMTServiceImpl.class);
@Autowired
private IUserMapper iUserMapper;
@Autowired
private RedisCache redisCache;
@Autowired
private IUserService iUserService;
@Autowired
private IShopService iShopService;
private final static String SALT = "2af72f100c356273d46284f6fd1dfc08";
private final static String AES_KEY = "qbhajinldepmucsonaaaccgypwuvcjaa";
private final static String AES_IV = "2018534749963515";
/**
* 项目启动时,初始化数据
*/
@PostConstruct
public void init() {
new Thread(new Runnable() {
@Override
public void run() {
refreshAll();
}
}).start();
}
@Override
public String getMTVersion() {
String mtVersion = Convert.toStr(redisCache.getCacheObject("mt_version"));
if (StringUtils.isNotEmpty(mtVersion)) {
return mtVersion;
}
String url = "https://apps.apple.com/cn/app/i%E8%8C%85%E5%8F%B0/id1600482450";
String htmlContent = HttpUtil.get(url);
Pattern pattern = Pattern.compile("new__latest__version\">(.*?)</p>", Pattern.DOTALL);
Matcher matcher = pattern.matcher(htmlContent);
if (matcher.find()) {
mtVersion = matcher.group(1);
mtVersion = mtVersion.replace("版本 ", "");
}
redisCache.setCacheObject("mt_version", mtVersion);
return mtVersion;
}
@Override
public void refreshMTVersion() {
redisCache.deleteObject("mt_version");
getMTVersion();
}
@Override
public Boolean sendCode(String mobile, String deviceId) {
Map<String, Object> data = new HashMap<>();
data.put("mobile", mobile);
data.put("md5", signature(mobile));
data.put("timestamp", String.valueOf(System.currentTimeMillis()));
// data.put("MT-APP-Version", MT_VERSION);
HttpRequest request = HttpUtil.createRequest(Method.POST,
"https://app.moutai519.com.cn/xhr/front/user/register/vcode");
request.header("MT-Device-ID", deviceId);
request.header("MT-APP-Version", getMTVersion());
request.header("User-Agent", "iOS;16.3;Apple;?unrecognized?");
request.header("Content-Type", "application/json");
HttpResponse execute = request.body(JSONObject.toJSONString(data)).execute();
JSONObject jsonObject = JSONObject.parseObject(execute.body());
//成功返回 {"code":2000}
logger.info("「发送验证码返回」:" + jsonObject.toJSONString());
if (jsonObject.getString("code").equals("2000")) {
return Boolean.TRUE;
} else {
logger.error("「发送验证码-失败」:" + jsonObject.toJSONString());
throw new ServiceException("发送验证码错误");
// return false;
}
}
@Override
public boolean login(String mobile, String code, String deviceId) {
Map<String, String> map = new HashMap<>();
map.put("mobile", mobile);
map.put("vCode", code);
map.put("md5", signature(mobile + code + "" + ""));
map.put("timestamp", String.valueOf(System.currentTimeMillis()));
map.put("MT-APP-Version", getMTVersion());
HttpRequest request = HttpUtil.createRequest(Method.POST,
"https://app.moutai519.com.cn/xhr/front/user/register/login");
IUser user = iUserMapper.selectById(mobile);
if (user != null) {
deviceId = user.getDeviceId();
}
request.header("MT-Device-ID", deviceId);
request.header("MT-APP-Version", getMTVersion());
request.header("User-Agent", "iOS;16.3;Apple;?unrecognized?");
request.header("Content-Type", "application/json");
HttpResponse execute = request.body(JSONObject.toJSONString(map)).execute();
JSONObject body = JSONObject.parseObject(execute.body());
if (body.getString("code").equals("2000")) {
// logger.info("「登录请求-成功」" + body.toJSONString());
iUserService.insertIUser(Long.parseLong(mobile), deviceId, body);
return true;
} else {
logger.error("「登录请求-失败」" + body.toJSONString());
throw new ServiceException("登录失败,本地错误日志已记录");
// return false;
}
}
@Override
public void reservation(IUser iUser) {
if (StringUtils.isEmpty(iUser.getItemCode())) {
return;
}
String[] items = iUser.getItemCode().split("@");
String logContent = "";
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);
logContent += String.format("[预约项目]:%s\n[shopId]:%s\n[结果返回]:%s\n\n", itemId, shopId, json.toString());
} catch (Exception e) {
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);
//预约后延迟领取耐力值
getEnergyAwardDelay(iUser);
}
/**
* 延迟执行:获取申购耐力值,并记录日志
*
* @param iUser
*/
public void getEnergyAwardDelay(IUser iUser) {
Runnable runnable = new Runnable() {
@Override
public void run() {
String logContent = "";
//sleep 10秒
try {
Thread.sleep(10000);
//预约后领取耐力值
String energyAward = getEnergyAward(iUser);
没有合适的资源?快使用搜索试试~ 我知道了~
茅台预约app程序 茅台酒预约系统 多账户自动预约程序源码 茅台批量预约软件.zip
共549个文件
java:209个
svg:92个
vue:87个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 171 浏览量
2024-02-22
10:23:32
上传
评论
收藏 201.6MB ZIP 举报
温馨提示
茅台app预约程序可以干什么: 有人购买阿里云服务器部署, 有人花200元请技术员家里服务器部署 有人在别人部署的机器上,搭便车部署 有人部署后卖账号给需求者, 各种现象都有 预约抢购,抢到转手卖给黄牛,抢到就是赚到,至少大几百赚 自动新增门店,内置上千家门店数据搭建好添加账号据即可使用,多的就不多说懂的自然懂 手把手图文搭建教程(新手小白也能看得懂)
资源推荐
资源详情
资源评论
收起资源包目录
茅台预约app程序 茅台酒预约系统 多账户自动预约程序源码 茅台批量预约软件.zip (549个子文件)
package.bat 152B
build.bat 109B
run-web.bat 107B
nginx.conf 1KB
redis.conf 35B
.env.development 200B
Dockerfile 361B
.editorconfig 514B
.eslintignore 298B
401.gif 160KB
.gitattributes 0B
.gitignore 463B
.gitignore 256B
ie.html 23KB
index.html 5KB
favicon.ico 4KB
IMTServiceImpl.java 24KB
Convert.java 24KB
StringUtils.java 14KB
SysMenuServiceImpl.java 14KB
ReflectUtils.java 13KB
LogAspect.java 13KB
IShopServiceImpl.java 11KB
SysUserServiceImpl.java 9KB
HttpUtils.java 9KB
ApiResourceScanner.java 8KB
PermissionService.java 8KB
TokenService.java 8KB
SysRoleServiceImpl.java 8KB
FileUploadUtils.java 7KB
IpUtils.java 7KB
RedisCache.java 7KB
SysRoleController.java 6KB
SecurityConfig.java 6KB
SysConfigServiceImpl.java 6KB
SysUserController.java 6KB
SysLoginService.java 5KB
DictUtils.java 5KB
SysProfileController.java 5KB
SysDictTypeServiceImpl.java 5KB
ServletUtils.java 5KB
SysPermissionService.java 5KB
IUserController.java 5KB
SysResourceServiceImpl.java 5KB
DateUtils.java 4KB
LambdaQueryWrapperX.java 4KB
SysMenuController.java 4KB
SpringUtils.java 4KB
PageQuery.java 4KB
CaptchaConfig.java 4KB
DefaultResourceCollector.java 4KB
IUser.java 4KB
SwaggerConfig.java 4KB
SameUrlDataInterceptor.java 4KB
ResourceReportListener.java 4KB
SysUserService.java 4KB
AsyncFactory.java 4KB
SysRegisterService.java 4KB
GlobalExceptionHandler.java 3KB
AopTargetUtils.java 3KB
SysMenuService.java 3KB
SysRoleService.java 3KB
SysDictTypeController.java 3KB
SysPasswordService.java 3KB
BaseMapperX.java 3KB
SysUserMapper.java 3KB
IUserServiceImpl.java 3KB
SecurityUtils.java 3KB
SysDictDataController.java 3KB
SysConfigController.java 3KB
CaptchaController.java 3KB
Constants.java 3KB
MyDBFieldHandler.java 3KB
SysMenuMapper.java 3KB
MyWebMvcConfig.java 3KB
SysUserEntity.java 3KB
PermitAllUrlProperties.java 3KB
R.java 3KB
SysLoginController.java 3KB
SysMenuEntity.java 3KB
IUserMapper.java 3KB
RedisConfig.java 2KB
LoginUser.java 2KB
RouterVo.java 2KB
SysOperLogEntity.java 2KB
JwtAuthenticationTokenFilter.java 2KB
UserDetailsServiceImpl.java 2KB
CharsetKit.java 2KB
InvalidExtensionException.java 2KB
SysDictDataMapper.java 2KB
SysRoleEntity.java 2KB
SysLoginLogEntity.java 2KB
Seq.java 2KB
IShop.java 2KB
SysConfigService.java 2KB
SysOperLogMapper.java 2KB
Threads.java 2KB
JacksonConfig.java 2KB
SysLogininforController.java 2KB
SysRoleMapper.java 2KB
共 549 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
百创科技
- 粉丝: 1988
- 资源: 243
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功