feat(tenant-balance): 新增提现站内信通知功能
在提现流程中,向租户联系人发送站内信通知,模板码 tx-001,携带提现金额参数。
This commit is contained in:
@@ -10,6 +10,8 @@ import com.yolo.keyboard.framework.common.util.collection.CollectionUtils;
|
||||
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.yolo.keyboard.framework.tenant.core.context.TenantContextHolder;
|
||||
import com.yolo.keyboard.module.infra.api.config.ConfigApi;
|
||||
import com.yolo.keyboard.module.system.api.notify.NotifyMessageSendApi;
|
||||
import com.yolo.keyboard.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
||||
import com.yolo.keyboard.utils.BizNoGenerator;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -59,7 +61,11 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
|
||||
@Resource
|
||||
private KeyboardTenantWithdrawOrderMapper tenantWithdrawOrderMapper;
|
||||
|
||||
@Resource
|
||||
private NotifyMessageSendApi notifyMessageSendApi;
|
||||
|
||||
private static final String WITHDRAW_DAYS_CONFIG_KEY = "WITHDRAW-DAYS";
|
||||
private static final String WITHDRAW_NOTIFY_TEMPLATE_CODE = "tx-001";
|
||||
|
||||
@Override
|
||||
public Long createTenantBalance(TenantBalanceSaveReqVO createReqVO) {
|
||||
@@ -300,6 +306,32 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
|
||||
.updatedAt(now)
|
||||
.build();
|
||||
tenantWithdrawOrderMapper.insert(withdrawOrder);
|
||||
|
||||
// 8. 发送站内信通知
|
||||
sendWithdrawNotify(tenantId, withdrawAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送提现站内信通知
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param withdrawAmount 提现金额
|
||||
*/
|
||||
private void sendWithdrawNotify(Long tenantId, BigDecimal withdrawAmount) {
|
||||
// 获取租户信息,找到联系人用户ID
|
||||
TenantDO tenant = tenantMapper.selectById(tenantId);
|
||||
if (tenant == null || tenant.getContactUserId() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建站内信请求
|
||||
NotifySendSingleToUserReqDTO reqDTO = new NotifySendSingleToUserReqDTO();
|
||||
reqDTO.setUserId(tenant.getContactUserId());
|
||||
reqDTO.setTemplateCode(WITHDRAW_NOTIFY_TEMPLATE_CODE);
|
||||
reqDTO.setTemplateParams(Map.of("amount", withdrawAmount.toPlainString()));
|
||||
|
||||
// 发送站内信
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(reqDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user