用户 二维码

This commit is contained in:
2025-11-25 11:10:32 +08:00
parent d0bc24138c
commit eaac56dd8e
4 changed files with 48 additions and 22 deletions

View File

@@ -27,4 +27,5 @@ public interface UserInfoService extends IService<UserInfo> {
void updateDistributionAmount(long userId, BigDecimal amount);
void initAc(UserInfo userInfo);
}

View File

@@ -0,0 +1,22 @@
package com.czg.order.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 用于获取 商品成本价
*
* @author ww
* @description
*/
@Data
public class ProductCostAmountVO {
private Long productId;
private Long skuId;
//向上取整 保留两位小数
private BigDecimal costAmount;
private Long count;
private BigDecimal totalCostAmount;
}

View File

@@ -36,8 +36,6 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService {
@Resource
private WechatAuthUtil wechatAuthUtil;
@Resource
private AcAccountUtil acAccountUtil;
@Resource
private AlipayUtil alipayUtil;
@Resource
private UserInfoService userInfoService;
@@ -121,28 +119,10 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService {
userInfo.setLastLoginTime(DateUtil.date().toLocalDateTime());
userInfoService.saveOrUpdate(userInfo);
initAc(userInfo);
userInfoService.initAc(userInfo);
// StpKit.USER.login(userInfo.getId());
StpKit.USER.login(userInfo.getId(), openId, null, null, null, MyStpLogic.LoginType.USER, false, "userMini", false);
String followIndex = paramsService.getSysParamValue(SysParamCodeEnum.FOLLOW_INDEX.getCode());
return new LoginTokenDTO(StpKit.USER.getTokenValue(), followIndex, userInfo);
}
/**
* 初始化用户微信公众号二维码\
*/
private void initAc(UserInfo userInfo) {
if (userInfo.getIsAc() == null) {
userInfo.setIsAc(0);
}
if (userInfo.getIsAc() == 0 &&
(StrUtil.isBlank(userInfo.getWechatAcQrcode()) || userInfo.getAcQrcodeValidTime() == null || userInfo.getAcQrcodeValidTime().isBefore(LocalDateTime.now()))) {
String qrCode = acAccountUtil.createQrCode(userInfo.getId());
if (StrUtil.isNotBlank(qrCode)) {
userInfo.setWechatAcQrcode(qrCode);
userInfo.setAcQrcodeValidTime(LocalDateTime.now().plusDays(29));
userInfoService.updateById(userInfo);
}
}
}
}

View File

@@ -16,6 +16,7 @@ import com.czg.exception.CzgException;
import com.czg.service.RedisService;
import com.czg.service.account.mapper.ShopUserMapper;
import com.czg.service.account.mapper.UserInfoMapper;
import com.czg.service.account.util.AcAccountUtil;
import com.czg.system.service.SmsService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
@@ -24,6 +25,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 服务层实现。
@@ -37,6 +39,8 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
private ShopUserMapper shopUserMapper;
@Resource
private RedisService redisService;
@Resource
private AcAccountUtil acAccountUtil;
@DubboReference
private SmsService smsService;
@@ -47,7 +51,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
if (userInfo == null) {
throw new CzgException("用户信息不存在");
}
initAc(userInfo);
UserInfoAssetsSummaryDTO assetsSummaryDTO = shopUserMapper.selectAssetsSummary(userInfoId);
UserInfoDTO userInfoDTO = BeanUtil.copyProperties(userInfo, UserInfoDTO.class);
userInfoDTO.setAssetsSummary(assetsSummaryDTO);
@@ -106,4 +110,23 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
throw new CzgException("更新分销金额失败");
}
}
/**
* 初始化用户微信公众号二维码\
*/
@Override
public void initAc(UserInfo userInfo) {
if (userInfo.getIsAc() == null) {
userInfo.setIsAc(0);
}
if (userInfo.getIsAc() == 0 &&
(StrUtil.isBlank(userInfo.getWechatAcQrcode()) || userInfo.getAcQrcodeValidTime() == null || userInfo.getAcQrcodeValidTime().isBefore(LocalDateTime.now()))) {
String qrCode = acAccountUtil.createQrCode(userInfo.getId());
if (StrUtil.isNotBlank(qrCode)) {
userInfo.setWechatAcQrcode(qrCode);
userInfo.setAcQrcodeValidTime(LocalDateTime.now().plusDays(29));
updateById(userInfo);
}
}
}
}