package cn.pluss.platform.ali.impl;

import cn.pluss.platform.ali.AlipayService;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.device.MercOrderNewService;
import cn.pluss.platform.entity.MercOrderNew;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.util.ParametersUtil;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.*;
import com.alipay.api.domain.AlipayTradeAppPayModel;
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.alipay.api.response.AlipayTradeWapPayResponse;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.UUID;

@Slf4j
@Service
public class AlipayServiceImpl implements AlipayService {

    @Resource
    private MercOrderNewService mercOrderNewService;

    @Override
    public void remit(String account, String realName, String money) {
        try {
            CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
            certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do");
//            certAlipayRequest.setAppId("2021001189650608");
//            certAlipayRequest.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDWIvHm57tQURFF+UKIxNnnZcxnBPZ5oXwQlJjmUzv3qInD/I9TBBBvlRsY1ugRioH7KGwpUI0vjBuSzZYKx8ckktAIb03j75nSHOFD0Mn23y73bjVznj2NVLeVvDKPP8vfFO+7VYM2vBNHrXlvBSjfb/0gP0wZa1H2uqwKVdRHnTJgllzINKcO8ttosRqUZlj8oysCbV8BXDQ5B8QPKsvbtbva9v8giwp3Utk490Ufqh/cX0IL28PMBBp0SL7ptrbN9mT7FA02+T9Me1BevXBHBsqykgZfbuptEIg/tn93lBCM4cP70nXMz4hTYSP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Vqb5Y5AoGAPEc//P14ppYSx/G3f2rFML/G2pc6OgSABtbbKSgziX11AbVEzaqmmQI39TMkaLSdBAzqzmaLg3ZYnHsvBLg1il/7xE/d7nYlkaCwbEC+M1MzPGzXODt+5jusUVzO4Uk4bX9asBQJsWVhC851eoi/G4o7VZ4tal2fz17pyiuZq40=");
//            certAlipayRequest.setFormat("json");
//            certAlipayRequest.setCharset("UTF-8");
//            certAlipayRequest.setSignType("RSA2");
//            certAlipayRequest.setCertPath ( "/home/syb/cert/appCertPublicKey_2021001189650608.crt" );
//            certAlipayRequest.setAlipayPublicCertPath (  "/home/syb/cert/alipayCertPublicKey_RSA2 (2).crt"  );
//            certAlipayRequest.setRootCertPath ( "/home/syb/cert/alipayRootCert (2).crt" );

            certAlipayRequest.setAppId("2021003133649094");
            String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDP0ky+6wTP7mTiyuA3rfUXW9kibwU3q4V8R/zWE5zGOIaMv/bQ3La/0WWUGHd9K/bsgQ6GLBE+i74QU/3RzfdrbTvrL6GrLupMxxgdiikmvkhPRwkWVPghjNmbJhG6+gva1K8BfE0QtbP3oghnBc78TSyp02aoKFIjo98+21fXUQZs8yagoZBojoQ8zcSr09TsCB4BCm+nSEhD7yEa7HyPcX+FkMtRFXt0XsxnBwV/9T95vaBNGKQoNdvY5evIVRnSInc4E4k8MU3sm+YxrPHWMKWZJn2SP/1kPXIGc/IZkf6AZGeZXMNL36kz8k6Z/1f/TsOKioHX5J498ueuc1HvAgMBAAECggEARDtKoUAuQ0qE6wUq2n0NxA6O2sRSlTWGTQihlXO4/EegvWNlWKuugInybM4fpQQjPQEeUKT1QHDHBTteUVzrR+UEUDJCRR7RJEYVv9UVr7e3q/epnyBkmzdQVqUIGzhvXfiIQNebwcm2fa5ATfrVO3bnHBbhVIJwfW0XJd8EFxfWonUDjtPfk8wTEjmNqz6vXhpk3ncV7MMY07ehbYaMA4NbbysABKRP0S9515JUX0NkBtxnhVm2ojcoc1Wjy3//TN8RXpC17E1Tyd/9pQIxmosLjS1gcX1WzphMZU0Y/74yHiE0WQCKP3J6PkdBTQDIqubyRdErJ9TYSe9+u3OZyQKBgQDrtap3LItv8IjH6O5Lg4xMU9r9dFW8QVc3dD1yn+wWq5x54mnUo5d6cTa7HqZ9SgS7gxWQZG/km9R2cJLQsATlQjdHyEoNKtqdgl3vB8MGK+Lwh6vNhE2z2svRJqQpzZfs1dKwI74mASDzwu/HjdkOFO2BVzjG3IPmrDRmN+7w8wKBgQDhthAKdbkhb7vjlgckGqDyy28QVb1YfZ4YzwW5aZiAhBmQhfZZEB5/KAYKRkToFg6Nqz6cBHwb1rH1YtOua8Dgr5XsqPQz9+MCCrUKxVt/1ziWhkpaNxEobT7QYtJiaGvuLxGP7uqpJGDpePCLHQTxmocsj8UgEE49HDj4qlO6FQKBgFGip5mC2gA5BIaITA/nTa4Z1Ny3cAI1dymDnsyWSsRHR3iHTDQTPKFxmI0SPoNiIWV4Lv3Fa2N3/QvQTWjtraRhXJgF7G/HCdRHlJT20TrP9FduBbi2O9swyip0AaNgy1+BZukOWAr9lRYXy8gHfsd7xA5p0QY+1YgM2FEWyjC1AoGBAKaSAsKFYGuRltp9BKYbVL35bexjKgodIkhyt2m+yQHG+0rR4hyWLbtvYQ3CD+YrKPBZ+SmQkbrFta0/ErL86Gmoiv8NLLMRdCE0n6jkPwNYZHWJg2OSkgIApUOKOnLPVx9+8voCuoC6zR5f1z0C3Hwkqy8ypqpj/ilRI6Y3pPSFAoGAaxBlqCUBFEhs/FnYf9neoPzx9WYDmJY7PgNgZ/s0H9vaGqyWPLWyF95/dTZ5yrBsABQyuIfDa2/m8y1YJaIJ/qU29FDq/GMv6IX4zDgm2iaWNZFnMoW7qSEkpVISSLoVxat4D556YI6FrQeoUAS+L1iEFgS33ln1tTyqb7mSe00=";
            certAlipayRequest.setPrivateKey(privateKey);
            certAlipayRequest.setFormat("json");
            certAlipayRequest.setCharset("UTF-8");
            certAlipayRequest.setSignType("RSA2");
            certAlipayRequest.setCertPath("/home/syb/cert/20220622/appCertPublicKey_2021003133649094.crt");
            certAlipayRequest.setAlipayPublicCertPath("/home/syb/cert/20220622/alipayCertPublicKey_RSA2.crt");
            certAlipayRequest.setRootCertPath("/home/syb/cert/20220622/alipayRootCert.crt");

//            certAlipayRequest.setAppId("2021003133649094");
//            String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDP0ky+6wTP7mTiyuA3rfUXW9kibwU3q4V8R/zWE5zGOIaMv/bQ3La/0WWUGHd9K/bsgQ6GLBE+i74QU/3RzfdrbTvrL6GrLupMxxgdiikmvkhPRwkWVPghjNmbJhG6+gva1K8BfE0QtbP3oghnBc78TSyp02aoKFIjo98+21fXUQZs8yagoZBojoQ8zcSr09TsCB4BCm+nSEhD7yEa7HyPcX+FkMtRFXt0XsxnBwV/9T95vaBNGKQoNdvY5evIVRnSInc4E4k8MU3sm+YxrPHWMKWZJn2SP/1kPXIGc/IZkf6AZGeZXMNL36kz8k6Z/1f/TsOKioHX5J498ueuc1HvAgMBAAECggEARDtKoUAuQ0qE6wUq2n0NxA6O2sRSlTWGTQihlXO4/EegvWNlWKuugInybM4fpQQjPQEeUKT1QHDHBTteUVzrR+UEUDJCRR7RJEYVv9UVr7e3q/epnyBkmzdQVqUIGzhvXfiIQNebwcm2fa5ATfrVO3bnHBbhVIJwfW0XJd8EFxfWonUDjtPfk8wTEjmNqz6vXhpk3ncV7MMY07ehbYaMA4NbbysABKRP0S9515JUX0NkBtxnhVm2ojcoc1Wjy3//TN8RXpC17E1Tyd/9pQIxmosLjS1gcX1WzphMZU0Y/74yHiE0WQCKP3J6PkdBTQDIqubyRdErJ9TYSe9+u3OZyQKBgQDrtap3LItv8IjH6O5Lg4xMU9r9dFW8QVc3dD1yn+wWq5x54mnUo5d6cTa7HqZ9SgS7gxWQZG/km9R2cJLQsATlQjdHyEoNKtqdgl3vB8MGK+Lwh6vNhE2z2svRJqQpzZfs1dKwI74mASDzwu/HjdkOFO2BVzjG3IPmrDRmN+7w8wKBgQDhthAKdbkhb7vjlgckGqDyy28QVb1YfZ4YzwW5aZiAhBmQhfZZEB5/KAYKRkToFg6Nqz6cBHwb1rH1YtOua8Dgr5XsqPQz9+MCCrUKxVt/1ziWhkpaNxEobT7QYtJiaGvuLxGP7uqpJGDpePCLHQTxmocsj8UgEE49HDj4qlO6FQKBgFGip5mC2gA5BIaITA/nTa4Z1Ny3cAI1dymDnsyWSsRHR3iHTDQTPKFxmI0SPoNiIWV4Lv3Fa2N3/QvQTWjtraRhXJgF7G/HCdRHlJT20TrP9FduBbi2O9swyip0AaNgy1+BZukOWAr9lRYXy8gHfsd7xA5p0QY+1YgM2FEWyjC1AoGBAKaSAsKFYGuRltp9BKYbVL35bexjKgodIkhyt2m+yQHG+0rR4hyWLbtvYQ3CD+YrKPBZ+SmQkbrFta0/ErL86Gmoiv8NLLMRdCE0n6jkPwNYZHWJg2OSkgIApUOKOnLPVx9+8voCuoC6zR5f1z0C3Hwkqy8ypqpj/ilRI6Y3pPSFAoGAaxBlqCUBFEhs/FnYf9neoPzx9WYDmJY7PgNgZ/s0H9vaGqyWPLWyF95/dTZ5yrBsABQyuIfDa2/m8y1YJaIJ/qU29FDq/GMv6IX4zDgm2iaWNZFnMoW7qSEkpVISSLoVxat4D556YI6FrQeoUAS+L1iEFgS33ln1tTyqb7mSe00=";
//            certAlipayRequest.setPrivateKey(privateKey);
//            certAlipayRequest.setFormat("json");
//            certAlipayRequest.setCharset("UTF-8");
//            certAlipayRequest.setSignType("RSA2");
//            certAlipayRequest.setCertPath ( "C:\\Users\\DJH\\Downloads\\appCertPublicKey_2021003133649094.crt" );
//            certAlipayRequest.setAlipayPublicCertPath (  "C:\\Users\\DJH\\Downloads\\alipayCertPublicKey_RSA2.crt"  );
//            certAlipayRequest.setRootCertPath ( "C:\\Users\\DJH\\Downloads\\alipayRootCert.crt" );
            DefaultAlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest);
            // 构建request内容
            AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
            JSONObject bizJson = new JSONObject();
            JSONObject payeeInfo = new JSONObject();
            // 身份信息设置为帐号
            payeeInfo.put("identity_type", "ALIPAY_LOGON_ID");
            payeeInfo.put("identity", account);
            payeeInfo.put("name", realName);

            bizJson.put("out_biz_no", UUID.randomUUID().toString().replace("-", ""));
            bizJson.put("trans_amount", money);
            bizJson.put("product_code", "TRANS_ACCOUNT_NO_PWD");
            bizJson.put("biz_scene", "DIRECT_TRANSFER");
            bizJson.put("payee_info", payeeInfo);
            bizJson.put("order_title", "银收客分润");
            bizJson.put("remark", "银收客分润");

            JSONObject bizParam = new JSONObject();
            bizParam.put("payer_show_name", "银收客");

            bizJson.put("business_params", bizParam);

            request.setBizContent(bizJson.toString());

            AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
            if (response.isSuccess()) {
                log.info("调用成功");
            } else {
                log.error(response.getSubMsg());
                throw new MsgException(response.getSubMsg());
            }

        } catch (Exception e) {
            e.printStackTrace();
            throw new MsgException(e.getMessage());
        }
    }

    @Override
    public Object aliPayPhone(String orderNo) {
        MercOrderNew mercOrder = mercOrderNewService.getOrderByNo(orderNo);
        if (mercOrder == null) {
            throw new MsgException("订单号有误");
        }

        //app
        mercOrder.setOrderNo(orderNo);
        mercOrder.setOrderAmt(mercOrder.getOrderAmt());
        mercOrder.setReceiver(mercOrder.getReceiver());
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", ParametersUtil.ZY_ALI_APP_ID,
                ParametersUtil.ZY_PRI, "json", "UTF-8", ParametersUtil.ZY_PUB, "RSA2");
        AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
        request.setNotifyUrl(ParametersUtil.domain+"/wap/merchant/aliDeviceCallBack");
        request.setReturnUrl("");
        JSONObject bizContent = new JSONObject();
        bizContent.put("out_trade_no", mercOrder.getOrderNo());
        bizContent.put("total_amount", mercOrder.getOrderAmt());
        bizContent.put("subject", mercOrder.getReceiver());

        /************/

        bizContent.put("product_code", "QUICK_MSECURITY_PAY");
        request.setBizContent(bizContent.toString());
        AlipayTradeAppPayResponse response = null;
        try {
            response = response = alipayClient.sdkExecute(request);
        } catch (AlipayApiException e) {
            throw new RuntimeException(e);
        }
        if (response.isSuccess()) {
            System.out.println("success");
            String body = response.getBody();
            return body;
        } else {
            System.out.println("fail");
            return "支付失败";
        }

//        String privateKey = ParametersUtil.ZY_PRI;
//        String alipayPublicKey = ParametersUtil.ZY_PUB;
//        AlipayConfig alipayConfig = new AlipayConfig();
//        alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
//        alipayConfig.setAppId(ParametersUtil.ZY_ALI_APP_ID);
//        alipayConfig.setPrivateKey(privateKey);
//        alipayConfig.setFormat("json");
//        alipayConfig.setAlipayPublicKey(alipayPublicKey);
//        alipayConfig.setCharset("UTF-8");
//        alipayConfig.setSignType("RSA2");
//        AlipayClient alipayClient = null;
//        try {
//            alipayClient = new DefaultAlipayClient(alipayConfig);
//        } catch (AlipayApiException e) {
//            throw new RuntimeException(e);
//        }
//        AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
//        AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
//        model.setOutTradeNo(mercOrder.getOrderNo());
//        model.setTotalAmount(mercOrder.getOrderAmt().toString());
//        model.setSubject(mercOrder.getReceiver());
//        request.setBizModel(model);
//        AlipayTradeAppPayResponse response = null;
//        try {
//            response = alipayClient.sdkExecute(request);
//        } catch (AlipayApiException e) {
//            throw new RuntimeException(e);
//        }
//
//        if (response.isSuccess()) {
//            System.out.println("调用成功");
//            return ResultGenerator.genSuccessResult(response.getBody());
//        } else {
//            System.out.println("调用失败");
//            return ResultGenerator.genFailResult("支付失败");
//        }
    }

    public String moneyForMat(BigDecimal amount) {
        DecimalFormat formatter = new DecimalFormat("#0.00");
        String formattedAmount = formatter.format(amount);

        return formattedAmount;
    }

    public static void main(String[] args) throws AlipayApiException {
        MercOrderNew mercOrder = new MercOrderNew();
////        if (mercOrder == null){
////            throw new MsgException("订单号有误");
////        }
        mercOrder.setOrderNo("b3dc8aab4f204be7b7bc6738dc91ddd2");
        mercOrder.setOrderAmt(new BigDecimal("0.1"));
        mercOrder.setReceiver("测测测");
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "2021003175619219",
                "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCInywsrhhiSNj7jjOB4/zL79pAaLzoYOuOqHeQELxgXrVFmpqJ7y76wniu4nrHKfp4jQVIHw4+IkBsTNwABTPiryVzAQ4ydb/opzn4zblWRB4S7mAgnc2wqO4FMcwSOiHh7uPFAqvB8oZmEizlbXIJSiDFd3rqG2l8ZADjwuwM0nue1fUJLu65d2B6NDFgBIa11enkrNyX9uPiaeIFW62lvTN1W2AUqTJLvfko5ejExGUDkie6g5W5MIvUSKfq7sDkpt5IoQCooBzjJJ/Ckfw/rJlqoPDFzUSiANBABwu0jAJ42MGYdJ8+dyDDUNla20xmMjXbRtUe5roVzJrrgMjFAgMBAAECggEAPKPx9o77sbxF2zod8JxiW57Fj+stVjOWuoZaM27KPjgrW46o42pvvsvMx0stVfNzAkkNvBpUtw167Nccm0Gz6vz0sVwZkhojqT94gs/FYN3xP1PhBPkmEDCbHWEiBEEbQu5G2O47kGV2dB3DIb53bFoju6Ixw3GRW64DmxSss2+ZsErAWPBwbxIbUDGzIxtGhuWrvWX6pSnnvs+PNNqyoisXnh4cDjrmS9qSgsgcL4D0HwNGTsG1uBeLx4g3D2vKKqhP1osEly91P0QAGzcpuvKqeJ2ZwfFMDlabeOyqRQxFW/FLT2DuY1KmBhcGx6tjDMo7EEpVJ7NHcSHYfAa6wQKBgQDzZbIAV7shEiwS6ZwLSbeMvJkWELJtmEGk/qI/01tULHmrwDh8FIjbrHZrQNXruZ+dS+RObahCKywjYVEr/g15v5vv4yA20bmUgmO27/mVj6mpw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8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB", "RSA2");
        AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();

        JSONObject bizContent = new JSONObject();
        bizContent.put("out_trade_no", mercOrder.getOrderNo());
        bizContent.put("total_amount", mercOrder.getOrderAmt());
        bizContent.put("subject", mercOrder.getReceiver());


        /************/

        bizContent.put("product_code", "QUICK_MSECURITY_PAY");
        request.setBizContent(bizContent.toString());
        AlipayTradeWapPayResponse response = null;
        try {
            response = alipayClient.sdkExecute(request);
        } catch (AlipayApiException e) {
            throw new RuntimeException(e);
        }

        if (response.isSuccess()) {
            System.out.println("success");
            System.out.println(response.getBody());
        } else {
            System.out.println("fail");

        }
    }

        // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
        // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
        // System.out.println(diagnosisUrl);



}

