是公钥字符串格式不正确引起的问题
<?php
//根据私钥生成私钥和公钥格式
$privkey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCBMg7tUdRWJk8ZmWeJEeEwWrIZTbOD9cVY7klgTBdc0WJkQ5cMdWqdi0jvL3VQNi/wShTRTObECNc9ouoe4A2klVg1ywjYN3g3TZ531fqLJDHzHwF0FcchZ4RTzZjXtFRv6ZHPt3JaBEdOO2Z8cL8yeqBrrL8O5vSXvgDuAN3BiwIDAQAB';
$res = openssl_pkey_new();
// Get private key
openssl_pkey_export($res, $privkey);
// Get public key
$pubkey = openssl_pkey_get_details($res);
$pubkey = $pubkey["key"];
var_dump($privkey);
var_dump($pubkey);
exit;
//exit;
$pub = '-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvwu79BFjwVLaeN7jgmoK
RF9BxseVMHN7nvP+6FxWAeeuNW9lvM4UfcxsiY/eamaEB0z4aFQjJSQsSYGWjuEq
S4BQMAXbjQjsWYhIglV2+XHYkGW43suCCyKnxVS+jOTFQ+kWyIH2tf3Kqn4ZtZ75
2qa0RgDZtqZ7Kegt+NDoMDAtNEFi0NRHN8SekBYmoqfskW8+3jX9V13Vx436KDvc
uesD21Y3qXEXEQNc9D5TI+3g7kUoeYDzCtnH+Hhb8GgMbJJ47La1SqnLgbUk0HWj
p4hOcP29kxj0oTUVQl1QLYy1HZghGdm4t7uiroXQ7ozO7B5Wh+k3NfGEkYRafed0
cQIDAQAB
-----END PUBLIC KEY-----';
$pri = '-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC/C7v0EWPBUtp4
3uOCagpEX0HGx5Uwc3ue8/7oXFYB5641b2W8zhR9zGyJj95qZoQHTPhoVCMlJCxJ
gZaO4SpLgFAwBduNCOxZiEiCVXb5cdiQZbjey4ILIqfFVL6M5MVD6RbIgfa1/cqq
fhm1nvnaprRG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k0H2QKBgQDN
Y3a0OC31vAFTDGfseWARazd4M/vAnKh69gg1L3RcI2StwM07UAqIrEKNyeDbXUee
RiDq0FQ9hipFrbEwz0yQzT1ogPDbM7TDB5H3/5R9wUa0bLTgOim98acSZ3m+sXaE
TQ0c1d4vx1zZgrP0VRQbESAAknaMoQ5eyq1flHKC1QKBgQC4eNtNM3AVR1nNfdcA
5cHQF5sj9jULwkBJDAuFqEuTGLfGmHLBLUE+RrSg1tj9x4/LZMzjW90Wdm2krYz6
BDmHQrDBOYmLwrSwaigtjM4Siec9qN6o4dTS1NMB7dxIFgmIj7NbEp4T0ibWayCx
mPX/LSMllc4og+qqR/8JhI1/YA==
-----END PRIVATE KEY-----';
$arr['out_trade_no']='2020120111428011';
$arr['total_amount']=20;
$arr['trade_status']='fall_all';
$data=json_encode($arr);
openssl_private_encrypt($data,$partialEncrypted,$pri);
openssl_public_decrypt($partialEncrypted, $decrypted,$pub); //OPENSSL_NO_PADDING
var_dump($decrypted);die;