Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro
# Conflicts: # yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java # yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java # yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.pay.enums;
|
||||
|
||||
/**
|
||||
* 通知模板枚举类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface MessageTemplateConstants {
|
||||
|
||||
// ======================= 小程序订阅消息 =======================
|
||||
|
||||
String WXA_WALLET_RECHARGER_PAID = "充值成功通知";
|
||||
|
||||
}
|
@@ -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.extra.spring.SpringUtil;
|
||||
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,16 +15,19 @@ 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.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.service.order.PayOrderService;
|
||||
import cn.iocoder.yudao.module.pay.service.refund.PayRefundService;
|
||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
@@ -31,8 +36,10 @@ 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.MessageTemplateConstants.WXA_WALLET_RECHARGER_PAID;
|
||||
import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
|
||||
|
||||
/**
|
||||
@@ -61,6 +68,8 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
private PayRefundService payRefundService;
|
||||
@Resource
|
||||
private PayWalletRechargePackageService payWalletRechargePackageService;
|
||||
@Resource
|
||||
public SocialClientApi socialClientApi;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -96,7 +105,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 +135,24 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
// TODO 需要钱包中加个可提现余额
|
||||
payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id),
|
||||
PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice());
|
||||
|
||||
// 4. 发送订阅消息
|
||||
getSelf().sendWalletRechargerPaidMessage(payOrderId, walletRecharge);
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendWalletRechargerPaidMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) {
|
||||
// 1. 获得会员钱包信息
|
||||
PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId());
|
||||
// 2. 构建并发送模版消息
|
||||
socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO()
|
||||
.setUserId(wallet.getUserId()).setUserType(wallet.getUserType())
|
||||
.setTemplateTitle(WXA_WALLET_RECHARGER_PAID)
|
||||
.setPage("pages/user/wallet/money") // 钱包详情界面
|
||||
.addMessage("character_string1", String.valueOf(payOrderId)) // 支付单编号
|
||||
.addMessage("amount2", fenToYuanStr(walletRecharge.getTotalPrice())) // 充值金额
|
||||
.addMessage("time3", LocalDateTimeUtil.formatNormal(walletRecharge.getCreateTime())) // 充值时间
|
||||
.addMessage("phrase4", "充值成功")); // 充值状态
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,4 +309,13 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
return payOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得自身的代理对象,解决 AOP 生效问题
|
||||
*
|
||||
* @return 自己
|
||||
*/
|
||||
private PayWalletRechargeServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user