币安订单查询修改

This commit is contained in:
tianfeng 2026-03-03 15:38:37 +08:00
parent 6f5e2610e0
commit 8d3e44912c
8 changed files with 40 additions and 76 deletions

View File

@ -51,6 +51,9 @@ public interface FreightGoldClientApi {
@GetMapping("/existsBalance")
ResultResponse<Boolean> existsBalance(@RequestParam("userId") Long userId);
@GetMapping("/existsRecord")
ResultResponse<Boolean> existsRecord(@RequestParam("txId") String txId);
/**
* 是否为货运代理角色

View File

@ -63,6 +63,16 @@ public enum FreightErrorCode implements IResponseErrorCode {
* 未达到发货门槛
*/
NOT_THRESHOLD(5509, "Delivery threshold not reached"),
/**
* 您的金币已到账
*/
THE_GOLD_COINS_HAVE_ARRIVED(5510, "Your gold coin has arrived."),
/**
* 不正确的订单编号
*/
INCORRECT_ORDER_NUMBER(5511, "Incorrect order number"),
;

View File

@ -75,17 +75,8 @@ public class FreightRechargeCmdExe {
BigDecimal earnPoints = FreightPolicyEnum.earnPoints(bigDecimal);
BigDecimal rechargeRatio = freightGoldClient.rechargeRatio(cmd.getReqUserId()).getBody();
if (rechargeRatio.compareTo(BigDecimal.ZERO) > 0) {
earnPoints = bigDecimal.multiply(rechargeRatio).setScale(0, RoundingMode.FLOOR);
}
// 操作失败
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE,
incrCandyBalance(cmd.requireReqSysOrigin(), cmd.getReqUserId(), earnPoints));
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Hooka 币商充值").append("\n")
stringBuilder.append("Likei 币商充值").append("\n")
.append("用户ID:").append(userProfile.getAccount()).append("\n")
.append("充值金额: ").append(bigDecimal).append("\n")
.append("自动到账金币: ").append(earnPoints).append("\n")
@ -112,12 +103,6 @@ public class FreightRechargeCmdExe {
.setRemark(cmd.getTxId())
.setCreateUser(cmd.getReqUserId())
.setUpdateUser(cmd.getReqUserId()));
// 记录充值金额: 货运代理充值500以上则发送货运代理徽章
BigDecimal amount = userFreightRechargeRecordClient.inrNowMonthAmount(cmd.getReqUserId(),
ArithmeticUtils.lteZero(bigDecimal) ? BigDecimal.ZERO : bigDecimal)
.getBody();
sendFreightShipBadge(cmd.getReqUserId(), amount);
}
} catch (UnsupportedEncodingException | NoSuchAlgorithmException | InvalidKeyException e) {
throw new RuntimeException(e);
@ -142,64 +127,4 @@ public class FreightRechargeCmdExe {
.orElse(BigDecimal.ZERO);
}
/**
* 余额如果大于1250则发送货运代理徽章.
*
* @param userId 代理用户id.
* @param balance 代理余额.
*/
public void sendFreightShipBadge(Long userId, BigDecimal balance) {
if (Objects.isNull(balance)) {
return;
}
Long freightBadgeId = getFreightBadgeId();
if (Objects.isNull(freightBadgeId)) {
return;
}
if (balance.compareTo(BigDecimal.valueOf(500)) < 0) {
return;
}
badgeBackpackClient.giveBadgePermanent(freightBadgeId, userId);
}
private boolean incrCandyBalance(String sysOrigin, Long userId,
BigDecimal quantity) {
UserFreightBalanceDTO freightBalance = freightGoldClient.getFreightBalance(userId)
.getBody();
if (Objects.isNull(freightBalance)) {
ResponseAssert.isFalse(
UserErrorCode.USER_IS_SELLER, ResponseAssert.requiredSuccess(
freightGoldClient.existsSeller(userId)));
//获得货运代理徽章
Long badgeId = getFreightBadgeId();
if (Objects.nonNull(badgeId) && quantity.compareTo(BigDecimal.valueOf(1250)) >= 0) {
//发送货运代理徽章
badgeBackpackClient.giveBadgePermanent(badgeId, userId);
}
// 增加新开货运代理审查记录
freightGoldClient.addFreightAgentReview(new FreightAgentReviewCmd()
.setSysOrigin(sysOrigin)
.setUserId(userId)
);
}
if (Objects.equals(Boolean.TRUE, ResponseAssert.requiredSuccess(
freightGoldClient.incrCandyBalance(SysOriginPlatformEnum.valueOf(sysOrigin), userId,
quantity)))) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
private Long getFreightBadgeId() {
return badgeSourceClient.getFreightBadgeId().getBody();
}
}

View File

@ -71,6 +71,8 @@ public interface FreightBalanceRunningWaterService extends BaseService<FreightBa
* @param userIds 用户ID集合
* @return 用户ID -> 交易次数
*/
boolean existsRecord(String txId);
Map<Long, Long> countTransactionsByUserIds(Set<Long> userIds);
/**

View File

@ -138,6 +138,18 @@ public class FreightBalanceRunningWaterServiceImpl extends
.list();
}
@Override
public boolean existsRecord(String txId) {
if (!StringUtils.isNotBlank(txId)) {
return false;
}
return query()
.select(FreightBalanceRunningWater::getId)
.eq(FreightBalanceRunningWater::getRemark, txId)
.last(PageConstant.formatLimit(1))
.getOne() != null;
}
@Override
public Map<Long, Long> countTransactionsByUserIds(Set<Long> userIds) {
if (CollectionUtils.isEmpty(userIds)) {

View File

@ -53,6 +53,11 @@ public class FreightGoldClientEndpoint implements FreightGoldClientApi {
return ResultResponse.success(freightGoldClientService.existsBalance(userId));
}
@Override
public ResultResponse<Boolean> existsRecord(String txId) {
return ResultResponse.success(freightGoldClientService.existsRecord(txId));
}
@Override
public ResultResponse<Boolean> checkFreightAgent(Long userId) {

View File

@ -51,6 +51,8 @@ public interface FreightGoldClientService {
*/
boolean existsBalance(Long userId);
boolean existsRecord(String txId);
/**
* 是否为货运代理角色
*

View File

@ -106,6 +106,11 @@ public class FreightGoldClientServiceImpl implements FreightGoldClientService {
return freightBalanceService.existsBalance(userId);
}
@Override
public boolean existsRecord(String txId) {
return freightBalanceRunningWaterService.existsRecord(txId);
}
@Override
public Boolean checkFreightAgent(Long userId) {
return freightBalanceService.checkFreightAgent(userId);