mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-09 15:51:52 +08:00
【新增】MALL: 更新会员用户余额相关接口
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.pay.api.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletUpdateBalanceReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.enums.UserTypeEnum.MEMBER;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_NOT_FOUND;
|
||||
|
||||
/**
|
||||
* 会员钱包 API 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class PayWalletApiImpl implements PayWalletApi {
|
||||
|
||||
@Resource
|
||||
private PayWalletService payWalletService;
|
||||
|
||||
@Override
|
||||
public void updateBalance(PayWalletUpdateBalanceReqDTO reqDTO) {
|
||||
// 获得用户钱包
|
||||
PayWalletDO wallet = payWalletService.getOrCreateWallet(reqDTO.getUserId(), MEMBER.getValue());
|
||||
if (wallet == null) {
|
||||
log.error("[updateBalance],reqDTO({}) 用户钱包不存在.", reqDTO);
|
||||
throw exception(WALLET_NOT_FOUND);
|
||||
}
|
||||
|
||||
// 更新钱包余额
|
||||
payWalletService.addWalletBalance(wallet.getId(), String.valueOf(reqDTO.getUserId()),
|
||||
PayWalletBizTypeEnum.UPDATE_BALANCE, reqDTO.getBalance());
|
||||
}
|
||||
|
||||
}
|
@@ -12,12 +12,12 @@ 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.pay.service.wallet.bo.WalletTransactionCreateReqBO;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -176,6 +176,9 @@ public class PayWalletServiceImpl implements PayWalletService {
|
||||
walletMapper.updateWhenRecharge(payWallet.getId(), price);
|
||||
break;
|
||||
}
|
||||
case UPDATE_BALANCE: // 更新余额
|
||||
walletMapper.updateWhenRecharge(payWallet.getId(), price);
|
||||
break;
|
||||
default: {
|
||||
// TODO 其它类型待实现
|
||||
throw new UnsupportedOperationException("待实现");
|
||||
|
Reference in New Issue
Block a user