puzhibing
2024-01-30 80b3ea5587ff7ec20541d9ca7c6c28739e4d615b
cloud-server-management/src/main/java/com/dsh/guns/modular/system/api/SaticScheduleTask.java
@@ -20,6 +20,7 @@
import com.dsh.guns.modular.system.service.IOperatorAuthService;
import com.dsh.guns.modular.system.service.IOperatorUserService;
import com.dsh.guns.modular.system.service.IUserService;
import com.dsh.guns.modular.system.util.PayMoneyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -38,59 +39,62 @@
    private IOperatorUserService operatorUserService;
    @Autowired
    private IUserService userService;
    @Autowired
    private PayMoneyUtil payMoneyUtil;
    private String appPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ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XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB";//支付宝支付公钥
    private String aliAppid = "2021004105665036";//支付宝appid
    // 一个小时执行一次
    @Scheduled(fixedRate=600000)
    @Scheduled(fixedRate=60000)
    private void configureTasks() {
        List<OperatorAuthAlipay> list = operatorAuthService.list(new QueryWrapper<OperatorAuthAlipay>());
        for (OperatorAuthAlipay operatorAuthAlipay : list) {
            System.err.println("执行定时任务时间: " + LocalDateTime.now());
            AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
                    aliAppid,
                    appPrivateKey, "json", "GBK",
                    alipay_public_key,
                    "RSA2");
            AntMerchantExpandIndirectZftorderQueryRequest request = new AntMerchantExpandIndirectZftorderQueryRequest();
            request.setBizContent("{" +
                    "  \"order_id\":\"" + operatorAuthAlipay.getOrderNo() + "\"," +
                    "  \"external_id\":\"" + operatorAuthAlipay.getOutBizNo() + "\"" +
                    "}");
            AntMerchantExpandIndirectZftorderQueryResponse response = null;
            try {
                response = alipayClient.execute(request);
            } catch (AlipayApiException e) {
                e.printStackTrace();
            }
            if (response.isSuccess()) {
                System.out.println("调用成功");
                JSONObject json = JSONObject.parseObject(response.getBody());
                System.err.println(json);
                JSONObject sign = json.getJSONObject("ant_merchant_expand_indirect_zftorder_query_response");
                JSONArray orders = sign.getJSONArray("orders");
                    JSONObject order = orders.getJSONObject(0);
                    // 提取订单信息
                    String reason = order.getString("reason");
                    String smid = order.getString("smid");
                    String merchantName = order.getString("merchant_name");
                    String applyTime = order.getString("apply_time");
                    String externalId = order.getString("external_id");
                    String orderId = order.getString("order_id");
                    String applyType = order.getString("apply_type");
                    String status = order.getString("status");
                    // 打印订单信息
                    System.out.println("Reason: " + reason);
                    System.out.println("Merchant Name: " + merchantName);
                    System.out.println("Apply Time: " + applyTime);
                    System.out.println("External ID: " + externalId);
                    System.out.println("Order ID: " + orderId);
                    System.out.println("Apply Type: " + applyType);
                    System.out.println("Status: " + status);
            } else {
                System.out.println("调用失败");
            }
        }
//        payMoneyUtil.getMessage();
//        List<OperatorAuthAlipay> list = operatorAuthService.list(new QueryWrapper<OperatorAuthAlipay>());
//        for (OperatorAuthAlipay operatorAuthAlipay : list) {
//            System.err.println("执行定时任务时间: " + LocalDateTime.now());
//            AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
//                    aliAppid,
//                    appPrivateKey, "json", "GBK",
//                    alipay_public_key,
//                    "RSA2");
//            AntMerchantExpandIndirectZftorderQueryRequest request = new AntMerchantExpandIndirectZftorderQueryRequest();
//            request.setBizContent("{" +
//                    "  \"order_id\":\"" + operatorAuthAlipay.getOrderNo() + "\"," +
//                    "  \"external_id\":\"" + operatorAuthAlipay.getOutBizNo() + "\"" +
//                    "}");
//            AntMerchantExpandIndirectZftorderQueryResponse response = null;
//            try {
//                response = alipayClient.execute(request);
//            } catch (AlipayApiException e) {
//                e.printStackTrace();
//            }
//            if (response.isSuccess()) {
//                System.out.println("调用成功");
//                JSONObject json = JSONObject.parseObject(response.getBody());
//                System.err.println(json);
//                JSONObject sign = json.getJSONObject("ant_merchant_expand_indirect_zftorder_query_response");
//                JSONArray orders = sign.getJSONArray("orders");
//                    JSONObject order = orders.getJSONObject(0);
//                    // 提取订单信息
//                    String reason = order.getString("reason");
//                    String smid = order.getString("smid");
//                    String merchantName = order.getString("merchant_name");
//                    String applyTime = order.getString("apply_time");
//                    String externalId = order.getString("external_id");
//                    String orderId = order.getString("order_id");
//                    String applyType = order.getString("apply_type");
//                    String status = order.getString("status");
//                    // 打印订单信息
//                    System.out.println("Reason: " + reason);
//                    System.out.println("Merchant Name: " + merchantName);
//                    System.out.println("Apply Time: " + applyTime);
//                    System.out.println("External ID: " + externalId);
//                    System.out.println("Order ID: " + orderId);
//                    System.out.println("Apply Type: " + applyType);
//                    System.out.println("Status: " + status);
//            } else {
//                System.out.println("调用失败");
//            }
//        }
@@ -225,9 +229,5 @@
//        }
    }
    public static void main(String[] args) {
        String s = "{\"sign\":\"Q8wa/EiKqeRiatW3mDhPA3Ia1jYXK6c8CxlhTQb0o9XHui16UURb7oiqnoS+P22q3a3POjmuhl/Rwm6MBGzp8RNcXwoWTExNq29OR/jZ6SU9HWiOUewv0/kGgNj4WHpbGbVqaoaW3/Q6w0IhCSRT3GAsULHPBeWQ2HyrScl549y/mwsI6bX132S9dHJ5O7we4Oho0pDWrQfE+daP4p+y1HVGeD6WGBq5HjXIuqNmE/ZrRFc/R+8baMwRQgECeohKhpPs9Ov1xuzeq/wuk/NuDG9YbE/+cKs/Kkg3fYIPM1CsIwvam3wP2iYhTaUlEYidt++EwJ2QVIB3OD5So5aKdg==\",\"ant_merchant_expand_indirect_zftorder_query_response\":{\"msg\":\"Success\",\"code\":\"10000\",\"orders\":[{\"reason\":\"公安网校验失败\",\"merchant_name\":\"成都玩湃生活体育发展有限公司\",\"apply_time\":\"2023-12-20 18:36:26\",\"external_id\":\"273c5a8ad59f4e5397253045af1de8fe\",\"order_id\":\"2023122000502000000005299341\",\"apply_type\":\"ZHIFUTONG_CREATE\",\"status\":\"-1\"}]}}";
    }
}