新增金币代理发货门槛

This commit is contained in:
tianfeng 2025-12-05 17:25:45 +08:00
parent 780b42ac0c
commit c8187c272d
5 changed files with 66 additions and 19 deletions

View File

@ -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"),
;

View File

@ -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.*;
/**
* <p>
@ -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());
}
/**
* 货运代理是否首次充值.
*

View File

@ -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<UserProfileDTO> response = userProfileClient.getByUserId(cmd.getAcceptUserId());
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND,response.getBody());
@ -104,6 +102,12 @@ public class SendFreightShipCmdExe {
ResponseAssert.isTrue(WalletErrorCode.INSUFFICIENT_BALANCE,
ArithmeticUtils.gte(cmd.getQuantity(), BigDecimal.ZERO));
FreightBalance freightBalance = freightBalanceService.getById(cmd.getReqUserId());
ResponseAssert.notNull(FreightErrorCode.NOT_FREIGHT, freightBalance);
Long result = 0L;
ResponseAssert.isTrue(FreightErrorCode.NOT_THRESHOLD, result > Optional.ofNullable(freightBalance.getDeliveryThreshold()).orElse(0));
// 支付密码效验
checkPayPassword(cmd);

View File

@ -0,0 +1,15 @@
package com.red.circle.wallet.app.dto.cmd;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class FreightBalanceUpdateCmd extends AppExtCommand {
@NotNull
private Integer deliveryThreshold;
}

View File

@ -106,4 +106,10 @@ public class FreightBalance extends TimestampBaseEntity {
@TableField("seller_quantity")
private Integer sellerQuantity;
/**
* 发货门槛
*/
@TableField("delivery_threshold")
private Integer deliveryThreshold;
}