Commit b917d92af5ba64231da71c7fe1e653cbc5971006

Authored by 芋道源码
Committed by Gitee
2 parents 401de303 8054847b

!1018 新增小程序订阅消息相关接口

Merge pull request !1018 from puhui999/develop
Showing 12 changed files with 266 additions and 20 deletions
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
... ... @@ -13,4 +13,9 @@ public interface MessageTemplateConstants {
13 13 String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过)
14 14 String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过)
15 15  
  16 + //======================= 订阅消息模版 =======================
  17 +
  18 + String ORDER_AFTERSALE_CHANGE = "售后进度通知";
  19 + String MONEY_CHANGE = "充值成功通知";
  20 +
16 21 }
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java
... ... @@ -5,10 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
5 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
6 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
7 7 import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
8   -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserBindReqVO;
9   -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserRespVO;
10   -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO;
11   -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialWxQrcodeReqVO;
  8 +import cn.iocoder.yudao.module.member.controller.app.social.vo.*;
12 9 import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
13 10 import cn.iocoder.yudao.module.system.api.social.SocialUserApi;
14 11 import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
... ... @@ -23,6 +20,8 @@ import jakarta.validation.Valid;
23 20 import org.springframework.validation.annotation.Validated;
24 21 import org.springframework.web.bind.annotation.*;
25 22  
  23 +import java.util.List;
  24 +
26 25 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
27 26 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
28 27  
... ... @@ -72,4 +71,10 @@ public class AppSocialUserController {
72 71 return success(Base64.encode(wxQrcode));
73 72 }
74 73  
  74 + @GetMapping("/get-subscribe-template")
  75 + @Operation(summary = "获得微信小程订阅模板")
  76 + public CommonResult<List<AppSocialWxSubscribeTemplateRespVO>> getSubscribeTemplate() {
  77 + return success(BeanUtils.toBean(socialClientApi.getSubscribeTemplate(), AppSocialWxSubscribeTemplateRespVO.class));
  78 + }
  79 +
75 80 }
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.member.controller.app.social.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +@Schema(description = "用户 APP - 获得小程序订阅模版 Response VO")
  7 +@Data
  8 +public class AppSocialWxSubscribeTemplateRespVO {
  9 +
  10 + @Schema(description = "添加至账号下的模板 id,发送小程序订阅消息时所需", requiredMode = Schema.RequiredMode.REQUIRED, example = "9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU")
  11 + private String priTmplId;
  12 +
  13 + @Schema(description = "模版标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单支付通知")
  14 + private String title;
  15 +
  16 + @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED)
  17 + private String content;
  18 +
  19 + @Schema(description = "模板内容示例", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单时间:2016年8月8日")
  20 + private String example;
  21 +
  22 + @Schema(description = "模版类型,2 为一次性订阅,3 为长期订阅", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  23 + private Integer type;
  24 +
  25 +}
... ...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java
1 1 package cn.iocoder.yudao.module.system.api.social;
2 2  
3   -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
4   -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
5   -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
  3 +import cn.iocoder.yudao.module.system.api.social.dto.*;
6 4 import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
7 5 import jakarta.validation.Valid;
8 6  
  7 +import java.util.List;
  8 +
9 9 /**
10 10 * 社交应用的 API 接口
11 11 *
... ... @@ -16,8 +16,8 @@ public interface SocialClientApi {
16 16 /**
17 17 * 获得社交平台的授权 URL
18 18 *
19   - * @param socialType 社交平台的类型 {@link SocialTypeEnum}
20   - * @param userType 用户类型
  19 + * @param socialType 社交平台的类型 {@link SocialTypeEnum}
  20 + * @param userType 用户类型
21 21 * @param redirectUri 重定向 URL
22 22 * @return 社交平台的授权 URL
23 23 */
... ... @@ -27,7 +27,7 @@ public interface SocialClientApi {
27 27 * 创建微信公众号 JS SDK 初始化所需的签名
28 28 *
29 29 * @param userType 用户类型
30   - * @param url 访问的 URL 地址
  30 + * @param url 访问的 URL 地址
31 31 * @return 签名
32 32 */
33 33 SocialWxJsapiSignatureRespDTO createWxMpJsapiSignature(Integer userType, String url);
... ... @@ -35,7 +35,7 @@ public interface SocialClientApi {
35 35 /**
36 36 * 获得微信小程序的手机信息
37 37 *
38   - * @param userType 用户类型
  38 + * @param userType 用户类型
39 39 * @param phoneCode 手机授权码
40 40 * @return 手机信息
41 41 */
... ... @@ -49,4 +49,18 @@ public interface SocialClientApi {
49 49 */
50 50 byte[] getWxaQrcode(@Valid SocialWxQrcodeReqDTO reqVO);
51 51  
  52 + /**
  53 + * 获得微信小程订阅模板
  54 + *
  55 + * @return 小程序订阅消息模版
  56 + */
  57 + List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplate();
  58 +
  59 + /**
  60 + * 发送订阅消息
  61 + *
  62 + * @param reqDTO 请求
  63 + */
  64 + void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO);
  65 +
52 66 }
... ...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.api.social.dto;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.KeyValue;
  4 +import lombok.Data;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * 微信小程序订阅消息 Request DTO
  11 + *
  12 + * @author HUIHUI
  13 + */
  14 +@Data
  15 +public class SocialWxSubscribeMessageReqDTO {
  16 +
  17 + /**
  18 + * 接收者(用户)的 openid.
  19 + * <pre>
  20 + * 参数:touser
  21 + * 是否必填: 是
  22 + * 描述: 接收者(用户)的 openid
  23 + * </pre>
  24 + */
  25 + private String toUser;
  26 +
  27 + /**
  28 + * 所需下发的模板消息的id.
  29 + * <pre>
  30 + * 参数:template_id
  31 + * 是否必填: 是
  32 + * 描述: 所需下发的模板消息的id
  33 + * </pre>
  34 + */
  35 + private String templateId;
  36 +
  37 + /**
  38 + * 点击模板卡片后的跳转页面,仅限本小程序内的页面.
  39 + * <pre>
  40 + * 参数:page
  41 + * 是否必填: 否
  42 + * 描述: 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
  43 + * </pre>
  44 + */
  45 + private String page;
  46 +
  47 + /**
  48 + * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
  49 + *
  50 + * 枚举 WxMaConstants.MiniProgramState
  51 + */
  52 + private String miniprogramState;
  53 +
  54 + /**
  55 + * 进入小程序查看的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN
  56 + *
  57 + * 枚举 WxMaConstants.MiniProgramLang
  58 + */
  59 + private String lang;
  60 +
  61 + /**
  62 + * 模板内容,不填则下发空模板.
  63 + * <pre>
  64 + * 参数:data
  65 + * 是否必填: 是
  66 + * 描述: 模板内容,不填则下发空模板
  67 + * </pre>
  68 + */
  69 + private List<KeyValue<String, String>> messages;
  70 +
  71 + public SocialWxSubscribeMessageReqDTO addData(String key, String value) {
  72 + if (messages == null) {
  73 + messages = new ArrayList<>();
  74 + }
  75 + messages.add(new KeyValue<>(key, value));
  76 + return this;
  77 + }
  78 +
  79 +}
... ...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.api.social.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +
  6 +/**
  7 + * 小程序订阅消息模版 Response DTO
  8 + *
  9 + * @author HUIHUI
  10 + */
  11 +@Data
  12 +public class SocialWxSubscribeTemplateRespDTO {
  13 +
  14 + /**
  15 + * 添加至账号下的模板 id,发送小程序订阅消息时所需
  16 + */
  17 + private String priTmplId;
  18 +
  19 + /**
  20 + * 模版标题
  21 + */
  22 + private String title;
  23 +
  24 + /**
  25 + * 模版内容
  26 + */
  27 + private String content;
  28 +
  29 + /**
  30 + * 模板内容示例
  31 + */
  32 + private String example;
  33 +
  34 + /**
  35 + * 模版类型,2 为一次性订阅,3 为长期订阅
  36 + */
  37 + private Integer type;
  38 +
  39 +}
... ...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
... ... @@ -121,8 +121,10 @@ public interface ErrorCodeConstants {
121 121  
122 122 ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR = new ErrorCode(1_002_018_200, "获得手机号失败");
123 123 ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR = new ErrorCode(1_002_018_201, "获得小程序码失败");
124   - ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_202, "社交客户端不存在");
125   - ErrorCode SOCIAL_CLIENT_UNIQUE = new ErrorCode(1_002_018_203, "社交客户端已存在配置");
  124 + ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR = new ErrorCode(1_002_018_202, "获得小程序订阅消息模版失败");
  125 + ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR = new ErrorCode(1_002_018_203, "发送小程序订阅消息失败");
  126 + ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_210, "社交客户端不存在");
  127 + ErrorCode SOCIAL_CLIENT_UNIQUE = new ErrorCode(1_002_018_211, "社交客户端已存在配置");
126 128  
127 129  
128 130 // ========== OAuth2 客户端 1-002-020-000 =========
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java
... ... @@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.system.api.social;
2 2  
3 3 import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
4 4 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
5   -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
6   -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
7   -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
  5 +import cn.iocoder.yudao.module.system.api.social.dto.*;
8 6 import cn.iocoder.yudao.module.system.service.social.SocialClientService;
  7 +import jakarta.annotation.Resource;
9 8 import me.chanjar.weixin.common.bean.WxJsapiSignature;
  9 +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;
10 10 import org.springframework.stereotype.Service;
11 11 import org.springframework.validation.annotation.Validated;
12 12  
13   -import jakarta.annotation.Resource;
  13 +import java.util.List;
14 14  
15 15 /**
16 16 * 社交应用的 API 实现类
... ... @@ -46,4 +46,15 @@ public class SocialClientApiImpl implements SocialClientApi {
46 46 return socialClientService.getWxaQrcode(reqVO);
47 47 }
48 48  
  49 + @Override
  50 + public List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplate() {
  51 + List<TemplateInfo> subscribeTemplate = socialClientService.getSubscribeTemplate();
  52 + return BeanUtils.toBean(subscribeTemplate, SocialWxSubscribeTemplateRespDTO.class);
  53 + }
  54 +
  55 + @Override
  56 + public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) {
  57 + socialClientService.sendSubscribeMessage(reqDTO);
  58 + }
  59 +
49 60 }
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http 0 → 100644
  1 +### 请求 /system/social-client/send-subscribe-message 接口 => 发送测试订阅消息
  2 +POST {{baseUrl}}/system/social-client/send-subscribe-message
  3 +Authorization: Bearer {{token}}
  4 +#Authorization: Bearer test100
  5 +tenant-id: {{adminTenentId}}
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
... ... @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.socail;
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO;
6 7 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
7 8 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO;
8 9 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
... ... @@ -11,13 +12,12 @@ import cn.iocoder.yudao.module.system.service.social.SocialClientService;
11 12 import io.swagger.v3.oas.annotations.Operation;
12 13 import io.swagger.v3.oas.annotations.Parameter;
13 14 import io.swagger.v3.oas.annotations.tags.Tag;
  15 +import jakarta.annotation.Resource;
  16 +import jakarta.validation.Valid;
14 17 import org.springframework.security.access.prepost.PreAuthorize;
15 18 import org.springframework.validation.annotation.Validated;
16 19 import org.springframework.web.bind.annotation.*;
17 20  
18   -import jakarta.annotation.Resource;
19   -import jakarta.validation.Valid;
20   -
21 21 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
22 22  
23 23 @Tag(name = "管理后台 - 社交客户端")
... ... @@ -70,4 +70,16 @@ public class SocialClientController {
70 70 return success(BeanUtils.toBean(pageResult, SocialClientRespVO.class));
71 71 }
72 72  
  73 + //======================= TODO 测试发送订阅消息 =======================
  74 +
  75 + @PostMapping("/send-subscribe-message")
  76 + public void testSendSubscribeMessage() {
  77 + SocialWxSubscribeMessageReqDTO reqDTO = new SocialWxSubscribeMessageReqDTO().setLang("zh_CN")
  78 + .setMiniprogramState("developer").setTemplateId("W4ybDTIwCfKHtMKR7fSfx83DtmVKEeXQo3Ti7GCw4_4")
  79 + .setToUser("oKNkb4xxw2H135-MVPKtEMkumK08");
  80 + reqDTO.addData("character_string1", "11111111").addData("amount2", "6666").addData("time3", "2024-01-01 10:10:10")
  81 + .addData("phrase4", "成功");
  82 + socialClientService.sendSubscribeMessage(reqDTO);
  83 + }
  84 +
73 85 }
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java
... ... @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.social;
3 3 import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 5 import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
  6 +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO;
6 7 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
7 8 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
8 9 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
... ... @@ -10,6 +11,9 @@ import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
10 11 import com.xingyuv.jushauth.model.AuthUser;
11 12 import jakarta.validation.Valid;
12 13 import me.chanjar.weixin.common.bean.WxJsapiSignature;
  14 +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;
  15 +
  16 +import java.util.List;
13 17  
14 18 /**
15 19 * 社交应用 Service 接口
... ... @@ -69,6 +73,20 @@ public interface SocialClientService {
69 73 */
70 74 byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO);
71 75  
  76 + /**
  77 + * 获得微信小程订阅模板
  78 + *
  79 + * @return 微信小程订阅模板
  80 + */
  81 + List<TemplateInfo> getSubscribeTemplate();
  82 +
  83 + /**
  84 + * 发送订阅消息
  85 + *
  86 + * @param reqDTO 请求
  87 + */
  88 + void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO);
  89 +
72 90 // =================== 客户端管理 ===================
73 91  
74 92 /**
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
1 1 package cn.iocoder.yudao.module.system.service.social;
2 2  
3 3 import cn.binarywang.wx.miniapp.api.WxMaService;
  4 +import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
4 5 import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
5 6 import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
  7 +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
6 8 import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl;
7 9 import cn.hutool.core.bean.BeanUtil;
8 10 import cn.hutool.core.lang.Assert;
... ... @@ -15,6 +17,7 @@ import cn.iocoder.yudao.framework.common.util.cache.CacheUtils;
15 17 import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
16 18 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
17 19 import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
  20 +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO;
18 21 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
19 22 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
20 23 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
... ... @@ -36,6 +39,7 @@ import jakarta.annotation.Resource;
36 39 import lombok.SneakyThrows;
37 40 import lombok.extern.slf4j.Slf4j;
38 41 import me.chanjar.weixin.common.bean.WxJsapiSignature;
  42 +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;
39 43 import me.chanjar.weixin.common.error.WxErrorException;
40 44 import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
41 45 import me.chanjar.weixin.mp.api.WxMpService;
... ... @@ -46,6 +50,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
46 50 import org.springframework.stereotype.Service;
47 51  
48 52 import java.time.Duration;
  53 +import java.util.List;
49 54 import java.util.Objects;
50 55  
51 56 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
... ... @@ -255,6 +260,32 @@ public class SocialClientServiceImpl implements SocialClientService {
255 260 }
256 261 }
257 262  
  263 + @Override
  264 + public List<TemplateInfo> getSubscribeTemplate() {
  265 + WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
  266 + try {
  267 + WxMaSubscribeService subscribeService = service.getSubscribeService();
  268 + return subscribeService.getTemplateList();
  269 + }catch (WxErrorException e) {
  270 + log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e);
  271 + throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR);
  272 + }
  273 + }
  274 +
  275 + @Override
  276 + public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) {
  277 + WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
  278 + try {
  279 + WxMaSubscribeService subscribeService = service.getSubscribeService();
  280 + WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class);
  281 + reqDTO.getMessages().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue())));
  282 + subscribeService.sendSubscribeMsg(message);
  283 + }catch (WxErrorException e) {
  284 + log.error("[sendSubscribeMessage][发送小程序订阅消息]", e);
  285 + throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR);
  286 + }
  287 + }
  288 +
258 289 /**
259 290 * 获得 clientId + clientSecret 对应的 WxMpService 对象
260 291 *
... ...