进件 支付调整
This commit is contained in:
@@ -13,11 +13,13 @@ import com.czg.entity.CzgBaseRespParams;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.*;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -35,9 +37,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgH5PayResp>
|
||||
*/
|
||||
public static CzgResult<CzgH5PayResp> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class);
|
||||
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,9 +49,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgJsPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgJsPayResp> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,9 +61,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgLtPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgLtPayResp> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,9 +73,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgScanPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgScanPayResp> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,9 +85,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgMicroPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgMicroPayResp> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,51 +236,41 @@ public class CzgPayUtils {
|
||||
}
|
||||
return sortParam;
|
||||
}
|
||||
private static 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();
|
||||
|
||||
// public static void main(String[] args) {
|
||||
//// String appId = "66691a6afdf641f0bf1dc701";
|
||||
// String appId = "66e3dd399a7621f45a6293c1";
|
||||
//// String appSecret = "jikd52TefZcSPI5hRWrfPSpQcXZrbqshbnLmqH6UattqspIDEzjbGvZmfwTW58RMf1XuPhN4zE1GbIjKy3b1oabgOx5n79faT93Si6i7g2IPSQJAln2NNsCSNynHIJ8";
|
||||
// String appSecret = "2p7TCixkN3FuhTqJyr23GNAfrqAqUt84T1IOSunCEEqFBP9gVkSO8CqrfNwNAJqLYuWmQou7lbwdW0Lb4zJVkBEdV7CPq3VhnbGDRIpQXpBNPOjJbor1IFGuLLOA7oll";
|
||||
// CzgJsPayReq bizData = new CzgJsPayReq("20250428150248328893", 100L,
|
||||
// "订单支付", "or1l867cx6JFbLgmppwtG46AUhwg","1.80.211.145", "http://store.sxczgkj.com/h5/#/pages/user-order/user-order", "", "");
|
||||
// bizData.setCurrency("cny");
|
||||
// bizData.setPayType("WECHAT");
|
||||
// bizData.setSubAppid("wxd88fffa983758a30");
|
||||
//
|
||||
// bizData.setSubject("订单支付");
|
||||
//// bizData.setStoreId("S2409148611");
|
||||
// bizData.setStoreId("S2406120331");
|
||||
//
|
||||
// CzgBaseReqParams params = CzgBaseReqParams.getInstance(appId, appSecret, bizData);
|
||||
// params.setVersion("1.0");
|
||||
// params.setReqId("57143686759273485473");
|
||||
// params.setReqTime("20250428150248");
|
||||
// params.setSignType("MD5");
|
||||
// CzgResult<CzgH5PayResp> czgH5PayRespCzgResult = sendCzg("https://paymentapi.sxczgkj.cn/api/open/payment/jspay", params, CzgH5PayResp.class);
|
||||
// System.out.println(czgH5PayRespCzgResult);
|
||||
// }
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
switch (data) {
|
||||
case CzgMicroPayResp ignored -> {
|
||||
if ("TRADE_SUCCESS".equals(data.getState())) {
|
||||
return result;
|
||||
} else if ("TRADE_AWAIT".equals(data.getState())) {
|
||||
result.setCode(CzgRespCode.WAIT_PAY.getCode());
|
||||
result.setMsg("等待用户付款");
|
||||
} else {
|
||||
result.setCode(CzgRespCode.FAILURE.getCode());
|
||||
}
|
||||
}
|
||||
case CzgH5PayResp h5PayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(h5PayResp.getPayInfo()));
|
||||
case CzgJsPayResp jsPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(jsPayResp.getPayInfo()));
|
||||
case CzgLtPayResp ltPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(ltPayResp.getPayInfo()));
|
||||
case CzgScanPayResp scanPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(scanPayResp.getPayInfo()));
|
||||
default -> throw new IllegalStateException("Unexpected value: " + data);
|
||||
}
|
||||
|
||||
result.setData(map);
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// CzgResult<Object> result = CzgResult.success();
|
||||
// CzgBaseRespParams respParams = new CzgBaseRespParams();
|
||||
// respParams.setCode("000000");
|
||||
// respParams.setMsg("成功");
|
||||
// respParams.setSign("6c0f1e11b0d3a16298c2dfeee8c1491a");
|
||||
// respParams.setBizData("{\"amount\":500,\"currency\":\"cny\",\"ifCode\":\"lklspay\",\"mchOrderNo\":\"WX1889977729515615615\",\"mercNo\":\"B240612563201\",\"note\":\"成功\",\"payOrderId\":\"202502151890598483156443138V6W\",\"payType\":\"WECHAT\",\"settlementType\":\"D1\",\"state\":\"TRADE_SUCCESS\",\"storeId\":\"S2406125309\",\"subject\":\"超掌柜\",\"tradeFee\":2}");
|
||||
// respParams.setTimestamp("20250215110620");
|
||||
// log.info("超掌柜交易请求响应,{}", respParams);
|
||||
//
|
||||
// result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
|
||||
// result.setMsg(respParams.getMsg());
|
||||
// if ("000000".equals(respParams.getCode()) && StrUtil.isNotBlank(respParams.getSign())) {
|
||||
// if (validateSign(respParams.getSign(), JSONObject.toJSONString(respParams))) {
|
||||
// log.info("验签失败");
|
||||
// }
|
||||
// result.setData(JSONObject.parseObject(respParams.getBizData(), CzgMicroPayResp.class));
|
||||
// }
|
||||
// System.out.println(JSONObject.toJSONString(result));
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user