From d7819bb819cd897d5933ac98bdec7e3ccc70846c Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期三, 23 十月 2024 10:55:24 +0800 Subject: [PATCH] fix: 冲突 --- src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java | 39 +++++++++++++++------------------------ 1 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java b/src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java index 543c152..30ffd9f 100644 --- a/src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java +++ b/src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java @@ -1,37 +1,33 @@ package com.mzl.flower.service.impl.wallet; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mzl.flower.config.exception.ValidationException; import com.mzl.flower.config.security.SecurityUtils; import com.mzl.flower.constant.Constants; import com.mzl.flower.dto.request.wallet.CreateWalletWithdrawRecordDTO; -import com.mzl.flower.dto.response.supplier.SupplierDTO; -import com.mzl.flower.entity.wallet.WalletDO; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.mzl.flower.config.exception.ValidationException; -import com.mzl.flower.config.security.SecurityUtils; import com.mzl.flower.dto.request.wallet.QueryWalletDTO; import com.mzl.flower.dto.request.wallet.WalletWithdrawRecordDTO; +import com.mzl.flower.dto.response.supplier.SupplierDTO; import com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO; +import com.mzl.flower.entity.wallet.WalletDO; import com.mzl.flower.entity.wallet.WalletWithdrawRecordDO; import com.mzl.flower.mapper.wallet.WalletWithdrawRecordMapper; import com.mzl.flower.service.supplier.SupplierService; import com.mzl.flower.service.wallet.WalletService; import com.mzl.flower.service.wallet.WalletWithdrawRecordService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import java.time.LocalDateTime; import java.util.List; -import org.springframework.transaction.annotation.Transactional; /** * <p> - * 服务实现类 + * 服务实现类 * </p> * * @author @TaoJie @@ -41,38 +37,35 @@ @Transactional @RequiredArgsConstructor public class WalletWithdrawRecordServiceImpl extends ServiceImpl<WalletWithdrawRecordMapper, WalletWithdrawRecordDO> implements WalletWithdrawRecordService { - @Autowired - private WalletService walletService; - - @Autowired - private SupplierService supplierService; + private final WalletWithdrawRecordMapper walletWithdrawRecordMapper; + private final WalletService walletService; + private final SupplierService supplierService; @Transactional @Override public boolean create(CreateWalletWithdrawRecordDTO dto) { - SupplierDTO supplierDTO=supplierService.getCurrentSupplier(); - if(null==supplierDTO){ + SupplierDTO supplierDTO = supplierService.getCurrentSupplier(); + if (null == supplierDTO) { throw new ValidationException("供应商不能为空"); } final WalletDO walletDO = walletService.getBySupplierId(); - if(null==walletDO){ + if (null == walletDO) { throw new ValidationException("钱包不能为空"); } // 查看钱包的金额是不是大于要提现的金额 - if(null!=walletDO.getWithdrawableAmount() && null!=dto.getAmount() - && walletDO.getWithdrawableAmount().compareTo(dto.getAmount())<0){ + if (null != walletDO.getWithdrawableAmount() && null != dto.getAmount() && walletDO.getWithdrawableAmount().compareTo(dto.getAmount()) < 0) { throw new ValidationException("钱包金额不足"); } - WalletWithdrawRecordDO withdrawRecordDO=new WalletWithdrawRecordDO(); + WalletWithdrawRecordDO withdrawRecordDO = new WalletWithdrawRecordDO(); withdrawRecordDO.setAmount(dto.getAmount()); withdrawRecordDO.setSupplierId(supplierDTO.getId()); withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.WAITING.name()); withdrawRecordDO.setMethod(Constants.WALLET_WITHDRAW_METHOD.WEIXIN.name()); withdrawRecordDO.create(SecurityUtils.getUserId()); + return save(withdrawRecordDO); + } - - private final WalletWithdrawRecordMapper walletWithdrawRecordMapper; @Override public Page<WalletWithdrawRecordVO> queryPage(QueryWalletDTO queryWalletDTO, Page page) { List<WalletWithdrawRecordVO> list = walletWithdrawRecordMapper.queryPage(queryWalletDTO, page); @@ -95,7 +88,5 @@ withdrawRecordDO.setApproveTime(LocalDateTime.now()); walletWithdrawRecordMapper.updateById(withdrawRecordDO); } - return save(withdrawRecordDO); - } } -- Gitblit v1.9.3