完善用户邀请码生成接口(用户注册)

This commit is contained in:
chen-xin-zhi 2025-06-04 17:23:47 +08:00
parent 2ba63d32e1
commit 0632b32c08
12 changed files with 71 additions and 9 deletions

View File

@ -21,6 +21,7 @@ import java.math.BigDecimal;
"withdrawalAmount",
"withdrawnAmount",
"totalIncome",
"uniteRate",
"userId",
"inviteQrCode",
})
@ -68,6 +69,12 @@ public class UserMainInfoAddRequest implements Serializable {
@Schema(description = "累计收入", example = "70.00")
private BigDecimal totalIncome;
/**
* 统一抽佣比例
*/
@Schema(description = "统一抽佣比例", example = "5")
private BigDecimal uniteRate;
/**
* 用户id
*/

View File

@ -67,6 +67,12 @@ public class UserMainInfoQueryRequest extends PageRequest implements Serializabl
@Schema(description = "累计收入", example = "70.00")
private BigDecimal totalIncome;
/**
* 统一抽佣比例
*/
@Schema(description = "统一抽佣比例", example = "5")
private BigDecimal uniteRate;
/**
* 用户id
*/

View File

@ -22,6 +22,7 @@ import java.math.BigDecimal;
"withdrawalAmount",
"withdrawnAmount",
"totalIncome",
"uniteRate",
"userId",
"inviteQrCode",
})
@ -76,6 +77,12 @@ public class UserMainInfoUpdateRequest implements Serializable {
@Schema(description = "累计收入", example = "70.00")
private BigDecimal totalIncome;
/**
* 统一抽佣比例
*/
@Schema(description = "统一抽佣比例", example = "5")
private BigDecimal uniteRate;
/**
* 用户id
*/

View File

@ -52,6 +52,11 @@ public class UserMainInfo implements Serializable {
*/
private BigDecimal totalIncome;
/**
* 统一抽佣比例
*/
private BigDecimal uniteRate;
/**
* 用户id
*/

View File

@ -62,6 +62,12 @@ public class UserMainInfoVO implements Serializable {
@Schema(description = "累计收入", example = "100.00")
private BigDecimal totalIncome;
/**
* 统一抽佣比例
*/
@Schema(description = "统一抽佣比例", example = "5")
private BigDecimal uniteRate;
/**
* 用户id
*/

View File

@ -18,6 +18,7 @@ import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -38,8 +39,9 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo>
// 上传文件的服务器存储目录
private static final String UPLOAD_DIR = "/www/wwwroot/fileUpload_qc/";
// 文件上传的存储目录
@Value("${file.upload-dir}")
private String uploadDir;
// 优化设置一个合理的缓冲区大小
@ -101,7 +103,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo>
.build();
this.save(fileInfo);
// 创建上传目录如果不存在
File file = new File(UPLOAD_DIR + fileName);
File file = new File(uploadDir + fileName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();// 如果路径不存在则创建
}
@ -132,7 +134,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo>
FileInfo fileInfo = this.getOne(lambdaQueryWrapper);
ThrowUtils.throwIf(fileInfo == null, ErrorCode.NOT_FOUND_ERROR, "文件不存在");
File file = new File(UPLOAD_DIR + fileInfo.getName());
File file = new File(uploadDir + fileInfo.getName());
// // 设置response的Header
response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileInfo.getName(), StandardCharsets.UTF_8));

View File

@ -34,6 +34,7 @@ import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.math.BigDecimal;
@ -129,6 +130,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
* 小程序用户注册
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void userInfoMiniRegister(UserInfoRegisterRequest userInfoRegisterRequest) {
String phoneNumber = userInfoRegisterRequest.getPhoneNumber();
ThrowUtils.throwIf(RegexUtils.isPhoneInvalid(phoneNumber), ErrorCode.PARAMS_ERROR, "手机号格式无效");

View File

@ -19,9 +19,11 @@ import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Resource;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -36,8 +38,9 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
// 上传文件的服务器存储目录
private static final String UPLOAD_DIR = "D:/qingcheng/image/";
// 文件上传的存储目录
@Value("${file.upload-dir}")
private String uploadDir;
private final static String ACCESS_TOKEN_KEY = "accessToken";
@ -99,6 +102,7 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
* 获取微信小程序二维码
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String getWxQrCode(String inviteCode) throws IOException {
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
if (accessToken == null) {
@ -107,7 +111,7 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
Map<String, Object> param = new HashMap<>();
param.put("page", "pages/loginModule/register/register");
param.put("scene", "invitationCode=" + inviteCode);
param.put("width", 430); // 宽度
param.put("width", 430);
param.put("check_path", false);
param.put("env_version", "develop");
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
@ -140,12 +144,12 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
byte[] resultBytes = resultStream.readAllBytes();
// 创建上传目录如果不存在
String biz = "default";
String fileName = "qrcode.png";
String fileName = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + "." + "png";
// 获取文件类型
String fileType = FileUtil.getSuffix(fileName);
// 获取view值
String view = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
File file = new File(UPLOAD_DIR + fileName);
File file = new File(uploadDir + fileName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();// 如果路径不存在则创建
}

View File

@ -23,6 +23,12 @@ spring:
max-request-size: 20MB
#文件上传和下载地址
file:
# upload-dir: /www/wwwroot/fileUpload_qc/
upload-dir: D:/qingcheng/image/
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8

View File

@ -24,6 +24,12 @@ spring:
max-request-size: 20MB
#文件上传和下载地址
file:
# upload-dir: /www/wwwroot/fileUpload_qc/
upload-dir: D:/qingcheng/image/
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8

View File

@ -23,6 +23,11 @@ spring:
max-file-size: 20MB
max-request-size: 20MB
#文件上传和下载地址
file:
# upload-dir: /www/wwwroot/fileUpload_qc/
upload-dir: D:/qingcheng/image/
jackson:
date-format: yyyy-MM-dd HH:mm:ss

View File

@ -24,6 +24,12 @@ spring:
max-request-size: 20MB
# 文件上传和下载地址
file:
# upload-dir: /www/wwwroot/fileUpload_qc/
upload-dir: D:/qingcheng/image/
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8