活动转账新增金币到账通知
This commit is contained in:
parent
db1d71dfee
commit
3336472708
@ -3,9 +3,13 @@ package com.red.circle.other.app.command.activity;
|
|||||||
import com.red.circle.common.business.core.enums.OpUserType;
|
import com.red.circle.common.business.core.enums.OpUserType;
|
||||||
import com.red.circle.common.business.core.enums.ReceiptType;
|
import com.red.circle.common.business.core.enums.ReceiptType;
|
||||||
import com.red.circle.component.redis.service.RedisService;
|
import com.red.circle.component.redis.service.RedisService;
|
||||||
|
import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient;
|
||||||
|
import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateCustomizeCmd;
|
||||||
|
import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum;
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||||
import com.red.circle.framework.core.response.ResponseErrorCode;
|
import com.red.circle.framework.core.response.ResponseErrorCode;
|
||||||
|
import com.red.circle.framework.dto.ResultResponse;
|
||||||
import com.red.circle.other.app.dto.clientobject.activity.LotteryWithdrawAmountCO;
|
import com.red.circle.other.app.dto.clientobject.activity.LotteryWithdrawAmountCO;
|
||||||
import com.red.circle.other.app.dto.cmd.activity.LotteryTransferCmd;
|
import com.red.circle.other.app.dto.cmd.activity.LotteryTransferCmd;
|
||||||
import com.red.circle.other.app.service.activity.LotteryActivityRestService;
|
import com.red.circle.other.app.service.activity.LotteryActivityRestService;
|
||||||
@ -14,7 +18,9 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw;
|
|||||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryUserProgressService;
|
import com.red.circle.other.infra.database.rds.service.activity.LotteryUserProgressService;
|
||||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryWithdrawService;
|
import com.red.circle.other.infra.database.rds.service.activity.LotteryWithdrawService;
|
||||||
import com.red.circle.other.inner.endpoint.user.region.UserRegionClient;
|
import com.red.circle.other.inner.endpoint.user.region.UserRegionClient;
|
||||||
|
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
|
||||||
import com.red.circle.other.inner.model.dto.user.SysExchangeGoldTipDTO;
|
import com.red.circle.other.inner.model.dto.user.SysExchangeGoldTipDTO;
|
||||||
|
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||||
import com.red.circle.tool.core.date.TimestampUtils;
|
import com.red.circle.tool.core.date.TimestampUtils;
|
||||||
import com.red.circle.tool.core.num.ArithmeticUtils;
|
import com.red.circle.tool.core.num.ArithmeticUtils;
|
||||||
import com.red.circle.tool.core.tuple.PennyAmount;
|
import com.red.circle.tool.core.tuple.PennyAmount;
|
||||||
@ -57,6 +63,8 @@ public class LotteryTransferExe {
|
|||||||
private final FreightBalanceClient freightBalanceClient;
|
private final FreightBalanceClient freightBalanceClient;
|
||||||
private final FreightBalanceRunningWaterClient freightBalanceRunningWaterClient;
|
private final FreightBalanceRunningWaterClient freightBalanceRunningWaterClient;
|
||||||
private final LotteryWithdrawAmountQryExe lotteryWithdrawAmountQryExe;
|
private final LotteryWithdrawAmountQryExe lotteryWithdrawAmountQryExe;
|
||||||
|
private final OfficialNoticeClient officialNoticeClient;
|
||||||
|
private final UserProfileClient userProfileClient;
|
||||||
|
|
||||||
public void execute(LotteryTransferCmd cmd) {
|
public void execute(LotteryTransferCmd cmd) {
|
||||||
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
|
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
|
||||||
@ -151,6 +159,16 @@ public class LotteryTransferExe {
|
|||||||
.setOrigin(FreightBalanceOrigin.PURCHASE.name())
|
.setOrigin(FreightBalanceOrigin.PURCHASE.name())
|
||||||
.setRemark(remark)
|
.setRemark(remark)
|
||||||
.setCreateUser(cmd.requiredReqUserId()));
|
.setCreateUser(cmd.requiredReqUserId()));
|
||||||
|
|
||||||
|
String noticeContent = getNoticeContent(cmd, goldQuantity);
|
||||||
|
officialNoticeClient.send(
|
||||||
|
NoticeExtTemplateCustomizeCmd.builder()
|
||||||
|
.toAccount(cmd.getAcceptUserId())
|
||||||
|
.noticeType(OfficialNoticeTypeEnum.COIN_SELLER_COINS_RECEIVED)
|
||||||
|
.content(noticeContent)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +186,35 @@ public class LotteryTransferExe {
|
|||||||
walletGoldClient.changeBalance(build);
|
walletGoldClient.changeBalance(build);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getNoticeContent(LotteryTransferCmd 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
|
||||||
|
*/
|
||||||
|
private String resolveAccount(Long userId) {
|
||||||
|
ResultResponse<UserProfileDTO> response = userProfileClient.getByUserId(userId);
|
||||||
|
if (!response.checkSuccess() || response.getBody() == null) {
|
||||||
|
return Objects.toString(userId);
|
||||||
|
}
|
||||||
|
UserProfileDTO profile = response.getBody();
|
||||||
|
return profile.getOwnSpecialId() != null
|
||||||
|
? profile.getOwnSpecialId().getAccount()
|
||||||
|
: profile.getAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得1$兑换多少金币比例,基于区域+用户输入的美元.
|
* 获得1$兑换多少金币比例,基于区域+用户输入的美元.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user