mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-07 21:10:05 +08:00
commit
e6afd28f01
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.product.api.spu.dto;
|
|||||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品 SPU 信息 Response DTO
|
* 商品 SPU 信息 Response DTO
|
||||||
*
|
*
|
||||||
@ -68,6 +70,13 @@ public class ProductSpuRespDTO {
|
|||||||
|
|
||||||
// ========== 物流相关字段 =========
|
// ========== 物流相关字段 =========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配送方式数组
|
||||||
|
*
|
||||||
|
* 对应 DeliveryTypeEnum 枚举
|
||||||
|
*/
|
||||||
|
private List<Integer> deliveryTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物流配置模板编号
|
* 物流配置模板编号
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】");
|
ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】");
|
||||||
ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态");
|
ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态");
|
||||||
ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单");
|
ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单");
|
||||||
|
ErrorCode ORDER_CANCEL_PAID_FAIL = new ErrorCode(1_011_000_033, "交易订单取消支付失败,原因:订单不是【{}】状态");
|
||||||
|
|
||||||
// ========== After Sale 模块 1-011-000-100 ==========
|
// ========== After Sale 模块 1-011-000-100 ==========
|
||||||
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");
|
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");
|
||||||
|
@ -18,6 +18,8 @@ import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO;
|
|||||||
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
|
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
|
||||||
|
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi;
|
import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi;
|
||||||
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
|
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
|
||||||
@ -111,6 +113,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
private ProductCommentApi productCommentApi;
|
private ProductCommentApi productCommentApi;
|
||||||
@Resource
|
@Resource
|
||||||
public SocialClientApi socialClientApi;
|
public SocialClientApi socialClientApi;
|
||||||
|
@Resource
|
||||||
|
public PayRefundApi payRefundApi;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TradeOrderProperties tradeOrderProperties;
|
private TradeOrderProperties tradeOrderProperties;
|
||||||
@ -855,14 +859,28 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void cancelPaidOrder(Long userId, Long orderId) {
|
public void cancelPaidOrder(Long userId, Long orderId) {
|
||||||
// TODO @puhui999:需要校验状态;已支付的情况下,才可以。
|
// 1.1 检验订单存在
|
||||||
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
|
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
throw exception(ORDER_NOT_FOUND);
|
throw exception(ORDER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
|
// 1.2 校验订单是否支付
|
||||||
|
if (!order.getPayStatus()) {
|
||||||
|
throw exception(ORDER_CANCEL_PAID_FAIL, "已支付");
|
||||||
|
}
|
||||||
|
// 1.3 校验订单是否已退款
|
||||||
|
if (ObjUtil.equal(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) {
|
||||||
|
throw exception(ORDER_CANCEL_PAID_FAIL, "未退款");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO @puhui999:需要退款
|
// 2.1 取消订单
|
||||||
|
cancelOrder0(order, TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE);
|
||||||
|
// 2.2 创建退款单
|
||||||
|
payRefundApi.createRefund(new PayRefundCreateReqDTO()
|
||||||
|
.setAppKey(tradeOrderProperties.getPayAppKey()).setUserIp(getClientIP()) // 支付应用
|
||||||
|
.setMerchantOrderId(String.valueOf(order.getId())) // 支付单号
|
||||||
|
.setMerchantRefundId(String.valueOf(order.getId()))
|
||||||
|
.setReason("取消支付订单").setPrice(order.getPayPrice()));// 价格信息
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.module.member.api.address.MemberAddressApi;
|
import cn.iocoder.yudao.module.member.api.address.MemberAddressApi;
|
||||||
import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO;
|
import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
|
||||||
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum;
|
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum;
|
||||||
@ -17,18 +19,19 @@ import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplate
|
|||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO.OrderItem;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO.OrderItem;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运费的 {@link TradePriceCalculator} 实现类
|
* 运费的 {@link TradePriceCalculator} 实现类
|
||||||
@ -49,13 +52,20 @@ public class TradeDeliveryPriceCalculator implements TradePriceCalculator {
|
|||||||
private DeliveryExpressTemplateService deliveryExpressTemplateService;
|
private DeliveryExpressTemplateService deliveryExpressTemplateService;
|
||||||
@Resource
|
@Resource
|
||||||
private TradeConfigService tradeConfigService;
|
private TradeConfigService tradeConfigService;
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi productSpuApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
||||||
if (param.getDeliveryType() == null) {
|
if (param.getDeliveryType() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO @puhui999:需要校验,是不是存在商品不能门店自提,或者不能快递发货的情况。就是说,配送方式不匹配哈
|
// 校验是不是存在商品不能门店自提,或者不能快递发货的情况。就是说,配送方式不匹配哈
|
||||||
|
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(convertSet(result.getItems(), OrderItem::getSpuId));
|
||||||
|
if (anyMatch(spuList, item -> !item.getDeliveryTypes().contains(param.getDeliveryType()))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (DeliveryTypeEnum.PICK_UP.getType().equals(param.getDeliveryType())) {
|
if (DeliveryTypeEnum.PICK_UP.getType().equals(param.getDeliveryType())) {
|
||||||
calculateByPickUp(param);
|
calculateByPickUp(param);
|
||||||
} else if (DeliveryTypeEnum.EXPRESS.getType().equals(param.getDeliveryType())) {
|
} else if (DeliveryTypeEnum.EXPRESS.getType().equals(param.getDeliveryType())) {
|
||||||
@ -124,7 +134,7 @@ public class TradeDeliveryPriceCalculator implements TradePriceCalculator {
|
|||||||
Map<Long, List<OrderItem>> template2ItemMap = convertMultiMap(selectedSkus, OrderItem::getDeliveryTemplateId);
|
Map<Long, List<OrderItem>> template2ItemMap = convertMultiMap(selectedSkus, OrderItem::getDeliveryTemplateId);
|
||||||
// 依次计算快递运费
|
// 依次计算快递运费
|
||||||
for (Map.Entry<Long, List<OrderItem>> entry : template2ItemMap.entrySet()) {
|
for (Map.Entry<Long, List<OrderItem>> entry : template2ItemMap.entrySet()) {
|
||||||
Long templateId = entry.getKey();
|
Long templateId = entry.getKey();
|
||||||
List<OrderItem> orderItems = entry.getValue();
|
List<OrderItem> orderItems = entry.getValue();
|
||||||
DeliveryExpressTemplateRespBO templateBO = expressTemplateMap.get(templateId);
|
DeliveryExpressTemplateRespBO templateBO = expressTemplateMap.get(templateId);
|
||||||
if (templateBO == null) {
|
if (templateBO == null) {
|
||||||
@ -144,8 +154,8 @@ public class TradeDeliveryPriceCalculator implements TradePriceCalculator {
|
|||||||
/**
|
/**
|
||||||
* 按配送方式来计算运费
|
* 按配送方式来计算运费
|
||||||
*
|
*
|
||||||
* @param orderItems SKU 商品项目
|
* @param orderItems SKU 商品项目
|
||||||
* @param chargeMode 配送计费方式
|
* @param chargeMode 配送计费方式
|
||||||
* @param templateCharge 快递运费配置
|
* @param templateCharge 快递运费配置
|
||||||
*/
|
*/
|
||||||
private void calculateExpressFeeByChargeMode(List<OrderItem> orderItems, Integer chargeMode,
|
private void calculateExpressFeeByChargeMode(List<OrderItem> orderItems, Integer chargeMode,
|
||||||
|
@ -33,12 +33,6 @@
|
|||||||
<artifactId>yudao-module-infra-api</artifactId>
|
<artifactId>yudao-module-infra-api</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- TODO @puhui999:不在 MemberUserController 提供接口,而是 PayWalletController 增加。不然 member 耦合 pay 拉。 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-module-pay-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.member.controller.admin.user;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
||||||
import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert;
|
import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
||||||
@ -16,8 +15,6 @@ import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
|
|||||||
import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService;
|
import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService;
|
||||||
import cn.iocoder.yudao.module.member.service.tag.MemberTagService;
|
import cn.iocoder.yudao.module.member.service.tag.MemberTagService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi;
|
|
||||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletUpdateBalanceReqDTO;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -53,8 +50,6 @@ public class MemberUserController {
|
|||||||
private MemberGroupService memberGroupService;
|
private MemberGroupService memberGroupService;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberPointRecordService memberPointRecordService;
|
private MemberPointRecordService memberPointRecordService;
|
||||||
@Resource
|
|
||||||
private PayWalletApi payWalletApi;
|
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新会员用户")
|
@Operation(summary = "更新会员用户")
|
||||||
@ -81,15 +76,6 @@ public class MemberUserController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update-balance")
|
|
||||||
@Operation(summary = "更新会员用户余额")
|
|
||||||
@PreAuthorize("@ss.hasPermission('member:user:update-balance')")
|
|
||||||
public CommonResult<Boolean> updateUserBalance(@Valid @RequestBody MemberUserUpdateBalanceReqVO updateReqVO) {
|
|
||||||
payWalletApi.updateBalance(BeanUtils.toBean(updateReqVO, PayWalletUpdateBalanceReqDTO.class)
|
|
||||||
.setUserId(updateReqVO.getId()));
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得会员用户")
|
@Operation(summary = "获得会员用户")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.api.wallet;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletUpdateBalanceReqDTO;
|
|
||||||
|
|
||||||
// TODO @puhui999:不在 MemberUserController 提供接口,而是 PayWalletController 增加。不然 member 耦合 pay 拉。
|
|
||||||
/**
|
|
||||||
* 会员钱包 API 接口
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
public interface PayWalletApi {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新钱包余额
|
|
||||||
*
|
|
||||||
* @param reqDTO 请求
|
|
||||||
*/
|
|
||||||
void updateBalance(PayWalletUpdateBalanceReqDTO reqDTO);
|
|
||||||
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.api.wallet.dto;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
// TODO @puhui999:不在 MemberUserController 提供接口,而是 PayWalletController 增加。不然 member 耦合 pay 拉。
|
|
||||||
/**
|
|
||||||
* 钱包余额更新 Request DTO
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class PayWalletUpdateBalanceReqDTO {
|
|
||||||
|
|
||||||
@NotNull(message = "用户编号不能为空")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 变动余额,正数为增加,负数为减少
|
|
||||||
*/
|
|
||||||
@NotNull(message = "变动余额不能为空")
|
|
||||||
private Integer balance;
|
|
||||||
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
// @puhui999:不在 MemberUserController 提供接口,而是 PayWalletController 增加。不然 member 耦合 pay 拉。
|
|
||||||
/**
|
|
||||||
* 会员钱包 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -4,9 +4,11 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.PayWalletPageReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
|
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.controller.admin.wallet.vo.wallet.PayWalletUserReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert;
|
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.dal.dataobject.wallet.PayWalletDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -15,12 +17,12 @@ import jakarta.validation.Valid;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.enums.UserTypeEnum.MEMBER;
|
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.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_NOT_FOUND;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 用户钱包")
|
@Tag(name = "管理后台 - 用户钱包")
|
||||||
@RestController
|
@RestController
|
||||||
@ -48,6 +50,21 @@ public class PayWalletController {
|
|||||||
return success(PayWalletConvert.INSTANCE.convertPage(pageResult));
|
return success(PayWalletConvert.INSTANCE.convertPage(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999:修改钱包余额,权限标识,记得加下噢
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.user.vo;
|
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 用户修改余额 Request VO")
|
@Schema(description = "管理后台 - 修改钱包余额 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = true)
|
public class PayWalletUpdateBalanceReqVO {
|
||||||
public class MemberUserUpdateBalanceReqVO {
|
|
||||||
|
|
||||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788")
|
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788")
|
||||||
@NotNull(message = "用户编号不能为空")
|
@NotNull(message = "用户编号不能为空")
|
||||||
private Long id;
|
private Long userId;
|
||||||
|
|
||||||
@Schema(description = "变动余额,正数为增加,负数为减少", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "变动余额,正数为增加,负数为减少", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
@NotNull(message = "变动余额不能为空")
|
@NotNull(message = "变动余额不能为空")
|
Loading…
Reference in New Issue
Block a user