mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-13 09:04:59 +08:00
【代码评审】SYSTEM:订阅消息
This commit is contained in:
parent
f46d47a966
commit
345f41b153
@ -11,6 +11,7 @@ public interface MessageTemplateConstants {
|
|||||||
|
|
||||||
String PAY_WALLET_CHANGE = "充值成功通知";
|
String PAY_WALLET_CHANGE = "充值成功通知";
|
||||||
|
|
||||||
|
// TODO @puhui999:这种建议不枚举,直接写~嘿嘿。
|
||||||
/**
|
/**
|
||||||
* 充值成功通知模版参数
|
* 充值成功通知模版参数
|
||||||
*
|
*
|
||||||
|
@ -11,6 +11,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.PAY_WALLET_CHANGE;
|
import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.PAY_WALLET_CHANGE;
|
||||||
|
|
||||||
|
// TODO @puhui999:建议可以先直接调用,不要新建一个 client。
|
||||||
/**
|
/**
|
||||||
* 订阅消息
|
* 订阅消息
|
||||||
*
|
*
|
||||||
|
@ -139,8 +139,10 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
|||||||
sendPayWalletChangeMessage(payOrderId, walletRecharge);
|
sendPayWalletChangeMessage(payOrderId, walletRecharge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @puhui999:发送,使用异步发送;@Async
|
||||||
private void sendPayWalletChangeMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) {
|
private void sendPayWalletChangeMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) {
|
||||||
PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId());
|
PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId());
|
||||||
|
// TODO @puhui999:可以使用 MapUtil.builder();另外,不应该是并发 hashmap 哈
|
||||||
Map<String, String> messages = MapUtil.newConcurrentHashMap(4);
|
Map<String, String> messages = MapUtil.newConcurrentHashMap(4);
|
||||||
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.NO, String.valueOf(payOrderId));
|
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.NO, String.valueOf(payOrderId));
|
||||||
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.PRICE,
|
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.PRICE,
|
||||||
|
@ -57,6 +57,7 @@ public interface SocialClientApi {
|
|||||||
*/
|
*/
|
||||||
List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplateList(Integer userType);
|
List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplateList(Integer userType);
|
||||||
|
|
||||||
|
// TODO @puhui999:sendSubscribeMessage 两个方法,可以融合成一个么?
|
||||||
/**
|
/**
|
||||||
* 发送微信小程序订阅消息
|
* 发送微信小程序订阅消息
|
||||||
*
|
*
|
||||||
|
@ -75,6 +75,7 @@ public class SocialClientApiImpl implements SocialClientApi {
|
|||||||
|
|
||||||
public void sendSubscribeMessage(String templateTitle, Map<String, String> messages, Integer userType, Long userId,
|
public void sendSubscribeMessage(String templateTitle, Map<String, String> messages, Integer userType, Long userId,
|
||||||
Integer socialType, String path) {
|
Integer socialType, String path) {
|
||||||
|
// TODO @puhui999:建议是,先不拆小方法。因为逻辑的复杂度其实不高哈。合在一个方法里,因为咱写了 1.1 1.2 2. 这样的逻辑,也能一下子看懂。
|
||||||
// 1.1 获得订阅模版
|
// 1.1 获得订阅模版
|
||||||
SocialWxSubscribeTemplateRespDTO template = getTemplate(templateTitle, userType);
|
SocialWxSubscribeTemplateRespDTO template = getTemplate(templateTitle, userType);
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
@ -104,6 +105,7 @@ public class SocialClientApiImpl implements SocialClientApi {
|
|||||||
.setTemplateId(template.getId()).setToUser(openId).setPage(path);
|
.setTemplateId(template.getId()).setToUser(openId).setPage(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @puhui999:建议下沉到 service 实现。
|
||||||
/**
|
/**
|
||||||
* 获得小程序订阅消息模版
|
* 获得小程序订阅消息模版
|
||||||
*
|
*
|
||||||
@ -120,6 +122,7 @@ public class SocialClientApiImpl implements SocialClientApi {
|
|||||||
return CollectionUtil.findOne(templateList, item -> ObjUtil.equal(item.getTitle(), templateTitle));
|
return CollectionUtil.findOne(templateList, item -> ObjUtil.equal(item.getTitle(), templateTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @puhui999:建议下沉到 service 实现。
|
||||||
/**
|
/**
|
||||||
* 获得用户 openId
|
* 获得用户 openId
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user