From 37f3d16b75bb388d665c93ff0ed3945093df42bc Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期四, 07 十一月 2024 20:09:35 +0800 Subject: [PATCH] add:钱包功能调整 --- src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java b/src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java index 45291a2..1f3d758 100644 --- a/src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java +++ b/src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java @@ -5,6 +5,7 @@ import com.mzl.flower.constant.LockConstants; import com.mzl.flower.dto.request.wallet.QueryWalletAmountDTO; import com.mzl.flower.dto.response.supplier.SupplierDTO; +import com.mzl.flower.entity.supplier.Supplier; import com.mzl.flower.entity.wallet.WalletDO; import com.mzl.flower.enums.TrueOrFalseEnum; import com.mzl.flower.mapper.wallet.WalletMapper; @@ -17,6 +18,7 @@ import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.text.SimpleDateFormat; @@ -76,6 +78,8 @@ @Override public WalletDO getOrCreateBySupplierId(Long supplierId) { + + WalletDO walletDO=getBySupplierId(supplierId); if(null==walletDO){ RLock lock = redissonClient.getLock(String.format(LockConstants.WALLET_SUPPLIER_ID_KEY, supplierId)); @@ -84,9 +88,12 @@ try { walletDO=getBySupplierId(supplierId); if(null!=walletDO) return walletDO; + + final Supplier supplier = supplierService.getSupplierById(supplierId); + // 创建一个钱包 walletDO =new WalletDO(); - walletDO.setUserId(SecurityUtils.getUserId()); + walletDO.setUserId(supplier.getUserId()); walletDO.setSupplierId(supplierId); walletDO.setTotalAmount(BigDecimal.ZERO); walletDO.setWithdrawableAmount(BigDecimal.ZERO); @@ -96,7 +103,7 @@ walletDO.setSettlingAmount(BigDecimal.ZERO); walletDO.setTotalDeduction(BigDecimal.ZERO); walletDO.setTotalTransactionAmount(BigDecimal.ZERO); - walletDO.setSettlingAmount(BigDecimal.ZERO); + walletDO.setSettledAmount(BigDecimal.ZERO); walletDO.create(SecurityUtils.getUserId()); baseMapper.insert(walletDO); // 将再次查询的结果返回 @@ -130,7 +137,10 @@ @Override public BigDecimal getWaittingSettlementAmount(WalletDO walletDO) { - + if(null!=walletDO && !StringUtils.isEmpty(walletDO.getSupplierId()) && StringUtils.isEmpty(walletDO.getUserId())){ + final Supplier supplier = supplierService.getSupplierById(walletDO.getSupplierId()); + walletDO.setUserId(supplier.getUserId()); + } return baseMapper.getWaittingSettlementAmount(walletDO); } -- Gitblit v1.9.3