mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update
This commit is contained in:
@@ -20,6 +20,11 @@ public class SettleOrderReport {
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 结算单编号
|
||||
*/
|
||||
private String settleCode;
|
||||
|
||||
/**
|
||||
* 运营商id
|
||||
*/
|
||||
@@ -62,13 +67,11 @@ public class SettleOrderReport {
|
||||
|
||||
/**
|
||||
* 收入金额
|
||||
* 订单主表中orderAmount的累计金额
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 虚拟金额
|
||||
* 也就是不对账的部分消费
|
||||
*/
|
||||
private BigDecimal virtualAmount;
|
||||
|
||||
@@ -79,13 +82,11 @@ public class SettleOrderReport {
|
||||
|
||||
/**
|
||||
* 交易金额
|
||||
* 结算金额拆分为 交易金额 + 交易手续费
|
||||
*/
|
||||
private BigDecimal tradeAmount;
|
||||
|
||||
/**
|
||||
* 交易手续费
|
||||
* 结算金额拆分为 交易金额 + 交易手续费
|
||||
*/
|
||||
private BigDecimal tradeFee;
|
||||
|
||||
@@ -94,6 +95,11 @@ public class SettleOrderReport {
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 删除标识(0-正常;1-删除)
|
||||
*/
|
||||
|
||||
@@ -4,11 +4,9 @@ import com.jsowell.pile.domain.SettleOrderReport;
|
||||
import com.jsowell.pile.dto.MerchantOrderReportDTO;
|
||||
import com.jsowell.pile.vo.web.SettleOrderReportVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SettleOrderReportMapper {
|
||||
/**
|
||||
* delete by primary key
|
||||
@@ -64,10 +62,10 @@ public interface SettleOrderReportMapper {
|
||||
|
||||
int updateBatch(List<SettleOrderReport> list);
|
||||
|
||||
int updateBatchSelective(List<SettleOrderReport> list);
|
||||
|
||||
int batchInsert(@Param("list") List<SettleOrderReport> list);
|
||||
|
||||
int updateBatchSelective(List<SettleOrderReport> list);
|
||||
|
||||
/**
|
||||
* 查询结算订单报
|
||||
*
|
||||
|
||||
@@ -151,8 +151,6 @@ public interface IOrderBasicInfoService {
|
||||
|
||||
void orderSplittingOperations(String merchantId, String tradeDate);
|
||||
|
||||
void tempOrderSplittingOperations(String merchantId, String tradeDate);
|
||||
|
||||
List<BalanceDeductionAmountVO> calculateTheBalanceDeductionAmount(String memberId, BigDecimal amount);
|
||||
|
||||
/**
|
||||
@@ -173,8 +171,6 @@ public interface IOrderBasicInfoService {
|
||||
*/
|
||||
List<OrderBasicInfo> queryOrderList(List<String> orderCodeList);
|
||||
|
||||
void tempOrderRefund();
|
||||
|
||||
void realTimeMonitorDataRedis2DB(String transactionCode, String orderCode);
|
||||
|
||||
/**
|
||||
@@ -292,9 +288,6 @@ public interface IOrderBasicInfoService {
|
||||
|
||||
List<OrderPeriodAmountVO> transformPeriodAmountByOrderDetail(OrderDetail orderDetail);
|
||||
|
||||
|
||||
String tempUpdateVirtualAmount(QueryOrderDTO dto);
|
||||
|
||||
/**
|
||||
* 汇付支付 订单退款
|
||||
* @param dto
|
||||
@@ -347,5 +340,4 @@ public interface IOrderBasicInfoService {
|
||||
*/
|
||||
void retryRefundOrder(String orderCode) throws BaseAdaPayException;
|
||||
|
||||
void splitTheBillForOrderTemp(String merchantId, List<String> orderCodeList);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.jsowell.pile.dto.SettleOrderReportDTO;
|
||||
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 结算订单报Service接口
|
||||
@@ -101,5 +100,4 @@ public interface ISettleOrderReportService {
|
||||
|
||||
List<SettleOrderReport> queryOrderReport(List<String> stationIdList, String startTime, String endTime);
|
||||
|
||||
Map<String, Object> queryUndividedOrder(SettleOrderReportDTO dto);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.jsowell.pile.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.jsowell.pile.domain.SettleOrderReport;
|
||||
public interface SettleOrderReportService{
|
||||
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(SettleOrderReport record);
|
||||
|
||||
int insertOrUpdate(SettleOrderReport record);
|
||||
|
||||
int insertOrUpdateSelective(SettleOrderReport record);
|
||||
|
||||
int insertSelective(SettleOrderReport record);
|
||||
|
||||
SettleOrderReport selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(SettleOrderReport record);
|
||||
|
||||
int updateByPrimaryKey(SettleOrderReport record);
|
||||
|
||||
int updateBatch(List<SettleOrderReport> list);
|
||||
|
||||
int batchInsert(List<SettleOrderReport> list);
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.google.common.base.Joiner;
|
||||
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.dto.QueryPaymentConfirmDTO;
|
||||
import com.jsowell.adapay.operation.PaymentConfirmOperation;
|
||||
@@ -1210,62 +1209,6 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
orderSplittingOperations(adapayMemberAccount, stationReportList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动接口执行订单分账逻辑
|
||||
*/
|
||||
@Override
|
||||
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 = queryOrderList(orderCodeList);
|
||||
if (CollectionUtils.isEmpty(orderBasicInfos)) {
|
||||
logger.info("手动接口执行订单分账逻辑-站点:{}, 日期:{}, 没有查到订单数据", orderReport.getStationId(), tradeDate);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 执行分账
|
||||
for (OrderBasicInfo orderBasicInfo : orderBasicInfos) {
|
||||
try {
|
||||
OrderSettleResult orderSettleResult = null;
|
||||
logger.info("手动接口执行订单分账逻辑-orderCode:{}, payMode:{}", orderBasicInfo.getOrderCode(), orderBasicInfo.getPayMode());
|
||||
if (OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) {
|
||||
logger.info("手动接口执行订单分账逻辑-order:{}, result:{}", JSON.toJSONString(orderBasicInfo), JSON.toJSONString(orderSettleResult));
|
||||
// 余额支付的订单 只用余额支付转账
|
||||
// orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount);
|
||||
} else {
|
||||
// 在线支付,进行支付确认分账
|
||||
orderSettleResult = 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额支付订单,使用余额分账
|
||||
*
|
||||
@@ -1437,43 +1380,6 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
return orderBasicInfoMapper.queryOrderList(orderCodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时订单退款
|
||||
*/
|
||||
@Override
|
||||
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 {
|
||||
this.weChatRefund(weChatRefundDTO);
|
||||
} catch (Exception e) {
|
||||
logger.error("临时订单退款接口发生异常 orderCode:{}", orderBasicInfo.getOrderCode(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从redis中取出实时记录保存到表中j
|
||||
* 当订单完成的时候调用
|
||||
@@ -2431,25 +2337,6 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
return Lists.newArrayList(sharp, peak, flat, valley);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 + "条订单数据";
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇付支付-订单退款处理逻辑
|
||||
* 汇付支付订单退款
|
||||
@@ -2690,6 +2577,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
|
||||
// 计算报表
|
||||
SettleOrderReport settleOrderReport = new SettleOrderReport();
|
||||
String settleCode = "SETTLE_" + IdUtils.getOrderCode();
|
||||
settleOrderReport.setSettleCode(settleCode);
|
||||
settleOrderReport.setMerchantId(stationInfo.getMerchantId());
|
||||
settleOrderReport.setStationId(stationId);
|
||||
settleOrderReport.setUseElectricity(useElectricity);
|
||||
@@ -2994,77 +2883,6 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 = 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_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) {
|
||||
// 余额支付的订单
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询余额订单分账信息
|
||||
*
|
||||
|
||||
@@ -3,12 +3,10 @@ package com.jsowell.pile.service.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
|
||||
import com.jsowell.adapay.response.QueryPaymentConfirmDetailResponse;
|
||||
import com.jsowell.adapay.service.AdapayService;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -31,7 +29,6 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 结算订单报Service业务层处理
|
||||
@@ -73,43 +70,6 @@ public class SettleOrderReportServiceImpl implements ISettleOrderReportService {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryUndividedOrder(SettleOrderReportDTO dto) {
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
|
||||
SettleOrderReport orderReport = 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 (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();
|
||||
if (!CollectionUtils.isEmpty(paymentConfirms)) {
|
||||
clearingBillVO.setConfirmInfo(paymentConfirms.get(0));
|
||||
clearingList.add(clearingBillVO);
|
||||
} else {
|
||||
unClearingList.add(clearingBillVO);
|
||||
}
|
||||
}
|
||||
resultMap.put("clearingList", clearingList);
|
||||
resultMap.put("unClearingList", unClearingList);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询站点订单日报明细
|
||||
|
||||
Reference in New Issue
Block a user