Commit 345f41b1535d8ec7ead8b312259e70fbce028ff2
1 parent
f46d47a9
【代码评审】SYSTEM:订阅消息
Showing
5 changed files
with
8 additions
and
0 deletions
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java
| @@ -11,6 +11,7 @@ public interface MessageTemplateConstants { | @@ -11,6 +11,7 @@ public interface MessageTemplateConstants { | ||
| 11 | 11 | ||
| 12 | String PAY_WALLET_CHANGE = "充值成功通知"; | 12 | String PAY_WALLET_CHANGE = "充值成功通知"; |
| 13 | 13 | ||
| 14 | + // TODO @puhui999:这种建议不枚举,直接写~嘿嘿。 | ||
| 14 | /** | 15 | /** |
| 15 | * 充值成功通知模版参数 | 16 | * 充值成功通知模版参数 |
| 16 | * | 17 | * |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/message/subscribe/SubscribeMessageClient.java
| @@ -11,6 +11,7 @@ import java.util.Map; | @@ -11,6 +11,7 @@ import java.util.Map; | ||
| 11 | 11 | ||
| 12 | import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.PAY_WALLET_CHANGE; | 12 | import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.PAY_WALLET_CHANGE; |
| 13 | 13 | ||
| 14 | +// TODO @puhui999:建议可以先直接调用,不要新建一个 client。 | ||
| 14 | /** | 15 | /** |
| 15 | * 订阅消息 | 16 | * 订阅消息 |
| 16 | * | 17 | * |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
| @@ -139,8 +139,10 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | @@ -139,8 +139,10 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | ||
| 139 | sendPayWalletChangeMessage(payOrderId, walletRecharge); | 139 | sendPayWalletChangeMessage(payOrderId, walletRecharge); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | + // TODO @puhui999:发送,使用异步发送;@Async | ||
| 142 | private void sendPayWalletChangeMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) { | 143 | private void sendPayWalletChangeMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) { |
| 143 | PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId()); | 144 | PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId()); |
| 145 | + // TODO @puhui999:可以使用 MapUtil.builder();另外,不应该是并发 hashmap 哈 | ||
| 144 | Map<String, String> messages = MapUtil.newConcurrentHashMap(4); | 146 | Map<String, String> messages = MapUtil.newConcurrentHashMap(4); |
| 145 | messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.NO, String.valueOf(payOrderId)); | 147 | messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.NO, String.valueOf(payOrderId)); |
| 146 | messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.PRICE, | 148 | messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.PRICE, |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java
| @@ -57,6 +57,7 @@ public interface SocialClientApi { | @@ -57,6 +57,7 @@ public interface SocialClientApi { | ||
| 57 | */ | 57 | */ |
| 58 | List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplateList(Integer userType); | 58 | List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplateList(Integer userType); |
| 59 | 59 | ||
| 60 | + // TODO @puhui999:sendSubscribeMessage 两个方法,可以融合成一个么? | ||
| 60 | /** | 61 | /** |
| 61 | * 发送微信小程序订阅消息 | 62 | * 发送微信小程序订阅消息 |
| 62 | * | 63 | * |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java
| @@ -75,6 +75,7 @@ public class SocialClientApiImpl implements SocialClientApi { | @@ -75,6 +75,7 @@ public class SocialClientApiImpl implements SocialClientApi { | ||
| 75 | 75 | ||
| 76 | public void sendSubscribeMessage(String templateTitle, Map<String, String> messages, Integer userType, Long userId, | 76 | public void sendSubscribeMessage(String templateTitle, Map<String, String> messages, Integer userType, Long userId, |
| 77 | Integer socialType, String path) { | 77 | Integer socialType, String path) { |
| 78 | + // TODO @puhui999:建议是,先不拆小方法。因为逻辑的复杂度其实不高哈。合在一个方法里,因为咱写了 1.1 1.2 2. 这样的逻辑,也能一下子看懂。 | ||
| 78 | // 1.1 获得订阅模版 | 79 | // 1.1 获得订阅模版 |
| 79 | SocialWxSubscribeTemplateRespDTO template = getTemplate(templateTitle, userType); | 80 | SocialWxSubscribeTemplateRespDTO template = getTemplate(templateTitle, userType); |
| 80 | if (template == null) { | 81 | if (template == null) { |
| @@ -104,6 +105,7 @@ public class SocialClientApiImpl implements SocialClientApi { | @@ -104,6 +105,7 @@ public class SocialClientApiImpl implements SocialClientApi { | ||
| 104 | .setTemplateId(template.getId()).setToUser(openId).setPage(path); | 105 | .setTemplateId(template.getId()).setToUser(openId).setPage(path); |
| 105 | } | 106 | } |
| 106 | 107 | ||
| 108 | + // TODO @puhui999:建议下沉到 service 实现。 | ||
| 107 | /** | 109 | /** |
| 108 | * 获得小程序订阅消息模版 | 110 | * 获得小程序订阅消息模版 |
| 109 | * | 111 | * |
| @@ -120,6 +122,7 @@ public class SocialClientApiImpl implements SocialClientApi { | @@ -120,6 +122,7 @@ public class SocialClientApiImpl implements SocialClientApi { | ||
| 120 | return CollectionUtil.findOne(templateList, item -> ObjUtil.equal(item.getTitle(), templateTitle)); | 122 | return CollectionUtil.findOne(templateList, item -> ObjUtil.equal(item.getTitle(), templateTitle)); |
| 121 | } | 123 | } |
| 122 | 124 | ||
| 125 | + // TODO @puhui999:建议下沉到 service 实现。 | ||
| 123 | /** | 126 | /** |
| 124 | * 获得用户 openId | 127 | * 获得用户 openId |
| 125 | * | 128 | * |