mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-17 05:39:50 +08:00
update rabbit消息结算订单
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
package com.jsowell.mq;
|
package com.jsowell.mq;
|
||||||
|
|
||||||
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
import com.jsowell.common.constant.RabbitConstants;
|
import com.jsowell.common.constant.RabbitConstants;
|
||||||
import com.jsowell.pile.dto.AfterSettleOrderDTO;
|
import com.jsowell.pile.dto.AfterSettleOrderDTO;
|
||||||
|
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -16,6 +19,8 @@ import java.io.IOException;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class OrderRabbitListener {
|
public class OrderRabbitListener {
|
||||||
|
@Autowired
|
||||||
|
private OrderBasicInfoService orderBasicInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多线程消费请求消息
|
* 多线程消费请求消息
|
||||||
@@ -24,6 +29,13 @@ public class OrderRabbitListener {
|
|||||||
@RabbitListener(queues = RabbitConstants.QUEUE_CHARGE_ORDER_DATA)
|
@RabbitListener(queues = RabbitConstants.QUEUE_CHARGE_ORDER_DATA)
|
||||||
public void receiveChargeOrderData(AfterSettleOrderDTO afterSettleOrderDTO, Channel channel, Message message) throws IOException {
|
public void receiveChargeOrderData(AfterSettleOrderDTO afterSettleOrderDTO, Channel channel, Message message) throws IOException {
|
||||||
log.info("接收到订单结算数据:{}", afterSettleOrderDTO);
|
log.info("接收到订单结算数据:{}", afterSettleOrderDTO);
|
||||||
|
|
||||||
|
try {
|
||||||
|
orderBasicInfoService.realTimeOrderSplit(afterSettleOrderDTO);
|
||||||
|
} catch (BaseAdaPayException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
//由于配置设置了手动应答,所以这里要进行一个手动应答。注意:如果设置了自动应答,这里又进行手动应答,会出现double ack,那么程序会报错。
|
//由于配置设置了手动应答,所以这里要进行一个手动应答。注意:如果设置了自动应答,这里又进行手动应答,会出现double ack,那么程序会报错。
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,8 @@ public interface OrderBasicInfoService{
|
|||||||
|
|
||||||
OrderSplitResult doBalancePaymentWithDelay(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException;
|
OrderSplitResult doBalancePaymentWithDelay(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException;
|
||||||
|
|
||||||
|
OrderSplitResult realTimeOrderSplit(AfterSettleOrderDTO afterSettleOrderDTO) throws BaseAdaPayException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量查询订单
|
* 批量查询订单
|
||||||
* @param orderCodeList
|
* @param orderCodeList
|
||||||
|
|||||||
@@ -1455,6 +1455,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
* @param orderBasicInfo 订单
|
* @param orderBasicInfo 订单
|
||||||
* @param adapayMemberAccount 结算账户
|
* @param adapayMemberAccount 结算账户
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public OrderSplitResult doPaymentConfirmWithDelay(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
|
public OrderSplitResult doPaymentConfirmWithDelay(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
|
||||||
// 订单编号
|
// 订单编号
|
||||||
String orderCode = orderBasicInfo.getOrderCode();
|
String orderCode = orderBasicInfo.getOrderCode();
|
||||||
@@ -1505,30 +1506,9 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
* 订单实时分账方法
|
* 订单实时分账方法
|
||||||
* 2024年9月24日16点17分 新的分账方法
|
* 2024年9月24日16点17分 新的分账方法
|
||||||
*/
|
*/
|
||||||
public OrderSplitResult realTimeOrderSplit(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
|
@Override
|
||||||
// 订单编号
|
public OrderSplitResult realTimeOrderSplit(AfterSettleOrderDTO afterSettleOrderDTO) throws BaseAdaPayException {
|
||||||
String orderCode = orderBasicInfo.getOrderCode();
|
|
||||||
// 订单结算金额
|
|
||||||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
|
||||||
// 查询订单支付记录
|
|
||||||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
|
||||||
// 需要分账信息
|
|
||||||
List<PaymentInfo> paymentInfos = Lists.newArrayList();
|
|
||||||
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
|
||||||
BigDecimal payAmount = orderPayRecord.getPayAmount();
|
|
||||||
BigDecimal refundAmount = orderPayRecord.getRefundAmount() == null ? BigDecimal.ZERO : orderPayRecord.getRefundAmount();
|
|
||||||
// 如果相减等于0,说明这笔支付单退完了,就不用分账了
|
|
||||||
BigDecimal subtract = payAmount.subtract(refundAmount);
|
|
||||||
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
|
||||||
paymentInfos.addAll(orderPayRecordService.parseDeductionRecord(orderPayRecord.getDeductionRecord()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据站点id查询该站点配置的分账信息, 如果为空表示本运营商分100%
|
|
||||||
List<ShareMemberVO> shareMemberList = stationSplitConfigService.queryShareMembersByStationId(orderBasicInfo.getStationId());
|
|
||||||
|
|
||||||
// 计算每个账户 订单分账金额
|
|
||||||
List<DivMember> divMemberList = splitAmount(shareMemberList, settleAmount, paymentInfos);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user