Skip to content

Commit

Permalink
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-…
Browse files Browse the repository at this point in the history
…vue-pro

# Conflicts:
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java
  • Loading branch information
YunaiV committed Aug 2, 2024
2 parents 0e9ed0c + 7de5463 commit cdfce46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ public CommonResult<AppSocialUserRespVO> getSocialUser(@RequestParam("type") Int

@PostMapping("/wxa-qrcode")
@Operation(summary = "获得微信小程序码(base64 image)")
public CommonResult<String> getWxaQrcode(@RequestBody @Valid AppSocialWxQrcodeReqVO reqVO) {
public CommonResult<String> getWxaQrcode(@RequestBody @Valid AppSocialWxaQrcodeReqVO reqVO) {
byte[] wxQrcode = socialClientApi.getWxaQrcode(BeanUtils.toBean(reqVO, SocialWxQrcodeReqDTO.class));
return success(Base64.encode(wxQrcode));
}

@GetMapping("/get-subscribe-template-list")
@Operation(summary = "获得微信小程订阅模板列表")
public CommonResult<List<AppSocialWxSubscribeTemplateRespVO>> getSubscribeTemplateList() {
public CommonResult<List<AppSocialWxaSubscribeTemplateRespVO>> getSubscribeTemplateList() {
List<SocialWxaSubscribeTemplateRespDTO> template = socialClientApi.getWxaSubscribeTemplateList(UserTypeEnum.MEMBER.getValue());
return success(BeanUtils.toBean(template, AppSocialWxSubscribeTemplateRespVO.class));
return success(BeanUtils.toBean(template, AppSocialWxaSubscribeTemplateRespVO.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@Schema(description = "用户 APP - 获得获取小程序码 Request VO")
@Data
public class AppSocialWxQrcodeReqVO {
public class AppSocialWxaQrcodeReqVO {

/**
* 页面路径不能携带参数(参数请放在scene字段里)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@Schema(description = "用户 APP - 获得小程序订阅模版 Response VO")
@Data
public class AppSocialWxSubscribeTemplateRespVO {
public class AppSocialWxaSubscribeTemplateRespVO {

@Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED,
example = "9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import cn.iocoder.yudao.module.system.api.social.dto.*;
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

import static cn.hutool.core.collection.CollUtil.findOne;
Expand All @@ -33,7 +34,7 @@ public class SocialClientApiImpl implements SocialClientApi {
@Resource
private SocialClientService socialClientService;
@Resource
public SocialUserApi socialUserApi;
private SocialUserService socialUserService;

@Override
public String getAuthorizeUrl(Integer socialType, Integer userType, String redirectUri) {
Expand Down Expand Up @@ -68,29 +69,29 @@ public List<SocialWxaSubscribeTemplateRespDTO> getWxaSubscribeTemplateList(Integ
@Override
public void sendWxaSubscribeMessage(SocialWxaSubscribeMessageSendReqDTO reqDTO) {
// 1.1 获得订阅模版列表
List<SocialWxaSubscribeTemplateRespDTO> templateList = getWxaSubscribeTemplateList(reqDTO.getUserType());
List<TemplateInfo> templateList = socialClientService.getSubscribeTemplateList(reqDTO.getUserType());
if (CollUtil.isEmpty(templateList)) {
log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO);
return;
}
// 1.2 获得需要使用的模版
SocialWxaSubscribeTemplateRespDTO template = findOne(templateList, item ->
TemplateInfo template = findOne(templateList, item ->
ObjUtil.equal(item.getTitle(), reqDTO.getTemplateTitle()));
if (template == null) {
log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO);
log.warn("[sendWxaSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO);
return;
}

// 2. 获得社交用户
SocialUserRespDTO socialUser = socialUserApi.getSocialUserByUserId(reqDTO.getUserType(), reqDTO.getUserId(),
SocialUserRespDTO socialUser = socialUserService.getSocialUserByUserId(reqDTO.getUserType(), reqDTO.getUserId(),
SocialTypeEnum.WECHAT_MINI_APP.getType());
if (StrUtil.isBlankIfStr(socialUser.getOpenid())) {
log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:会员 openid 缺失]", reqDTO);
log.warn("[sendWxaSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:会员 openid 缺失]", reqDTO);
return;
}

// 3. 发送订阅消息
socialClientService.sendSubscribeMessage(reqDTO, template.getId(), socialUser.getOpenid());
socialClientService.sendSubscribeMessage(reqDTO, template.getPriTmplId(), socialUser.getOpenid());
}

}

0 comments on commit cdfce46

Please sign in to comment.