From 0632b32c0802839316a016d2a6c9d896d30c546b Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Wed, 4 Jun 2025 17:23:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=94=A8=E6=88=B7=E9=82=80?= =?UTF-8?q?=E8=AF=B7=E7=A0=81=E7=94=9F=E6=88=90=E6=8E=A5=E5=8F=A3=EF=BC=88?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/userMainInfo/UserMainInfoAddRequest.java | 7 +++++++ .../dto/userMainInfo/UserMainInfoQueryRequest.java | 6 ++++++ .../userMainInfo/UserMainInfoUpdateRequest.java | 7 +++++++ .../promotion/model/entity/UserMainInfo.java | 5 +++++ .../model/vo/userMainInfo/UserMainInfoVO.java | 6 ++++++ .../service/file/impl/FileInfoServiceImpl.java | 10 ++++++---- .../service/userInfo/impl/UserInfoServiceImpl.java | 2 ++ .../wechat/impl/WechatGetQrcodeServiceImpl.java | 14 +++++++++----- src/main/resources/application-dev.yml | 6 ++++++ src/main/resources/application-prod.yml | 6 ++++++ src/main/resources/application-test-caozhe.yml | 5 +++++ src/main/resources/application-test.yml | 6 ++++++ 12 files changed, 71 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java index fd6b356..6037afb 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java @@ -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 */ diff --git a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java index f81c93e..09f8f03 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java @@ -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 */ diff --git a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java index 67bfc59..db46d3f 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java @@ -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 */ diff --git a/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java b/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java index ed52f59..687cbd1 100644 --- a/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java +++ b/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java @@ -52,6 +52,11 @@ public class UserMainInfo implements Serializable { */ private BigDecimal totalIncome; + /** + * 统一抽佣比例 + */ + private BigDecimal uniteRate; + /** * 用户id */ diff --git a/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java index a8e276e..0499ec5 100644 --- a/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java +++ b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java @@ -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 */ diff --git a/src/main/java/com/greenorange/promotion/service/file/impl/FileInfoServiceImpl.java b/src/main/java/com/greenorange/promotion/service/file/impl/FileInfoServiceImpl.java index 9c1e11e..5e4ae40 100644 --- a/src/main/java/com/greenorange/promotion/service/file/impl/FileInfoServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/file/impl/FileInfoServiceImpl.java @@ -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 - // 上传文件的服务器存储目录 - 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 .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 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)); diff --git a/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java b/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java index aada021..e40846d 100644 --- a/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java @@ -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 * 小程序用户注册 */ @Override + @Transactional(rollbackFor = Exception.class) public void userInfoMiniRegister(UserInfoRegisterRequest userInfoRegisterRequest) { String phoneNumber = userInfoRegisterRequest.getPhoneNumber(); ThrowUtils.throwIf(RegexUtils.isPhoneInvalid(phoneNumber), ErrorCode.PARAMS_ERROR, "手机号格式无效"); diff --git a/src/main/java/com/greenorange/promotion/service/wechat/impl/WechatGetQrcodeServiceImpl.java b/src/main/java/com/greenorange/promotion/service/wechat/impl/WechatGetQrcodeServiceImpl.java index 761b32c..3b7c6aa 100644 --- a/src/main/java/com/greenorange/promotion/service/wechat/impl/WechatGetQrcodeServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/wechat/impl/WechatGetQrcodeServiceImpl.java @@ -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 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();// 如果路径不存在则创建 } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 4a11b0a..31e1477 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -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 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 99f13f3..23599ec 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -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 diff --git a/src/main/resources/application-test-caozhe.yml b/src/main/resources/application-test-caozhe.yml index 14e9da2..a88814f 100644 --- a/src/main/resources/application-test-caozhe.yml +++ b/src/main/resources/application-test-caozhe.yml @@ -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 diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 8f4ef39..9962244 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -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