--9.18
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
package com.peanut.modules.pay.applePay.utils;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//购买所需参数类
|
||||
@ApiModel(value = "支付数据字段对比")
|
||||
@Data
|
||||
@AllArgsConstructor //有参数的构造方法
|
||||
@NoArgsConstructor //无参构造方法
|
||||
public class AddIosOrderPM implements Serializable {
|
||||
|
||||
//
|
||||
// /**
|
||||
// * ios支付所需参数
|
||||
// */
|
||||
// private String receipt;
|
||||
//
|
||||
// /**
|
||||
// * 用户id
|
||||
// */
|
||||
// private Integer userId;
|
||||
//
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 交易编号
|
||||
* eg:1000000852134037 交易唯一标识符;
|
||||
*/
|
||||
private String transaction_id;
|
||||
/**
|
||||
* APP所有权类型 eg: PURCHASED为沙箱环境
|
||||
* eg:PURCHASED
|
||||
*/
|
||||
private String in_app_ownership_type;
|
||||
/**
|
||||
* 原来的交易编号 原始购买标识符
|
||||
* eg:1000000852108057
|
||||
*/
|
||||
private String original_transaction_id;
|
||||
/**
|
||||
* 数量
|
||||
* eg:1 购买消耗品的数量
|
||||
*/
|
||||
private String quantity;
|
||||
/**
|
||||
* 唯一标识符
|
||||
* eg:1e10a9ec617549f986765b8546eddd0a9f349f15
|
||||
*/
|
||||
private String unique_identifier;
|
||||
/**
|
||||
* item_id
|
||||
* eg:1578853844
|
||||
*/
|
||||
private String item_id;
|
||||
/**
|
||||
* 处于介绍报价期
|
||||
* eg:false
|
||||
*/
|
||||
private String is_in_intro_offer_period;
|
||||
/**
|
||||
* 购买日期
|
||||
* eg:2021-08-02 03:57:56 America/Los_Angeles
|
||||
*/
|
||||
private String purchase_date_pst;
|
||||
/**
|
||||
* 原始购买日期 ms
|
||||
* eg:1627900203000
|
||||
*/
|
||||
private String original_purchase_date_ms;
|
||||
/**
|
||||
* 原始购买日期
|
||||
* eg:2021-08-02 03:30:03 America/Los_Angeles 太平洋时区
|
||||
*/
|
||||
private String original_purchase_date_pst;
|
||||
/**
|
||||
* 是试用期
|
||||
* eg:false
|
||||
*/
|
||||
private String is_trial_period;
|
||||
/**
|
||||
* 原始购买日期
|
||||
* eg:2021-08-02 10:30:03 Etc/GMT 原始购买时间 ISO 8601日期格式
|
||||
*/
|
||||
private String original_purchase_date;
|
||||
/**
|
||||
* 购买日期ms 时间日期
|
||||
*/
|
||||
private String purchase_date_ms;
|
||||
/**
|
||||
* 产品id 购买产品唯一标识符
|
||||
* eg:2
|
||||
*/
|
||||
private String product_id;
|
||||
private String bvrs;
|
||||
/**
|
||||
* 购买日期
|
||||
* eg:2021-08-02 10:57:56 Etc/GMT 时间日期
|
||||
*/
|
||||
private String purchase_date;
|
||||
private String bid;
|
||||
/**
|
||||
* 唯一供应商标识符
|
||||
* eg:A1D7647F-019C-4D15-A23C-3A48CFBFF4E3
|
||||
*/
|
||||
private String unique_vendor_identifier;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.peanut.modules.pay.applePay.utils;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IPayNotifyPo {
|
||||
@ApiModelProperty("苹果支付凭证")
|
||||
private String transactionReceipt;
|
||||
|
||||
@ApiModelProperty("苹果支付单号")
|
||||
private String payId;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("金额id")
|
||||
private String moneyId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.peanut.modules.pay.applePay.utils;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("订单号")
|
||||
public class TsBill implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
// @ApiModelProperty("苹果支付凭证")
|
||||
// private String transactionReceipt;
|
||||
//
|
||||
// @ApiModelProperty("苹果支付单号")
|
||||
// private String payId;
|
||||
// iOS端支付完成,苹果返回给iOS端的那个receiptData app返回的数据
|
||||
// @ApiModelProperty("用户id")
|
||||
// private String userId;
|
||||
//
|
||||
// @ApiModelProperty("金额id")
|
||||
// private String moneyId;
|
||||
// @ApiModelProperty("")
|
||||
// private String currentState;
|
||||
// @ApiModelProperty("IOS内购商品Id")
|
||||
// private String product_id; // IOS内购商品Id
|
||||
// @ApiModelProperty("应用内购买的时间")
|
||||
// private String purchase_date_pst; // 应用内购买的时间
|
||||
// @ApiModelProperty("购买的消费品数量")
|
||||
// private String quantity; // 购买的消费品数量
|
||||
// @ApiModelProperty("交易的唯一标识符")
|
||||
// private String transaction_id; //
|
||||
//
|
||||
// @ApiModelProperty("支付时间")
|
||||
// private String purchase_date_ms; //
|
||||
// @ApiModelProperty("拿到收据的MD5")
|
||||
// private String receiptMd5; //
|
||||
// @ApiModelProperty("拿到收据的MD5")
|
||||
// private String BillNum; //
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
private String id;
|
||||
@ApiModelProperty("用户ID")
|
||||
private String usersId;
|
||||
@ApiModelProperty("充值配置ID")
|
||||
private String paymentConfigId;
|
||||
@ApiModelProperty("交易单号,根据当前的28位当前时间加上11位随机数字对上的")
|
||||
private String billNum;
|
||||
@ApiModelProperty("交易号")
|
||||
private String tradeNo;
|
||||
@ApiModelProperty("账单生成方式,比如充值,说说币之类的")
|
||||
private String billContent;
|
||||
@ApiModelProperty("账单对应的金额id")
|
||||
private String billSumofmoney;
|
||||
@ApiModelProperty("账单类型还是充值")
|
||||
private Integer billState;
|
||||
@ApiModelProperty(" 当前状态,0是支付失败,1是支付成功,10是待支付")
|
||||
private Integer currentState;
|
||||
@ApiModelProperty("支付方式,0是虚拟币,1是支付宝,2是微信,3是ios")
|
||||
private Integer paymentMethod;
|
||||
@ApiModelProperty("收据MD5,仅ios可用")
|
||||
private String receipt;
|
||||
@ApiModelProperty("创集时间")
|
||||
private String createtdate;
|
||||
@ApiModelProperty("修改时间")
|
||||
private String updatedate;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.pay.applePay.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author talkmate
|
||||
*/
|
||||
@Mapper
|
||||
public interface TsBillMapper extends BaseMapper<TsBill>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.peanut.modules.pay.wechat.util;
|
||||
|
||||
import org.apache.http.Consts;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.SSLContextBuilder;
|
||||
import org.apache.http.conn.ssl.TrustStrategy;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.io.IOException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* http请求客户端
|
||||
*/
|
||||
public class HttpClientUtils {
|
||||
private String url;
|
||||
private Map<String, String> param;
|
||||
private int statusCode;
|
||||
private String content;
|
||||
private String xmlParam;
|
||||
private boolean isHttps;
|
||||
|
||||
public boolean isHttps() {
|
||||
return isHttps;
|
||||
}
|
||||
|
||||
public void setHttps(boolean isHttps) {
|
||||
this.isHttps = isHttps;
|
||||
}
|
||||
|
||||
public String getXmlParam() {
|
||||
return xmlParam;
|
||||
}
|
||||
|
||||
public void setXmlParam(String xmlParam) {
|
||||
this.xmlParam = xmlParam;
|
||||
}
|
||||
|
||||
public HttpClientUtils(String url, Map<String, String> param) {
|
||||
this.url = url;
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
public HttpClientUtils(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setParameter(Map<String, String> map) {
|
||||
param = map;
|
||||
}
|
||||
|
||||
public void addParameter(String key, String value) {
|
||||
if (param == null)
|
||||
param = new HashMap<String, String>();
|
||||
param.put(key, value);
|
||||
}
|
||||
|
||||
public void post() throws ClientProtocolException, IOException {
|
||||
HttpPost http = new HttpPost(url);
|
||||
setEntity(http);
|
||||
execute(http);
|
||||
}
|
||||
|
||||
public void put() throws ClientProtocolException, IOException {
|
||||
HttpPut http = new HttpPut(url);
|
||||
setEntity(http);
|
||||
execute(http);
|
||||
}
|
||||
|
||||
public void get() throws ClientProtocolException, IOException {
|
||||
if (param != null) {
|
||||
StringBuilder url = new StringBuilder(this.url);
|
||||
boolean isFirst = true;
|
||||
for (String key : param.keySet()) {
|
||||
if (isFirst) {
|
||||
url.append("?");
|
||||
isFirst = false;
|
||||
}else {
|
||||
url.append("&");
|
||||
}
|
||||
url.append(key).append("=").append(param.get(key));
|
||||
}
|
||||
this.url = url.toString();
|
||||
}
|
||||
HttpGet http = new HttpGet(url);
|
||||
execute(http);
|
||||
}
|
||||
|
||||
/**
|
||||
* set http post,put param
|
||||
*/
|
||||
private void setEntity(HttpEntityEnclosingRequestBase http) {
|
||||
if (param != null) {
|
||||
List<NameValuePair> nvps = new LinkedList<NameValuePair>();
|
||||
for (String key : param.keySet())
|
||||
nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数
|
||||
http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数
|
||||
}
|
||||
if (xmlParam != null) {
|
||||
http.setEntity(new StringEntity(xmlParam, Consts.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
private void execute(HttpUriRequest http) throws ClientProtocolException,
|
||||
IOException {
|
||||
CloseableHttpClient httpClient = null;
|
||||
try {
|
||||
if (isHttps) {
|
||||
SSLContext sslContext = new SSLContextBuilder()
|
||||
.loadTrustMaterial(null, new TrustStrategy() {
|
||||
// 信任所有
|
||||
public boolean isTrusted(X509Certificate[] chain,
|
||||
String authType)
|
||||
throws CertificateException {
|
||||
return true;
|
||||
}
|
||||
}).build();
|
||||
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
|
||||
sslContext);
|
||||
httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
|
||||
.build();
|
||||
} else {
|
||||
httpClient = HttpClients.createDefault();
|
||||
}
|
||||
CloseableHttpResponse response = httpClient.execute(http);
|
||||
try {
|
||||
if (response != null) {
|
||||
if (response.getStatusLine() != null)
|
||||
statusCode = response.getStatusLine().getStatusCode();
|
||||
HttpEntity entity = response.getEntity();
|
||||
// 响应内容
|
||||
content = EntityUtils.toString(entity, Consts.UTF_8);
|
||||
}
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
httpClient.close();
|
||||
}
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getContent() throws ParseException, IOException {
|
||||
return content;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.peanut.modules.pay.wechat.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 订单号工具类
|
||||
*
|
||||
* @author y
|
||||
* @since 1.0
|
||||
*/
|
||||
public class OrderNoUtils {
|
||||
|
||||
/**
|
||||
* 获取订单编号
|
||||
* @return
|
||||
*/
|
||||
public static String getOrderNo() {
|
||||
|
||||
return "ORDER_" + getNo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取退款单编号
|
||||
* @return
|
||||
*/
|
||||
public static String getRefundNo() {
|
||||
return "REFUND_" + getNo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编号
|
||||
* @return
|
||||
*/
|
||||
public static String getNo() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String newDate = sdf.format(new Date());
|
||||
String result = "";
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
result += random.nextInt(10);
|
||||
}
|
||||
return newDate + result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.peanut.modules.pay.wechat.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class WXConfigUtil {
|
||||
private byte[] certData;
|
||||
public static final String APP_ID = ""; //app Id
|
||||
public static final String KEY = "";//秘钥
|
||||
public static final String MCH_ID = ""; //商户号
|
||||
|
||||
public WXConfigUtil() throws Exception {
|
||||
String certPath = "------------------------";//从微信商户平台下载的安全证书存放的路径 eg:D:\apiclient_cert.p12
|
||||
File file = new File(certPath);
|
||||
InputStream certStream = new FileInputStream(file);
|
||||
this.certData = new byte[(int) file.length()];
|
||||
certStream.read(this.certData);
|
||||
certStream.close();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user