execPayResult
This commit is contained in:
parent
efedf7276e
commit
26a4592bcd
|
|
@ -1,6 +1,5 @@
|
||||||
package com.czg.controller;
|
package com.czg.controller;
|
||||||
|
|
||||||
import com.czg.entity.resp.*;
|
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||||
import com.czg.service.order.service.PayService;
|
import com.czg.service.order.service.PayService;
|
||||||
|
|
@ -13,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付
|
* 支付
|
||||||
*
|
*
|
||||||
|
|
@ -29,7 +30,7 @@ public class PayController {
|
||||||
* h5支付
|
* h5支付
|
||||||
*/
|
*/
|
||||||
@PostMapping("h5Pay")
|
@PostMapping("h5Pay")
|
||||||
public CzgResult<CzgH5PayResp> h5PayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> h5PayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||||
return payService.h5PayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
return payService.h5PayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,7 +41,7 @@ public class PayController {
|
||||||
* openId 必填
|
* openId 必填
|
||||||
*/
|
*/
|
||||||
@PostMapping("jsPay")
|
@PostMapping("jsPay")
|
||||||
public CzgResult<CzgJsPayResp> jsPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> jsPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||||
return payService.jsPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
return payService.jsPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +51,7 @@ public class PayController {
|
||||||
* openId 必填
|
* openId 必填
|
||||||
*/
|
*/
|
||||||
@PostMapping("ltPayOrder")
|
@PostMapping("ltPayOrder")
|
||||||
public CzgResult<CzgLtPayResp> ltPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> ltPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||||
return payService.ltPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
return payService.ltPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ public class PayController {
|
||||||
* 正扫
|
* 正扫
|
||||||
*/
|
*/
|
||||||
@PostMapping("scanPay")
|
@PostMapping("scanPay")
|
||||||
public CzgResult<CzgScanPayResp> scanPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> scanPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||||
return payService.scanPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
return payService.scanPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +68,7 @@ public class PayController {
|
||||||
* authCode 必填 扫描码
|
* authCode 必填 扫描码
|
||||||
*/
|
*/
|
||||||
@PostMapping("microPay")
|
@PostMapping("microPay")
|
||||||
public CzgResult<Object> microPayOrder(@Validated @RequestBody OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> microPayOrder(@Validated @RequestBody OrderPayParamDTO payParam) {
|
||||||
return payService.microPayOrder(payParam);
|
return payService.microPayOrder(payParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class CzgJsPayResp extends CzgBaseResp{
|
public class CzgJsPayResp extends CzgBaseResp {
|
||||||
|
|
||||||
private CzgPayInfo payInfo;
|
private CzgPayInfo payInfo;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,27 +16,27 @@ public interface PayService {
|
||||||
/**
|
/**
|
||||||
* h5支付
|
* h5支付
|
||||||
*/
|
*/
|
||||||
CzgResult<CzgH5PayResp> h5PayOrder(String clintIp, OrderPayParamDTO payParam);
|
CzgResult<Map<String, Object>> h5PayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* js支付
|
* js支付
|
||||||
*/
|
*/
|
||||||
CzgResult<CzgJsPayResp> jsPayOrder(String clintIp, OrderPayParamDTO payParam);
|
CzgResult<Map<String, Object>> jsPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序支付
|
* 小程序支付
|
||||||
*/
|
*/
|
||||||
CzgResult<CzgLtPayResp> ltPayOrder(String clintIp, OrderPayParamDTO payParam);
|
CzgResult<Map<String, Object>> ltPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PC扫码支付
|
* PC扫码支付
|
||||||
*/
|
*/
|
||||||
CzgResult<CzgScanPayResp> scanPayOrder(String clintIp, OrderPayParamDTO payParam);
|
CzgResult<Map<String, Object>> scanPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聚合反扫
|
* 聚合反扫
|
||||||
*/
|
*/
|
||||||
CzgResult<Object> microPayOrder(OrderPayParamDTO payParam);
|
CzgResult<Map<String, Object>> microPayOrder(OrderPayParamDTO payParam);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.czg.service.order.service.impl;
|
package com.czg.service.order.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.account.entity.ShopMerchant;
|
import com.czg.account.entity.ShopMerchant;
|
||||||
import com.czg.account.service.ShopMerchantService;
|
import com.czg.account.service.ShopMerchantService;
|
||||||
import com.czg.entity.req.*;
|
import com.czg.entity.req.*;
|
||||||
|
|
@ -24,6 +25,8 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ww
|
* @author ww
|
||||||
|
|
@ -48,7 +51,7 @@ public class PayServiceImpl implements PayService {
|
||||||
private final String refundJsonExtParam = "{\"payType\":\"1\"}";
|
private final String refundJsonExtParam = "{\"payType\":\"1\"}";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<CzgH5PayResp> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||||
|
|
@ -60,7 +63,7 @@ public class PayServiceImpl implements PayService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<CzgJsPayResp> jsPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> jsPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||||
|
|
@ -71,7 +74,7 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<CzgLtPayResp> ltPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> ltPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||||
|
|
@ -82,7 +85,7 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<CzgScanPayResp> scanPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> scanPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||||
|
|
@ -93,7 +96,7 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<Object> microPayOrder(OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> microPayOrder(OrderPayParamDTO payParam) {
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||||
|
|
@ -129,7 +132,7 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upOrderPayInfo(@NonNull Long orderId, @NotBlank String payType, @NotBlank String payOrderNo) {
|
private void upOrderPayInfo(@NonNull Long orderId, @NotBlank String payType, @NotBlank String payOrderNo) {
|
||||||
orderInfoService.updateChain().of(OrderInfo.class)
|
orderInfoService.updateChain()
|
||||||
.set(OrderInfo::getPayOrderNo, payOrderNo)
|
.set(OrderInfo::getPayOrderNo, payOrderNo)
|
||||||
.set(OrderInfo::getPayType, payType)
|
.set(OrderInfo::getPayType, payType)
|
||||||
.where(OrderInfo::getId).eq(orderId)
|
.where(OrderInfo::getId).eq(orderId)
|
||||||
|
|
@ -137,40 +140,43 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CzgResult<CzgH5PayResp> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) {
|
private CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) {
|
||||||
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||||
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
||||||
return czgPayService.h5Pay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
CzgResult<CzgH5PayResp> h5PayRespCzgResult = czgPayService.h5Pay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
return execPayResult(h5PayRespCzgResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<CzgJsPayResp> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData) {
|
private CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData) {
|
||||||
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
||||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||||
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
||||||
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
||||||
return czgPayService.jsPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
CzgResult<CzgJsPayResp> jsPayRespCzgResult = czgPayService.jsPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
return execPayResult(jsPayRespCzgResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<CzgLtPayResp> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) {
|
private CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) {
|
||||||
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
||||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||||
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
||||||
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
||||||
return czgPayService.ltPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
CzgResult<CzgLtPayResp> ltPayRespCzgResult = czgPayService.ltPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
return execPayResult(ltPayRespCzgResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<CzgScanPayResp> scanPay(@NonNull Long shopId, CzgScanPayReq bizData) {
|
private CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData) {
|
||||||
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||||
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
||||||
return czgPayService.scanPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
CzgResult<CzgScanPayResp> scanPayRespCzgResult = czgPayService.scanPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
return execPayResult(scanPayRespCzgResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Object> microPay(@NonNull Long shopId, CzgMicroPayReq bizData) {
|
private CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData) {
|
||||||
CzgResult<Object> result = CzgResult.success();
|
|
||||||
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||||
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
||||||
|
|
@ -189,19 +195,8 @@ public class PayServiceImpl implements PayService {
|
||||||
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
|
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
|
||||||
}
|
}
|
||||||
CzgResult<CzgMicroPayResp> czgScanPayResult = czgPayService.microPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
CzgResult<CzgMicroPayResp> czgScanPayResult = czgPayService.microPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
if (czgScanPayResult.getCode() != 200 || czgScanPayResult.getData() == null) {
|
|
||||||
result.setCode(500);
|
return execPayResult(czgScanPayResult);
|
||||||
result.setMsg(czgScanPayResult.getMsg());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
CzgMicroPayResp data = czgScanPayResult.getData();
|
|
||||||
result.setMsg(data.getNote());
|
|
||||||
if ("TRADE_SUCCESS".equals(data.getState())) {
|
|
||||||
result.setCode(200);
|
|
||||||
} else {
|
|
||||||
result.setCode(500);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
|
private CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
|
||||||
|
|
@ -209,4 +204,38 @@ public class PayServiceImpl implements PayService {
|
||||||
bizData.setNotifyUrl(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_REFUND_NOTIFY_URL.getCode()));
|
bizData.setNotifyUrl(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_REFUND_NOTIFY_URL.getCode()));
|
||||||
return czgPayService.refundOrder(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
return czgPayService.refundOrder(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CzgResult<Map<String, Object>> execPayResult(CzgResult<? extends CzgBaseResp> res) {
|
||||||
|
CzgResult<Map<String, Object>> result = CzgResult.success();
|
||||||
|
if (res.getCode() != 200 || res.getData() == null) {
|
||||||
|
result.setCode(500);
|
||||||
|
result.setMsg(res.getMsg());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
CzgBaseResp data = res.getData();
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
switch (data) {
|
||||||
|
case CzgMicroPayResp ignored -> {
|
||||||
|
if (!"TRADE_SUCCESS".equals(data.getState())) {
|
||||||
|
result.setCode(500);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
case CzgH5PayResp h5PayResp -> map = JSONObject.parseObject(JSONObject.toJSONString(h5PayResp.getPayInfo()));
|
||||||
|
case CzgJsPayResp jsPayResp -> map = JSONObject.parseObject(JSONObject.toJSONString(jsPayResp.getPayInfo()));
|
||||||
|
case CzgLtPayResp ltPayResp -> {
|
||||||
|
map.put("payInfo", JSONObject.toJSONString(ltPayResp.getPayInfo()));
|
||||||
|
map.put("liteInfo", JSONObject.toJSONString(ltPayResp.getLiteInfo()));
|
||||||
|
}
|
||||||
|
case CzgScanPayResp scanPayResp -> map = JSONObject.parseObject(JSONObject.toJSONString(scanPayResp.getPayInfo()));
|
||||||
|
default -> throw new IllegalStateException("Unexpected value: " + data);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.setData(map);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue