From c8187c272d80410ca64dc7aa1bd199214694d5c5 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 5 Dec 2025 17:25:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=91=E5=B8=81=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=8F=91=E8=B4=A7=E9=97=A8=E6=A7=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wallet/inner/error/FreightErrorCode.java | 9 ++++- .../adapter/app/FreightRestController.java | 39 +++++++++++++------ .../freight/SendFreightShipCmdExe.java | 16 +++++--- .../app/dto/cmd/FreightBalanceUpdateCmd.java | 15 +++++++ .../rds/entity/freight/FreightBalance.java | 6 +++ 5 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/dto/cmd/FreightBalanceUpdateCmd.java diff --git a/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/error/FreightErrorCode.java b/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/error/FreightErrorCode.java index 278a5eeb..24006f4c 100644 --- a/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/error/FreightErrorCode.java +++ b/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/error/FreightErrorCode.java @@ -56,7 +56,14 @@ public enum FreightErrorCode implements IResponseErrorCode { /** * 不等你超过经销商最大金额 */ - NOT_MAX_SOME(5508, "Cannot be greater than the dealer's maximum sales amount"); + NOT_MAX_SOME(5508, "Cannot be greater than the dealer's maximum sales amount"), + + + /** + * 未达到发货门槛 + */ + NOT_THRESHOLD(5509, "Delivery threshold not reached"), + ; diff --git a/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/FreightRestController.java b/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/FreightRestController.java index 23fd70ef..d48aadbf 100644 --- a/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/FreightRestController.java +++ b/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/FreightRestController.java @@ -4,29 +4,25 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.app.AppAccountCmd; import com.red.circle.common.business.dto.cmd.app.AppFlowCmd; import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd; +import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.web.controller.BaseController; import com.red.circle.wallet.app.dto.clientobject.FreightAccountCO; import com.red.circle.wallet.app.dto.clientobject.FreightDealerUserSearchResultCO; import com.red.circle.wallet.app.dto.clientobject.FreightRunningWaterCO; import com.red.circle.wallet.app.dto.clientobject.FreightSearchUserResultCO; import com.red.circle.wallet.app.dto.clientobject.FreightSellerCO; -import com.red.circle.wallet.app.dto.cmd.FreightDealerShipCmd; -import com.red.circle.wallet.app.dto.cmd.FreightDealerToUserShipCmd; -import com.red.circle.wallet.app.dto.cmd.FreightSellerCmd; -import com.red.circle.wallet.app.dto.cmd.FreightSellerQryCmd; -import com.red.circle.wallet.app.dto.cmd.FreightSellerRunningWaterQryCmd; -import com.red.circle.wallet.app.dto.cmd.FreightSellerUsableGoldCmd; -import com.red.circle.wallet.app.dto.cmd.FreightShipSendCmd; +import com.red.circle.wallet.app.dto.cmd.*; import com.red.circle.wallet.app.service.UserFreightService; import java.math.BigDecimal; import java.util.List; + +import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalance; +import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceService; +import com.red.circle.wallet.inner.error.FreightErrorCode; +import com.red.circle.wallet.inner.error.WalletErrorCode; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** *
@@ -44,6 +40,7 @@ import org.springframework.web.bind.annotation.RestController;
public class FreightRestController extends BaseController {
private final UserFreightService userFreightService;
+ private final FreightBalanceService freightBalanceService;
/**
* 货运账户余额.
@@ -124,6 +121,24 @@ public class FreightRestController extends BaseController {
return userFreightService.sendFreightShip(cmd);
}
+ @PutMapping("/threshold")
+ public Boolean updateFreightBalance(@RequestBody @Validated FreightBalanceUpdateCmd cmd) {
+ FreightBalance freightBalance = freightBalanceService.getById(cmd.getReqUserId());
+ ResponseAssert.notNull(FreightErrorCode.NOT_FREIGHT, freightBalance);
+ freightBalance.setDeliveryThreshold(cmd.getDeliveryThreshold());
+ return freightBalanceService.updateSelectiveById(freightBalance);
+ }
+
+ /**
+ * 查询货运代理信息
+ * @param cmd
+ * @return
+ */
+ @GetMapping("/threshold")
+ public FreightBalance getFreightThreshold(AppAccountCmd cmd) {
+ return freightBalanceService.getById(cmd.getReqUserId());
+ }
+
/**
* 货运代理是否首次充值.
*
diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java
index eff3472d..0771bed9 100644
--- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java
+++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java
@@ -35,11 +35,13 @@ import com.red.circle.wallet.domain.gateway.WalletGoldGateway;
import com.red.circle.wallet.domain.wallet.WalletReceipt;
import com.red.circle.wallet.infra.database.cache.service.UserPayAuthCacheService;
import com.red.circle.wallet.infra.database.rds.entity.auth.PayAuth;
+import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalance;
import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalanceRunningWater;
import com.red.circle.wallet.infra.database.rds.service.auth.PayAuthService;
import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceRunningWaterService;
import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceService;
import com.red.circle.wallet.infra.sync.ControlSwitch;
+import com.red.circle.wallet.inner.error.FreightErrorCode;
import com.red.circle.wallet.inner.error.WalletErrorCode;
import com.red.circle.wallet.inner.model.enums.FreightBalanceOrigin;
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
@@ -49,6 +51,8 @@ import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
+
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -86,12 +90,6 @@ public class SendFreightShipCmdExe {
controlSwitch.execute(cmd.requireReqSysOriginChildEnum());
log.warn("{}", JacksonUtils.toJson(cmd));
-// ResponseAssert.isTrue(CommonErrorCode.REPEATED_SUBMISSION, redisService.setIfAbsent(
-// "SFS:" + cmd.getReqTraceId(),
-// 1,
-// TimeUnit.MINUTES
-// )
-// );
ResultResponse