超级币商发货更改

This commit is contained in:
tianfeng 2026-03-04 18:40:20 +08:00
parent 4046be18ed
commit e1081f89b6

View File

@ -117,14 +117,8 @@ public class SendFreightShipCmdExe {
// 判断发送者和接收者的代理类型
boolean senderIsSuperFreight = freightBalanceService.checkSuperFreightAgent(cmd.requiredReqUserId());
boolean acceptIsSuperFreight = freightBalanceService.checkSuperFreightAgent(cmd.getAcceptUserId());
boolean acceptIsFreight = freightBalanceService.checkFreightAgent(cmd.getAcceptUserId());
// 权限校验超级经销商才可以发货给经销商和超级经销商普通经销商不能发货给经销商或超级经销商
if (acceptIsFreight || acceptIsSuperFreight) {
ResponseAssert.isTrue(FreightErrorCode.NOT_SUPER_FREIGHT, senderIsSuperFreight);
}
// 扣款失败
ResponseAssert.isTrue(WalletErrorCode.DEDUCTION_FAILED,
freightBalanceService
@ -137,13 +131,24 @@ public class SendFreightShipCmdExe {
FreightBalanceRunningWater runningWater = saveRunningWater(cmd, balance);
// 发货目标是普通经销商 incrCandyBalance 进货运钱包目标是超级经销商或普通用户 changeBalance 进金币钱包
if (acceptIsFreight && !acceptIsSuperFreight) {
if (senderIsSuperFreight && acceptIsFreight) {
// 目标是经销商入货运余额
ResponseAssert.isTrue(WalletErrorCode.DEDUCTION_FAILED,
freightBalanceService.incrCandyBalance(
cmd.requireReqSysOriginEnum(),
cmd.getAcceptUserId(),
cmd.getQuantity()));
String noticeContent = getNoticeContent2(cmd, cmd.getQuantity());
officialNoticeClient.send(
NoticeExtTemplateCustomizeCmd.builder()
.toAccount(cmd.getAcceptUserId())
.noticeType(OfficialNoticeTypeEnum.COIN_SELLER_COINS_RECEIVED)
.content(noticeContent)
.build()
);
} else {
// 目标是超级经销商或普通用户入金币钱包
walletGoldGateway.changeBalance(new WalletReceipt()
@ -158,19 +163,19 @@ public class SendFreightShipCmdExe {
.setOpUserType(OpUserType.APP)
.setCreateTime(cmd.reqTimeElseNow())
);
}
try {
String noticeContent = getNoticeContent(cmd, cmd.getQuantity());
officialNoticeClient.send(
NoticeExtTemplateCustomizeCmd.builder()
.toAccount(cmd.getAcceptUserId())
.noticeType(OfficialNoticeTypeEnum.USER_COINS_RECEIVED)
.content(noticeContent)
.build()
);
} catch (Exception e) {
log.error("send freight balance failed: {}", e.getMessage());
try {
String noticeContent = getNoticeContent(cmd, cmd.getQuantity());
officialNoticeClient.send(
NoticeExtTemplateCustomizeCmd.builder()
.toAccount(cmd.getAcceptUserId())
.noticeType(OfficialNoticeTypeEnum.USER_COINS_RECEIVED)
.content(noticeContent)
.build()
);
} catch (Exception e) {
log.error("send freight balance failed: {}", e.getMessage());
}
}
// 累计充值
@ -212,6 +217,21 @@ public class SendFreightShipCmdExe {
return String.format(noticeTemplate, agencyAccount, goldCoins);
}
private String getNoticeContent2(FreightShipSendCmd cmd, BigDecimal goldQuantity) {
// 获取发送者代理 account
String agencyAccount = resolveAccount(cmd.getReqUserId());
// 获取接收者的区域判断是否为阿拉伯语
ResultResponse<String> regionResponse = userRegionClient.getRegionCode(cmd.getAcceptUserId());
boolean arRegion = regionResponse.checkSuccess() && "AR".equals(regionResponse.getBody());
long goldCoins = goldQuantity.longValue();
String noticeTemplate = arRegion
? "لقد استلمت %,d عملة. تم تحويل الأموال من المستخدم (ID: %s) إلى محفظة وكالة الشحن الخاصة بك. يرجى تأكيد الاستلام."
: "You have received %,d Coins. The funds have been transferred from user (ID: %s) to your recharge agency wallet. Please confirm receipt.";
return String.format(noticeTemplate, goldCoins, agencyAccount);
}
/**
* 获取用户展示的 account优先取专属号ownSpecialId否则取普通 account
*/