|
@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
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.config.impl.WxMaRedisBetterConfigImpl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
@@ -16,6 +17,7 @@ import cn.iocoder.yudao.framework.common.util.cache.CacheUtils;
|
|
|
import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
|
|
|
+import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
|
|
@@ -258,6 +260,32 @@ public class SocialClientServiceImpl implements SocialClientService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<TemplateInfo> getSubscribeTemplate() {
|
|
|
+ WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
|
|
|
+ try {
|
|
|
+ WxMaSubscribeService subscribeService = service.getSubscribeService();
|
|
|
+ return subscribeService.getTemplateList();
|
|
|
+ }catch (WxErrorException e) {
|
|
|
+ log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e);
|
|
|
+ throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) {
|
|
|
+ WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
|
|
|
+ try {
|
|
|
+ WxMaSubscribeService subscribeService = service.getSubscribeService();
|
|
|
+ WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class);
|
|
|
+ reqDTO.getData().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue())));
|
|
|
+ subscribeService.sendSubscribeMsg(message);
|
|
|
+ }catch (WxErrorException e) {
|
|
|
+ log.error("[sendSubscribeMessage][发送小程序订阅消息]", e);
|
|
|
+ throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获得 clientId + clientSecret 对应的 WxMpService 对象
|
|
|
*
|
|
@@ -367,16 +395,4 @@ public class SocialClientServiceImpl implements SocialClientService {
|
|
|
return socialClientMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<TemplateInfo> getSubscribeTemplate() {
|
|
|
- WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
|
|
|
- try {
|
|
|
- WxMaSubscribeService subscribeService = service.getSubscribeService();
|
|
|
- return subscribeService.getTemplateList();
|
|
|
- }catch (WxErrorException e) {
|
|
|
- log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e);
|
|
|
- throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|