临时接口,订单退款

This commit is contained in:
2023-05-31 13:59:27 +08:00
parent 0c1144d0e5
commit 922c0428b7
11 changed files with 112 additions and 6 deletions

View File

@@ -208,4 +208,6 @@ public interface OrderBasicInfoMapper {
int batchUpdateOrderDetail(@Param("list") List<OrderDetail> orderDetailList);
List<OrderDetail> getOrderDetailList(List<String> orderCodes);
List<OrderBasicInfo> tempQueryWeChatRefundOrders(@Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@@ -1,6 +1,7 @@
package com.jsowell.pile.mapper;
import com.jsowell.pile.domain.WxpayRefundCallback;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -18,4 +19,6 @@ public interface WxpayRefundCallbackMapper {
// int updateByPrimaryKey(WxpayRefundCallback record);
List<WxpayRefundCallback> selectWxpayRefundCallbackList(List<String> outTradeNoList);
List<WxpayRefundCallback> selectByOrderCodeList(@Param("orderCodes") List<String> orderCodeList);
}

View File

@@ -132,7 +132,9 @@ public interface IOrderBasicInfoService {
List<OrderVO> getListByMemberIdAndOrderStatus(String memberId, List<String> orderStatusList, LocalDateTime dateTime, String stationId);
void realTimeMonitorDataRedis2DB(String transactionCode, String orderCode);
void tempOrderRefund();
void realTimeMonitorDataRedis2DB(String transactionCode, String orderCode);
void updateElecAmount();

View File

@@ -16,4 +16,6 @@ public interface WxpayRefundCallbackService {
// int updateByPrimaryKey(WxpayRefundCallback record);
List<WxpayRefundCallback> selectWxpayRefundCallbackList(List<String> outTradeNoList);
List<WxpayRefundCallback> selectByOrderCodeList(List<String> orderCodeList);
}

View File

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
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.huifu.adapay.model.Refund;
import com.jsowell.common.constant.CacheConstants;
@@ -776,8 +777,39 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
}
// TODO 推送停止充电结果 notification_stop_charge_result
}
/**
* 临时订单退款
*/
@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();
// 微信退款逻辑
WeChatRefundDTO weChatRefundDTO = new WeChatRefundDTO();
weChatRefundDTO.setOrderCode(orderBasicInfo.getOrderCode());
weChatRefundDTO.setRefundType("1");
weChatRefundDTO.setRefundAmount(refundAmount);
this.weChatRefund(weChatRefundDTO);
}
}
/**

View File

@@ -1,8 +1,10 @@
package com.jsowell.pile.service.impl;
import com.google.common.collect.Lists;
import com.jsowell.pile.domain.WxpayRefundCallback;
import com.jsowell.pile.mapper.WxpayRefundCallbackMapper;
import com.jsowell.pile.service.WxpayRefundCallbackService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -29,6 +31,14 @@ public class WxpayRefundCallbackServiceImpl implements WxpayRefundCallbackServic
return wxpayRefundCallbackMapper.selectWxpayRefundCallbackList(outTradeNoList);
}
@Override
public List<WxpayRefundCallback> selectByOrderCodeList(List<String> orderCodeList) {
if (CollectionUtils.isEmpty(orderCodeList)) {
return Lists.newArrayList();
}
return wxpayRefundCallbackMapper.selectByOrderCodeList(orderCodeList);
}
// @Override
// public WxpayRefundCallback selectByPrimaryKey(Integer id) {
// return wxpayRefundCallbackMapper.selectByPrimaryKey(id);