Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai 2025-03-11 16:24:33 +08:00
commit a8af203c31
8 changed files with 154 additions and 10 deletions

View File

@ -0,0 +1,31 @@
package com.czg.controller.user;
import com.czg.resp.CzgResult;
import com.czg.service.account.util.AliOssUtil;
import jakarta.annotation.Resource;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/**
* @author Administrator
*/
@RestController
@RequestMapping("/user/common")
public class UCommonController {
@Resource
private AliOssUtil aliOssUtil;
/**
* 文件上传
* @param file 文件信息
* @return 上传路径
* @throws Exception 异常
*/
@PostMapping("/upload")
public CzgResult<?> upload(MultipartFile file) throws Exception {
return CzgResult.success(aliOssUtil.uploadSuffix(file.getBytes(), FilenameUtils.getExtension(file.getOriginalFilename())));
}
}

View File

@ -38,7 +38,7 @@ public class UserController {
*/
@PutMapping
public CzgResult<Boolean> update(@RequestBody UserInfoEditDTO userInfoEditDTO) {
return CzgResult.success(userInfoService.updateInfo( StpKit.USER.getLoginIdAsLong(), userInfoEditDTO));
return CzgResult.success(userInfoService.updateInfo(StpKit.USER.getShopId(-1L), StpKit.USER.getLoginIdAsLong(), userInfoEditDTO));
}
/**

View File

@ -16,7 +16,7 @@ public interface UserInfoService extends IService<UserInfo> {
UserInfoDTO getInfo(long userInfoId);
Boolean updateInfo(long userId, UserInfoEditDTO userInfoEditDTO);
Boolean updateInfo(long shopId, long userId, UserInfoEditDTO userInfoEditDTO);
Boolean updatePwd(long userId, UserInfoPwdEditDTO userInfoPwdEditDTO);

View File

@ -0,0 +1,104 @@
package com.czg.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* Miscellaneous methods for calculating digests.
*
* <p>Mainly for internal use within the framework; consider
* <a href="https://commons.apache.org/codec/">Apache Commons Codec</a>
* for a more comprehensive suite of digest utilities.
*
* @author Arjen Poutsma
* @author Juergen Hoeller
* @author Craig Andrews
* @since 3.0
*/
public abstract class DigestUtils {
private static final String MD5_ALGORITHM_NAME = "MD5";
private static final char[] HEX_CHARS =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
/**
* Calculate the MD5 digest of the given bytes.
* @param bytes the bytes to calculate the digest over
* @return the digest
*/
public static byte[] md5Digest(byte[] bytes) {
return digest(MD5_ALGORITHM_NAME, bytes);
}
/**
* Return a hexadecimal string representation of the MD5 digest of the given bytes.
* @param bytes the bytes to calculate the digest over
* @return a hexadecimal digest string
*/
public static String md5DigestAsHex(byte[] bytes) {
return digestAsHexString(MD5_ALGORITHM_NAME, bytes);
}
/**
* Append a hexadecimal string representation of the MD5 digest of the given
* bytes to the given {@link StringBuilder}.
* @param bytes the bytes to calculate the digest over
* @param builder the string builder to append the digest to
* @return the given string builder
*/
public static StringBuilder appendMd5DigestAsHex(byte[] bytes, StringBuilder builder) {
return appendDigestAsHex(MD5_ALGORITHM_NAME, bytes, builder);
}
/**
* Create a new {@link MessageDigest} with the given algorithm.
* <p>Necessary because {@code MessageDigest} is not thread-safe.
*/
private static MessageDigest getDigest(String algorithm) {
try {
return MessageDigest.getInstance(algorithm);
}
catch (NoSuchAlgorithmException ex) {
throw new IllegalStateException("Could not find MessageDigest with algorithm \"" + algorithm + "\"", ex);
}
}
private static byte[] digest(String algorithm, byte[] bytes) {
return getDigest(algorithm).digest(bytes);
}
private static String digestAsHexString(String algorithm, byte[] bytes) {
char[] hexDigest = digestAsHexChars(algorithm, bytes);
return new String(hexDigest);
}
private static StringBuilder appendDigestAsHex(String algorithm, byte[] bytes, StringBuilder builder) {
char[] hexDigest = digestAsHexChars(algorithm, bytes);
return builder.append(hexDigest);
}
private static char[] digestAsHexChars(String algorithm, byte[] bytes) {
byte[] digest = digest(algorithm, bytes);
return encodeHex(digest);
}
private static char[] encodeHex(byte[] bytes) {
char[] chars = new char[32];
for (int i = 0; i < chars.length; i = i + 2) {
byte b = bytes[i / 2];
chars[i] = HEX_CHARS[(b >>> 0x4) & 0xf];
chars[i + 1] = HEX_CHARS[b & 0xf];
}
return chars;
}
}

View File

@ -1,7 +1,5 @@
package com.czg.utils;
import org.springframework.util.DigestUtils;
/**
* @author ww
*/

View File

@ -87,9 +87,11 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
@Override
public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) {
long count = count(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId()));
if (count > 0) {
throw new ApiNotPrintException("手机号已存在");
if (StrUtil.isNotBlank(shopUserEditDTO.getPhone())) {
long count = count(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId()));
if (count > 0) {
throw new ApiNotPrintException("手机号已存在");
}
}
ShopUser shopUser = getUserInfo(shopId, shopUserEditDTO.getId());
BeanUtil.copyProperties(shopUserEditDTO, shopUser);

View File

@ -8,6 +8,7 @@ import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
import com.czg.account.dto.user.userinfo.UserInfoDTO;
import com.czg.account.dto.user.userinfo.UserInfoEditDTO;
import com.czg.account.dto.user.userinfo.UserInfoPwdEditDTO;
import com.czg.account.entity.ShopUser;
import com.czg.account.entity.UserInfo;
import com.czg.account.service.UserInfoService;
import com.czg.config.RedisCst;
@ -16,6 +17,7 @@ import com.czg.service.RedisService;
import com.czg.service.account.mapper.ShopUserMapper;
import com.czg.service.account.mapper.UserInfoMapper;
import com.czg.system.service.SmsService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
@ -51,10 +53,17 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
}
@Override
public Boolean updateInfo(long userId, UserInfoEditDTO userInfoEditDTO) {
public Boolean updateInfo(long shopId, long userId, UserInfoEditDTO userInfoEditDTO) {
UserInfo userInfo = getById(userId);
BeanUtil.copyProperties(userInfoEditDTO, userInfo);
return save(userInfo);
if (save(userInfo)) {
if (shopId != -1L) {
ShopUser shopUser = BeanUtil.copyProperties(userInfo, ShopUser.class);
return shopUserMapper.updateByQuery(shopUser, new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userId)) > 0;
}
return true;
}
return false;
}
@Override

View File

@ -435,7 +435,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
prodCouponAmount.setPrice((prodCouponAmount.getPrice().add(orderDetail.getUnitPrice())).multiply(orderDetail.getCouponNum()));
} else {
orderDetail.setCouponNum(BigDecimal.ZERO);
orderDetail.setPayAmount(orderDetail.getNum().subtract(orderDetail.getReturnNum()).multiply(orderDetail.getUnitPrice()));
orderDetail.setPayAmount((orderDetail.getNum().subtract(orderDetail.getReturnNum())).multiply(orderDetail.getUnitPrice()));
}
totalAmount.setPrice(totalAmount.getPrice().add(orderDetail.getPayAmount()));
resultList.add(orderDetail);