mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 16:05:08 +08:00
Merge branch 'develop' of https://gitee.com/puhui999/ruoyi-vue-pro into develop
# Conflicts: # yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java # yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java
This commit is contained in:
@ -11,4 +11,18 @@ public interface MessageTemplateConstants {
|
||||
|
||||
String PAY_WALLET_CHANGE = "充值成功通知";
|
||||
|
||||
/**
|
||||
* 充值成功通知模版参数
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
class PayWalletChangeTemplateParams {
|
||||
|
||||
public static final String NO = "character_string1"; // 流水编号
|
||||
public static final String PRICE = "amount2"; // 充值金额
|
||||
public static final String PAY_TIME = "time3"; // 充值时间
|
||||
public static final String STATUS = "phrase4"; // 充值状态
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.pay.message;
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.pay.message.subscribe;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.PAY_WALLET_CHANGE;
|
||||
|
||||
/**
|
||||
* 订阅消息
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SubscribeMessageClient {
|
||||
|
||||
public static final String WALLET_MONEY_PATH = "pages/user/wallet/money"; // 钱包详情页
|
||||
|
||||
@Resource
|
||||
public SocialClientApi socialClientApi;
|
||||
|
||||
/**
|
||||
* 发送钱包充值通知
|
||||
*
|
||||
* @param messages 消息
|
||||
* @param userType 用户类型
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
@Async
|
||||
public void sendPayWalletChangeMessage(Map<String, String> messages, Integer userType, Long userId) {
|
||||
sendWxMessage(PAY_WALLET_CHANGE, messages, userType, userId, WALLET_MONEY_PATH);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送微信订阅消息
|
||||
*
|
||||
* @param templateTitle 模版标题
|
||||
* @param messages 消息
|
||||
* @param userType 用户类型
|
||||
* @param userId 用户编号
|
||||
* @param path 点击模板卡片后的跳转页面,仅限本小程序内的页面
|
||||
*/
|
||||
private void sendWxMessage(String templateTitle, Map<String, String> messages, Integer userType, Long userId,
|
||||
String path) {
|
||||
socialClientApi.sendSubscribeMessage(templateTitle, messages, userType, userId, SocialTypeEnum.WECHAT_MINI_APP.getType(), path);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
||||
@ -13,24 +15,28 @@ import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargeMapper;
|
||||
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants;
|
||||
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.message.subscribe.SubscribeMessageClient;
|
||||
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
||||
import cn.iocoder.yudao.module.pay.service.refund.PayRefundService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.hutool.core.util.ObjectUtil.notEqual;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
||||
import static cn.iocoder.yudao.framework.common.util.number.MoneyUtils.fenToYuanStr;
|
||||
import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
|
||||
@ -61,6 +67,8 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
private PayRefundService payRefundService;
|
||||
@Resource
|
||||
private PayWalletRechargePackageService payWalletRechargePackageService;
|
||||
@Resource
|
||||
private SubscribeMessageClient subscribeMessageClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -96,7 +104,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
|
||||
@Override
|
||||
public PageResult<PayWalletRechargeDO> getWalletRechargePackagePage(Long userId, Integer userType,
|
||||
PageParam pageReqVO, Boolean payStatus) {
|
||||
PageParam pageReqVO, Boolean payStatus) {
|
||||
PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType);
|
||||
return walletRechargeMapper.selectPage(pageReqVO, wallet.getId(), payStatus);
|
||||
}
|
||||
@ -126,6 +134,21 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
// TODO 需要钱包中加个可提现余额
|
||||
payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id),
|
||||
PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice());
|
||||
|
||||
// 4. 发送订阅消息
|
||||
sendPayWalletChangeMessage(payOrderId, walletRecharge);
|
||||
}
|
||||
|
||||
private void sendPayWalletChangeMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) {
|
||||
PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId());
|
||||
Map<String, String> messages = MapUtil.newConcurrentHashMap(4);
|
||||
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.NO, String.valueOf(payOrderId));
|
||||
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.PRICE,
|
||||
fenToYuanStr(walletRecharge.getTotalPrice()));
|
||||
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.STATUS, "充值成功");
|
||||
messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.PAY_TIME,
|
||||
LocalDateTimeUtil.formatNormal(LocalDateTime.now()));
|
||||
subscribeMessageClient.sendPayWalletChangeMessage(messages, wallet.getUserType(), wallet.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user