提交修改
This commit is contained in:
parent
4ad9532c6e
commit
33e140f5d6
@ -46,6 +46,7 @@ private static final long serialVersionUID = 1L;
|
||||
public final static String channel_ = CLASS_NAME + "channel"; // 渠道,如抖音,微信小程序,朋友圈,bilibili 等
|
||||
public final static String promoter_id = CLASS_NAME + "promoter_id"; // 推广者买家id
|
||||
public final static String trade_info = CLASS_NAME + "trade_info"; // 交易信息
|
||||
public final static String transaction_id = CLASS_NAME + "transaction_id"; // 事务id
|
||||
//
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
@ -97,6 +98,8 @@ private static final long serialVersionUID = 1L;
|
||||
private String promoterId;
|
||||
//交易信息
|
||||
private String tradeInfo;
|
||||
//事务id
|
||||
private String transactionId;
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
@ -472,6 +475,21 @@ private static final long serialVersionUID = 1L;
|
||||
this.tradeInfo = tradeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事务id
|
||||
* @return
|
||||
*/
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
/**
|
||||
* 事务id
|
||||
* @param transactionId
|
||||
*/
|
||||
public void setTransactionId(String transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VvTradeOrderEntity{" +
|
||||
@ -500,6 +518,7 @@ private static final long serialVersionUID = 1L;
|
||||
",channel=" + channel +
|
||||
",promoterId=" + promoterId +
|
||||
",tradeInfo=" + tradeInfo +
|
||||
",transactionId=" + transactionId +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class MysqlMain_update {
|
||||
List<TablesBean> list = new ArrayList<TablesBean>();
|
||||
|
||||
list.add(new TablesBean("vv_trade_order"));
|
||||
list.add(new TablesBean("vv_trade_order_line"));
|
||||
|
||||
|
||||
|
||||
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();
|
||||
|
||||
@ -2,22 +2,32 @@ package com.heyu.api.jsapi;
|
||||
|
||||
// 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/merchant/4014931831
|
||||
|
||||
import com.heyu.api.jsapi.dto.*;
|
||||
import com.heyu.api.data.dao.vv.VvReverseOrderDao;
|
||||
import com.heyu.api.data.dao.vv.VvTradeOrderDao;
|
||||
import com.heyu.api.data.entity.vv.VvReverseOrderEntity;
|
||||
import com.heyu.api.data.entity.vv.VvTradeOrderEntity;
|
||||
import com.heyu.api.data.utils.BigDecimalUtil;
|
||||
import com.heyu.api.jsapi.dto.close.CloseOrderRequest;
|
||||
import com.heyu.api.jsapi.dto.pay.*;
|
||||
import com.heyu.api.jsapi.dto.refund.*;
|
||||
import com.heyu.api.jsapi.dto.refund.query.QueryByOutRefundNoRequest;
|
||||
import com.heyu.api.jsapi.utils.PemUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import java.security.Signature;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -28,12 +38,6 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class JsapiPrepay {
|
||||
|
||||
private static String HOST = "https://api.mch.weixin.qq.com";
|
||||
|
||||
private static String METHOD = "POST";
|
||||
|
||||
private static String PATH = "/v3/pay/transactions/jsapi";
|
||||
|
||||
@Value("${eb.config.weixin.pay.appid}")
|
||||
private String appid;
|
||||
|
||||
@ -50,10 +54,23 @@ public class JsapiPrepay {
|
||||
private PublicKey wechatPayPublicKey;
|
||||
|
||||
|
||||
@Autowired
|
||||
private VvTradeOrderDao vvTradeOrderDao;
|
||||
|
||||
@Autowired
|
||||
private VvReverseOrderDao vvReverseOrderDao;
|
||||
|
||||
|
||||
|
||||
|
||||
@Value("${eb.config.weixin.pay.notifyUrl}")
|
||||
private String notifyUrl;
|
||||
|
||||
|
||||
|
||||
@Value("${eb.config.weixin.pay.refundNotifyUrl}")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
public JsapiPrepay() {
|
||||
|
||||
}
|
||||
@ -77,6 +94,10 @@ public class JsapiPrepay {
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* https://pay.weixin.qq.com/doc/v3/merchant/4012791897
|
||||
* JSAPI/小程序下单
|
||||
*/
|
||||
public DirectAPIv3JsapiPrepayResponse prePay(Long tradeOrderId,
|
||||
Long amount,
|
||||
String openid) {
|
||||
@ -101,9 +122,12 @@ public class JsapiPrepay {
|
||||
return doPay(request);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 商户订单号查询订单
|
||||
*
|
||||
* https://pay.weixin.qq.com/doc/v3/merchant/4012791900
|
||||
*/
|
||||
public DirectAPIv3QueryResponse queryOrder(String transactionId) {
|
||||
|
||||
QueryByWxTradeNoRequest request = new QueryByWxTradeNoRequest();
|
||||
request.transactionId = transactionId;
|
||||
request.mchid = mchid;
|
||||
@ -143,6 +167,10 @@ public class JsapiPrepay {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭订单
|
||||
* https://pay.weixin.qq.com/doc/v3/merchant/4012791901
|
||||
*/
|
||||
public void close(String tradeOrderId) {
|
||||
String HOST = "https://api.mch.weixin.qq.com";
|
||||
String METHOD = "POST";
|
||||
@ -170,7 +198,6 @@ public class JsapiPrepay {
|
||||
// 2XX 成功,验证应答签名
|
||||
WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
|
||||
httpResponse.headers(), respBody);
|
||||
|
||||
return;
|
||||
} else {
|
||||
throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
|
||||
@ -180,11 +207,128 @@ public class JsapiPrepay {
|
||||
}
|
||||
}
|
||||
|
||||
/****
|
||||
* https://pay.weixin.qq.com/doc/v3/merchant/4012791903
|
||||
* 退款申请
|
||||
*/
|
||||
public Refund refund(Long tradeOrderId, Long reverseOrderId) {
|
||||
VvTradeOrderEntity vvTradeOrderEntity = vvTradeOrderDao.selectVvTradeOrderById(tradeOrderId);
|
||||
VvReverseOrderEntity vvReverseOrderEntity = vvReverseOrderDao.selectVvReverseOrderById(reverseOrderId);
|
||||
CreateRequest request = new CreateRequest();
|
||||
request.transactionId = vvTradeOrderEntity.getTransactionId(); // 【微信支付订单号】 微信支付侧订单的唯一标识,订单支付成功后,查询订单和支付成功回调通知会返回该参数。transaction_id和out_trade_no必须二选一进行传参。
|
||||
request.outTradeNo = tradeOrderId + ""; // 【商户订单号】 商户下单时传入的商户系统内部订单号。transaction_id和out_trade_no必须二选一进行传参。
|
||||
request.outRefundNo = reverseOrderId + ""; //【商户退款单号】 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一商户退款单号多次请求只退一笔。不可超过64个字节数。
|
||||
request.reason = vvReverseOrderEntity.getRefundReason(); // 【退款原因】 若商户传了退款原因,该原因将在下发给用户的退款消息中显示,具体展示可参见退款通知UI示意图。请注意:1、该退款原因参数的长度不得超过80个字节;2、当订单退款金额小于等于1元且为部分退款时,退款原因将不会在消息中体现。
|
||||
request.notifyUrl = refundNotifyUrl; // 【退款结果回调url】 异步接收微信支付退款结果通知的回调地址,通知url必须为外网可访问的url,不能携带参数。 如果传了该参数,则商户平台上配置的回调地址(商户平台-交易中心-退款管理-退款配置)将不会生效,优先回调当前传的这个地址。
|
||||
/**
|
||||
* AVAILABLE: 仅对旧资金流商户适用(请参考旧资金流介绍区分),传此枚举指定从可用余额账户出资,否则默认使用未结算资金退款。
|
||||
* UNSETTLED: 仅对出行预付押金退款适用,指定从未结算资金出资。
|
||||
*/
|
||||
request.fundsAccount = ReqFundsAccount.AVAILABLE; // 【退款资金来源】 若传递此参数则使用对应的资金账户退款。
|
||||
// 【金额信息】订单退款金额信息
|
||||
request.amount = new AmountReq();
|
||||
|
||||
Long refundAmount = BigDecimalUtil.multiply(vvReverseOrderEntity.getRefundAmount(), new BigDecimal(100)).longValue();
|
||||
Long tradeOrderAmount = BigDecimalUtil.multiply(vvTradeOrderEntity.getAllPrice(), new BigDecimal(100)).longValue();
|
||||
|
||||
request.amount.refund =refundAmount; // 【退款金额】 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。
|
||||
// 【退款出资账户及金额】退款需从指定账户出资时,可传递该参数以指定出资金额(币种最小单位,仅限整数)。
|
||||
// 多账户出资退款需满足:1、未开通退款支出分离功能;2、订单为待分账或分账中的分账订单。
|
||||
// 传递参数需确保:1、基本账户可用与不可用余额之和等于退款金额;2、账户类型不重复。不符条件将返回错误。
|
||||
request.amount.from = new ArrayList<>();
|
||||
{
|
||||
FundsFromItem fromItem = new FundsFromItem();
|
||||
fromItem.account = Account.AVAILABLE; // 【出资账户类型】 退款出资的账户类型。
|
||||
fromItem.amount = refundAmount; // AVAILABLE : 可用余额
|
||||
request.amount.from.add(fromItem); // 【出资金额】对应账户出资金额
|
||||
};
|
||||
|
||||
request.amount.total = tradeOrderAmount; // 必填 【原订单金额】 原支付交易的订单总金额,币种的最小单位,只能为整数
|
||||
request.amount.currency = "CNY"; // 必填 【退款币种】 符合ISO 4217标准的三位字母代码,固定传:CNY,代表人民币。
|
||||
String HOST = refundNotifyUrl;
|
||||
String METHOD = "POST";
|
||||
String PATH = "/v3/refund/domestic/refunds";
|
||||
String uri = PATH;
|
||||
|
||||
String reqBody = WXPayUtility.toJson(request);
|
||||
Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
|
||||
reqBuilder.addHeader("Accept", "application/json");
|
||||
reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
|
||||
reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, reqBody));
|
||||
reqBuilder.addHeader("Content-Type", "application/json");
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody);
|
||||
reqBuilder.method(METHOD, requestBody);
|
||||
Request httpRequest = reqBuilder.build();
|
||||
|
||||
// 发送HTTP请求
|
||||
OkHttpClient client = new OkHttpClient.Builder().build();
|
||||
try (Response httpResponse = client.newCall(httpRequest).execute()) {
|
||||
String respBody = WXPayUtility.extractBody(httpResponse);
|
||||
if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
|
||||
// 2XX 成功,验证应答签名
|
||||
WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
|
||||
httpResponse.headers(), respBody);
|
||||
|
||||
// 从HTTP应答报文构建返回数据
|
||||
return WXPayUtility.fromJson(respBody, Refund.class);
|
||||
} else {
|
||||
throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* https://pay.weixin.qq.com/doc/v3/merchant/4012791904
|
||||
*查询单笔退款(通过商户退款单号)
|
||||
*
|
||||
* 提交退款申请后,推荐每间隔1分钟调用该接口查询一次退款状态,若超过5分钟仍是退款处理中状态,建议开始逐步衰减查询频率(比如之后间隔5分钟、10分钟、20分钟、30分钟……查询一次)。
|
||||
*
|
||||
* 退款有一定延时,零钱支付的订单退款一般5分钟内到账,银行卡支付的订单退款一般1-3个工作日到账。
|
||||
*
|
||||
* 同一商户号查询退款频率限制为300qps,如返回FREQUENCY_LIMITED频率限制报错可间隔1分钟再重试查询。
|
||||
*/
|
||||
public Refund queryRefund(String reverseOrderId) {
|
||||
String HOST = "https://api.mch.weixin.qq.com";
|
||||
String METHOD = "GET";
|
||||
String PATH = "/v3/refund/domestic/refunds/{out_refund_no}";
|
||||
QueryByOutRefundNoRequest request = new QueryByOutRefundNoRequest();
|
||||
request.outRefundNo = reverseOrderId + ""; // 【商户退款单号】 商户申请退款时传入的商户系统内部退款单号。
|
||||
String uri = PATH;
|
||||
uri = uri.replace("{out_refund_no}", WXPayUtility.urlEncode(request.outRefundNo));
|
||||
Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
|
||||
reqBuilder.addHeader("Accept", "application/json");
|
||||
reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
|
||||
reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null));
|
||||
reqBuilder.method(METHOD, null);
|
||||
Request httpRequest = reqBuilder.build();
|
||||
|
||||
// 发送HTTP请求
|
||||
OkHttpClient client = new OkHttpClient.Builder().build();
|
||||
try (Response httpResponse = client.newCall(httpRequest).execute()) {
|
||||
String respBody = WXPayUtility.extractBody(httpResponse);
|
||||
if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
|
||||
// 2XX 成功,验证应答签名
|
||||
WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
|
||||
httpResponse.headers(), respBody);
|
||||
|
||||
// 从HTTP应答报文构建返回数据
|
||||
return WXPayUtility.fromJson(respBody, Refund.class);
|
||||
} else {
|
||||
throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DirectAPIv3JsapiPrepayResponse doPay(DirectAPIv3JsapiPrepayRequest request) {
|
||||
String HOST = "https://api.mch.weixin.qq.com";
|
||||
String METHOD = "POST";
|
||||
String PATH = "/v3/pay/transactions/jsapi";
|
||||
String uri = PATH;
|
||||
String reqBody = WXPayUtility.toJson(request);
|
||||
Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.close;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
package com.heyu.api.jsapi.dto.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum Account {
|
||||
@SerializedName("AVAILABLE")
|
||||
AVAILABLE,
|
||||
@SerializedName("UNAVAILABLE")
|
||||
UNAVAILABLE
|
||||
}
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Amount {
|
||||
@SerializedName("total")
|
||||
public Long total;
|
||||
|
||||
@SerializedName("refund")
|
||||
public Long refund;
|
||||
|
||||
@SerializedName("from")
|
||||
public List<FundsFromItem> from;
|
||||
|
||||
@SerializedName("payer_total")
|
||||
public Long payerTotal;
|
||||
|
||||
@SerializedName("payer_refund")
|
||||
public Long payerRefund;
|
||||
|
||||
@SerializedName("settlement_refund")
|
||||
public Long settlementRefund;
|
||||
|
||||
@SerializedName("settlement_total")
|
||||
public Long settlementTotal;
|
||||
|
||||
@SerializedName("discount_refund")
|
||||
public Long discountRefund;
|
||||
|
||||
@SerializedName("currency")
|
||||
public String currency;
|
||||
|
||||
@SerializedName("refund_fee")
|
||||
public Long refundFee;
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AmountReq {
|
||||
@SerializedName("refund")
|
||||
public Long refund;
|
||||
|
||||
@SerializedName("from")
|
||||
public List<FundsFromItem> from;
|
||||
|
||||
@SerializedName("total")
|
||||
public Long total;
|
||||
|
||||
@SerializedName("currency")
|
||||
public String currency;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum Channel {
|
||||
@SerializedName("ORIGINAL")
|
||||
ORIGINAL,
|
||||
@SerializedName("BALANCE")
|
||||
BALANCE,
|
||||
@SerializedName("OTHER_BALANCE")
|
||||
OTHER_BALANCE,
|
||||
@SerializedName("OTHER_BANKCARD")
|
||||
OTHER_BANKCARD
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.heyu.api.jsapi.dto.pay.GoodsDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreateRequest {
|
||||
@SerializedName("transaction_id")
|
||||
public String transactionId;
|
||||
|
||||
@SerializedName("out_trade_no")
|
||||
public String outTradeNo;
|
||||
|
||||
@SerializedName("out_refund_no")
|
||||
public String outRefundNo;
|
||||
|
||||
@SerializedName("reason")
|
||||
public String reason;
|
||||
|
||||
@SerializedName("notify_url")
|
||||
public String notifyUrl;
|
||||
|
||||
@SerializedName("funds_account")
|
||||
public ReqFundsAccount fundsAccount;
|
||||
|
||||
@SerializedName("amount")
|
||||
public AmountReq amount;
|
||||
|
||||
@SerializedName("goods_detail")
|
||||
public List<GoodsDetail> goodsDetail;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum FundsAccount {
|
||||
@SerializedName("UNSETTLED")
|
||||
UNSETTLED,
|
||||
@SerializedName("AVAILABLE")
|
||||
AVAILABLE,
|
||||
@SerializedName("UNAVAILABLE")
|
||||
UNAVAILABLE,
|
||||
@SerializedName("OPERATION")
|
||||
OPERATION,
|
||||
@SerializedName("BASIC")
|
||||
BASIC,
|
||||
@SerializedName("ECNY_BASIC")
|
||||
ECNY_BASIC
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
public static class FundsFromItem {
|
||||
@SerializedName("account")
|
||||
public Account account;
|
||||
|
||||
@SerializedName("amount")
|
||||
public Long amount;
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.heyu.api.jsapi.dto.pay.GoodsDetail;
|
||||
|
||||
public class Promotion {
|
||||
@SerializedName("promotion_id")
|
||||
public String promotionId;
|
||||
|
||||
@SerializedName("scope")
|
||||
public PromotionScope scope;
|
||||
|
||||
@SerializedName("type")
|
||||
public PromotionType type;
|
||||
|
||||
@SerializedName("amount")
|
||||
public Long amount;
|
||||
|
||||
@SerializedName("refund_amount")
|
||||
public Long refundAmount;
|
||||
|
||||
@SerializedName("goods_detail")
|
||||
public List<GoodsDetail> goodsDetail;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum PromotionScope {
|
||||
@SerializedName("GLOBAL")
|
||||
GLOBAL,
|
||||
@SerializedName("SINGLE")
|
||||
SINGLE
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum PromotionType {
|
||||
@SerializedName("CASH")
|
||||
CASH,
|
||||
@SerializedName("NOCASH")
|
||||
NOCASH
|
||||
}
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Refund {
|
||||
@SerializedName("refund_id")
|
||||
public String refundId;
|
||||
|
||||
@SerializedName("out_refund_no")
|
||||
public String outRefundNo;
|
||||
|
||||
@SerializedName("transaction_id")
|
||||
public String transactionId;
|
||||
|
||||
@SerializedName("out_trade_no")
|
||||
public String outTradeNo;
|
||||
|
||||
@SerializedName("channel")
|
||||
public Channel channel;
|
||||
|
||||
@SerializedName("user_received_account")
|
||||
public String userReceivedAccount;
|
||||
|
||||
@SerializedName("success_time")
|
||||
public String successTime;
|
||||
|
||||
@SerializedName("create_time")
|
||||
public String createTime;
|
||||
|
||||
@SerializedName("status")
|
||||
public Status status;
|
||||
|
||||
@SerializedName("funds_account")
|
||||
public FundsAccount fundsAccount;
|
||||
|
||||
@SerializedName("amount")
|
||||
public Amount amount;
|
||||
|
||||
@SerializedName("promotion_detail")
|
||||
public List<Promotion> promotionDetail;
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum ReqFundsAccount {
|
||||
@SerializedName("AVAILABLE")
|
||||
AVAILABLE,
|
||||
@SerializedName("UNSETTLED")
|
||||
UNSETTLED
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package com.heyu.api.jsapi.dto.refund;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum Status {
|
||||
@SerializedName("SUCCESS")
|
||||
SUCCESS,
|
||||
@SerializedName("CLOSED")
|
||||
CLOSED,
|
||||
@SerializedName("PROCESSING")
|
||||
PROCESSING,
|
||||
@SerializedName("ABNORMAL")
|
||||
ABNORMAL
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.heyu.api.jsapi.dto.refund.query;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class QueryByOutRefundNoRequest {
|
||||
@SerializedName("out_refund_no")
|
||||
@Expose(serialize = false)
|
||||
public String outRefundNo;
|
||||
|
||||
}
|
||||
|
||||
@ -16,8 +16,8 @@ import com.heyu.api.data.enums.DelayTypeEnums;
|
||||
import com.heyu.api.data.enums.RoleEnums;
|
||||
import com.heyu.api.data.utils.*;
|
||||
import com.heyu.api.jsapi.JsapiPrepay;
|
||||
import com.heyu.api.jsapi.dto.DirectAPIv3JsapiPrepayResponse;
|
||||
import com.heyu.api.jsapi.dto.WxPayVO;
|
||||
import com.heyu.api.jsapi.dto.pay.DirectAPIv3JsapiPrepayResponse;
|
||||
import com.heyu.api.jsapi.dto.pay.WxPayVO;
|
||||
import com.heyu.api.utils.ISelect;
|
||||
import com.heyu.api.utils.PPageUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -91,10 +91,6 @@ public class AppOrderController {
|
||||
@Value("${eb.config.weixin.pay.privateKeyFilePath}")
|
||||
private String privateKey;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* https://api.1024api.com/api-interface/app/order/list
|
||||
*
|
||||
|
||||
@ -12,8 +12,7 @@ import com.heyu.api.data.entity.vv.VvTradeOrderEntity;
|
||||
import com.heyu.api.data.entity.vv.VvTradeOrderLineEntity;
|
||||
import com.heyu.api.data.utils.NumberUtil;
|
||||
import com.heyu.api.jsapi.JsapiPrepay;
|
||||
import com.heyu.api.jsapi.dto.DirectAPIv3QueryResponse;
|
||||
import com.heyu.api.jsapi.dto.QueryByWxTradeNoRequest;
|
||||
import com.heyu.api.jsapi.dto.pay.DirectAPIv3QueryResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -91,7 +90,7 @@ public class AppWeiXinPayNotifyController {
|
||||
// AES-GCM解密方法
|
||||
private String decrypt(String ciphertext, String associatedData, String nonce) throws Exception {
|
||||
// 将APIv3密钥转为字节数组
|
||||
byte[] key = apiv3key.getBytes(StandardCharsets.UTF_8)
|
||||
byte[] key = apiv3key.getBytes(StandardCharsets.UTF_8);
|
||||
Key secretKey = new SecretKeySpec(key, "AES");
|
||||
|
||||
// 使用AES-GCM解密
|
||||
@ -107,11 +106,10 @@ public class AppWeiXinPayNotifyController {
|
||||
|
||||
private void updateOrderStatus(String outTradeNo, String transactionId) {
|
||||
try {
|
||||
|
||||
DirectAPIv3QueryResponse response = jsapiPrepay.queryOrder(transactionId);
|
||||
|
||||
VvTradeOrderEntity tradeOrderEntity = tradeOrderDao.selectVvTradeOrderById(NumberUtil.objToLong(outTradeNo));
|
||||
tradeOrderEntity.setTradeInfo(JSON.toJSONString(response));
|
||||
tradeOrderEntity.setTransactionId(transactionId);
|
||||
tradeOrderDao.updateVvTradeOrderById(tradeOrderEntity);
|
||||
}catch ( Exception e ){
|
||||
log.error("AppWeiXinPayNotifyController updateOrderStatus error:{}",e.getMessage());
|
||||
|
||||
@ -74,10 +74,7 @@ eb:
|
||||
appid: wx75fa59c097bd3dfd
|
||||
notifyUrl: https://api.1024api.com/api-interface/app/weixin/payNotify
|
||||
apiv3key: E938F17ABF6843743F49688269F73B7D
|
||||
|
||||
|
||||
|
||||
|
||||
refundNotifyUrl: https://api.1024api.com/api-interface/app/weixin/refundNotify
|
||||
|
||||
|
||||
tencent:
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.api.test;
|
||||
|
||||
import com.heyu.api.jsapi.WXPayUtility;
|
||||
import com.heyu.api.jsapi.dto.DirectAPIv3QueryResponse;
|
||||
import com.heyu.api.jsapi.dto.QueryByWxTradeNoRequest;
|
||||
import com.heyu.api.jsapi.dto.pay.DirectAPIv3QueryResponse;
|
||||
import com.heyu.api.jsapi.dto.pay.QueryByWxTradeNoRequest;
|
||||
|
||||
public class JSAPIQueryTest {
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.api.test;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.heyu.api.jsapi.JsapiPrepay;
|
||||
import com.heyu.api.jsapi.WXPayUtility;
|
||||
import com.heyu.api.jsapi.dto.*;
|
||||
import com.heyu.api.jsapi.dto.pay.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -3,7 +3,7 @@ package com.api.test;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.heyu.api.jsapi.JsapiPrepay;
|
||||
import com.heyu.api.jsapi.WXPayUtility;
|
||||
import com.heyu.api.jsapi.dto.*;
|
||||
import com.heyu.api.jsapi.dto.pay.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user