feat:第三方支付查询订单详情
This commit is contained in:
1 parent
e12828656f
commit
2727c3627c
19 files changed
+220
-50
No files matched your search
+1
@@ -16,6 +16,7 @@ public enum ThirdPayApiBizTypeEnum {
|
||||
REFUND("20", "退款"),
|
||||
WALLET_INFO("30", "钱包详情"),
|
||||
WATER("40", "流水"),
|
||||
DETAIL("50", "订单详情"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
|
||||
+2
@@ -19,9 +19,11 @@ public enum ThirdPayVoStatusEnum {
|
||||
USER_EXIST(501, "用户不存在"),
|
||||
ORDER_EXIST(502, "订单不存在"),
|
||||
MCH_EXIST(503, "第三方商户未配置"),
|
||||
ORDER_REFUND_EXIST(504, "订单未退款"),
|
||||
BALANCE_NOT_ENOUGH(505, "用户余额不足"),
|
||||
ORDER_HAVE_PAY(506, "订单已支付"),
|
||||
ORDER_HAVE_REFUND(507, "订单已退款"),
|
||||
DETAIL_ITEM_NOT_ONE(508, "查询详情条目不为一"),
|
||||
UNKNOWN_ERROR(599, "未知错误,请联系管理员"),
|
||||
;
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PayDetailDto {
|
||||
|
||||
/**
|
||||
* 第三方订单id(thirdOrderId、thirdRefundId二选一)
|
||||
*/
|
||||
private String thirdOrderId;
|
||||
|
||||
/**
|
||||
* 第三方退款(thirdOrderId、thirdRefundId二选一,有退款操作才能查询到数据,否则返回null)
|
||||
*/
|
||||
private String thirdRefundId;
|
||||
|
||||
}
|
||||
+8
@@ -62,5 +62,13 @@ public class ThirdPayApiController {
|
||||
return thirdPayApiService.water(body, headers);
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@Operation(summary = "订单详情", description = "订单详情")
|
||||
@PostMapping("/detail")
|
||||
public PayBaseVo<PayWaterVo> detail(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
|
||||
String body = httpEntity.getBody();
|
||||
return thirdPayApiService.detail(body, headers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+5
@@ -30,4 +30,9 @@ public interface ThirdPayApiService {
|
||||
* 流水查询
|
||||
*/
|
||||
PayBaseVo<List<PayWaterVo>> water(String json, Map<String, String> headers);
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
PayBaseVo<PayWaterVo> detail(String json, Map<String, String> headers);
|
||||
}
|
||||
+59
-4
@@ -7,10 +7,7 @@ import com.bsd.pjcloud.hard.api.feign.RemoteHardThirdPayService;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayApiBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPaySoureBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayVoStatusEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayGetWalletInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.WaterDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.*;
|
||||
import com.bsd.pjcloud.thirdparty.entity.ThirdKeyManageEntity;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdKeyManageService;
|
||||
@@ -268,4 +265,62 @@ public class ThirdPayApiServiceImpl implements ThirdPayApiService {
|
||||
return baseVo;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
@Override
|
||||
public PayBaseVo<PayWaterVo> detail(String json, Map<String, String> headers) {
|
||||
// 日志
|
||||
long startTime = System.currentTimeMillis();
|
||||
ThirdPayLogEntity logObj = ThirdPayLogEntity.builder().apiUrl("/third/third-pay-api/detail").bizType(ThirdPayApiBizTypeEnum.DETAIL.getType()).req(json).paySourceType(ThirdPaySoureBizTypeEnum.LB.getType()).build();
|
||||
// 开始处理
|
||||
PayBaseVo baseVo = new PayBaseVo<PayWaterVo>();
|
||||
ThirdKeyManageEntity keySetting = keyManageService.checkSignAndReturnConfig(json, headers);
|
||||
if (ObjectUtil.isEmpty(keySetting)) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.SIGN_ERROR);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
PayDetailDto dto = JSONUtil.toBean(json, PayDetailDto.class);
|
||||
if (ObjectUtil.isAllEmpty(dto.getThirdOrderId(), dto.getThirdRefundId())) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.PARAMS_ERROR);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
try {
|
||||
PayBaseVo<PayWaterVo> orderDetail = hardThirdPayService.orderDetail(dto, ThirdPaySoureBizTypeEnum.valueOfByType(keySetting.getBizType()));
|
||||
if (ObjectUtil.isEmpty(orderDetail)) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.UNKNOWN_ERROR);
|
||||
baseVo.setData(orderDetail);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
// 加密一下手机号
|
||||
if (ObjectUtil.isNotEmpty(orderDetail.getData())) {
|
||||
PayWaterVo data = orderDetail.getData();
|
||||
if (ObjectUtil.isNotEmpty(data.getSignPhone())) {
|
||||
data.setSignPhone(LbRetailSignUtils.sm4Encrypt(data.getSignPhone(), keySetting.getFieldKey()));
|
||||
}
|
||||
}
|
||||
return orderDetail;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|订单详情,json|{}|headers|{}|", TAG, json, headers, e);
|
||||
baseVo.set(ThirdPayVoStatusEnum.UNKNOWN_ERROR);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
+15
@@ -39,6 +39,8 @@ public class PayTest {
|
||||
|
||||
private final String waterUrl = "/third/third-pay-api/water";
|
||||
|
||||
private final String detailUrl = "/third/third-pay-api/detail";
|
||||
|
||||
@Resource
|
||||
private ThirdKeyManageService keyManageService;
|
||||
|
||||
@@ -143,6 +145,19 @@ public class PayTest {
|
||||
log.info(res);
|
||||
}
|
||||
|
||||
// 查询订单详情
|
||||
@Test
|
||||
public void detail() throws Exception {
|
||||
ThirdKeyManageEntity config = getLbConfig();
|
||||
Map<String, Object> paramsMap = new HashMap<>();
|
||||
paramsMap.put("thirdOrderId", "");
|
||||
paramsMap.put("thirdRefundId", "10");
|
||||
String body = JSONUtil.toJsonStr(paramsMap);
|
||||
// 发送请求
|
||||
String res = HttpRequest.post(baseUrl + detailUrl).contentType("application/json").header(apiCountersign(body)).body(body).execute().body();
|
||||
log.info(res);
|
||||
}
|
||||
|
||||
private ThirdKeyManageEntity getLbConfig() {
|
||||
return keyManageService.get(ThirdKeyTypeEnum.LB);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user