44323
2023-11-24 ae9bfd2d66f68a553786ac78b12f4390e65e4e09
cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java
@@ -76,7 +76,7 @@
    private String key = "";//微信商户号
    private String callbackPath = "";//支付回调网关地址
    private String callbackPath = "8.137.22.229:56666/account";//支付回调网关地址
    private String app_cert_path = "C:/cert/alipay/user/app_cert_path.crt";//应用公钥证书路径
@@ -160,45 +160,42 @@
        //分账
        Integer    coursePackagePayments = coursePackageClient.queryByCode(outTradeNo);
        Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo);
        Integer siteBookings = siteClient.queryByCode(outTradeNo);
        List<Integer> stores = new ArrayList<>();
        stores.add(coursePackagePayments);
        stores.add(paymentCompetitions);
        stores.add(siteBookings);
        OperatorUser operatorUser = siteClient.queryOperator(stores);
        String alipayProportion = operatorUser.getAlipayProportion();
        String alipayNum = operatorUser.getAlipayNum();
        ExtendParams extendParams = new ExtendParams();
//        extendParams.setSysServiceProviderId("YOUR_SERVICE_PROVIDER_ID");
        model.setExtendParams(extendParams);
        RoyaltyInfo royaltyInfo = new RoyaltyInfo();
//        royaltyInfo.setRoyaltyType("transfer");
        RoyaltyDetailInfos royaltyDetailInfo1 = new RoyaltyDetailInfos();
        royaltyDetailInfo1.setTransOutType("userId");
        royaltyDetailInfo1.setTransOut(aliAppid);
        royaltyDetailInfo1.setTransInType("loginName");
        royaltyDetailInfo1.setTransIn("18398968484");
        royaltyDetailInfo1.setDesc("分账描述1");
        royaltyDetailInfo1.setAmountPercentage(alipayProportion);
        List<RoyaltyDetailInfos> royaltyDetailInfos = new ArrayList<>();
        royaltyInfo.setRoyaltyDetailInfos(royaltyDetailInfos);
        model.setRoyaltyInfo(royaltyInfo);
        System.err.println("=================="+royaltyInfo);
//        Integer    coursePackagePayments = coursePackageClient.queryByCode(outTradeNo);
//        Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo);
//        Integer siteBookings = siteClient.queryByCode(outTradeNo);
//        List<Integer> stores = new ArrayList<>();
//        stores.add(coursePackagePayments);
//        stores.add(paymentCompetitions);
//        stores.add(siteBookings);
//
//        OperatorUser operatorUser = siteClient.queryOperator(stores);
//
//        String alipayProportion = operatorUser.getAlipayProportion();
//        String alipayNum = operatorUser.getAlipayNum();
//
//        ExtendParams extendParams = new ExtendParams();
////        extendParams.setSysServiceProviderId("YOUR_SERVICE_PROVIDER_ID");
//        model.setExtendParams(extendParams);
//
//        RoyaltyInfo royaltyInfo = new RoyaltyInfo();
////        royaltyInfo.setRoyaltyType("transfer");
//
//
//        RoyaltyDetailInfos royaltyDetailInfo1 = new RoyaltyDetailInfos();
//        royaltyDetailInfo1.setTransOutType("userId");
//        royaltyDetailInfo1.setTransOut(aliAppid);
//        royaltyDetailInfo1.setTransInType("loginName");
//        royaltyDetailInfo1.setTransIn("18398968484");
//
//        royaltyDetailInfo1.setDesc("分账描述1");
//        royaltyDetailInfo1.setAmountPercentage(alipayProportion);
//        List<RoyaltyDetailInfos> royaltyDetailInfos = new ArrayList<>();
//
//
//
//        royaltyInfo.setRoyaltyDetailInfos(royaltyDetailInfos);
//        model.setRoyaltyInfo(royaltyInfo);
//        System.err.println("=================="+royaltyInfo);
        //
        request.setBizModel(model);
        request.setNotifyUrl(callbackPath + notifyUrl);
@@ -207,6 +204,7 @@
            AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
            Map<String, String> map = new HashMap<>();
            map.put("orderString", response.getBody());
            map.put("returnId",passbackParams);
            System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。
            return ResultUtil.success(map);
        } catch (AlipayApiException e) {
@@ -317,19 +315,20 @@
     * @return
     * @throws Exception
     */
    public ResultUtil queryALIOrder(String out_trade_no) throws Exception{
    public AlipayTradeQueryResponse queryALIOrder(String out_trade_no) throws Exception{
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliAppid, appPrivateKey,"json","UTF-8",alipay_public_key,"RSA2");
        AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
        request.setBizContent("{" +
                "  \"out_trade_no\":\"" + out_trade_no + "\"" +
                "}");
        AlipayTradeQueryResponse response = alipayClient.execute(request);
        if(response.isSuccess()){
            String tradeStatus = response.getTradeStatus();//交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)
            return ResultUtil.success(tradeStatus);
        } else {
            return ResultUtil.error(response.getMsg());
        }
        return response;
//        if(response.isSuccess()){
//            String tradeStatus = response.getTradeStatus();//交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)
//            return ResultUtil.success(response);
//        } else {
//            return ResultUtil.error(response.getMsg());
//        }
    }