|
@@ -5,6 +5,10 @@ import com.usky.dxtop.common.utils.DateUtils;
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
import com.usky.dxtop.common.utils.sign.Md5Utils;
|
|
import com.usky.dxtop.common.utils.sign.Md5Utils;
|
|
import com.usky.dxtop.common.utils.uuid.UUID;
|
|
import com.usky.dxtop.common.utils.uuid.UUID;
|
|
|
|
+import lombok.Data;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.TreeMap;
|
|
import java.util.TreeMap;
|
|
@@ -13,65 +17,74 @@ import java.util.TreeMap;
|
|
* @author yq
|
|
* @author yq
|
|
* @date 2021/8/23 14:50
|
|
* @date 2021/8/23 14:50
|
|
*/
|
|
*/
|
|
-public class TopApi {
|
|
|
|
|
|
+@Data
|
|
|
|
+@Component
|
|
|
|
+@ConfigurationProperties(prefix = "toppay")
|
|
|
|
+public class TopApiConfiger {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 版本
|
|
* 版本
|
|
*/
|
|
*/
|
|
- public static final String VERSION = "v1.0";
|
|
|
|
-
|
|
|
|
- public static final String URL = "https://interfacetest.allinpaygx.com";
|
|
|
|
-
|
|
|
|
|
|
+ @Value("${toppay.version}")
|
|
|
|
+ public String version;
|
|
/**
|
|
/**
|
|
* 扫码支付
|
|
* 扫码支付
|
|
*/
|
|
*/
|
|
- public static final String SCAN_TO_PAY_URL = String.format("%s%s",URL,"/api/access/payInterface/usePaymentCode");
|
|
|
|
|
|
+ @Value("${toppay.scanPayUrl}")
|
|
|
|
+ public String scanPayUrl;
|
|
/**
|
|
/**
|
|
* 交易查询
|
|
* 交易查询
|
|
*/
|
|
*/
|
|
- public static final String DEAL_SELECT_URL = String.format("%s%s",URL,"/api/access/payInterface/findOrderInfo");
|
|
|
|
|
|
+ @Value("${toppay.dealSelectUrl}")
|
|
|
|
+ public String dealSelectUrl;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 统一支付
|
|
* 统一支付
|
|
*/
|
|
*/
|
|
- public static final String UNIFY_URL = String.format("%s%s",URL,"/api/access/payInterface/unifiedPay");
|
|
|
|
|
|
+ @Value("${toppay.unifyUrl}")
|
|
|
|
+ public String unifyUrl;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 商户编号
|
|
* 商户编号
|
|
*/
|
|
*/
|
|
- public static final String MERCHANT_NO = "121050000127";
|
|
|
|
|
|
+ @Value("${toppay.merchantNo}")
|
|
|
|
+ public String merchantNo;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 密钥
|
|
* 密钥
|
|
*/
|
|
*/
|
|
- public static final String SECRET = "MTEODEKT";
|
|
|
|
|
|
+ @Value("${toppay.secret}")
|
|
|
|
+ public String secret;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 回调url
|
|
* 回调url
|
|
*/
|
|
*/
|
|
- public static final String SCAN_NOTIFY_URL = "https://wx.ewoogi.com/dxapi/top/notify";
|
|
|
|
|
|
+ @Value("${toppay.notifyUrl}")
|
|
|
|
+ public String notifyUrl;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 微信appid
|
|
* 微信appid
|
|
*/
|
|
*/
|
|
- public static final String WX_APP_ID = "wx40274c2aaec24330";
|
|
|
|
|
|
+ @Value("${toppay.wxAppId}")
|
|
|
|
+ public String wxAppId;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 微信密钥
|
|
* 微信密钥
|
|
*/
|
|
*/
|
|
- public static final String WX_APP_SECRET = "4b0c04f796a8bed2c2435cc68362b22b";
|
|
|
|
|
|
+ @Value("${toppay.wxAppSecret}")
|
|
|
|
+ public String wxAppSecret;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 拼接扫码支付参数
|
|
* 拼接扫码支付参数
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static TreeMap<String, String> generateScanPayApiParam(String merchantOrderNo, Integer amount, String note,
|
|
|
|
|
|
+ public TreeMap<String, String> generateScanPayApiParam(String merchantOrderNo, Integer amount, String note,
|
|
String storeNo, String backUrl, String orderNumber,
|
|
String storeNo, String backUrl, String orderNumber,
|
|
String validTime, String remark, String goods){
|
|
String validTime, String remark, String goods){
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
- tMap.put("version",VERSION);
|
|
|
|
|
|
+ tMap.put("version",version);
|
|
tMap.put("payTime",DateUtils.dateTimeNow());
|
|
tMap.put("payTime",DateUtils.dateTimeNow());
|
|
- tMap.put("merchantNo",MERCHANT_NO);
|
|
|
|
|
|
+ tMap.put("merchantNo",merchantNo);
|
|
tMap.put("merchantOrderNo",merchantOrderNo);
|
|
tMap.put("merchantOrderNo",merchantOrderNo);
|
|
tMap.put("amount",amount.toString());
|
|
tMap.put("amount",amount.toString());
|
|
tMap.put("note",note);
|
|
tMap.put("note",note);
|
|
@@ -80,7 +93,7 @@ public class TopApi {
|
|
tMap.put("orderNumber",orderNumber);
|
|
tMap.put("orderNumber",orderNumber);
|
|
tMap.put("validTime",validTime);
|
|
tMap.put("validTime",validTime);
|
|
tMap.put("remark",remark);
|
|
tMap.put("remark",remark);
|
|
- tMap.put("notifyUrl",SCAN_NOTIFY_URL);
|
|
|
|
|
|
+ tMap.put("notifyUrl",notifyUrl);
|
|
tMap.put("goods",goods);
|
|
tMap.put("goods",goods);
|
|
return tMap;
|
|
return tMap;
|
|
}
|
|
}
|
|
@@ -93,10 +106,10 @@ public class TopApi {
|
|
* @param groupNo
|
|
* @param groupNo
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static TreeMap<String, String> generateDealSelectParam(String merchantOrderNo,String storeNo,String trxid,String groupNo){
|
|
|
|
|
|
+ public TreeMap<String, String> generateDealSelectParam(String merchantOrderNo,String storeNo,String trxid,String groupNo){
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
- tMap.put("version",VERSION);
|
|
|
|
- tMap.put("merchantNo",MERCHANT_NO);
|
|
|
|
|
|
+ tMap.put("version",version);
|
|
|
|
+ tMap.put("merchantNo",merchantNo);
|
|
tMap.put("merchantOrderNo",merchantOrderNo);
|
|
tMap.put("merchantOrderNo",merchantOrderNo);
|
|
tMap.put("storeNo",storeNo);
|
|
tMap.put("storeNo",storeNo);
|
|
tMap.put("trxid",trxid);
|
|
tMap.put("trxid",trxid);
|
|
@@ -115,11 +128,11 @@ public class TopApi {
|
|
* @param groupNo
|
|
* @param groupNo
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static TreeMap<String, String> generateReturnDealParam(Integer amount,String orderNo,String oriMerchantOrderNo,
|
|
|
|
|
|
+ public TreeMap<String, String> generateReturnDealParam(Integer amount,String orderNo,String oriMerchantOrderNo,
|
|
String trxid,String refundType,String remark,String groupNo){
|
|
String trxid,String refundType,String remark,String groupNo){
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
- tMap.put("version",VERSION);
|
|
|
|
- tMap.put("merchantNo",MERCHANT_NO);
|
|
|
|
|
|
+ tMap.put("version",version);
|
|
|
|
+ tMap.put("merchantNo",merchantNo);
|
|
tMap.put("amount",amount.toString());
|
|
tMap.put("amount",amount.toString());
|
|
tMap.put("orderNo",orderNo);
|
|
tMap.put("orderNo",orderNo);
|
|
tMap.put("oriMerchantOrderNo",oriMerchantOrderNo);
|
|
tMap.put("oriMerchantOrderNo",oriMerchantOrderNo);
|
|
@@ -149,17 +162,17 @@ public class TopApi {
|
|
* @param consumerIp
|
|
* @param consumerIp
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static TreeMap<String, String> generateUnifyParam(String merchantOrderNo,Integer amount,String notifyUrl,
|
|
|
|
|
|
+ public TreeMap<String, String> generateUnifyParam(String merchantOrderNo,Integer amount,String notifyUrl,
|
|
String backUrl,String note,String orderName,String acct,
|
|
String backUrl,String note,String orderName,String acct,
|
|
String payType,String validTime,String subAppid,
|
|
String payType,String validTime,String subAppid,
|
|
String remark,String asinfo,String groupNo,
|
|
String remark,String asinfo,String groupNo,
|
|
String consumerIp){
|
|
String consumerIp){
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
TreeMap<String, String> tMap = new TreeMap<>();
|
|
- tMap.put("version",VERSION);
|
|
|
|
- tMap.put("merchantNo",MERCHANT_NO);
|
|
|
|
|
|
+ tMap.put("version",version);
|
|
|
|
+ tMap.put("merchantNo",merchantNo);
|
|
tMap.put("merchantOrderNo",merchantOrderNo);
|
|
tMap.put("merchantOrderNo",merchantOrderNo);
|
|
tMap.put("amount",amount.toString());
|
|
tMap.put("amount",amount.toString());
|
|
- tMap.put("notifyUrl",SCAN_NOTIFY_URL);
|
|
|
|
|
|
+ tMap.put("notifyUrl",notifyUrl);
|
|
tMap.put("backUrl",backUrl);
|
|
tMap.put("backUrl",backUrl);
|
|
tMap.put("note",note);
|
|
tMap.put("note",note);
|
|
tMap.put("orderName",orderName);
|
|
tMap.put("orderName",orderName);
|
|
@@ -175,13 +188,13 @@ public class TopApi {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static String generateParam(TreeMap<String, String> params){
|
|
|
|
|
|
+ public String generateParam(TreeMap<String, String> params){
|
|
return String.format("%s&sign=%s",
|
|
return String.format("%s&sign=%s",
|
|
- TopApi.joinParam(params),
|
|
|
|
- TopApi.signData(params));
|
|
|
|
|
|
+ this.joinParam(params),
|
|
|
|
+ this.signData(params));
|
|
}
|
|
}
|
|
|
|
|
|
- public static String joinParam(TreeMap<String, String> params){
|
|
|
|
|
|
+ public String joinParam(TreeMap<String, String> params){
|
|
StringBuilder buf = new StringBuilder();
|
|
StringBuilder buf = new StringBuilder();
|
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
|
if (!StringUtils.isBlank(entry.getValue()) && !"sign".equals(entry.getKey())) {
|
|
if (!StringUtils.isBlank(entry.getValue()) && !"sign".equals(entry.getKey())) {
|
|
@@ -200,14 +213,14 @@ public class TopApi {
|
|
* @param treeMap
|
|
* @param treeMap
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static String signData(Map<String, String> treeMap) {
|
|
|
|
|
|
+ public String signData(Map<String, String> treeMap) {
|
|
StringBuilder buf = new StringBuilder();
|
|
StringBuilder buf = new StringBuilder();
|
|
for (Map.Entry<String, String> entry : treeMap.entrySet()) {
|
|
for (Map.Entry<String, String> entry : treeMap.entrySet()) {
|
|
if (!StringUtils.isBlank(entry.getValue()) && !"sign".equals(entry.getKey())) {
|
|
if (!StringUtils.isBlank(entry.getValue()) && !"sign".equals(entry.getKey())) {
|
|
buf.append(entry.getKey()).append(entry.getValue());
|
|
buf.append(entry.getKey()).append(entry.getValue());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- buf.append(SECRET);
|
|
|
|
|
|
+ buf.append(secret);
|
|
return Md5Utils.hash(buf.toString()).toUpperCase();
|
|
return Md5Utils.hash(buf.toString()).toUpperCase();
|
|
}
|
|
}
|
|
|
|
|