Browse Source

快捷充值

xiongzhu 3 years ago
parent
commit
b4e8529dda

+ 1 - 1
src/test/java/com/izouma/nineth/CommonTest.java

@@ -746,6 +746,6 @@ public class CommonTest {
 
     @Test
     public void decrypt() throws Exception {
-        System.out.println(AESEncryptUtil.decrypt("946B7C9FB530401F25088C321D1322EA7D4C5B71BE30BF488CBCA0D34362682E"));
+        System.out.println(AESEncryptUtil.decrypt("C4EE0C1050C613707CE88FE3BDAA13CAA3A702AD2B010B23EDB1F94A44CC485E"));
     }
 }

+ 171 - 0
src/test/java/com/izouma/nineth/GenerateUrl.java

@@ -0,0 +1,171 @@
+package com.izouma.nineth;
+
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Auther YaoJun Qi
+ * @Date 2021/03/05 13:43
+ * @description
+ */
+
+public class GenerateUrl {
+    public static void main(String[] args) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        Calendar calendar = Calendar.getInstance();
+        String createTime = sdf.format(calendar.getTime());
+        calendar.add(Calendar.HOUR, 1);
+        String endTime = sdf.format(calendar.getTime());
+
+        String version = "10";
+        String mer_no = "6888806043057";
+        //key1
+        String mer_key = "fvLh4EEoJPJEkqg+6s3B8sTRVREAyVAxS34+5JGiJOmIFnIrnfD1k/KiUYo5Nfb7tBx0jj9HOI0=";
+        UUID uuid = UUID.randomUUID();
+        String mer_order_no = uuid.toString().replaceAll("-", "");
+        String notify_url = "https://www.baidu.com";
+        String order_amt = "1";
+        String return_url = "http://sandcash/return";
+        String goods_name = "test";
+        //"userId":"用户在商户下唯一标识 1-10位","userName":"证件姓名","idCard":"18位身份证号码"
+        String pay_extra = "{\"userId\":\"1\",\"userName\":\"熊竹\",\"idCard\":\"321002199408304614\"}";
+        //md5key
+        String key = "KvKQYXhwvkoQRAiQN2IzVSaecqYFP8emDHJrLettbShZsd8k/V2OU/myAV6My/qeotZ8K0WG8ifDzgelCexY7517gmF7SqFUcyuKgSC+HFNmn14C4iy9JRy0NvsSJRjgMzZWAhrwNL5ixuz+UKFTiw==";
+
+
+        Map<String, String> map = new LinkedHashMap<>();
+        map.put("accsplit_flag", "NO");
+        map.put("create_ip", "127_0_0_1");
+        map.put("create_time", createTime);
+//        if(!(gh_static_url==null||"".equals(gh_static_url)))map.put("gh_static_url",gh_static_url);;
+        map.put("mer_key", mer_key);
+        map.put("mer_no", mer_no);
+        map.put("mer_order_no", mer_order_no);
+        map.put("notify_url", notify_url);
+        map.put("order_amt", order_amt);
+        map.put("pay_extra", pay_extra);
+        map.put("return_url", return_url);
+        map.put("sign_type", "MD5");
+        map.put("store_id", "000000");
+        map.put("version", version);
+        map.put("key", key);
+
+
+//        map.put("expire_time",endTime);
+//        map.put("goods_name",goods_name);
+//        map.put("product_code","02010006");
+//        map.put("clear_cycle","0");
+
+        String signature = "";
+
+        for (String s : map.keySet()) {
+            if (!(map.get(s) == null || map.get(s).equals(""))) {
+                signature += s + "=";
+                signature += map.get(s) + "&";
+            }
+        }
+        signature = signature.substring(0, signature.length() - 1);
+        System.out.println("签名内容\n" + signature);
+
+        String sign = MD5Util.encode(signature).toUpperCase();
+
+        System.out.println("签名结果\n" + sign);
+
+
+        //url
+        String url = "https://sandcash.mixienet.com.cn/pay/h5/quicktopup?" +
+                "version=" + version + "" +
+                "&mer_no=" + mer_no + "" +
+                "&mer_key=" + URLEncoder.encode(mer_key) + "" +
+                "&mer_order_no=" + mer_order_no + "" +
+                "&create_time=" + createTime + "" +
+                "&expire_time=" + endTime + "" +  //endTime
+                "&order_amt=1" +
+                "&notify_url=" + URLEncoder.encode(notify_url) + "" +
+                "&return_url=" + URLEncoder.encode(return_url) + "" +
+                "&create_ip=127_0_0_1" +
+                "&goods_name=" + URLEncoder.encode(goods_name) + "" +
+                "&store_id=000000" +
+                "&product_code=06030003" +
+                "&clear_cycle=3" +
+                "&pay_extra=" + URLEncoder.encode(pay_extra) + "" +
+                "&meta_option=%5B%7B%22s%22%3A%22Android%22,%22n%22%3A%22wxDemo%22,%22id%22%3A%22com.pay.paytypetest%22,%22sc%22%3A%22com.pay.paytypetest%22%7D%5D" +
+                "&accsplit_flag=NO" +
+                "&jump_scheme=" +
+//                "&gh_static_url="+gh_static_url+""+
+                "&sign_type=MD5" +
+                "&key=" + URLEncoder.encode(key, StandardCharsets.UTF_8) +
+                "&sign=" + sign + "";
+
+        System.out.println("url\n\n" + url);
+
+    }
+
+
+}
+
+
+class MD5Util {
+
+
+    /**
+     * 缁変焦婀侀弸鍕拷鐘虫煙濞夛拷,鐏忓棜顕氬銉ュ徔缁槒顔曟稉鍝勫礋娓氬膩瀵拷.
+     */
+    private MD5Util() {
+    }
+
+    private static final String[] hex = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
+
+    public static String encode(String password) {
+        try {
+            MessageDigest md5 = MessageDigest.getInstance("MD5");
+            byte[] byteArray = md5.digest(password.getBytes("utf-8"));
+            String passwordMD5 = byteArrayToHexString(byteArray);
+            return passwordMD5;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return password;
+    }
+
+    public static String encode(String password, String enc) {
+        try {
+            MessageDigest md5 = MessageDigest.getInstance("MD5");
+            byte[] byteArray = md5.digest(password.getBytes(enc));
+            String passwordMD5 = byteArrayToHexString(byteArray);
+            return passwordMD5;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return password;
+    }
+
+    private static String byteArrayToHexString(byte[] byteArray) {
+        StringBuffer sb = new StringBuffer();
+        for (byte b : byteArray) {
+            sb.append(byteToHexChar(b));
+        }
+        return sb.toString();
+    }
+
+    private static Object byteToHexChar(byte b) {
+        int n = b;
+        if (n < 0) {
+            n = 256 + n;
+        }
+        int d1 = n / 16;
+        int d2 = n % 16;
+        return hex[d1] + hex[d2];
+    }
+
+
+    public static void main(String[] args) {
+        System.out.println(encode("accsplit_flag=NO&activity_no=MP20201228132838216&benefit_amount=0.5&create_ip=172_12_12_12&create_time=20210112161203&mer_key=Xx52CDtWRH1etGu4IfFEB4OeRrnbr+EUd5VO7cBQFCqxfDl5FJcJaUjKJbHapVsyxSODBEbssNk=&mer_no=16938552&mer_order_no=20210112161203087575052491&notify_url=http://sandcash/notify&order_amt=10.0&pay_extra={\"mer_app_id\":\"\",\"openid\":\"\",\"buyer_id\":\"\",\"wx_app_id\":\"\",\"gh_ori_id\":\"gh_8f69bbed2867\",\"path_url\":\"pages/zf/index?\",\"miniProgramType\":\"0\"}&return_url=http://www.baidu.com&sign_type=MD5&store_id=100001&version=1.0&key=\"閸熷棙鍩涢幓鎰返\"").toUpperCase());
+//        encode("ganxuehui","admin");
+    }
+
+}
+

+ 9 - 3
src/test/java/com/izouma/nineth/service/SandPayServiceTest.java

@@ -2,6 +2,8 @@ package com.izouma.nineth.service;
 
 import cn.com.sandpay.cashier.sdk.*;
 import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.internal.util.AlipaySignature;
 import com.izouma.nineth.ApplicationTests;
 import com.izouma.nineth.utils.DateTimeUtils;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
@@ -13,14 +15,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
 
 @Slf4j
 class SandPayServiceTest {
@@ -337,4 +338,9 @@ class SandPayServiceTest {
             log.error(e.getMessage());
         }
     }
+
+    @Test
+    public void quick() {
+
+    }
 }