From ae1471f378f399f76518539ec8992e64a3673436 Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期三, 08 一月 2025 15:26:06 +0800
Subject: [PATCH] 1.订单提交:订单最小金额配置
---
src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java | 31 +++++++++++++++++++++++++------
1 files changed, 25 insertions(+), 6 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 40beec9..0e784cd 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);
@@ -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);
}
@@ -154,15 +164,24 @@
queryWalletAmountDTO.setStartTime(getWalletOnLineTime());
queryWalletAmountDTO.setUserId(walletDO.getUserId());
- // 质检扣款
- BigDecimal checkDeduceAmount = walletReduceService.getCheckReduceAmount(queryWalletAmountDTO);
- checkDeduceAmount = checkDeduceAmount != null ? checkDeduceAmount : BigDecimal.ZERO;
+ // 质检扣款(缺货和补货)
+ BigDecimal checkReplaceLockAmount = walletReduceService.getCheckLackReplaceAmount(queryWalletAmountDTO);
+ checkReplaceLockAmount = checkReplaceLockAmount != null ? checkReplaceLockAmount : BigDecimal.ZERO;
+
+ // 质检扣款(降级)
+ BigDecimal checkReduceAmount = walletReduceService.getCheckReduceAmount(queryWalletAmountDTO);
+ checkReduceAmount = checkReduceAmount != null ? checkReduceAmount : BigDecimal.ZERO;
+
// 售后扣款
BigDecimal saleDeduceAmount = walletReduceService.getSaleReduceAmount(queryWalletAmountDTO);
saleDeduceAmount = saleDeduceAmount != null ? saleDeduceAmount : BigDecimal.ZERO;
+ // 集货站运费
+ BigDecimal stationFeeAmount = walletReduceService.getStationFeeAmount(queryWalletAmountDTO);
+ stationFeeAmount = stationFeeAmount != null ? stationFeeAmount : BigDecimal.ZERO;
+
// 总扣款
- BigDecimal deduceAmount = checkDeduceAmount.add(saleDeduceAmount);
+ BigDecimal deduceAmount = checkReplaceLockAmount.add(checkReduceAmount).add(saleDeduceAmount).add(stationFeeAmount);
return deduceAmount;
}
--
Gitblit v1.9.3