mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
1217 lines
64 KiB
Java
1217 lines
64 KiB
Java
package com.jsowell.service;
|
||
|
||
import com.alibaba.fastjson2.JSON;
|
||
import com.alibaba.fastjson2.JSONArray;
|
||
import com.alibaba.fastjson2.JSONObject;
|
||
import com.google.common.collect.ImmutableMap;
|
||
import com.google.common.collect.Lists;
|
||
import com.google.common.collect.Maps;
|
||
import com.google.common.collect.Sets;
|
||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||
import com.jsowell.adapay.common.AdaPayment;
|
||
import com.jsowell.adapay.common.PaymentConfirmInfo;
|
||
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
|
||
import com.jsowell.adapay.response.PaymentConfirmResponse;
|
||
import com.jsowell.adapay.response.QueryPaymentConfirmDetailResponse;
|
||
import com.jsowell.adapay.service.AdapayService;
|
||
import com.jsowell.adapay.vo.OrderSplitResult;
|
||
import com.jsowell.adapay.vo.PaymentInfo;
|
||
import com.jsowell.common.annotation.CostTime;
|
||
import com.jsowell.common.constant.RabbitConstants;
|
||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||
import com.jsowell.common.core.redis.RedisCache;
|
||
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
||
import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
|
||
import com.jsowell.common.enums.ykc.*;
|
||
import com.jsowell.common.exception.BusinessException;
|
||
import com.jsowell.common.util.DateUtils;
|
||
import com.jsowell.common.util.StringUtils;
|
||
import com.jsowell.pile.domain.*;
|
||
import com.jsowell.pile.dto.*;
|
||
import com.jsowell.pile.mapper.OrderBasicInfoMapper;
|
||
import com.jsowell.pile.service.*;
|
||
import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
|
||
import com.jsowell.pile.service.programlogic.ProgramLogicFactory;
|
||
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
||
import com.jsowell.pile.transaction.service.TransactionService;
|
||
import com.jsowell.pile.vo.web.*;
|
||
import org.apache.commons.collections4.CollectionUtils;
|
||
import org.slf4j.Logger;
|
||
import org.slf4j.LoggerFactory;
|
||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Service;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
|
||
import java.math.BigDecimal;
|
||
import java.math.RoundingMode;
|
||
import java.text.MessageFormat;
|
||
import java.time.LocalDateTime;
|
||
import java.util.Date;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.Set;
|
||
import java.util.concurrent.TimeUnit;
|
||
import java.util.function.Function;
|
||
import java.util.stream.Collectors;
|
||
|
||
@Service
|
||
public class TempService {
|
||
|
||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||
|
||
@Autowired
|
||
private OrderBasicInfoMapper orderBasicInfoMapper;
|
||
|
||
@Autowired
|
||
private OrderBasicInfoService orderBasicInfoService;
|
||
|
||
@Autowired
|
||
private ClearingWithdrawInfoService clearingWithdrawInfoService;
|
||
|
||
@Autowired
|
||
private OrderPayRecordService orderPayRecordService;
|
||
|
||
@Autowired
|
||
private AdapayCallbackRecordService adapayCallbackRecordService;
|
||
|
||
@Autowired
|
||
protected TransactionService transactionService;
|
||
|
||
@Autowired
|
||
protected RabbitTemplate rabbitTemplate;
|
||
|
||
@Autowired
|
||
protected MemberGroupService memberGroupService;
|
||
|
||
@Autowired
|
||
private WxpayRefundCallbackService wxpayRefundCallbackService;
|
||
|
||
@Autowired
|
||
private PileMerchantInfoService pileMerchantInfoService;
|
||
|
||
@Autowired
|
||
private SettleOrderReportService settleOrderReportService;
|
||
|
||
@Autowired
|
||
private AdapayMemberAccountService adapayMemberAccountService;
|
||
|
||
@Autowired
|
||
private AdapayService adapayService;
|
||
|
||
@Autowired
|
||
private MemberAdapayRecordService memberAdapayRecordService;
|
||
|
||
@Autowired
|
||
private PileMsgRecordService pileMsgRecordService;
|
||
|
||
@Autowired
|
||
private OrderDetailService orderDetailService;
|
||
|
||
@Autowired
|
||
private OrderMonitorDataService orderMonitorDataService;
|
||
|
||
@Autowired
|
||
private RedisCache redisCache;
|
||
|
||
@Autowired
|
||
private OrderUnsplitRecordService orderUnsplitRecordService;
|
||
|
||
/**
|
||
* 计算订单耗电量
|
||
* 内蒙古站点
|
||
*/
|
||
public void calculateOrderElectricity(QueryOrderDTO dto) {
|
||
// 根据站点id查询充电桩列表
|
||
// List<String> pileSnList = Lists.newArrayList("88240000006708", "88240000006709", "88240000006713", "88240000006714");
|
||
// 查询充电桩的订单列表
|
||
List<OrderListVO> orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto);
|
||
logger.info("查询订单列表:{}", JSON.toJSONString(orderListVOS));
|
||
// 根据充电桩编号,查询报文
|
||
for (OrderListVO orderVO : orderListVOS) {
|
||
String pileSn = orderVO.getPileSn();
|
||
// List<PileMsgRecord> pileFeedList = pileMsgRecordMapper.getPileFeedList(pileSn);
|
||
}
|
||
|
||
//
|
||
}
|
||
|
||
/**
|
||
* 手动接口执行订单分账逻辑
|
||
*/
|
||
public void tempOrderSplittingOperations(String merchantId, String tradeDate) {
|
||
logger.info("手动接口执行订单分账逻辑-运营商:{}, 交易日期:{}, 进行分账处理start", merchantId, tradeDate);
|
||
|
||
// 查询运营商有没有开通结算账户
|
||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
|
||
if (adapayMemberAccount == null) {
|
||
logger.error("手动接口执行订单分账逻辑-订单分账逻辑error, 运营商id:{}, 未配置结算账户", merchantId);
|
||
return;
|
||
}
|
||
|
||
String appId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId);
|
||
|
||
// 根据交易日期查询运营商下面所有站点的交易日报
|
||
List<SettleOrderReport> stationReportList = settleOrderReportService.selectByMerchantIdAndDate(merchantId, tradeDate);
|
||
for (SettleOrderReport orderReport : stationReportList) {
|
||
String orderCodes = orderReport.getOrderCodes();
|
||
if (StringUtils.isBlank(orderCodes)) {
|
||
logger.info("手动接口执行订单分账逻辑-站点:{}, 日期:{}, 没有查到订单数据", orderReport.getStationId(), tradeDate);
|
||
continue;
|
||
}
|
||
List<String> orderCodeList = Lists.newArrayList(StringUtils.split(orderCodes, ","));
|
||
List<OrderBasicInfo> orderBasicInfos = orderBasicInfoService.queryOrderList(orderCodeList);
|
||
if (CollectionUtils.isEmpty(orderBasicInfos)) {
|
||
logger.info("手动接口执行订单分账逻辑-站点:{}, 日期:{}, 没有查到订单数据", orderReport.getStationId(), tradeDate);
|
||
continue;
|
||
}
|
||
|
||
// 执行分账
|
||
for (OrderBasicInfo orderBasicInfo : orderBasicInfos) {
|
||
try {
|
||
OrderSplitResult orderSettleResult = null;
|
||
logger.info("手动接口执行订单分账逻辑-orderCode:{}, payMode:{}", orderBasicInfo.getOrderCode(), orderBasicInfo.getPayMode());
|
||
if (OrderPayModeEnum.PAYMENT_OF_PRINCIPAL_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) {
|
||
logger.info("手动接口执行订单分账逻辑-order:{}, result:{}", JSON.toJSONString(orderBasicInfo), JSON.toJSONString(orderSettleResult));
|
||
// 余额支付的订单 只用余额支付转账
|
||
// orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount);
|
||
} else {
|
||
// 在线支付,进行支付确认分账
|
||
// orderSettleResult = orderBasicInfo.doPaymentConfirmWithDelay(orderBasicInfo, adapayMemberAccount, appId);
|
||
}
|
||
// if (orderSettleResult != null && AdapayStatusEnum.SUCCEEDED.getValue().equals(orderSettleResult.getStatus())) {
|
||
// JSONObject jsonObject = JSON.parseObject(orderSettleResult.getDescription());
|
||
// String orderCode = (String) jsonObject.get("orderCode");
|
||
// }
|
||
} catch (Exception e) {
|
||
logger.error("手动接口执行订单分账逻辑-订单交易确认失败:{}", orderBasicInfo.getOrderCode(), e);
|
||
}
|
||
}
|
||
}
|
||
logger.info("手动接口执行订单分账逻辑-运营商:{}, 交易日期:{}, 进行分账处理end", merchantId, tradeDate);
|
||
}
|
||
|
||
public String tempUpdateVirtualAmount(QueryOrderDTO dto) {
|
||
dto.setOrderStatus(OrderStatusEnum.ORDER_COMPLETE.getValue());
|
||
List<OrderListVO> orderListVOS = orderBasicInfoMapper.selectOrderBasicInfoList(dto);
|
||
if (CollectionUtils.isEmpty(orderListVOS)) {
|
||
return "没有订单需要修改";
|
||
}
|
||
int i = 0;
|
||
for (OrderListVO orderListVO : orderListVOS) {
|
||
try {
|
||
tempUpdateVirtualAmount(orderListVO);
|
||
i += 1;
|
||
} catch (Exception e) {
|
||
logger.error("修改虚拟金额字段失败", e);
|
||
}
|
||
}
|
||
return "共查询到" + orderListVOS.size() + "条订单,修改成功" + i + "条订单数据";
|
||
}
|
||
|
||
private void tempUpdateVirtualAmount(OrderListVO orderListVO) {
|
||
if (orderListVO.getVirtualAmount() != null) {
|
||
return;
|
||
}
|
||
// 订单总消费金额
|
||
BigDecimal orderAmount = new BigDecimal(orderListVO.getOrderAmount());
|
||
// 支付金额
|
||
BigDecimal payAmount = new BigDecimal(orderListVO.getPayAmount());
|
||
|
||
if (orderAmount.compareTo(payAmount) > 0) {
|
||
orderAmount = payAmount;
|
||
}
|
||
|
||
// 使用虚拟金额消费 金额
|
||
BigDecimal virtualAmount = BigDecimal.ZERO;
|
||
// 结算金额
|
||
BigDecimal settleAmount = BigDecimal.ZERO;
|
||
|
||
if (orderAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||
if (StringUtils.equals(orderListVO.getPayMode(), OrderPayModeEnum.PAYMENT_OF_PRINCIPAL_BALANCE.getValue())) {
|
||
/*
|
||
余额支付 查询支付记录,如全部用本金支付,则虚拟金额为0,结算金额为订单消费金额,
|
||
如果使用了赠送金额,虚拟金额为赠送金额支付部分,结算金额=订单消费金额-虚拟金额消费部分
|
||
*/
|
||
// 查询支付记录
|
||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderListVO.getOrderCode());
|
||
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||
if (StringUtils.equals(orderPayRecord.getPayMode(), OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())) {
|
||
BigDecimal refundAmount = orderPayRecord.getRefundAmount();
|
||
if (refundAmount == null) {
|
||
// 退款金额为null, 需要退款的金额 = 支付金额 - 订单金额
|
||
refundAmount = orderPayRecord.getPayAmount().subtract(orderAmount);
|
||
}
|
||
// 赠送金额消费部分 = 支付金额 - 需要退款金额
|
||
virtualAmount = orderPayRecord.getPayAmount().subtract(refundAmount);
|
||
// 结算金额 = 订单金额 - 赠送金额消费部分
|
||
settleAmount = orderAmount.subtract(virtualAmount);
|
||
} else {
|
||
// 没有使用赠送金额支付,那么虚拟金额就是0,结算金额就等于订单金额
|
||
settleAmount = orderAmount;
|
||
}
|
||
}
|
||
} else {
|
||
/*
|
||
微信支付 虚拟金额为0 结算金额等于订单消费金额
|
||
*/
|
||
settleAmount = orderAmount;
|
||
}
|
||
}
|
||
|
||
OrderBasicInfo build = OrderBasicInfo.builder()
|
||
.id(Integer.parseInt(orderListVO.getId()))
|
||
.orderCode(orderListVO.getOrderCode())
|
||
.orderAmount(orderAmount)
|
||
.virtualAmount(virtualAmount)
|
||
.settleAmount(settleAmount)
|
||
.build();
|
||
orderBasicInfoService.updateOrderBasicInfo(build);
|
||
}
|
||
|
||
/**
|
||
* 临时订单退款
|
||
*/
|
||
public void tempOrderRefund() {
|
||
// 查询出2023-05-29 12:00:00到2023-05-30 23:59:59中使用微信支付,并且有退款金额的订单
|
||
String startTime = "2023-05-29 12:00:00";
|
||
String endTime = "2023-05-30 23:59:59";
|
||
List<OrderBasicInfo> orderList = orderBasicInfoMapper.tempQueryWeChatRefundOrders(startTime, endTime);
|
||
Map<String, OrderBasicInfo> orderBasicInfoMap = orderList.stream().collect(Collectors.toMap(OrderBasicInfo::getOrderCode, Function.identity(), (k1, k2) -> k1));
|
||
Set<String> orderCodes = orderBasicInfoMap.keySet();
|
||
|
||
// 根据上面的订单号,查微信退款回调,找出没有记录的订单,重新发起一遍退款
|
||
List<WxpayRefundCallback> wxpayRefundCallbacks = wxpayRefundCallbackService.selectByOrderCodeList(Lists.newArrayList(orderCodes));
|
||
Set<String> refundOrders = wxpayRefundCallbacks.stream().map(WxpayRefundCallback::getOrderCode).collect(Collectors.toSet());
|
||
|
||
// orderCodeList refundOrders 取差集
|
||
Sets.SetView<String> difference = Sets.difference(orderCodes, refundOrders);
|
||
for (String orderCode : difference) {
|
||
OrderBasicInfo orderBasicInfo = orderBasicInfoMap.get(orderCode);
|
||
if (orderBasicInfo == null) {
|
||
continue;
|
||
}
|
||
BigDecimal refundAmount = orderBasicInfo.getRefundAmount();
|
||
// 微信退款逻辑
|
||
ApplyRefundDTO weChatRefundDTO = new ApplyRefundDTO();
|
||
weChatRefundDTO.setOrderCode(orderBasicInfo.getOrderCode());
|
||
weChatRefundDTO.setRefundType("1");
|
||
weChatRefundDTO.setRefundAmount(refundAmount);
|
||
try {
|
||
// orderBasicInfoService.weChatRefund(weChatRefundDTO);
|
||
} catch (Exception e) {
|
||
logger.error("临时订单退款接口发生异常 orderCode:{}", orderBasicInfo.getOrderCode(), e);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void splitTheBillForOrderTemp(String merchantId, List<String> orderCodeList) {
|
||
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId);
|
||
if (StringUtils.isBlank(wechatAppId)) {
|
||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_WECHAT_APP_ID_IS_NULL);
|
||
}
|
||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
|
||
if (adapayMemberAccount == null) {
|
||
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_MEMBER_IS_NULL_ERROR);
|
||
}
|
||
List<OrderBasicInfo> orderBasicInfos = orderBasicInfoService.queryOrderList(orderCodeList);
|
||
for (OrderBasicInfo orderBasicInfo : orderBasicInfos) {
|
||
try {
|
||
splitTheBillForOrderTemp(adapayMemberAccount, orderBasicInfo, wechatAppId);
|
||
} catch (BaseAdaPayException e) {
|
||
logger.error("余额支付订单分账工具, 发生异常", e);
|
||
throw new RuntimeException(e);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void splitTheBillForOrderTemp(AdapayMemberAccount adapayMemberAccount, OrderBasicInfo orderBasicInfo, String wechatAppId) throws BaseAdaPayException {
|
||
logger.info("");
|
||
// 查询会员余额支付记录
|
||
List<MemberAdapayRecord> recordList = memberAdapayRecordService.selectAdapayRecordList(orderBasicInfo.getMemberId(), ScenarioEnum.BALANCE.getValue());
|
||
if (CollectionUtils.isEmpty(recordList)) {
|
||
logger.info("余额支付订单分账工具, memberId:{}, 未查询到余额充值记录", orderBasicInfo.getMemberId());
|
||
return;
|
||
}
|
||
String orderCode = orderBasicInfo.getOrderCode();
|
||
if (recordList.size() > 1) {
|
||
logger.info("余额支付订单分账工具, 会员充值记录存在多条,orderCode:{}由人工手动处理", orderCode);
|
||
return;
|
||
}
|
||
|
||
// 订单分账金额
|
||
BigDecimal amount = queryBalanceOrderSettleInfo(orderCode, orderBasicInfo.getMemberId(), wechatAppId);
|
||
|
||
// 判断分账金额 和结算金额是否相等
|
||
if (amount.compareTo(BigDecimal.ZERO) == 0) {
|
||
logger.info("余额支付订单分账工具, orderCode:{}, 已分账金额为0, 订单结算金额为:{}, 重试执行订单分账", orderCode, orderBasicInfo.getSettleAmount());
|
||
|
||
// 修改会员的汇付支付记录
|
||
for (MemberAdapayRecord memberAdapayRecord : recordList) {
|
||
BigDecimal spendAmt = memberAdapayRecord.getSpendAmt();
|
||
spendAmt = spendAmt.subtract(orderBasicInfo.getOrderAmount());
|
||
memberAdapayRecord.setSpendAmt(spendAmt);
|
||
|
||
BigDecimal balanceAmt = memberAdapayRecord.getBalanceAmt();
|
||
balanceAmt = balanceAmt.add(orderBasicInfo.getOrderAmount());
|
||
memberAdapayRecord.setBalanceAmt(balanceAmt);
|
||
memberAdapayRecordService.updateByPrimaryKeySelective(memberAdapayRecord);
|
||
}
|
||
|
||
// 分账金额为0,表示该订单没有执行过分账,再次执行分账
|
||
if (OrderPayModeEnum.PAYMENT_OF_PRINCIPAL_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) {
|
||
// 余额支付的订单
|
||
orderBasicInfoService.doBalancePaymentWithDelay(orderBasicInfo, adapayMemberAccount, wechatAppId);
|
||
}
|
||
|
||
// 再次查询分账
|
||
BigDecimal bigDecimal = queryBalanceOrderSettleInfo(orderCode, orderBasicInfo.getMemberId(), wechatAppId);
|
||
logger.info("余额支付订单分账工具, orderCode:{}, 重新分账完成, 分账金额:{}, 订单结算金额:{}", orderCode, bigDecimal, orderBasicInfo.getSettleAmount());
|
||
} else {
|
||
logger.info("余额支付订单分账工具, orderCode:{}, 已分账金额为:{}, 订单结算金额为:{}, 不再执行订单分账", orderCode, amount, orderBasicInfo.getSettleAmount());
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 查询余额订单 分账信息
|
||
* @param orderCode
|
||
* @param memberId
|
||
* @param wechatAppId
|
||
* @return
|
||
*/
|
||
private BigDecimal queryBalanceOrderSettleInfo(String orderCode, String memberId, String wechatAppId) {
|
||
BigDecimal resultAmt = BigDecimal.ZERO;
|
||
// 查询会员余额支付记录
|
||
List<MemberAdapayRecord> recordList = memberAdapayRecordService.selectAdapayRecordList(memberId, ScenarioEnum.BALANCE.getValue());
|
||
if (CollectionUtils.isEmpty(recordList)) {
|
||
return resultAmt;
|
||
}
|
||
|
||
// 用汇付api查询分账信息
|
||
for (MemberAdapayRecord record : recordList) {
|
||
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
||
dto.setWechatAppId(wechatAppId);
|
||
dto.setPaymentId(record.getPaymentId());
|
||
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
||
if (response != null && CollectionUtils.isNotEmpty(response.getPaymentConfirms())) {
|
||
for (PaymentConfirmInfo paymentConfirm : response.getPaymentConfirms()) {
|
||
JSONObject jsonObject = JSON.parseObject(paymentConfirm.getDescription());
|
||
if (StringUtils.equals(jsonObject.getString("orderCode"), orderCode)) {
|
||
// 订单号对的上,累计分账金额
|
||
resultAmt = resultAmt.add(new BigDecimal(paymentConfirm.getConfirmAmt()));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return resultAmt;
|
||
}
|
||
|
||
/**
|
||
* 查询未分账订单
|
||
* @param dto
|
||
* @return
|
||
*/
|
||
public Map<String, Object> queryUndividedOrder(SettleOrderReportDTO dto) {
|
||
Map<String, Object> resultMap = Maps.newHashMap();
|
||
|
||
SettleOrderReport orderReport = settleOrderReportService.selectByStationIdAndDate(dto.getStationId(), dto.getTradeDate());
|
||
if (orderReport == null) {
|
||
throw new BusinessException("00300002", "查询站点订单日报为空");
|
||
}
|
||
String orderCodes = orderReport.getOrderCodes();
|
||
List<String> orderCodeList = Lists.newArrayList(StringUtils.split(orderCodes, ","));
|
||
List<ClearingBillVO> clearingBillVOList = clearingWithdrawInfoService.selectWithdrawInfoByOrderCodeList(orderCodeList);
|
||
if (org.springframework.util.CollectionUtils.isEmpty(clearingBillVOList)) {
|
||
throw new BusinessException("00300005", "查询清分信息为空");
|
||
}
|
||
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(orderReport.getMerchantId());
|
||
// clearing
|
||
List<ClearingBillVO> clearingList = Lists.newArrayList();
|
||
List<ClearingBillVO> unClearingList = Lists.newArrayList();
|
||
for (ClearingBillVO clearingBillVO : clearingBillVOList) {
|
||
String paymentId = clearingBillVO.getPaymentId();
|
||
QueryPaymentConfirmDTO build = QueryPaymentConfirmDTO.builder()
|
||
.wechatAppId(wechatAppId)
|
||
.paymentId(paymentId)
|
||
.build();
|
||
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(build);
|
||
List<PaymentConfirmInfo> paymentConfirms = response.getPaymentConfirms();
|
||
if (CollectionUtils.isEmpty(paymentConfirms)) {
|
||
unClearingList.add(clearingBillVO);
|
||
} else {
|
||
clearingBillVO.setConfirmInfo(paymentConfirms.get(0));
|
||
clearingList.add(clearingBillVO);
|
||
}
|
||
}
|
||
resultMap.put("clearingList", clearingList);
|
||
resultMap.put("unClearingList", unClearingList);
|
||
resultMap.put("orderSize", clearingBillVOList.size());
|
||
return resultMap;
|
||
}
|
||
|
||
public void batchRefundOrder(List<String> orderCodeList) throws BaseAdaPayException {
|
||
List<OrderBasicInfo> orderBasicInfos = orderBasicInfoService.queryOrderList(orderCodeList);
|
||
for (OrderBasicInfo orderBasicInfo : orderBasicInfos) {
|
||
String payMode = orderBasicInfo.getPayMode();
|
||
if (StringUtils.equals(payMode, OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
|
||
orderBasicInfoService.retryRefundOrder(orderBasicInfo);
|
||
} else {
|
||
orderBasicInfoService.orderPaymentSettlementAndRefund(orderBasicInfo);
|
||
}
|
||
// logger.info("批量进行问题订单退款,orderCode:{}, result:{}", orderBasicInfo.getOrderCode(), JSON.toJSONString(result));
|
||
}
|
||
}
|
||
|
||
public void updateMemberAdapayRecord(String memberId) {
|
||
// 查询
|
||
List<MemberAdapayRecord> memberAdapayRecordList = memberAdapayRecordService.selectAdapayRecordList(memberId, ScenarioEnum.BALANCE.getValue());
|
||
|
||
}
|
||
|
||
/**
|
||
* 余额支付分账
|
||
* @param orderBasicInfo
|
||
* @param adapayMemberAccount
|
||
* @param wechatAppId
|
||
*/
|
||
public void doBalancePaymentTemp(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
|
||
String orderCode = orderBasicInfo.getOrderCode();
|
||
// 查询订单支付记录
|
||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
||
logger.info("doBalancePaymentTemp-查询订单:{}支付记录:{}", orderCode, JSON.toJSONString(orderPayRecordList));
|
||
if (CollectionUtils.isEmpty(orderPayRecordList)) {
|
||
return;
|
||
}
|
||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||
OrderPayRecord record = orderPayRecordList.get(0);
|
||
String deductionRecord = record.getDeductionRecord();
|
||
List<PaymentInfo> paymentInfos = orderPayRecordService.parseDeductionRecord(deductionRecord);
|
||
|
||
// 通过paymentId查询 分账记录
|
||
for (PaymentInfo paymentInfo : paymentInfos) {
|
||
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
||
String paymentId = paymentInfo.getPaymentId();
|
||
dto.setPaymentId(paymentId);
|
||
dto.setWechatAppId(wechatAppId);
|
||
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
||
if (response == null) {
|
||
continue;
|
||
}
|
||
List<PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
||
if (CollectionUtils.isNotEmpty(confirms)) {
|
||
// 已经分过账
|
||
for (PaymentConfirmInfo confirm : confirms) {
|
||
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
||
|
||
// 找到orderCode的分账记录
|
||
if (StringUtils.equals(jsonObject.getString("orderCode"), orderCode)) {
|
||
// 分账金额
|
||
BigDecimal confirmAmt = new BigDecimal(confirm.getConfirmAmt());
|
||
// 校验是不是分给正确的商户
|
||
String adapayMemberId = jsonObject.getString("adapayMemberId");
|
||
if (!StringUtils.equals(adapayMemberId, adapayMemberAccount.getAdapayMemberId())) {
|
||
// 撤销原分账
|
||
adapayService.createConfirmReverse(confirm.getId(), wechatAppId);
|
||
// 重新分账
|
||
adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, confirmAmt, orderCode, wechatAppId);
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
// 未分账情况
|
||
adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, settleAmount, orderCode, wechatAppId);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void verifyUndividedPayment(QueryOrderDTO dto) {
|
||
String wechatAppId = "wxbb3e0d474569481d";
|
||
String startTime = dto.getStartTime();
|
||
String endTime = dto.getEndTime();
|
||
// 查询时间段的订单
|
||
// List<AdapayCallbackRecord> list = adapayCallbackRecordService.selectByDateTime(startTime, endTime);
|
||
List<OrderPaymentDetailVO> orderPayDetailVOS = orderBasicInfoService.queryOrderPayDetail(startTime, endTime);
|
||
logger.info("校验未分账的支付单-在 {} - {} 期间,共查询到{}条支付记录", startTime, endTime, orderPayDetailVOS.size());
|
||
// 查询支付单 分账情况
|
||
for (OrderPaymentDetailVO record : orderPayDetailVOS) {
|
||
String paymentId = record.getPaymentId();
|
||
BigDecimal confirmAmt = record.getSettleAmount();
|
||
String orderCode = record.getOrderCode();
|
||
QueryPaymentConfirmDTO queryPaymentConfirmDTO = new QueryPaymentConfirmDTO();
|
||
queryPaymentConfirmDTO.setWechatAppId(wechatAppId);
|
||
queryPaymentConfirmDTO.setPaymentId(paymentId);
|
||
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(queryPaymentConfirmDTO);
|
||
logger.info("校验未分账的支付单-支付id:{}, 查询到的分账信息:{}", paymentId, JSON.toJSONString(response));
|
||
List<PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
||
if (CollectionUtils.isEmpty(confirms)) {
|
||
logger.info("校验未分账的支付单-支付id:{}没有进行过分账", paymentId);
|
||
// 没有配置结算账户的,默认分到本商户
|
||
AdapayMemberAccount defaultAccount = adapayMemberAccountService.getDefault();
|
||
PaymentConfirmResponse paymentConfirmRequest = adapayService.createPaymentConfirmRequest(paymentId, defaultAccount, confirmAmt, orderCode, wechatAppId);
|
||
logger.info("校验未分账的支付单-支付id:{}, 执行分账结果:{}", paymentId, JSON.toJSONString(paymentConfirmRequest));
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 检查支付单
|
||
* @param dto
|
||
*/
|
||
public void checkPayment(QueryOrderDTO dto) throws BaseAdaPayException {
|
||
// 根据时间段查询支付对象列表
|
||
List<AdaPayment> adaPayments = adapayService.queryPaymentList(dto.getStartTime(), dto.getEndTime());
|
||
if (CollectionUtils.isEmpty(adaPayments)) {
|
||
return;
|
||
}
|
||
|
||
List<String> paymentIdList = Lists.newArrayList();
|
||
BigDecimal total = BigDecimal.ZERO;
|
||
|
||
AdapayMemberAccount aDefault = adapayMemberAccountService.getDefault();
|
||
String wechatAppId = "wxbb3e0d474569481d";
|
||
|
||
for (AdaPayment adaPayment : adaPayments) {
|
||
String paymentId = adaPayment.getId();
|
||
String pay_mode = adaPayment.getPay_mode();
|
||
if (StringUtils.isBlank(pay_mode)) {
|
||
// 实时分账的不检查
|
||
continue;
|
||
}
|
||
|
||
String status = adaPayment.getStatus();
|
||
if (!StringUtils.equals(status, AdapayStatusEnum.SUCCEEDED.getValue())) {
|
||
// 不是交易成功的不检查
|
||
continue;
|
||
}
|
||
|
||
if (StringUtils.equals(paymentId, "002212023102509474610563069333816762368")) {
|
||
continue;
|
||
}
|
||
|
||
// 交易金额
|
||
BigDecimal payAmt = new BigDecimal(adaPayment.getPay_amt());
|
||
|
||
// 若为延时分账时,已发起支付撤销的总金额
|
||
BigDecimal reservedAmt = new BigDecimal(adaPayment.getReserved_amt());
|
||
|
||
// 若为延时分账时,已发起支付确认的总金额
|
||
BigDecimal confirmedAmt = new BigDecimal(adaPayment.getConfirmed_amt());
|
||
|
||
BigDecimal subtract = payAmt.subtract(reservedAmt).subtract(confirmedAmt);
|
||
|
||
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
||
paymentIdList.add(paymentId);
|
||
total = total.add(subtract);
|
||
logger.info("支付单:{}, 支付金额:{}, 总撤销金额:{}, 总确认金额:{}, 剩余金额:{}",
|
||
paymentId, payAmt, reservedAmt, confirmedAmt, subtract);
|
||
|
||
// adapayService.createPaymentConfirmRequest(paymentId, aDefault, subtract, null, wechatAppId);
|
||
}
|
||
}
|
||
logger.info("{} - {} 期间,共有{}笔支付单存在剩余金额, 共计:{},list:{}", dto.getStartTime(), dto.getEndTime(), paymentIdList.size(), total, JSON.toJSONString(paymentIdList));
|
||
}
|
||
|
||
/**
|
||
* 校验是否为并充订单
|
||
*/
|
||
@CostTime
|
||
public Map<String, List<String>> checkCombinedChargingOrder(List<String> orderCodeList) throws BaseAdaPayException {
|
||
Map<String, List<String>> resultMap = Maps.newHashMap();
|
||
List<String> combinedChargingOrderList = Lists.newArrayList();
|
||
List<String> notCombinedChargingOrderList = Lists.newArrayList();
|
||
List<String> noDataOrderList = Lists.newArrayList();
|
||
for (String orderCode : orderCodeList) {
|
||
// 查询orderMonitorData
|
||
OrderMonitorData orderMonitorData = orderMonitorDataService.selectByOrderCode(orderCode);
|
||
if (orderMonitorData == null) {
|
||
logger.info("订单:{}不存在", orderCode);
|
||
noDataOrderList.add(orderCode);
|
||
continue;
|
||
}
|
||
JSONArray jsonArray = JSONArray.parseArray(orderMonitorData.getMonitorData());
|
||
List<BigDecimal> orderOutputCurrentList = Lists.newArrayList();
|
||
for (int i = 0; i < jsonArray.size(); i++) {
|
||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||
String outputCurrent = jsonObject.getString("outputCurrent");
|
||
orderOutputCurrentList.add(new BigDecimal(outputCurrent));
|
||
}
|
||
// 如果orderOutputCurrentList中任意一值大于250,判定为并充订单
|
||
if (orderOutputCurrentList.stream().anyMatch(current -> current.compareTo(new BigDecimal("250")) > 0)) {
|
||
combinedChargingOrderList.add(orderCode);
|
||
} else {
|
||
notCombinedChargingOrderList.add(orderCode);
|
||
}
|
||
}
|
||
resultMap.put("combinedChargingOrderList", combinedChargingOrderList);
|
||
resultMap.put("notCombinedChargingOrderList", notCombinedChargingOrderList);
|
||
resultMap.put("noDataOrderList", noDataOrderList);
|
||
return resultMap;
|
||
}
|
||
|
||
/**
|
||
* 修正并充订单数据
|
||
* @param dto
|
||
*/
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public List<String> correctCombinedChargingOrder(QueryOrderDTO dto) {
|
||
List<String> orderCodeList = dto.getOrderCodeList();
|
||
logger.info("修正并充订单数据工具,订单号:{}", JSON.toJSONString(orderCodeList));
|
||
// 查询临时表,不要重复修正
|
||
String redisKey = "correct_combined_charging_order";
|
||
List<String> redisResult = redisCache.getCacheList(redisKey);
|
||
if (CollectionUtils.isNotEmpty(redisResult)) {
|
||
logger.info("修正并充订单数据工具, 已修正订单:{}", JSON.toJSONString(redisResult));
|
||
// 过滤掉已修正的订单
|
||
orderCodeList.removeAll(redisResult);
|
||
logger.info("修正并充订单数据工具. 过滤掉已修正的订单剩余:{}", JSON.toJSONString(orderCodeList));
|
||
}
|
||
if (CollectionUtils.isEmpty(orderCodeList)) {
|
||
logger.info("修正并充订单数据工具, 无需要修正的订单");
|
||
return Lists.newArrayList();
|
||
}
|
||
|
||
BigDecimal multiple = new BigDecimal("0.5");
|
||
// 查询订单主表数据
|
||
List<OrderBasicInfo> orderBasicInfos = orderBasicInfoService.queryOrderList(orderCodeList);
|
||
for (OrderBasicInfo orderBasicInfo : orderBasicInfos) {
|
||
orderBasicInfo.setOrderAmount(orderBasicInfo.getOrderAmount().multiply(multiple));
|
||
orderBasicInfo.setVirtualAmount(orderBasicInfo.getVirtualAmount().multiply(multiple));
|
||
orderBasicInfo.setUpdateTime(DateUtils.getNowDate());
|
||
}
|
||
// 查询订单详情数据
|
||
List<OrderDetail> orderDetailList = orderBasicInfoService.getOrderDetailList(orderCodeList);
|
||
for (OrderDetail orderDetail : orderDetailList) {
|
||
// 订单总用电量
|
||
orderDetail.setTotalUsedElectricity(orderDetail.getTotalUsedElectricity().multiply(multiple));
|
||
// 订单总电费金额
|
||
orderDetail.setTotalElectricityAmount(orderDetail.getTotalElectricityAmount().multiply(multiple));
|
||
// 订单总服务费金额
|
||
orderDetail.setTotalServiceAmount(orderDetail.getTotalServiceAmount().multiply(multiple));
|
||
// 订单总金额
|
||
orderDetail.setTotalOrderAmount(orderDetail.getTotalOrderAmount().multiply(multiple));
|
||
// 尖时段
|
||
if (orderDetail.getSharpUsedElectricity() != null && orderDetail.getSharpUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||
orderDetail.setSharpUsedElectricity(orderDetail.getSharpUsedElectricity().multiply(multiple));
|
||
// orderDetail.setSharpAmount(orderDetail.getSharpAmount().multiply(multiple));
|
||
orderDetail.setSharpAmount(orderDetail.getSharpPrice().multiply(orderDetail.getSharpUsedElectricity()));
|
||
}
|
||
// 峰时段
|
||
if (orderDetail.getPeakUsedElectricity() != null && orderDetail.getPeakUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||
orderDetail.setPeakUsedElectricity(orderDetail.getPeakUsedElectricity().multiply(multiple));
|
||
// orderDetail.setPeakAmount(orderDetail.getPeakAmount().multiply(multiple));
|
||
orderDetail.setPeakAmount(orderDetail.getPeakPrice().multiply(orderDetail.getPeakUsedElectricity()));
|
||
}
|
||
// 平时段
|
||
if (orderDetail.getFlatUsedElectricity() != null && orderDetail.getFlatUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||
orderDetail.setFlatUsedElectricity(orderDetail.getFlatUsedElectricity().multiply(multiple));
|
||
// orderDetail.setFlatAmount(orderDetail.getFlatAmount().multiply(multiple));
|
||
orderDetail.setFlatAmount(orderDetail.getFlatPrice().multiply(orderDetail.getFlatUsedElectricity()));
|
||
}
|
||
// 谷时段
|
||
if (orderDetail.getValleyUsedElectricity() != null && orderDetail.getValleyUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||
orderDetail.setValleyUsedElectricity(orderDetail.getValleyUsedElectricity().multiply(multiple));
|
||
// orderDetail.setValleyAmount(orderDetail.getValleyAmount().multiply(multiple));
|
||
orderDetail.setValleyAmount(orderDetail.getValleyPrice().multiply(orderDetail.getValleyUsedElectricity()));
|
||
}
|
||
orderDetail.setUpdateTime(DateUtils.getNowDate());
|
||
}
|
||
// 更新数据库
|
||
int updateCount = 0;
|
||
if (CollectionUtils.isNotEmpty(orderBasicInfos)) {
|
||
updateCount = orderBasicInfoService.updateBatch(orderBasicInfos);
|
||
}
|
||
if (CollectionUtils.isNotEmpty(orderDetailList)) {
|
||
orderDetailService.updateBatch(orderDetailList);
|
||
}
|
||
|
||
if (orderCodeList.size() == updateCount) {
|
||
logger.info("修正并充订单数据工具, 修正成功, 订单号:{}", JSON.toJSONString(orderCodeList));
|
||
Map<String, List<String>> redisMap = Maps.newHashMap();
|
||
redisMap.put(redisKey, orderCodeList);
|
||
redisCache.batchSetCacheList(redisMap, 300, TimeUnit.DAYS);
|
||
}
|
||
|
||
return orderCodeList;
|
||
}
|
||
|
||
/**
|
||
* 关闭未支付订单
|
||
*/
|
||
public void closeUnpaidOrder(QueryOrderDTO dto) {
|
||
// 查询未支付订单
|
||
List<OrderBasicInfo> unpaidOrderList = orderBasicInfoService.getUnpaidOrderList(dto.getStartTime(), dto.getEndTime());
|
||
logger.info("closeUnpaidOrders, startTime:{}, endTime:{}, 未支付订单:{}", dto.getStartTime(), dto.getEndTime(), JSON.toJSONString(unpaidOrderList));
|
||
// 关闭未支付订单
|
||
orderBasicInfoService.closeUnpaidOrders(unpaidOrderList);
|
||
}
|
||
|
||
public void calculateOrderDiscountsV2(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) {
|
||
String orderCode = orderBasicInfo.getOrderCode();
|
||
String transactionCode = orderBasicInfo.getTransactionCode();
|
||
String memberId = orderBasicInfo.getMemberId(); // 会员id
|
||
String stationId = orderBasicInfo.getStationId(); // 站点id
|
||
String merchantId = orderBasicInfo.getMerchantId(); // 运营商id
|
||
|
||
if (orderDetail == null) {
|
||
logger.info("计算订单折扣V2, OrderDetail为空(orderCode:{}, transactionCode:{}), 直接返回!", orderCode, transactionCode);
|
||
return;
|
||
}
|
||
|
||
// 原始电费金额
|
||
BigDecimal originalTotalElectricityAmount = orderDetail.getTotalElectricityAmount();
|
||
// 原始服务费金额
|
||
BigDecimal originalTotalServiceAmount = orderDetail.getTotalServiceAmount();
|
||
logger.info("计算订单折扣V2, orderCode:{}, 原始电费金额:{}, 原始服务费金额:{}", orderCode, originalTotalElectricityAmount, originalTotalServiceAmount);
|
||
// 电费折扣金额 初始值为0
|
||
BigDecimal electricityAmountDiscount = BigDecimal.ZERO;
|
||
// 服务费折扣金额 初始值为0
|
||
BigDecimal serviceAmountDiscount = BigDecimal.ZERO;
|
||
// 优惠后电费金额 初始值为优惠前金额
|
||
BigDecimal afterDiscountElectricityAmount = BigDecimal.ZERO;
|
||
// 优惠后服务费金额 初始值为优惠前金额
|
||
BigDecimal afterDiscountServiceAmount = BigDecimal.ZERO;
|
||
|
||
// 查询会员在该站点享受的优惠
|
||
MemberDiscountVO memberDiscountVO = memberGroupService.queryMemberDiscountV2(merchantId, stationId, memberId);
|
||
if (memberDiscountVO == null) {
|
||
// 如果没有优惠,则优惠后金额 等于优惠前金额
|
||
afterDiscountServiceAmount = orderDetail.getTotalServiceAmount();
|
||
afterDiscountElectricityAmount = orderDetail.getTotalElectricityAmount();
|
||
} else {
|
||
// 集团会员的订单,记录集团编号
|
||
orderBasicInfo.setGroupCode(memberDiscountVO.getGroupCode());
|
||
|
||
// 集团会员的优惠计费模板
|
||
BillingTemplateVO billingTemplateVO = memberDiscountVO.getBillingTemplateVO();
|
||
|
||
// 尖时段用电量
|
||
BigDecimal sharpUsedElectricity = orderDetail.getSharpUsedElectricity();
|
||
if (sharpUsedElectricity != null) {
|
||
// 计算该时段电费 = 电费单价 x 用电量
|
||
BigDecimal sharpElectricityAmount = billingTemplateVO.getSharpElectricityPrice()
|
||
.multiply(sharpUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
// 计算该时段服务费
|
||
BigDecimal sharpServiceAmount = billingTemplateVO.getSharpServicePrice()
|
||
.multiply(sharpUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
|
||
// 汇总
|
||
afterDiscountElectricityAmount = afterDiscountElectricityAmount.add(sharpElectricityAmount);
|
||
afterDiscountServiceAmount = afterDiscountServiceAmount.add(sharpServiceAmount);
|
||
logger.info("计算订单折扣V2, orderCode:{}, 尖时段用电量:{}, 电费单价:{}, 电费金额:{}, 服务费单价:{}, 服务费金额:{}", orderCode, sharpUsedElectricity,
|
||
billingTemplateVO.getSharpElectricityPrice(), sharpElectricityAmount, billingTemplateVO.getSharpServicePrice(), sharpServiceAmount);
|
||
}
|
||
|
||
// 峰时段用电量
|
||
BigDecimal peakUsedElectricity = orderDetail.getPeakUsedElectricity();
|
||
if (peakUsedElectricity != null) {
|
||
// 计算该时段电费 = 电费单价 x 用电量
|
||
BigDecimal peakElectricityAmount = billingTemplateVO.getPeakElectricityPrice()
|
||
.multiply(peakUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
// 计算该时段服务费
|
||
BigDecimal peakServiceAmount = billingTemplateVO.getPeakServicePrice()
|
||
.multiply(peakUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
|
||
// 汇总
|
||
afterDiscountElectricityAmount = afterDiscountElectricityAmount.add(peakElectricityAmount);
|
||
afterDiscountServiceAmount = afterDiscountServiceAmount.add(peakServiceAmount);
|
||
logger.info("计算订单折扣V2, orderCode:{}, 峰时段用电量:{}, 电费单价:{}, 电费金额:{}, 服务费单价:{}, 服务费金额:{}", orderCode, peakUsedElectricity,
|
||
billingTemplateVO.getPeakElectricityPrice(), peakElectricityAmount, billingTemplateVO.getPeakServicePrice(), peakServiceAmount);
|
||
}
|
||
|
||
// 平时段用电量
|
||
BigDecimal flatUsedElectricity = orderDetail.getFlatUsedElectricity();
|
||
if (flatUsedElectricity != null) {
|
||
// 计算该时段电费 = 电费单价 x 用电量
|
||
BigDecimal flatElectricityAmount = billingTemplateVO.getFlatElectricityPrice()
|
||
.multiply(flatUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
// 计算该时段服务费
|
||
BigDecimal flatServiceAmount = billingTemplateVO.getFlatServicePrice()
|
||
.multiply(flatUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
|
||
// 汇总
|
||
afterDiscountElectricityAmount = afterDiscountElectricityAmount.add(flatElectricityAmount);
|
||
afterDiscountServiceAmount = afterDiscountServiceAmount.add(flatServiceAmount);
|
||
logger.info("计算订单折扣V2, orderCode:{}, 平时段用电量:{}, 电费单价:{}, 电费金额:{}, 服务费单价:{}, 服务费金额:{}", orderCode, flatUsedElectricity,
|
||
billingTemplateVO.getFlatElectricityPrice(), flatElectricityAmount, billingTemplateVO.getFlatServicePrice(), flatServiceAmount);
|
||
}
|
||
|
||
// 谷时段用电量
|
||
BigDecimal valleyUsedElectricity = orderDetail.getValleyUsedElectricity();
|
||
if (valleyUsedElectricity != null) {
|
||
// 计算该时段电费 = 电费单价 x 用电量
|
||
BigDecimal valleyElectricityAmount = billingTemplateVO.getValleyElectricityPrice()
|
||
.multiply(valleyUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
// 计算该时段服务费
|
||
BigDecimal valleyServiceAmount = billingTemplateVO.getValleyServicePrice()
|
||
.multiply(valleyUsedElectricity)
|
||
.setScale(2, RoundingMode.DOWN);
|
||
|
||
// 汇总
|
||
afterDiscountElectricityAmount = afterDiscountElectricityAmount.add(valleyElectricityAmount);
|
||
afterDiscountServiceAmount = afterDiscountServiceAmount.add(valleyServiceAmount);
|
||
logger.info("计算订单折扣V2, orderCode:{}, 谷时段用电量:{}, 电费单价:{}, 电费金额:{}, 服务费单价:{}, 服务费金额:{}", orderCode, valleyUsedElectricity,
|
||
billingTemplateVO.getValleyElectricityPrice(), valleyElectricityAmount, billingTemplateVO.getValleyServicePrice(), valleyServiceAmount);
|
||
}
|
||
|
||
// 计算优惠了多少钱
|
||
// 电费折扣金额 = 优惠前电费 - 优惠后电费
|
||
electricityAmountDiscount = originalTotalElectricityAmount.subtract(afterDiscountElectricityAmount);
|
||
// 服务费折扣金额 = 优惠前服务费 - 优惠后服务费
|
||
serviceAmountDiscount = originalTotalServiceAmount.subtract(afterDiscountServiceAmount);
|
||
}
|
||
|
||
/*
|
||
更新 数据
|
||
*/
|
||
// 订单折扣金额 = 电费折扣金额 + 服务费折扣金额
|
||
BigDecimal discountAmount = electricityAmountDiscount.add(serviceAmountDiscount);
|
||
orderBasicInfo.setDiscountAmount(discountAmount);
|
||
|
||
// 更新结算金额 结算金额 = 消费金额 - 虚拟金额 - 优惠金额
|
||
BigDecimal newSettleAmount = orderBasicInfo.getSettleAmount().subtract(discountAmount);
|
||
if (newSettleAmount.compareTo(BigDecimal.ZERO) < 0) {
|
||
// 如果结算金额为0,减去优惠金额后为负数,还设置为0
|
||
newSettleAmount = BigDecimal.ZERO;
|
||
}
|
||
orderBasicInfo.setSettleAmount(newSettleAmount);
|
||
orderBasicInfo.setActualReceivedAmount(newSettleAmount);
|
||
|
||
// 优惠后总消费金额 = 折扣后电费 + 折扣后服务费
|
||
BigDecimal totalConsumeAmount = afterDiscountServiceAmount.add(afterDiscountElectricityAmount);
|
||
|
||
// 更新退款金额 = 支付金额 - 优惠后总消费金额
|
||
BigDecimal refundAmount = orderBasicInfo.getPayAmount().subtract(totalConsumeAmount).setScale(2, RoundingMode.DOWN);
|
||
orderBasicInfo.setRefundAmount(refundAmount);
|
||
// 电费折扣金额(电费便宜了多少钱)
|
||
orderDetail.setDiscountElectricityAmount(electricityAmountDiscount);
|
||
// 服务费折扣金额(服务费便宜了多少钱)
|
||
orderDetail.setDiscountServiceAmount(serviceAmountDiscount);
|
||
logger.info("计算订单折扣, orderCode:{}, memberId:{}, 订单折扣金额:{}, 电费折扣金额:{}, 服务费折扣金额:{}, 优惠后总消费金额:{}",
|
||
orderCode, memberId, discountAmount, electricityAmountDiscount, serviceAmountDiscount, totalConsumeAmount);
|
||
}
|
||
|
||
public void testSettleOrderLogicV2(String orderCode) {
|
||
// 查询订单主表
|
||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||
|
||
LocalDateTime localDateTime = DateUtils.date2LocalDateTime(orderBasicInfo.getSettlementTime());
|
||
// 开始时间为localDateTime减30秒
|
||
LocalDateTime startTime = localDateTime.minusSeconds(30);
|
||
// 结束时间为localDateTime加30秒
|
||
LocalDateTime endTime = localDateTime.plusSeconds(30);
|
||
// 查询这笔订单的交易记录原始数据
|
||
List<PileMsgRecord> pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
|
||
if (CollectionUtils.isEmpty(pileFeedListV2)) {
|
||
// 如果没有交易记录原始数据,则使用停止充电时间作为开始时间和结束时间再查一次
|
||
localDateTime = DateUtils.date2LocalDateTime(orderBasicInfo.getChargeEndTime());
|
||
startTime = localDateTime.minusSeconds(30);
|
||
endTime = localDateTime.plusSeconds(30);
|
||
pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
|
||
}
|
||
TransactionRecordsData data = null;
|
||
for (PileMsgRecord pileMsgRecord : pileFeedListV2) {
|
||
TransactionRecordsData parse = JSONObject.parseObject(pileMsgRecord.getJsonMsg(), TransactionRecordsData.class);
|
||
if (StringUtils.equals(parse.getTransactionCode(), orderBasicInfo.getTransactionCode())) {
|
||
data = parse;
|
||
data.setVinCode("");
|
||
}
|
||
}
|
||
|
||
logger.info("testSettleOrderLogicV2, orderCode:{}, data:{}", orderCode, JSON.toJSONString(data));
|
||
if (data != null) {
|
||
testSettleOrderLogic(data, orderBasicInfo);
|
||
}
|
||
}
|
||
|
||
public void testSettleOrderLogic(TransactionRecordsData data, OrderBasicInfo orderBasicInfo) {
|
||
AbstractProgramLogic programLogic = ProgramLogicFactory.getProgramLogic(MerchantDelayModeEnum.DELAY.getValue());
|
||
|
||
// 查询订单详情
|
||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderBasicInfo.getOrderCode());
|
||
|
||
programLogic.updateOrderBasicInfoAndOrderDetail(data, orderBasicInfo, orderDetail);
|
||
|
||
// 计算订单折扣
|
||
programLogic.calculateOrderDiscountsV2(orderBasicInfo, orderDetail);
|
||
|
||
logger.info("testSettleOrderLogic, orderCode:{}, 支付金额:{}, 消费金额:{}, 折扣金额:{}, 退款金额:{}, 结算金额:{}",
|
||
orderBasicInfo.getOrderCode(), orderBasicInfo.getPayAmount(), orderBasicInfo.getOrderAmount(),
|
||
orderBasicInfo.getDiscountAmount(), orderBasicInfo.getRefundAmount(), orderBasicInfo.getSettleAmount());
|
||
|
||
// 更新数据库
|
||
OrderTransactionDTO dto = new OrderTransactionDTO();
|
||
dto.setOrderBasicInfo(orderBasicInfo);
|
||
dto.setOrderDetail(orderDetail);
|
||
transactionService.doUpdateOrder(dto);
|
||
|
||
// 组装after参数
|
||
AfterSettleOrderDTO afterSettleOrderDTO = AfterSettleOrderDTO.builder()
|
||
.orderCode(orderBasicInfo.getOrderCode())
|
||
.merchantId(orderBasicInfo.getMerchantId())
|
||
.stationId(orderBasicInfo.getStationId())
|
||
.orderPayAmount(orderBasicInfo.getPayAmount()) // 支付金额
|
||
.orderConsumeAmount(orderBasicInfo.getOrderAmount()) // 消费金额
|
||
.orderSettleAmount(orderBasicInfo.getSettleAmount()) // 结算金额
|
||
.orderElectricityAmount(orderDetail.getTotalElectricityAmount()) // 电费金额
|
||
.orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount()) // 电费折扣金额
|
||
.orderServiceAmount(orderDetail.getTotalServiceAmount()) // 服务费金额
|
||
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount()) // 服务费折扣金额
|
||
.orderRefundAmount(orderBasicInfo.getRefundAmount()) // 退款金额
|
||
.build();
|
||
logger.info("testSettleOrderLogic, afterSettleOrderDTO:{}", JSON.toJSONString(afterSettleOrderDTO));
|
||
rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);
|
||
}
|
||
|
||
public void testSettleOrderLogicNotDelay(String orderCode) {
|
||
// 查询订单主表
|
||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||
|
||
Date date = orderBasicInfo.getSettlementTime();
|
||
if (date == null) {
|
||
date = orderBasicInfo.getChargeEndTime();
|
||
}
|
||
|
||
LocalDateTime localDateTime = DateUtils.date2LocalDateTime(date);
|
||
// 开始时间为localDateTime减30秒
|
||
LocalDateTime startTime = localDateTime.minusSeconds(30);
|
||
// 结束时间为localDateTime加30秒
|
||
LocalDateTime endTime = localDateTime.plusSeconds(30);
|
||
// logger.info("testSettleOrderLogicV2, orderCode:{}, settlementTime:{}, startTime:{}, endTime:{}", orderCode, orderBasicInfo.getSettlementTime(), startTime, endTime);
|
||
// logger.info("转换为Date类型, settlementTime:{}, startTime:{}, endTime:{}", orderBasicInfo.getSettlementTime(), DateUtils.localDateTime2Date(startTime), DateUtils.localDateTime2Date(endTime));
|
||
// 查询这笔订单的交易记录原始数据
|
||
List<PileMsgRecord> pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
|
||
// logger.info("testSettleOrderLogicV2, orderCode:{}, pileSn:{}, startTime:{}, endTime:{}, pileFeedListV2:{}",
|
||
// orderCode, orderBasicInfo.getPileSn(), startTime, endTime, JSON.toJSONString(pileFeedListV2));
|
||
TransactionRecordsData data = null;
|
||
for (PileMsgRecord pileMsgRecord : pileFeedListV2) {
|
||
TransactionRecordsData parse = JSONObject.parseObject(pileMsgRecord.getJsonMsg(), TransactionRecordsData.class);
|
||
if (StringUtils.equals(parse.getTransactionCode(), orderBasicInfo.getTransactionCode())) {
|
||
data = parse;
|
||
data.setVinCode("");
|
||
}
|
||
}
|
||
|
||
logger.info("testSettleOrderLogicNotDelay, orderCode:{}, data:{}", orderCode, JSON.toJSONString(data));
|
||
if (data != null) {
|
||
AbstractProgramLogic programLogic = ProgramLogicFactory.getProgramLogic(MerchantDelayModeEnum.NOT_DELAY.getValue());
|
||
programLogic.settleOrder(data, orderBasicInfo);
|
||
}
|
||
}
|
||
|
||
public void retrySplittingMethod(QueryOrderDTO dto) {
|
||
List<String> orderCodeList = Lists.newArrayList();
|
||
|
||
if (StringUtils.isNotBlank(dto.getOrderCode())) {
|
||
orderCodeList.add(dto.getOrderCode());
|
||
}
|
||
if (CollectionUtils.isNotEmpty(dto.getOrderCodeList())) {
|
||
orderCodeList.addAll(dto.getOrderCodeList());
|
||
}
|
||
|
||
if (CollectionUtils.isNotEmpty(orderCodeList)) {
|
||
for (String orderCode : orderCodeList) {
|
||
try {
|
||
retrySplittingMethod(orderCode);
|
||
} catch (Exception e) {
|
||
logger.error("retrySplittingMethod error, orderCode:{}", orderCode, e);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 重试分账逻辑
|
||
* 用于订单金额都已经计算好, 但是没有分账, 用来重新执行分账
|
||
*/
|
||
public void retrySplittingMethod(String orderCode) {
|
||
if (StringUtils.isBlank(orderCode)) {
|
||
return;
|
||
}
|
||
// 查询数据
|
||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||
if (orderBasicInfo == null) {
|
||
return;
|
||
}
|
||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||
if (orderDetail == null) {
|
||
return;
|
||
}
|
||
|
||
// 组装请求dto 组装after参数
|
||
AfterSettleOrderDTO afterSettleOrderDTO = AfterSettleOrderDTO.builder()
|
||
.orderCode(orderBasicInfo.getOrderCode())
|
||
.merchantId(orderBasicInfo.getMerchantId())
|
||
.stationId(orderBasicInfo.getStationId())
|
||
.orderPayAmount(orderBasicInfo.getPayAmount()) // 支付金额
|
||
.orderConsumeAmount(orderBasicInfo.getOrderAmount()) // 消费金额
|
||
.orderSettleAmount(orderBasicInfo.getSettleAmount()) // 结算金额
|
||
.orderElectricityAmount(orderDetail.getTotalElectricityAmount()) // 电费金额
|
||
.orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount()) // 电费折扣金额
|
||
.orderServiceAmount(orderDetail.getTotalServiceAmount()) // 服务费金额
|
||
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount()) // 服务费折扣金额
|
||
.orderRefundAmount(orderBasicInfo.getRefundAmount()) // 退款金额
|
||
.build();
|
||
logger.info("retrySplittingMethod, afterSettleOrderDTO:{}", JSON.toJSONString(afterSettleOrderDTO));
|
||
orderBasicInfoService.splittingMethod(afterSettleOrderDTO);
|
||
}
|
||
|
||
/**
|
||
* 调试订单
|
||
* @param dto
|
||
*/
|
||
public Map<String, Object> debugOrder(DebugOrderDTO dto) {
|
||
Map<String, Object> resultMap = Maps.newHashMap();
|
||
|
||
if (dto == null || StringUtils.isBlank(dto.getOrderCode())) {
|
||
logger.info("debugOrder, 参数为空直接放回");
|
||
return resultMap;
|
||
}
|
||
String orderCode = dto.getOrderCode();
|
||
resultMap.put("orderCode", orderCode);
|
||
|
||
// 根据订单号查询订单信息
|
||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||
if (orderBasicInfo == null || orderDetail == null) {
|
||
logger.info("debugOrder, orderCode:{}, orderBasicInfo:{}, orderDetail:{}", orderCode, orderBasicInfo, orderDetail);
|
||
return resultMap;
|
||
}
|
||
|
||
// 是否重新计算
|
||
String reCalculateFlag = dto.getReCalculateFlag();
|
||
String reCalculateFlagResult = orderCode + "本次未重新计算订单";
|
||
if (StringUtils.equals(reCalculateFlag, "1")) {
|
||
LocalDateTime localDateTime = DateUtils.date2LocalDateTime(orderBasicInfo.getSettlementTime());
|
||
// 开始时间为localDateTime减30秒
|
||
LocalDateTime startTime = localDateTime.minusSeconds(30);
|
||
// 结束时间为localDateTime加30秒
|
||
LocalDateTime endTime = localDateTime.plusSeconds(30);
|
||
// 查询这笔订单的交易记录原始数据
|
||
List<PileMsgRecord> pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
|
||
if (CollectionUtils.isEmpty(pileFeedListV2)) {
|
||
// 如果没有交易记录原始数据,则使用停止充电时间作为开始时间和结束时间再查一次
|
||
localDateTime = DateUtils.date2LocalDateTime(orderBasicInfo.getChargeEndTime());
|
||
startTime = localDateTime.minusSeconds(30);
|
||
endTime = localDateTime.plusSeconds(30);
|
||
pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
|
||
}
|
||
TransactionRecordsData data = null;
|
||
for (PileMsgRecord pileMsgRecord : pileFeedListV2) {
|
||
TransactionRecordsData parse = JSONObject.parseObject(pileMsgRecord.getJsonMsg(), TransactionRecordsData.class);
|
||
if (StringUtils.equals(parse.getTransactionCode(), orderBasicInfo.getTransactionCode())) {
|
||
data = parse;
|
||
data.setVinCode("");
|
||
}
|
||
}
|
||
|
||
if (data != null) {
|
||
AbstractProgramLogic programLogic = ProgramLogicFactory.getProgramLogic(MerchantDelayModeEnum.DELAY.getValue());
|
||
|
||
// 更新订单主表和订单详情中的各种金额
|
||
programLogic.updateOrderBasicInfoAndOrderDetail(data, orderBasicInfo, orderDetail);
|
||
|
||
// 计算订单折扣
|
||
programLogic.calculateOrderDiscountsV2(orderBasicInfo, orderDetail);
|
||
|
||
reCalculateFlagResult = MessageFormat.format("debugOrder重新计算订单, orderCode:{0}, 支付金额:{1}, 消费金额:{2}, 折扣金额:{3}, 退款金额:{4}, 结算金额:{5}",
|
||
orderBasicInfo.getOrderCode(), orderBasicInfo.getPayAmount(), orderBasicInfo.getOrderAmount(),
|
||
orderBasicInfo.getDiscountAmount(), orderBasicInfo.getRefundAmount(), orderBasicInfo.getSettleAmount());
|
||
|
||
// logger.info("debugOrder重新计算订单, orderCode:{}, 支付金额:{}, 消费金额:{}, 折扣金额:{}, 退款金额:{}, 结算金额:{}",
|
||
// orderBasicInfo.getOrderCode(), orderBasicInfo.getPayAmount(), orderBasicInfo.getOrderAmount(),
|
||
// orderBasicInfo.getDiscountAmount(), orderBasicInfo.getRefundAmount(), orderBasicInfo.getSettleAmount());
|
||
logger.info(reCalculateFlagResult);
|
||
|
||
// 更新数据库
|
||
OrderTransactionDTO orderTransactionDTO = new OrderTransactionDTO();
|
||
orderTransactionDTO.setOrderBasicInfo(orderBasicInfo);
|
||
orderTransactionDTO.setOrderDetail(orderDetail);
|
||
transactionService.doUpdateOrder(orderTransactionDTO);
|
||
} else {
|
||
reCalculateFlagResult = orderCode + "本次未重新计算订单, 原因: 未找到交易记录原始数据";
|
||
}
|
||
}
|
||
resultMap.put("reCalculate", ImmutableMap.of("value", reCalculateFlag, "message", reCalculateFlagResult));
|
||
|
||
// 组装after参数
|
||
AfterSettleOrderDTO afterSettleOrderDTO = AfterSettleOrderDTO.builder()
|
||
.orderCode(orderBasicInfo.getOrderCode())
|
||
.merchantId(orderBasicInfo.getMerchantId())
|
||
.stationId(orderBasicInfo.getStationId())
|
||
.orderPayAmount(orderBasicInfo.getPayAmount()) // 支付金额
|
||
.orderConsumeAmount(orderBasicInfo.getOrderAmount()) // 消费金额
|
||
.orderSettleAmount(orderBasicInfo.getSettleAmount()) // 结算金额
|
||
.orderElectricityAmount(orderDetail.getTotalElectricityAmount()) // 电费金额
|
||
.orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount()) // 电费折扣金额
|
||
.orderServiceAmount(orderDetail.getTotalServiceAmount()) // 服务费金额
|
||
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount()) // 服务费折扣金额
|
||
.orderRefundAmount(orderBasicInfo.getRefundAmount()) // 退款金额
|
||
.orderBasicInfo(orderBasicInfo)
|
||
.build();
|
||
|
||
// 是否重新退款
|
||
String reRefundFlag = dto.getReRefundFlag();
|
||
String reRefundFlagResult = orderCode + "本次未重新退款";
|
||
if (StringUtils.equals(reRefundFlag, "1")) {
|
||
// 订单退款,汇付退款
|
||
try {
|
||
orderBasicInfoService.refundMethod(afterSettleOrderDTO);
|
||
} catch (Exception e) {
|
||
logger.error("debugOrder-订单:{}, 订单退款,汇付退款异常", afterSettleOrderDTO.getOrderCode(), e);
|
||
}
|
||
reRefundFlagResult = MessageFormat.format("debugOrder-订单:{0}, 订单退款,汇付退款成功", afterSettleOrderDTO.getOrderCode());
|
||
logger.info(reRefundFlagResult);
|
||
}
|
||
resultMap.put("reRefund", ImmutableMap.of("value", reRefundFlag, "message", reRefundFlagResult));
|
||
|
||
// 是否重新分账
|
||
String reSplitFlag = dto.getReSplitFlag();
|
||
String reSplitFlagResult = orderCode + "本次未重新分账";
|
||
if (StringUtils.equals(reSplitFlag, "1")) {
|
||
try {
|
||
orderBasicInfoService.splittingMethod(afterSettleOrderDTO);
|
||
} catch (Exception e) {
|
||
logger.error("debugOrder-订单:{}, 订单结算金额,汇付分账异常", afterSettleOrderDTO.getOrderCode(), e);
|
||
}
|
||
reSplitFlagResult = MessageFormat.format("debugOrder-订单:{0}, 订单结算金额,汇付分账成功", afterSettleOrderDTO.getOrderCode());
|
||
logger.info(reSplitFlagResult);
|
||
}
|
||
resultMap.put("reSplit", ImmutableMap.of("value", reSplitFlag, "message", reSplitFlagResult));
|
||
logger.info("debugOrder结束, resultMap:{}", JSONObject.toJSONString(resultMap));
|
||
return resultMap;
|
||
}
|
||
|
||
public void sendOrderData2Mq(String orderCode) {
|
||
// 通过订单编号查询订单信息
|
||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||
if (orderBasicInfo == null || orderDetail == null) {
|
||
return;
|
||
}
|
||
// 发送消息
|
||
AfterSettleOrderDTO afterSettleOrderDTO = AfterSettleOrderDTO.builder()
|
||
.orderCode(orderBasicInfo.getOrderCode())
|
||
.merchantId(orderBasicInfo.getMerchantId())
|
||
.stationId(orderBasicInfo.getStationId())
|
||
.orderPayAmount(orderBasicInfo.getPayAmount()) // 支付金额
|
||
.orderConsumeAmount(orderBasicInfo.getOrderAmount()) // 消费金额
|
||
.orderSettleAmount(orderBasicInfo.getSettleAmount()) // 结算金额
|
||
.orderElectricityAmount(orderDetail.getTotalElectricityAmount()) // 电费金额
|
||
.orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount()) // 电费折扣金额
|
||
.orderServiceAmount(orderDetail.getTotalServiceAmount()) // 服务费金额
|
||
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount()) // 服务费折扣金额
|
||
.orderRefundAmount(orderBasicInfo.getRefundAmount()) // 退款金额
|
||
.build();
|
||
|
||
rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);
|
||
}
|
||
}
|
||
|