75 lines
2.3 KiB
Java
75 lines
2.3 KiB
Java
package com.erp.mq.producer;
|
|
|
|
import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
/**
|
|
* 财务消息生产者
|
|
* 负责发送财务相关的消息
|
|
*/
|
|
@Slf4j
|
|
@Component
|
|
public class FinanceMessageProducer extends BaseRocketMQProducer {
|
|
|
|
@Value("${erp.rocketmq.topics.finance}")
|
|
private String financeTopic;
|
|
|
|
public static final String TAGS_INVOICE = "invoice"; // 开票
|
|
public static final String TAGS_REFUND = "refund"; // 退款
|
|
public static final String TAGS_RECONCILIATION = "reconciliation"; // 对账
|
|
public static final String TAGS_SETTLEMENT = "settlement"; // 结算
|
|
|
|
@Override
|
|
protected String getTopic() {
|
|
return financeTopic;
|
|
}
|
|
|
|
@Override
|
|
protected String getProducerGroup() {
|
|
return "erp-finance-producer-group";
|
|
}
|
|
|
|
/**
|
|
* 发送开票消息
|
|
*/
|
|
public void sendInvoiceCreated(FinanceMessage financeMessage) {
|
|
log.info("发送开票消息 - InvoiceId: {}, Amount: {}",
|
|
financeMessage.getInvoiceId(), financeMessage.getAmount());
|
|
sendMessage(financeMessage, TAGS_INVOICE, financeMessage.getInvoiceId());
|
|
}
|
|
|
|
/**
|
|
* 发送退款消息
|
|
*/
|
|
public void sendRefundProcessed(FinanceMessage financeMessage) {
|
|
log.info("发送退款消息 - RefundId: {}, Amount: {}",
|
|
financeMessage.getRefundId(), financeMessage.getAmount());
|
|
sendMessage(financeMessage, TAGS_REFUND, financeMessage.getRefundId());
|
|
}
|
|
|
|
/**
|
|
* 发送对账消息
|
|
*/
|
|
public void sendReconciliation(FinanceMessage financeMessage) {
|
|
log.info("发送对账消息 - Date: {}", financeMessage.getSettlementDate());
|
|
sendMessage(financeMessage, TAGS_RECONCILIATION, financeMessage.getSettlementDate());
|
|
}
|
|
|
|
@Data
|
|
public static class FinanceMessage {
|
|
private String invoiceId;
|
|
private String refundId;
|
|
private String orderId;
|
|
private Double amount;
|
|
private String customerId;
|
|
private String customerName;
|
|
private String taxNumber;
|
|
private String invoiceType;
|
|
private String settlementDate;
|
|
private String status;
|
|
private Long timestamp;
|
|
}
|
|
}
|