Commit 4c846ef4ce4567dd7ea7c14eda70a888d5e73cda
1 parent
a9862b79
【新增】MALL: 新增退款订阅消息发送
Showing
10 changed files
with
60 additions
and
53 deletions
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java
| @@ -71,7 +71,7 @@ public class AppSocialUserController { | @@ -71,7 +71,7 @@ public class AppSocialUserController { | ||
| 71 | @GetMapping("/get-subscribe-template-list") | 71 | @GetMapping("/get-subscribe-template-list") |
| 72 | @Operation(summary = "获得微信小程订阅模板列表") | 72 | @Operation(summary = "获得微信小程订阅模板列表") |
| 73 | public CommonResult<List<AppSocialWxSubscribeTemplateRespVO>> getSubscribeTemplateList() { | 73 | public CommonResult<List<AppSocialWxSubscribeTemplateRespVO>> getSubscribeTemplateList() { |
| 74 | - List<SocialWxSubscribeTemplateRespDTO> template = socialClientApi.getSubscribeTemplateList(UserTypeEnum.MEMBER.getValue()); | 74 | + List<SocialWxaSubscribeTemplateRespDTO> template = socialClientApi.getWxaSubscribeTemplateList(UserTypeEnum.MEMBER.getValue()); |
| 75 | return success(BeanUtils.toBean(template, AppSocialWxSubscribeTemplateRespVO.class)); | 75 | return success(BeanUtils.toBean(template, AppSocialWxSubscribeTemplateRespVO.class)); |
| 76 | } | 76 | } |
| 77 | 77 |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java
| @@ -9,6 +9,7 @@ public interface MessageTemplateConstants { | @@ -9,6 +9,7 @@ public interface MessageTemplateConstants { | ||
| 9 | 9 | ||
| 10 | //======================= 小程序订阅消息 ======================= | 10 | //======================= 小程序订阅消息 ======================= |
| 11 | 11 | ||
| 12 | - String PAY_WALLET_CHANGE = "充值成功通知"; | 12 | + String WALLET_RECHARGER_PAID = "充值成功通知"; |
| 13 | + String WALLET_RECHARGE_REFUNDED = "退款申请通知"; | ||
| 13 | 14 | ||
| 14 | } | 15 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
| @@ -21,8 +21,7 @@ import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; | @@ -21,8 +21,7 @@ import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; | ||
| 21 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; | 21 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 22 | import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; | 22 | import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; |
| 23 | import cn.iocoder.yudao.module.system.api.social.SocialClientApi; | 23 | import cn.iocoder.yudao.module.system.api.social.SocialClientApi; |
| 24 | -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; | ||
| 25 | -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | 24 | +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; |
| 26 | import jakarta.annotation.Resource; | 25 | import jakarta.annotation.Resource; |
| 27 | import lombok.extern.slf4j.Slf4j; | 26 | import lombok.extern.slf4j.Slf4j; |
| 28 | import org.springframework.scheduling.annotation.Async; | 27 | import org.springframework.scheduling.annotation.Async; |
| @@ -40,7 +39,8 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString | @@ -40,7 +39,8 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString | ||
| 40 | import static cn.iocoder.yudao.framework.common.util.number.MoneyUtils.fenToYuanStr; | 39 | import static cn.iocoder.yudao.framework.common.util.number.MoneyUtils.fenToYuanStr; |
| 41 | import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE; | 40 | import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE; |
| 42 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; | 41 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; |
| 43 | -import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.PAY_WALLET_CHANGE; | 42 | +import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.WALLET_RECHARGER_PAID; |
| 43 | +import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.WALLET_RECHARGE_REFUNDED; | ||
| 44 | import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; | 44 | import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| @@ -140,21 +140,20 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | @@ -140,21 +140,20 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | ||
| 140 | PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice()); | 140 | PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice()); |
| 141 | 141 | ||
| 142 | // 4. 发送订阅消息 | 142 | // 4. 发送订阅消息 |
| 143 | - getSelf().sendPayWalletChangeMessage(payOrderId, walletRecharge); | 143 | + getSelf().sendWalletRechargerPaidMessage(payOrderId, walletRecharge); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | @Async | 146 | @Async |
| 147 | - public void sendPayWalletChangeMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) { | 147 | + public void sendWalletRechargerPaidMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) { |
| 148 | // 1. 获得会员钱包信息 | 148 | // 1. 获得会员钱包信息 |
| 149 | PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId()); | 149 | PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId()); |
| 150 | // 2. 构建并发送模版消息 | 150 | // 2. 构建并发送模版消息 |
| 151 | - socialClientApi.sendSubscribeMessage(new SocialWxSubscribeMessageSendReqDTO().setPage(WALLET_MONEY_PATH) | ||
| 152 | - .setUserId(wallet.getUserId()).setUserType(wallet.getUserType()) | ||
| 153 | - .setTemplateTitle(PAY_WALLET_CHANGE).setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType()) | ||
| 154 | - .addMessage("character_string1", String.valueOf(payOrderId)) | ||
| 155 | - .addMessage("amount2", fenToYuanStr(walletRecharge.getTotalPrice())) | ||
| 156 | - .addMessage("time3", LocalDateTimeUtil.formatNormal(LocalDateTime.now())) | ||
| 157 | - .addMessage("phrase4", "充值成功")); | 151 | + socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO().setPage(WALLET_MONEY_PATH) |
| 152 | + .setUserId(wallet.getUserId()).setUserType(wallet.getUserType()).setTemplateTitle(WALLET_RECHARGER_PAID) | ||
| 153 | + .addMessage("character_string1", String.valueOf(payOrderId)) // 支付单编号 | ||
| 154 | + .addMessage("amount2", fenToYuanStr(walletRecharge.getTotalPrice())) // 充值金额 | ||
| 155 | + .addMessage("time3", LocalDateTimeUtil.formatNormal(walletRecharge.getCreateTime())) // 充值时间 | ||
| 156 | + .addMessage("phrase4", "充值成功")); // 充值状态 | ||
| 158 | } | 157 | } |
| 159 | 158 | ||
| 160 | @Override | 159 | @Override |
| @@ -219,6 +218,24 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | @@ -219,6 +218,24 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | ||
| 219 | } | 218 | } |
| 220 | // 3. 更新钱包充值的退款字段 | 219 | // 3. 更新钱包充值的退款字段 |
| 221 | walletRechargeMapper.updateByIdAndRefunded(id, WAITING.getStatus(), updateObj); | 220 | walletRechargeMapper.updateByIdAndRefunded(id, WAITING.getStatus(), updateObj); |
| 221 | + | ||
| 222 | + // 4. 发送订阅消息 | ||
| 223 | + getSelf().sendWalletRechargeRefundedMessage(walletRecharge.getWalletId(), payRefund); | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + @Async | ||
| 227 | + public void sendWalletRechargeRefundedMessage(Long walletId, PayRefundDO payRefund) { | ||
| 228 | + // 1. 获得会员钱包信息 | ||
| 229 | + PayWalletDO wallet = payWalletService.getWallet(walletId); | ||
| 230 | + // 2. 构建并发送模版消息 | ||
| 231 | + String thing8 = PayRefundStatusEnum.isSuccess(payRefund.getStatus()) ? SUCCESS.getName() : FAILURE.getName(); | ||
| 232 | + socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO().setPage(WALLET_MONEY_PATH) | ||
| 233 | + .setUserId(wallet.getUserId()).setUserType(wallet.getUserType()).setTemplateTitle(WALLET_RECHARGE_REFUNDED) | ||
| 234 | + .addMessage("character_string1", String.valueOf(payRefund.getId())) // 退款订单编号 | ||
| 235 | + .addMessage("time7", LocalDateTimeUtil.formatNormal(payRefund.getCreateTime())) // 申请时间 | ||
| 236 | + .addMessage("amount3", fenToYuanStr(payRefund.getRefundPrice())) // 退款金额 | ||
| 237 | + .addMessage("thing4", payRefund.getReason()) // 退款原因 | ||
| 238 | + .addMessage("thing8", thing8 + ",点击卡片查看详情")); // 温馨提示 | ||
| 222 | } | 239 | } |
| 223 | 240 | ||
| 224 | private PayRefundDO validateWalletRechargeCanRefunded(PayWalletRechargeDO walletRecharge, Long payRefundId) { | 241 | private PayRefundDO validateWalletRechargeCanRefunded(PayWalletRechargeDO walletRecharge, Long payRefundId) { |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java
| @@ -32,6 +32,8 @@ public interface SocialClientApi { | @@ -32,6 +32,8 @@ public interface SocialClientApi { | ||
| 32 | */ | 32 | */ |
| 33 | SocialWxJsapiSignatureRespDTO createWxMpJsapiSignature(Integer userType, String url); | 33 | SocialWxJsapiSignatureRespDTO createWxMpJsapiSignature(Integer userType, String url); |
| 34 | 34 | ||
| 35 | + //======================= 微信小程序独有 ======================= | ||
| 36 | + | ||
| 35 | /** | 37 | /** |
| 36 | * 获得微信小程序的手机信息 | 38 | * 获得微信小程序的手机信息 |
| 37 | * | 39 | * |
| @@ -49,20 +51,18 @@ public interface SocialClientApi { | @@ -49,20 +51,18 @@ public interface SocialClientApi { | ||
| 49 | */ | 51 | */ |
| 50 | byte[] getWxaQrcode(@Valid SocialWxQrcodeReqDTO reqVO); | 52 | byte[] getWxaQrcode(@Valid SocialWxQrcodeReqDTO reqVO); |
| 51 | 53 | ||
| 52 | - // TODO @puhui999:要不是统一都叫 getWxaSubscribeTemplateList、SocialWxaSubscribeTemplateRespDTO | ||
| 53 | /** | 54 | /** |
| 54 | * 获得微信小程订阅模板 | 55 | * 获得微信小程订阅模板 |
| 55 | * | 56 | * |
| 56 | * @return 小程序订阅消息模版 | 57 | * @return 小程序订阅消息模版 |
| 57 | */ | 58 | */ |
| 58 | - List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplateList(Integer userType); | 59 | + List<SocialWxaSubscribeTemplateRespDTO> getWxaSubscribeTemplateList(Integer userType); |
| 59 | 60 | ||
| 60 | - // TODO @puhui999:sendWxaSubscribeMessage、SocialWxaSubscribeMessageSendReqDTO;然后不传递 socialType;就是专门给微信小程序的 | ||
| 61 | /** | 61 | /** |
| 62 | * 发送微信小程序订阅消息 | 62 | * 发送微信小程序订阅消息 |
| 63 | * | 63 | * |
| 64 | * @param reqDTO 请求 | 64 | * @param reqDTO 请求 |
| 65 | */ | 65 | */ |
| 66 | - void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO); | 66 | + void sendWxaSubscribeMessage(SocialWxaSubscribeMessageSendReqDTO reqDTO); |
| 67 | 67 | ||
| 68 | } | 68 | } |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageSendReqDTO.java renamed to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxaSubscribeMessageSendReqDTO.java
| 1 | package cn.iocoder.yudao.module.system.api.social.dto; | 1 | package cn.iocoder.yudao.module.system.api.social.dto; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | ||
| 5 | import jakarta.validation.constraints.NotEmpty; | 4 | import jakarta.validation.constraints.NotEmpty; |
| 6 | import jakarta.validation.constraints.NotNull; | 5 | import jakarta.validation.constraints.NotNull; |
| 7 | import lombok.Data; | 6 | import lombok.Data; |
| @@ -15,7 +14,7 @@ import java.util.Map; | @@ -15,7 +14,7 @@ import java.util.Map; | ||
| 15 | * @author HUIHUI | 14 | * @author HUIHUI |
| 16 | */ | 15 | */ |
| 17 | @Data | 16 | @Data |
| 18 | -public class SocialWxSubscribeMessageSendReqDTO { | 17 | +public class SocialWxaSubscribeMessageSendReqDTO { |
| 19 | 18 | ||
| 20 | /** | 19 | /** |
| 21 | * 用户编号 | 20 | * 用户编号 |
| @@ -34,14 +33,6 @@ public class SocialWxSubscribeMessageSendReqDTO { | @@ -34,14 +33,6 @@ public class SocialWxSubscribeMessageSendReqDTO { | ||
| 34 | private Integer userType; | 33 | private Integer userType; |
| 35 | 34 | ||
| 36 | /** | 35 | /** |
| 37 | - * 社交类型 | ||
| 38 | - * | ||
| 39 | - * 枚举 {@link SocialTypeEnum} | ||
| 40 | - */ | ||
| 41 | - @NotNull(message = "社交类型不能为空") | ||
| 42 | - private Integer socialType; | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | * 消息模版标题 | 36 | * 消息模版标题 |
| 46 | */ | 37 | */ |
| 47 | @NotEmpty(message = "消息模版标题不能为空") | 38 | @NotEmpty(message = "消息模版标题不能为空") |
| @@ -59,7 +50,7 @@ public class SocialWxSubscribeMessageSendReqDTO { | @@ -59,7 +50,7 @@ public class SocialWxSubscribeMessageSendReqDTO { | ||
| 59 | */ | 50 | */ |
| 60 | private Map<String, String> messages; | 51 | private Map<String, String> messages; |
| 61 | 52 | ||
| 62 | - public SocialWxSubscribeMessageSendReqDTO addMessage(String key, String value) { | 53 | + public SocialWxaSubscribeMessageSendReqDTO addMessage(String key, String value) { |
| 63 | if (messages == null) { | 54 | if (messages == null) { |
| 64 | messages = new HashMap<>(); | 55 | messages = new HashMap<>(); |
| 65 | } | 56 | } |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java renamed to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxaSubscribeTemplateRespDTO.java
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java
| @@ -6,12 +6,12 @@ import cn.hutool.core.util.ObjUtil; | @@ -6,12 +6,12 @@ import cn.hutool.core.util.ObjUtil; | ||
| 6 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | import cn.iocoder.yudao.module.system.api.social.dto.*; | 8 | import cn.iocoder.yudao.module.system.api.social.dto.*; |
| 9 | +import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | ||
| 9 | import cn.iocoder.yudao.module.system.service.social.SocialClientService; | 10 | import cn.iocoder.yudao.module.system.service.social.SocialClientService; |
| 10 | import jakarta.annotation.Resource; | 11 | import jakarta.annotation.Resource; |
| 11 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 12 | import me.chanjar.weixin.common.bean.WxJsapiSignature; | 13 | import me.chanjar.weixin.common.bean.WxJsapiSignature; |
| 13 | import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; | 14 | import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; |
| 14 | -import org.springframework.beans.factory.annotation.Value; | ||
| 15 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 16 | import org.springframework.validation.annotation.Validated; | 16 | import org.springframework.validation.annotation.Validated; |
| 17 | 17 | ||
| @@ -30,11 +30,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. | @@ -30,11 +30,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. | ||
| 30 | @Slf4j | 30 | @Slf4j |
| 31 | public class SocialClientApiImpl implements SocialClientApi { | 31 | public class SocialClientApiImpl implements SocialClientApi { |
| 32 | 32 | ||
| 33 | - /** | ||
| 34 | - * 小程序版本 | ||
| 35 | - */ | ||
| 36 | - @Value("${yudao.wxa-code.env-version}") | ||
| 37 | - public String envVersion; | ||
| 38 | @Resource | 33 | @Resource |
| 39 | private SocialClientService socialClientService; | 34 | private SocialClientService socialClientService; |
| 40 | @Resource | 35 | @Resource |
| @@ -51,6 +46,8 @@ public class SocialClientApiImpl implements SocialClientApi { | @@ -51,6 +46,8 @@ public class SocialClientApiImpl implements SocialClientApi { | ||
| 51 | return BeanUtils.toBean(signature, SocialWxJsapiSignatureRespDTO.class); | 46 | return BeanUtils.toBean(signature, SocialWxJsapiSignatureRespDTO.class); |
| 52 | } | 47 | } |
| 53 | 48 | ||
| 49 | + //======================= 微信小程序独有 ======================= | ||
| 50 | + | ||
| 54 | @Override | 51 | @Override |
| 55 | public SocialWxPhoneNumberInfoRespDTO getWxMaPhoneNumberInfo(Integer userType, String phoneCode) { | 52 | public SocialWxPhoneNumberInfoRespDTO getWxMaPhoneNumberInfo(Integer userType, String phoneCode) { |
| 56 | WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode); | 53 | WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode); |
| @@ -63,21 +60,21 @@ public class SocialClientApiImpl implements SocialClientApi { | @@ -63,21 +60,21 @@ public class SocialClientApiImpl implements SocialClientApi { | ||
| 63 | } | 60 | } |
| 64 | 61 | ||
| 65 | @Override | 62 | @Override |
| 66 | - public List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplateList(Integer userType) { | 63 | + public List<SocialWxaSubscribeTemplateRespDTO> getWxaSubscribeTemplateList(Integer userType) { |
| 67 | List<TemplateInfo> list = socialClientService.getSubscribeTemplateList(userType); | 64 | List<TemplateInfo> list = socialClientService.getSubscribeTemplateList(userType); |
| 68 | - return convertList(list, item -> BeanUtils.toBean(item, SocialWxSubscribeTemplateRespDTO.class).setId(item.getPriTmplId())); | 65 | + return convertList(list, item -> BeanUtils.toBean(item, SocialWxaSubscribeTemplateRespDTO.class).setId(item.getPriTmplId())); |
| 69 | } | 66 | } |
| 70 | 67 | ||
| 71 | @Override | 68 | @Override |
| 72 | - public void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO) { | 69 | + public void sendWxaSubscribeMessage(SocialWxaSubscribeMessageSendReqDTO reqDTO) { |
| 73 | // 1.1 获得订阅模版列表 | 70 | // 1.1 获得订阅模版列表 |
| 74 | - List<SocialWxSubscribeTemplateRespDTO> templateList = getSubscribeTemplateList(reqDTO.getUserType()); | 71 | + List<SocialWxaSubscribeTemplateRespDTO> templateList = getWxaSubscribeTemplateList(reqDTO.getUserType()); |
| 75 | if (CollUtil.isEmpty(templateList)) { | 72 | if (CollUtil.isEmpty(templateList)) { |
| 76 | log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO); | 73 | log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO); |
| 77 | return; | 74 | return; |
| 78 | } | 75 | } |
| 79 | // 1.2 获得需要使用的模版 | 76 | // 1.2 获得需要使用的模版 |
| 80 | - SocialWxSubscribeTemplateRespDTO template = findOne(templateList, item -> | 77 | + SocialWxaSubscribeTemplateRespDTO template = findOne(templateList, item -> |
| 81 | ObjUtil.equal(item.getTitle(), reqDTO.getTemplateTitle())); | 78 | ObjUtil.equal(item.getTitle(), reqDTO.getTemplateTitle())); |
| 82 | if (template == null) { | 79 | if (template == null) { |
| 83 | log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO); | 80 | log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO); |
| @@ -86,7 +83,7 @@ public class SocialClientApiImpl implements SocialClientApi { | @@ -86,7 +83,7 @@ public class SocialClientApiImpl implements SocialClientApi { | ||
| 86 | 83 | ||
| 87 | // 2. 获得社交用户 | 84 | // 2. 获得社交用户 |
| 88 | SocialUserRespDTO socialUser = socialUserApi.getSocialUserByUserId(reqDTO.getUserType(), reqDTO.getUserId(), | 85 | SocialUserRespDTO socialUser = socialUserApi.getSocialUserByUserId(reqDTO.getUserType(), reqDTO.getUserId(), |
| 89 | - reqDTO.getSocialType()); | 86 | + SocialTypeEnum.WECHAT_MINI_APP.getType()); |
| 90 | if (StrUtil.isBlankIfStr(socialUser.getOpenid())) { | 87 | if (StrUtil.isBlankIfStr(socialUser.getOpenid())) { |
| 91 | log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:会员 openid 缺失]", reqDTO); | 88 | log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:会员 openid 缺失]", reqDTO); |
| 92 | return; | 89 | return; |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
| @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | import cn.iocoder.yudao.module.system.api.social.SocialClientApi; | 6 | import cn.iocoder.yudao.module.system.api.social.SocialClientApi; |
| 7 | -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; | 7 | +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; |
| 8 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; | 8 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; |
| 9 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO; | 9 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO; |
| 10 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; | 10 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; |
| @@ -76,8 +76,8 @@ public class SocialClientController { | @@ -76,8 +76,8 @@ public class SocialClientController { | ||
| 76 | @PostMapping("/send-subscribe-message") | 76 | @PostMapping("/send-subscribe-message") |
| 77 | @Operation(summary = "发送订阅消息") // 用于测试 | 77 | @Operation(summary = "发送订阅消息") // 用于测试 |
| 78 | @PreAuthorize("@ss.hasPermission('system:social-client:query')") | 78 | @PreAuthorize("@ss.hasPermission('system:social-client:query')") |
| 79 | - public void sendSubscribeMessage(@RequestBody SocialWxSubscribeMessageSendReqDTO reqDTO) { | ||
| 80 | - socialClientApi.sendSubscribeMessage(reqDTO); | 79 | + public void sendSubscribeMessage(@RequestBody SocialWxaSubscribeMessageSendReqDTO reqDTO) { |
| 80 | + socialClientApi.sendWxaSubscribeMessage(reqDTO); | ||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | } | 83 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.system.service.social; | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.system.service.social; | ||
| 3 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; | 3 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; | 5 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; |
| 6 | -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; | 6 | +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; |
| 7 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; | 7 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; |
| 8 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; | 8 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; |
| 9 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; | 9 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; |
| @@ -87,7 +87,7 @@ public interface SocialClientService { | @@ -87,7 +87,7 @@ public interface SocialClientService { | ||
| 87 | * @param templateId 模版编号 | 87 | * @param templateId 模版编号 |
| 88 | * @param openId 会员 openId | 88 | * @param openId 会员 openId |
| 89 | */ | 89 | */ |
| 90 | - void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO, String templateId, String openId); | 90 | + void sendSubscribeMessage(SocialWxaSubscribeMessageSendReqDTO reqDTO, String templateId, String openId); |
| 91 | 91 | ||
| 92 | // =================== 客户端管理 =================== | 92 | // =================== 客户端管理 =================== |
| 93 | 93 |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
| @@ -6,6 +6,7 @@ import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | @@ -6,6 +6,7 @@ import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | ||
| 6 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; | 6 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; |
| 7 | import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; | 7 | import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; |
| 8 | import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; | 8 | import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; |
| 9 | +import cn.binarywang.wx.miniapp.constant.WxMaConstants; | ||
| 9 | import cn.hutool.core.bean.BeanUtil; | 10 | import cn.hutool.core.bean.BeanUtil; |
| 10 | import cn.hutool.core.collection.CollUtil; | 11 | import cn.hutool.core.collection.CollUtil; |
| 11 | import cn.hutool.core.lang.Assert; | 12 | import cn.hutool.core.lang.Assert; |
| @@ -18,7 +19,7 @@ import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; | @@ -18,7 +19,7 @@ import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; | ||
| 18 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; | 19 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| 19 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 20 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 20 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; | 21 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; |
| 21 | -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; | 22 | +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; |
| 22 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; | 23 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; |
| 23 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; | 24 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; |
| 24 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; | 25 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; |
| @@ -276,7 +277,7 @@ public class SocialClientServiceImpl implements SocialClientService { | @@ -276,7 +277,7 @@ public class SocialClientServiceImpl implements SocialClientService { | ||
| 276 | } | 277 | } |
| 277 | 278 | ||
| 278 | @Override | 279 | @Override |
| 279 | - public void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO, String templateId, String openId) { | 280 | + public void sendSubscribeMessage(SocialWxaSubscribeMessageSendReqDTO reqDTO, String templateId, String openId) { |
| 280 | WxMaService service = getWxMaService(reqDTO.getUserType()); | 281 | WxMaService service = getWxMaService(reqDTO.getUserType()); |
| 281 | try { | 282 | try { |
| 282 | WxMaSubscribeService subscribeService = service.getSubscribeService(); | 283 | WxMaSubscribeService subscribeService = service.getSubscribeService(); |
| @@ -293,13 +294,13 @@ public class SocialClientServiceImpl implements SocialClientService { | @@ -293,13 +294,13 @@ public class SocialClientServiceImpl implements SocialClientService { | ||
| 293 | * @param reqDTO 请求 | 294 | * @param reqDTO 请求 |
| 294 | * @param templateId 模版编号 | 295 | * @param templateId 模版编号 |
| 295 | * @param openId 会员 openId | 296 | * @param openId 会员 openId |
| 296 | - * @return 微信小程序订阅消息发送 | 297 | + * @return 微信小程序订阅消息请求参数 |
| 297 | */ | 298 | */ |
| 298 | - private WxMaSubscribeMessage buildMessageSendReqDTO(SocialWxSubscribeMessageSendReqDTO reqDTO, | 299 | + private WxMaSubscribeMessage buildMessageSendReqDTO(SocialWxaSubscribeMessageSendReqDTO reqDTO, |
| 299 | String templateId, String openId) { | 300 | String templateId, String openId) { |
| 300 | // 设置订阅消息基本参数 | 301 | // 设置订阅消息基本参数 |
| 301 | - WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage().setLang("zh_CN").setMiniprogramState(envVersion) | ||
| 302 | - .setTemplateId(templateId).setToUser(openId).setPage(reqDTO.getPage()); | 302 | + WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage().setLang(WxMaConstants.MiniProgramLang.ZH_CN) |
| 303 | + .setMiniprogramState(envVersion).setTemplateId(templateId).setToUser(openId).setPage(reqDTO.getPage()); | ||
| 303 | // 设置具体消息参数 | 304 | // 设置具体消息参数 |
| 304 | Map<String, String> messages = reqDTO.getMessages(); | 305 | Map<String, String> messages = reqDTO.getMessages(); |
| 305 | if (CollUtil.isNotEmpty(messages)) { | 306 | if (CollUtil.isNotEmpty(messages)) { |