2023-08-26 18:01:25 +08:00
|
|
|
|
package com.jsowell.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
2024-11-13 17:06:46 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
|
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;
|
2023-10-24 14:49:49 +08:00
|
|
|
|
import com.jsowell.adapay.common.AdaPayment;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
|
2023-10-16 10:18:06 +08:00
|
|
|
|
import com.jsowell.adapay.response.PaymentConfirmResponse;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
import com.jsowell.adapay.response.QueryPaymentConfirmDetailResponse;
|
|
|
|
|
|
import com.jsowell.adapay.service.AdapayService;
|
2024-09-24 16:39:42 +08:00
|
|
|
|
import com.jsowell.adapay.vo.OrderSplitResult;
|
2023-09-26 15:41:05 +08:00
|
|
|
|
import com.jsowell.adapay.vo.PaymentInfo;
|
2023-10-24 15:33:58 +08:00
|
|
|
|
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
import com.jsowell.common.enums.ykc.*;
|
|
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
|
|
|
|
|
import com.jsowell.common.util.StringUtils;
|
|
|
|
|
|
import com.jsowell.pile.domain.*;
|
|
|
|
|
|
import com.jsowell.pile.dto.ApplyRefundDTO;
|
|
|
|
|
|
import com.jsowell.pile.dto.QueryOrderDTO;
|
|
|
|
|
|
import com.jsowell.pile.dto.SettleOrderReportDTO;
|
|
|
|
|
|
import com.jsowell.pile.mapper.OrderBasicInfoMapper;
|
2024-11-07 15:02:52 +08:00
|
|
|
|
import com.jsowell.pile.mapper.PileMsgRecordMapper;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
import com.jsowell.pile.service.*;
|
|
|
|
|
|
import com.jsowell.pile.vo.web.ClearingBillVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.web.OrderListVO;
|
2024-08-06 15:46:43 +08:00
|
|
|
|
import com.jsowell.pile.vo.web.OrderPaymentDetailVO;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
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
|
2024-01-06 15:13:50 +08:00
|
|
|
|
private OrderBasicInfoService orderBasicInfoService;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ClearingWithdrawInfoService clearingWithdrawInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2023-08-28 11:17:06 +08:00
|
|
|
|
private OrderPayRecordService orderPayRecordService;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdapayCallbackRecordService adapayCallbackRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WxpayRefundCallbackService wxpayRefundCallbackService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2024-01-06 15:20:28 +08:00
|
|
|
|
private PileMerchantInfoService pileMerchantInfoService;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2024-01-06 15:20:28 +08:00
|
|
|
|
private SettleOrderReportService settleOrderReportService;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2023-11-29 11:55:33 +08:00
|
|
|
|
private AdapayMemberAccountService adapayMemberAccountService;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdapayService adapayService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private MemberAdapayRecordService memberAdapayRecordService;
|
|
|
|
|
|
|
2024-11-07 15:02:52 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileMsgRecordMapper pileMsgRecordMapper;
|
|
|
|
|
|
|
2024-11-13 17:06:46 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileMsgRecordService pileMsgRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private OrderMonitorDataService orderMonitorDataService;
|
|
|
|
|
|
|
2024-11-07 15:02:52 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 计算订单耗电量
|
|
|
|
|
|
* 内蒙古站点
|
|
|
|
|
|
*/
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-26 18:01:25 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 手动接口执行订单分账逻辑
|
|
|
|
|
|
*/
|
|
|
|
|
|
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 {
|
2024-09-24 16:39:42 +08:00
|
|
|
|
OrderSplitResult orderSettleResult = null;
|
2023-08-26 18:01:25 +08:00
|
|
|
|
logger.info("手动接口执行订单分账逻辑-orderCode:{}, payMode:{}", orderBasicInfo.getOrderCode(), orderBasicInfo.getPayMode());
|
2024-09-12 13:24:04 +08:00
|
|
|
|
if (OrderPayModeEnum.PAYMENT_OF_PRINCIPAL_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) {
|
2023-08-26 18:01:25 +08:00
|
|
|
|
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) {
|
2024-09-12 13:24:04 +08:00
|
|
|
|
if (StringUtils.equals(orderListVO.getPayMode(), OrderPayModeEnum.PAYMENT_OF_PRINCIPAL_BALANCE.getValue())) {
|
2023-08-26 18:01:25 +08:00
|
|
|
|
/*
|
|
|
|
|
|
余额支付 查询支付记录,如全部用本金支付,则虚拟金额为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()
|
2024-01-14 15:55:53 +08:00
|
|
|
|
.id(Integer.parseInt(orderListVO.getId()))
|
2023-08-26 18:01:25 +08:00
|
|
|
|
.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 {
|
2024-08-13 14:05:48 +08:00
|
|
|
|
// orderBasicInfoService.weChatRefund(weChatRefundDTO);
|
2023-08-26 18:01:25 +08:00
|
|
|
|
} 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,表示该订单没有执行过分账,再次执行分账
|
2024-09-12 13:24:04 +08:00
|
|
|
|
if (OrderPayModeEnum.PAYMENT_OF_PRINCIPAL_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) {
|
2023-08-26 18:01:25 +08:00
|
|
|
|
// 余额支付的订单
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-26 15:41:05 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询余额订单 分账信息
|
|
|
|
|
|
* @param orderCode
|
|
|
|
|
|
* @param memberId
|
|
|
|
|
|
* @param wechatAppId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-08-26 18:01:25 +08:00
|
|
|
|
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 (QueryPaymentConfirmDetailResponse.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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-26 15:41:05 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询未分账订单
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-08-26 18:01:25 +08:00
|
|
|
|
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<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> paymentConfirms = response.getPaymentConfirms();
|
2023-09-19 10:38:48 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(paymentConfirms)) {
|
|
|
|
|
|
unClearingList.add(clearingBillVO);
|
|
|
|
|
|
} else {
|
2023-08-26 18:01:25 +08:00
|
|
|
|
clearingBillVO.setConfirmInfo(paymentConfirms.get(0));
|
|
|
|
|
|
clearingList.add(clearingBillVO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
resultMap.put("clearingList", clearingList);
|
|
|
|
|
|
resultMap.put("unClearingList", unClearingList);
|
2023-09-19 10:38:48 +08:00
|
|
|
|
resultMap.put("orderSize", clearingBillVOList.size());
|
2023-08-26 18:01:25 +08:00
|
|
|
|
return resultMap;
|
|
|
|
|
|
}
|
2023-08-31 17:31:19 +08:00
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-05 16:42:33 +08:00
|
|
|
|
|
|
|
|
|
|
public void updateMemberAdapayRecord(String memberId) {
|
|
|
|
|
|
// 查询
|
|
|
|
|
|
List<MemberAdapayRecord> memberAdapayRecordList = memberAdapayRecordService.selectAdapayRecordList(memberId, ScenarioEnum.BALANCE.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-09-26 11:12:54 +08:00
|
|
|
|
|
2023-09-26 15:41:05 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 余额支付分账
|
|
|
|
|
|
* @param orderBasicInfo
|
|
|
|
|
|
* @param adapayMemberAccount
|
|
|
|
|
|
* @param wechatAppId
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void doBalancePaymentTemp(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
|
2023-09-26 11:12:54 +08:00
|
|
|
|
String orderCode = orderBasicInfo.getOrderCode();
|
|
|
|
|
|
// 查询订单支付记录
|
|
|
|
|
|
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
2023-09-26 15:56:36 +08:00
|
|
|
|
logger.info("doBalancePaymentTemp-查询订单:{}支付记录:{}", orderCode, JSON.toJSONString(orderPayRecordList));
|
2023-09-26 11:12:54 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(orderPayRecordList)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-09-27 10:57:36 +08:00
|
|
|
|
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
2023-09-26 11:12:54 +08:00
|
|
|
|
OrderPayRecord record = orderPayRecordList.get(0);
|
|
|
|
|
|
String deductionRecord = record.getDeductionRecord();
|
2024-01-17 16:35:03 +08:00
|
|
|
|
List<PaymentInfo> paymentInfos = orderPayRecordService.parseDeductionRecord(deductionRecord);
|
2023-09-26 11:12:54 +08:00
|
|
|
|
|
2023-09-26 15:41:05 +08:00
|
|
|
|
// 通过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<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(confirms)) {
|
2023-09-27 10:57:36 +08:00
|
|
|
|
// 已经分过账
|
2023-09-26 15:41:05 +08:00
|
|
|
|
for (QueryPaymentConfirmDetailResponse.PaymentConfirmInfo confirm : confirms) {
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
2023-09-26 11:12:54 +08:00
|
|
|
|
|
2023-09-26 15:41:05 +08:00
|
|
|
|
// 找到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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-27 10:57:36 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
// 未分账情况
|
|
|
|
|
|
adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, settleAmount, orderCode, wechatAppId);
|
2023-09-26 15:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-26 11:12:54 +08:00
|
|
|
|
}
|
2023-10-13 15:33:13 +08:00
|
|
|
|
|
|
|
|
|
|
public void verifyUndividedPayment(QueryOrderDTO dto) {
|
2023-10-16 10:18:06 +08:00
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
String startTime = dto.getStartTime();
|
|
|
|
|
|
String endTime = dto.getEndTime();
|
2023-10-13 15:33:13 +08:00
|
|
|
|
// 查询时间段的订单
|
2023-10-16 10:18:06 +08:00
|
|
|
|
// List<AdapayCallbackRecord> list = adapayCallbackRecordService.selectByDateTime(startTime, endTime);
|
2024-08-06 15:46:43 +08:00
|
|
|
|
List<OrderPaymentDetailVO> orderPayDetailVOS = orderBasicInfoService.queryOrderPayDetail(startTime, endTime);
|
2023-10-16 10:18:06 +08:00
|
|
|
|
logger.info("校验未分账的支付单-在 {} - {} 期间,共查询到{}条支付记录", startTime, endTime, orderPayDetailVOS.size());
|
2023-10-13 15:33:13 +08:00
|
|
|
|
// 查询支付单 分账情况
|
2024-08-06 15:46:43 +08:00
|
|
|
|
for (OrderPaymentDetailVO record : orderPayDetailVOS) {
|
2023-10-16 10:18:06 +08:00
|
|
|
|
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<QueryPaymentConfirmDetailResponse.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));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-24 13:14:33 +08:00
|
|
|
|
}
|
2023-10-16 10:18:06 +08:00
|
|
|
|
|
2023-10-24 13:14:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 检查支付单
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void checkPayment(QueryOrderDTO dto) throws BaseAdaPayException {
|
|
|
|
|
|
// 根据时间段查询支付对象列表
|
2023-10-24 14:49:49 +08:00
|
|
|
|
List<AdaPayment> adaPayments = adapayService.queryPaymentList(dto.getStartTime(), dto.getEndTime());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(adaPayments)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-24 15:33:58 +08:00
|
|
|
|
List<String> paymentIdList = Lists.newArrayList();
|
|
|
|
|
|
BigDecimal total = BigDecimal.ZERO;
|
|
|
|
|
|
|
2023-10-26 16:54:50 +08:00
|
|
|
|
AdapayMemberAccount aDefault = adapayMemberAccountService.getDefault();
|
|
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
|
2023-10-24 14:49:49 +08:00
|
|
|
|
for (AdaPayment adaPayment : adaPayments) {
|
2023-10-26 16:54:50 +08:00
|
|
|
|
String paymentId = adaPayment.getId();
|
2023-10-24 14:49:49 +08:00
|
|
|
|
String pay_mode = adaPayment.getPay_mode();
|
|
|
|
|
|
if (StringUtils.isBlank(pay_mode)) {
|
2023-10-24 15:33:58 +08:00
|
|
|
|
// 实时分账的不检查
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String status = adaPayment.getStatus();
|
|
|
|
|
|
if (!StringUtils.equals(status, AdapayStatusEnum.SUCCEEDED.getValue())) {
|
|
|
|
|
|
// 不是交易成功的不检查
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-26 16:54:50 +08:00
|
|
|
|
if (StringUtils.equals(paymentId, "002212023102509474610563069333816762368")) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-24 15:33:58 +08:00
|
|
|
|
// 交易金额
|
|
|
|
|
|
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);
|
2023-10-24 14:49:49 +08:00
|
|
|
|
|
2023-10-24 15:33:58 +08:00
|
|
|
|
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
2023-10-26 16:54:50 +08:00
|
|
|
|
paymentIdList.add(paymentId);
|
2023-10-24 15:33:58 +08:00
|
|
|
|
total = total.add(subtract);
|
|
|
|
|
|
logger.info("支付单:{}, 支付金额:{}, 总撤销金额:{}, 总确认金额:{}, 剩余金额:{}",
|
2023-10-26 16:54:50 +08:00
|
|
|
|
paymentId, payAmt, reservedAmt, confirmedAmt, subtract);
|
|
|
|
|
|
|
|
|
|
|
|
// adapayService.createPaymentConfirmRequest(paymentId, aDefault, subtract, null, wechatAppId);
|
2023-10-24 14:49:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-24 15:33:58 +08:00
|
|
|
|
logger.info("{} - {} 期间,共有{}笔支付单存在剩余金额, 共计:{},list:{}", dto.getStartTime(), dto.getEndTime(), paymentIdList.size(), total, JSON.toJSONString(paymentIdList));
|
2023-10-13 15:33:13 +08:00
|
|
|
|
}
|
2024-11-13 17:06:46 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 校验是否为并充订单
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, List<String>> checkCombinedChargingOrder(List<String> orderCodeList) throws BaseAdaPayException {
|
|
|
|
|
|
Map<String, List<String>> resultMap = Maps.newHashMap();
|
2024-11-13 17:10:47 +08:00
|
|
|
|
List<String> combinedChargingOrderList = Lists.newArrayList();
|
|
|
|
|
|
List<String> notCombinedChargingOrderList = Lists.newArrayList();
|
|
|
|
|
|
List<String> noDataOrderList = Lists.newArrayList();
|
2024-11-13 17:06:46 +08:00
|
|
|
|
for (String orderCode : orderCodeList) {
|
|
|
|
|
|
// 查询orderMonitorData
|
|
|
|
|
|
OrderMonitorData orderMonitorData = orderMonitorDataService.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (orderMonitorData == null) {
|
|
|
|
|
|
logger.info("订单:{}不存在", orderCode);
|
2024-11-13 17:10:47 +08:00
|
|
|
|
noDataOrderList.add(orderCode);
|
2024-11-13 17:06:46 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(orderMonitorData.getMonitorData());
|
2024-11-13 17:10:47 +08:00
|
|
|
|
List<BigDecimal> orderOutputCurrentList = Lists.newArrayList();
|
2024-11-13 17:06:46 +08:00
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
|
|
|
String outputCurrent = jsonObject.getString("outputCurrent");
|
2024-11-13 17:10:47 +08:00
|
|
|
|
orderOutputCurrentList.add(new BigDecimal(outputCurrent));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果orderOutputCurrentList中任意一值大于250,判定为并充订单
|
|
|
|
|
|
if (orderOutputCurrentList.stream().anyMatch(current -> current.compareTo(new BigDecimal("250")) > 0)) {
|
|
|
|
|
|
combinedChargingOrderList.add(orderCode);
|
|
|
|
|
|
} else {
|
2024-11-13 17:06:46 +08:00
|
|
|
|
notCombinedChargingOrderList.add(orderCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-11-13 17:10:47 +08:00
|
|
|
|
resultMap.put("combinedChargingOrderList", combinedChargingOrderList);
|
|
|
|
|
|
resultMap.put("notCombinedChargingOrderList", notCombinedChargingOrderList);
|
|
|
|
|
|
resultMap.put("noDataOrderList", noDataOrderList);
|
2024-11-13 17:06:46 +08:00
|
|
|
|
return resultMap;
|
|
|
|
|
|
}
|
2023-08-26 18:01:25 +08:00
|
|
|
|
}
|
2024-11-13 17:06:46 +08:00
|
|
|
|
|