mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-03 13:38:02 +08:00
新增 批量推送第三方平台订单接口
This commit is contained in:
@@ -25,6 +25,7 @@ import com.jsowell.pile.vo.uniapp.customer.MemberBalanceVO;
|
|||||||
import com.jsowell.pile.vo.web.PileStationVO;
|
import com.jsowell.pile.vo.web.PileStationVO;
|
||||||
import com.jsowell.service.OrderService;
|
import com.jsowell.service.OrderService;
|
||||||
import com.jsowell.service.TempService;
|
import com.jsowell.service.TempService;
|
||||||
|
import com.jsowell.thirdparty.platform.dto.PushOrderDTO;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -890,4 +891,22 @@ public class TempController extends BaseController {
|
|||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间区间批量推送订单
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/pushOrderInfoBatch")
|
||||||
|
public RestApiResponse<?> pushOrderInfoBatch(@RequestBody PushOrderDTO dto) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
tempService.pushOrderInfoBatch(dto);
|
||||||
|
response = new RestApiResponse<>();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("青海平台推送订单信息 error", e);
|
||||||
|
}
|
||||||
|
logger.info("青海平台推送订单信息 result:{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
|||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
||||||
import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
|
import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
|
||||||
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||||
import com.jsowell.common.enums.ykc.*;
|
import com.jsowell.common.enums.ykc.*;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
@@ -34,7 +35,13 @@ import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
|
|||||||
import com.jsowell.pile.service.programlogic.ProgramLogicFactory;
|
import com.jsowell.pile.service.programlogic.ProgramLogicFactory;
|
||||||
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
||||||
import com.jsowell.pile.transaction.service.TransactionService;
|
import com.jsowell.pile.transaction.service.TransactionService;
|
||||||
|
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||||
|
import com.jsowell.pile.vo.base.StationInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO;
|
||||||
import com.jsowell.pile.vo.web.*;
|
import com.jsowell.pile.vo.web.*;
|
||||||
|
import com.jsowell.thirdparty.common.CommonService;
|
||||||
|
import com.jsowell.thirdparty.platform.dto.PushOrderDTO;
|
||||||
|
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -117,6 +124,15 @@ public class TempService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderUnsplitRecordService orderUnsplitRecordService;
|
private OrderUnsplitRecordService orderUnsplitRecordService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommonService commonService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算订单耗电量
|
* 计算订单耗电量
|
||||||
* 内蒙古站点
|
* 内蒙古站点
|
||||||
@@ -1212,5 +1228,30 @@ public class TempService {
|
|||||||
|
|
||||||
rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);
|
rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间区间批量推送订单
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void pushOrderInfoBatch(PushOrderDTO dto) {
|
||||||
|
// 根据type查出对接的stationIds
|
||||||
|
List<StationInfoVO> stationInfoVOS = thirdPartyStationRelationService.selectStationList(dto.getThirdPartyType());
|
||||||
|
|
||||||
|
List<String> stationIds = stationInfoVOS.stream()
|
||||||
|
.map(StationInfoVO::getStationId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 批量查询需要推送的订单
|
||||||
|
List<OrderBasicInfo> orderInfos = orderBasicInfoService.getOrderBasicInfoByTimeInterval(stationIds, dto.getStartTime(), dto.getEndTime());
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(orderInfos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
orderInfos.forEach(orderBasicInfo -> {
|
||||||
|
// 推送第三方平台
|
||||||
|
commonService.commonPushOrderInfoV2(orderBasicInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -405,4 +405,13 @@ public interface OrderBasicInfoMapper {
|
|||||||
List<OrderVO> selectThirdPartyOrderList(@Param("dto") QueryStartChargeDTO dto);
|
List<OrderVO> selectThirdPartyOrderList(@Param("dto") QueryStartChargeDTO dto);
|
||||||
|
|
||||||
LocalDateTime queryOrderCreateTimeByStationId(String id);
|
LocalDateTime queryOrderCreateTimeByStationId(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数查询订单基本信息
|
||||||
|
* @param stationIds
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrderBasicInfo> getOrderBasicInfoByTimeInterval(@Param("stationIds") List<String> stationIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||||
}
|
}
|
||||||
@@ -231,6 +231,8 @@ public interface OrderBasicInfoService{
|
|||||||
|
|
||||||
OrderSplitResult verifyOrderConfirmAmount(List<String> paymentIds, String orderCode, BigDecimal settleAmount, String wechatAppId) throws BaseAdaPayException;
|
OrderSplitResult verifyOrderConfirmAmount(List<String> paymentIds, String orderCode, BigDecimal settleAmount, String wechatAppId) throws BaseAdaPayException;
|
||||||
|
|
||||||
|
OrderSplitResult verifyOrderConfirmAmountWithCancelSplit(List<String> paymentIds, String orderCode, BigDecimal settleAmount, String wechatAppId) throws BaseAdaPayException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量查询订单
|
* 批量查询订单
|
||||||
* @param orderCodeList
|
* @param orderCodeList
|
||||||
@@ -573,4 +575,6 @@ public interface OrderBasicInfoService{
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Object> verifyMergeChargeOrder(VerifyMergeChargeOrderDTO dto) throws Exception;
|
Map<String, Object> verifyMergeChargeOrder(VerifyMergeChargeOrderDTO dto) throws Exception;
|
||||||
|
|
||||||
|
List<OrderBasicInfo> getOrderBasicInfoByTimeInterval(List<String> stationIds, String startTime, String endTime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2439,6 +2439,75 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验订单分账金额(其他部分与上面方法一致,此方法仅加了撤销分账部分,只给临时接口用)
|
||||||
|
*
|
||||||
|
* @param paymentIds 支付id集合
|
||||||
|
* @param orderCode 订单编号
|
||||||
|
* @param settleAmount 结算金额
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OrderSplitResult verifyOrderConfirmAmountWithCancelSplit(List<String> paymentIds, String orderCode, BigDecimal settleAmount, String wechatAppId) throws BaseAdaPayException {
|
||||||
|
// 分账金额
|
||||||
|
BigDecimal totalConfirmAmt = BigDecimal.ZERO;
|
||||||
|
// 手续费
|
||||||
|
BigDecimal feeAmt = BigDecimal.ZERO;
|
||||||
|
// 通过支付id查询分账情况
|
||||||
|
for (String paymentId : paymentIds) {
|
||||||
|
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
||||||
|
dto.setPaymentId(paymentId);
|
||||||
|
dto.setWechatAppId(wechatAppId);
|
||||||
|
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
||||||
|
if (response != null) {
|
||||||
|
List<PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
||||||
|
if (CollectionUtils.isNotEmpty(confirms)) {
|
||||||
|
for (PaymentConfirmInfo confirm : confirms) {
|
||||||
|
// 校验分账是否撤销
|
||||||
|
if (queryConfirmReverseStatus(confirm.getId(), wechatAppId)) {
|
||||||
|
logger.info("支付确认id:" + confirm.getId() + "撤销了。。。");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 如果没有撤销,先撤销分账,再重新进行分账
|
||||||
|
adapayService.createConfirmReverse(confirm.getId(), wechatAppId);
|
||||||
|
|
||||||
|
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
||||||
|
if (StringUtils.equals(jsonObject.getString("orderCode"), orderCode)) {
|
||||||
|
// 订单号对的上,累计分账金额
|
||||||
|
BigDecimal confirmAmt = new BigDecimal(confirm.getConfirmAmt());
|
||||||
|
BigDecimal confirmedAmt = new BigDecimal(confirm.getConfirmedAmt());
|
||||||
|
BigDecimal orderConfirmedAmt = confirmedAmt.compareTo(BigDecimal.ZERO) == 0
|
||||||
|
? confirmedAmt
|
||||||
|
: confirmAmt;
|
||||||
|
totalConfirmAmt = totalConfirmAmt.add(orderConfirmedAmt);
|
||||||
|
feeAmt = feeAmt.add(new BigDecimal(confirm.getFeeAmt()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderSplitResult result = new OrderSplitResult();
|
||||||
|
result.setOrderCode(orderCode);
|
||||||
|
result.setSettleAmt(settleAmount.toString());
|
||||||
|
result.setConfirmAmt(totalConfirmAmt.toString());
|
||||||
|
if (totalConfirmAmt.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
feeAmt = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
result.setFeeAmt(feeAmt.toString());
|
||||||
|
String status;
|
||||||
|
// 如果确认金额和结算金额相等,返回succeeded,其他情况返回PENDING
|
||||||
|
if (settleAmount.compareTo(totalConfirmAmt) == 0) {
|
||||||
|
// 返回succeeded 标识该笔订单已经完成了分账,不要再次执行分账
|
||||||
|
status = AdapayStatusEnum.SUCCEEDED.getValue();
|
||||||
|
} else {
|
||||||
|
status = AdapayStatusEnum.PENDING.getValue();
|
||||||
|
}
|
||||||
|
result.setStatus(status);
|
||||||
|
logger.info("校验订单分账金额-orderCode:{}, 分账结果:{}", orderCode, JSON.toJSONString(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询分账撤销状态
|
* 查询分账撤销状态
|
||||||
*/
|
*/
|
||||||
@@ -5240,5 +5309,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderBasicInfo> getOrderBasicInfoByTimeInterval(List<String> stationIds, String startTime, String endTime) {
|
||||||
|
return orderBasicInfoMapper.getOrderBasicInfoByTimeInterval(stationIds, startTime, endTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3291,4 +3291,15 @@
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getOrderBasicInfoByTimeInterval" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from order_basic_info
|
||||||
|
where del_flag = '0'
|
||||||
|
and station_id in
|
||||||
|
<foreach collection="stationIds" item="stationId" open="(" separator="," close=")">
|
||||||
|
#{stationId,jdbcType=VARCHAR}
|
||||||
|
</foreach>
|
||||||
|
and create_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
26
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/PushOrderDTO.java
vendored
Normal file
26
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/PushOrderDTO.java
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.jsowell.thirdparty.platform.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送订单DTO
|
||||||
|
*
|
||||||
|
* @author Lemon
|
||||||
|
* @Date 2025/7/4 13:31:28
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class PushOrderDTO {
|
||||||
|
private String thirdPartyType;
|
||||||
|
|
||||||
|
private String orderCodeList;
|
||||||
|
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
private String endTime;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user