【同步】BOOT 和 CLOUD 的功能

This commit is contained in:
YunaiV
2024-09-07 12:46:56 +08:00
parent 1dea81fd0c
commit d2f0c00d8f
72 changed files with 1690 additions and 999 deletions

View File

@@ -18,9 +18,8 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable {
RECHARGE(1, "充值"),
RECHARGE_REFUND(2, "充值退款"),
PAYMENT(3, "支付"),
PAYMENT_REFUND(4, "支付退款");
// TODO 后续增加
PAYMENT_REFUND(4, "支付退款"),
UPDATE_BALANCE(5, "更新余额");
/**
* 业务分类
@@ -35,6 +34,6 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable {
@Override
public int[] array() {
return ARRAYS;
return ARRAYS;
}
}

View File

@@ -4,9 +4,11 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUpdateBalanceReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert;
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 io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -15,12 +17,12 @@ import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
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.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_NOT_FOUND;
@Tag(name = "管理后台 - 用户钱包")
@RestController
@@ -48,4 +50,21 @@ public class PayWalletController {
return success(PayWalletConvert.INSTANCE.convertPage(pageResult));
}
@PutMapping("/update-balance")
@Operation(summary = "更新会员用户余额")
@PreAuthorize("@ss.hasPermission('pay:wallet:update-balance')")
public CommonResult<Boolean> updateWalletBalance(@Valid @RequestBody PayWalletUpdateBalanceReqVO updateReqVO) {
// 获得用户钱包
PayWalletDO wallet = payWalletService.getOrCreateWallet(updateReqVO.getUserId(), MEMBER.getValue());
if (wallet == null) {
log.error("[updateWalletBalance]updateReqVO({}) 用户钱包不存在.", updateReqVO);
throw exception(WALLET_NOT_FOUND);
}
// 更新钱包余额
payWalletService.addWalletBalance(wallet.getId(), String.valueOf(updateReqVO.getUserId()),
PayWalletBizTypeEnum.UPDATE_BALANCE, updateReqVO.getBalance());
return success(true);
}
}

View File

@@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Schema(description = "管理后台 - 修改钱包余额 Request VO")
@Data
public class PayWalletUpdateBalanceReqVO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788")
@NotNull(message = "用户编号不能为空")
private Long userId;
@Schema(description = "变动余额,正数为增加,负数为减少", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
@NotNull(message = "变动余额不能为空")
private Integer balance;
}

View File

@@ -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("待实现");