feat:bug修改
This commit is contained in:
1 parent
e532c68c54
commit
bd1b400f50
11 files changed
+76
-20
No files matched your search
+3
@@ -15,4 +15,7 @@ public class OperationStatusVo {
|
||||
@Schema(description = "是否点赞")
|
||||
private Boolean isLike = false;
|
||||
|
||||
@Schema(description = "是否查看微信")
|
||||
private Boolean isLookWechat = false;
|
||||
|
||||
}
|
||||
+8
@@ -68,9 +68,17 @@ public class AppSocialUserController {
|
||||
return success(Base64.encode(wxQrcode));
|
||||
}
|
||||
|
||||
@GetMapping("/wxa-url-scheme")
|
||||
@Operation(summary = "获取小程序短链")
|
||||
@PermitAll
|
||||
public CommonResult<String> getWxUrlScheme(@RequestParam String path, @RequestParam String json) {
|
||||
return success(socialClientApi.getWxUrlScheme(path, json));
|
||||
}
|
||||
|
||||
@GetMapping("/get-subscribe-template-list")
|
||||
@Operation(summary = "获得微信小程订阅模板列表")
|
||||
@PermitAll
|
||||
|
||||
public CommonResult<List<AppSocialWxaSubscribeTemplateRespVO>> getSubscribeTemplateList() {
|
||||
List<SocialWxaSubscribeTemplateRespDTO> template = socialClientApi.getWxaSubscribeTemplateList(UserTypeEnum.MEMBER.getValue());
|
||||
return success(BeanUtils.toBean(template, AppSocialWxaSubscribeTemplateRespVO.class));
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ public interface OperationService {
|
||||
List<Long> getBlackUserIdList(Long memberId);
|
||||
|
||||
/**
|
||||
* 获取微信今日查看次数
|
||||
* 获取微信查看次数
|
||||
*/
|
||||
Integer lookWechatTodayCount(Long operateMemberId, Long memberId);
|
||||
Integer lookWechatCount(Long operateMemberId, Long memberId);
|
||||
}
|
||||
+6
-6
@@ -135,16 +135,16 @@ public class OperationServiceImpl implements OperationService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信今日查看次数
|
||||
* 获取微信查看次数
|
||||
*/
|
||||
@Override
|
||||
public Integer lookWechatTodayCount(Long operateMemberId, Long memberId) {
|
||||
public Integer lookWechatCount(Long operateMemberId, Long memberId) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Long count = operationMapper.selectCount(new LambdaQueryWrapperX<OperationDO>()
|
||||
.eq(OperationDO::getOperatorMemberId, operateMemberId)
|
||||
.eqIfPresent(OperationDO::getMemberId, memberId)
|
||||
.eq(OperationDO::getBizType, MemberRecentOperateEnum.MEMBER_LOOK_WECHAT.getType())
|
||||
.between(OperationDO::getCreateTime, now.with(LocalTime.MIN), now.with(LocalTime.MAX))
|
||||
.eq(OperationDO::getOperatorMemberId, operateMemberId)
|
||||
.eqIfPresent(OperationDO::getMemberId, memberId)
|
||||
.eq(OperationDO::getBizType, MemberRecentOperateEnum.MEMBER_LOOK_WECHAT.getType())
|
||||
// .between(OperationDO::getCreateTime, now.with(LocalTime.MIN), now.with(LocalTime.MAX))
|
||||
);
|
||||
return Math.toIntExact(count);
|
||||
}
|
||||
|
||||
+3
-3
@@ -295,12 +295,12 @@ public class RecentServiceImpl implements RecentService {
|
||||
}
|
||||
MemberConfigDO config = memberConfigService.getConfig();
|
||||
Integer vipLookWechtCout = config.getVipLookWechtCout();
|
||||
// 判断今天有没有查看过
|
||||
if (operationService.lookWechatTodayCount(operateMemberId, memberId) > 0) {
|
||||
// 今天有没有查看过他的微信
|
||||
if (operationService.lookWechatCount(operateMemberId, memberId) > 0) {
|
||||
return memberWechat;
|
||||
}
|
||||
// 查询用户今天有没有查看次数
|
||||
Integer userLookWechtCout = operationService.lookWechatTodayCount(operateMemberId, null);
|
||||
Integer userLookWechtCout = operationService.lookWechatCount(operateMemberId, null);
|
||||
if (userLookWechtCout > vipLookWechtCout) {
|
||||
throw exception(MemberErrorCode.EMPTY, "今日查看微信次数已用完");
|
||||
}
|
||||
|
||||
+4
-2
@@ -76,7 +76,8 @@
|
||||
resultType="cn.iocoder.yudao.module.member.controller.admin.recent.vo.OperationStatusVo">
|
||||
select
|
||||
a.member_id,
|
||||
if(a.biz_type = '4' and a.cancel_time is null, true, false) as isLike
|
||||
if(a.biz_type = '4' and a.cancel_time is null, true, false) as isLike,
|
||||
if(a.biz_type = '100' and a.cancel_time is null, true, false) as isLookWechat
|
||||
from member_operation a
|
||||
<where>
|
||||
a.deleted = '0'
|
||||
@@ -97,7 +98,8 @@
|
||||
resultType="cn.iocoder.yudao.module.member.controller.admin.recent.vo.OperationStatusVo">
|
||||
select
|
||||
a.member_recent_id,
|
||||
if(a.biz_type = '1' and a.cancel_time is null, true, false) as isLike
|
||||
if(a.biz_type = '1' and a.cancel_time is null, true, false) as isLike,
|
||||
if(a.biz_type = '100' and a.cancel_time is null, true, false) as isLookWechat
|
||||
from member_operation a
|
||||
<where>
|
||||
a.deleted = '0'
|
||||
|
||||
+5
@@ -44,6 +44,11 @@ public interface SocialClientApi {
|
||||
*/
|
||||
SocialWxPhoneNumberInfoRespDTO getWxMaPhoneNumberInfo(Integer userType, String phoneCode);
|
||||
|
||||
/**
|
||||
* 获取小程序短链
|
||||
*/
|
||||
String getWxUrlScheme(String path, String json);
|
||||
|
||||
/**
|
||||
* 获得小程序二维码
|
||||
*
|
||||
|
||||
+1
@@ -121,6 +121,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR = new ErrorCode(1_002_018_200, "获得手机号失败");
|
||||
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR = new ErrorCode(1_002_018_201, "获得小程序码失败");
|
||||
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_URL_SCHEME_ERROR = new ErrorCode(1_002_018_201, "获得小程序短链失败");
|
||||
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR = new ErrorCode(1_002_018_202, "获得小程序订阅消息模版失败");
|
||||
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR = new ErrorCode(1_002_018_203, "发送小程序订阅消息失败");
|
||||
ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_210, "社交客户端不存在");
|
||||
|
||||
+8
@@ -55,6 +55,14 @@ public class SocialClientApiImpl implements SocialClientApi {
|
||||
return BeanUtils.toBean(info, SocialWxPhoneNumberInfoRespDTO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序短链
|
||||
*/
|
||||
@Override
|
||||
public String getWxUrlScheme(String path, String json) {
|
||||
return socialClientService.getWxUrlScheme(path, json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) {
|
||||
return socialClientService.getWxaQrcode(reqVO);
|
||||
|
||||
+6
-1
@@ -57,6 +57,11 @@ public interface SocialClientService {
|
||||
|
||||
// =================== 微信小程序独有 ===================
|
||||
|
||||
/**
|
||||
* 获取小程序短链
|
||||
*/
|
||||
String getWxUrlScheme(String path, String json);
|
||||
|
||||
/**
|
||||
* 获得微信小程序的手机信息
|
||||
*
|
||||
@@ -76,7 +81,7 @@ public interface SocialClientService {
|
||||
|
||||
/**
|
||||
* 获得微信小程订阅模板
|
||||
*
|
||||
* <p>
|
||||
* 缓存的目的:考虑到微信小程序订阅消息选择好模版后几乎不会变动,缓存增加查询效率
|
||||
*
|
||||
* @param userType 用户类型
|
||||
|
||||
+30
-6
@@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
@@ -74,7 +75,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
|
||||
/**
|
||||
* 小程序码要打开的小程序版本
|
||||
*
|
||||
* <p>
|
||||
* 1. release:正式版
|
||||
* 2. trial:体验版
|
||||
* 3. developer:开发版
|
||||
@@ -83,7 +84,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
public String envVersion;
|
||||
/**
|
||||
* 订阅消息跳转小程序类型
|
||||
*
|
||||
* <p>
|
||||
* 1. developer:开发版
|
||||
* 2. trial:体验版
|
||||
* 3. formal:正式版
|
||||
@@ -102,10 +103,10 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
private StringRedisTemplate stringRedisTemplate; // WxMpService 需要使用到,所以在 Service 注入了它
|
||||
/**
|
||||
* 缓存 WxMpService 对象
|
||||
*
|
||||
* <p>
|
||||
* key:使用微信公众号的 appId + secret 拼接,即 {@link SocialClientDO} 的 clientId 和 clientSecret 属性。
|
||||
* 为什么 key 使用这种格式?因为 {@link SocialClientDO} 在管理后台可以变更,通过这个 key 存储它的单例。
|
||||
*
|
||||
* <p>
|
||||
* 为什么要做 WxMpService 缓存?因为 WxMpService 构建成本比较大,所以尽量保证它是单例。
|
||||
*/
|
||||
private final LoadingCache<String, WxMpService> wxMpServiceCache = CacheUtils.buildAsyncReloadingCache(
|
||||
@@ -126,7 +127,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
private WxMaProperties wxMaProperties;
|
||||
/**
|
||||
* 缓存 WxMaService 对象
|
||||
*
|
||||
* <p>
|
||||
* 说明同 {@link #wxMpServiceCache} 变量
|
||||
*/
|
||||
private final LoadingCache<String, WxMaService> wxMaServiceCache = CacheUtils.buildAsyncReloadingCache(
|
||||
@@ -260,6 +261,29 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序短链
|
||||
*/
|
||||
@Override
|
||||
public String getWxUrlScheme(String path, String json) {
|
||||
WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
|
||||
try {
|
||||
String urlScheme = service.getWxMaSchemeService().generate(WxMaGenerateSchemeRequest.newBuilder()
|
||||
.jumpWxa(
|
||||
WxMaGenerateSchemeRequest.JumpWxa.newBuilder().path(path).query(json).envVersion("trial").build()
|
||||
)
|
||||
.expireTime((long) (5 * 60 * 1000))
|
||||
.expireType(0)
|
||||
.build()
|
||||
);
|
||||
return urlScheme;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_URL_SCHEME_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) {
|
||||
WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
|
||||
@@ -407,7 +431,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
|
||||
/**
|
||||
* 校验社交应用是否重复,需要保证 userType + socialType 唯一
|
||||
*
|
||||
* <p>
|
||||
* 原因是,不同端(userType)选择某个社交登录(socialType)时,需要通过 {@link #buildAuthRequest(Integer, Integer)} 构建对应的请求
|
||||
*
|
||||
* @param id 编号
|
||||
|
||||
Reference in new issue
Block a user