{"id":618,"date":"2025-01-19T14:19:09","date_gmt":"2025-01-19T14:19:09","guid":{"rendered":"http:\/\/www.nywzjs.com\/?p=618"},"modified":"2025-01-19T23:31:34","modified_gmt":"2025-01-19T23:31:34","slug":"crmeb%e5%bc%80%e6%ba%90%e7%89%88%e5%a2%9e%e5%8a%a0%e5%88%86%e5%b8%90%e5%8a%9f%e8%83%bd%ef%bc%88%e6%9c%8d%e5%8a%a1%e5%95%86%e6%a8%a1%e5%bc%8f%e4%b8%8b%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.nywzjs.com\/?p=618","title":{"rendered":"CRMEB\u5f00\u6e90\u7248\u589e\u52a0\u5206\u5e10\u529f\u80fd\uff08\u670d\u52a1\u5546\u6a21\u5f0f\u4e0b\uff09"},"content":{"rendered":"\n<p>1\u3001\u589e\u52a0\u5fae\u4fe1\u652f\u4ed8\u5206\u5e10\u529f\u80fd<\/p>\n\n\n\n<p>\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/pay.weixin.qq.com\/doc\/v3\/partner\/4012690944<\/p>\n\n\n\n<p>\u5206\u5e10\u5546\u6237\u7684\u6765\u6e90\u4e3a\u4f9b\u5e94\u5546\uff0c\u53e6\u5916\u7684\u95ee\u9898\uff0c\u4e0d\u8d58\u8ff0\uff0c\u5728\u4f9b\u5e94\u5546\u4fe1\u606f\u4fee\u6539\u7684\u9875\u9762\u5f15\u7528\u652f\u4ed8\u64cd\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u5f15\u7528\u670d\u52a1\nuse crmeb\\services\\pay\\Pay;\n\/\/\u76f8\u5173\u4ee3\u7801\u6bb5\n\/\/\u6dfb\u52a0\u5206\u8d26\u63a5\u6536\u65b9\n                $pay = new Pay('v3_wechat_pay');\n                $res = $pay-&gt;receiversAdd($data&#91;'transfer_type'], $account, $name, 'SUPPLIER');\n                if (!array_key_exists('message', $res)){\n                    $data&#91;'is_sign'] = 1;\n                }else{\n                    throw new AdminException($res&#91;'message']);\n                }<\/code><\/pre>\n\n\n\n<p>\u76f8\u5e94\u7684\u670d\u52a1\u6587\u4ef6\u589e\u52a0\u5165\u53e3\uff0c\u5f00\u542fV3\u652f\u4ed8\u65f6\uff0c\u6587\u4ef6\u4e3a\uff1a\\crmeb\\services\\pay\\storage\\V3WechatPay.php\uff0c\u6dfb\u52a0\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n     *  \u6dfb\u52a0\u5206\u5e10\u7528\u6237\n     * @author yi716\n     *\/\n    public function receiversAdd($type, string $account, string $name, string $relation_type)\n    {\n        return $this-&gt;instance-&gt;v3pay-&gt;receiversAdd($type, $account, $name, $relation_type);\n    }<\/code><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u6587\u4ef6\u4e2d\uff0c\u56e0\u4e3a\u65b0\u589e\u4e86\u90e8\u5206\u7684\u5b57\u6bb5\uff0c\u6240\u4ee5\u9700\u8981\u628a\u5e38\u91cf\u589e\u52a0\u4e0a\u53bb\uff0c\u5728initialize\u51fd\u6570\u4e2d\u589e\u52a0\u4ee5\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$config&#91;'v3_payment']&#91;'mer_type'] = $merType = sys_config('mer_type');\n        if ($merType) {  \/\/ by yi716\n            $config&#91;'v3_payment']&#91;'sub_mch_id'] = trim(sys_config('pay_sub_merchant_id'));\n            $config&#91;'v3_payment']&#91;'sp_appid'] = trim(sys_config('sp_appid'));\n            $config&#91;'v3_payment']&#91;'sub_cert_path'] = public_path() . $this-&gt;getPemPath(sys_config('pay_sub_weixin_client_cert'));\n            $config&#91;'v3_payment']&#91;'sub_key_path'] = public_path() . $this-&gt;getPemPath(sys_config('pay_sub_weixin_client_key'));\n            $config&#91;'v3_payment']&#91;'sub_serial_no'] = trim(sys_config('pay_pub_weixin_serial_no'));\n            $config&#91;'v3_payment']&#91;'sub_key'] = trim(sys_config('pay_sub_weixin_key_v3'));\n        }<\/code><\/pre>\n\n\n\n<p>\u5728\u5177\u4f53\u64cd\u4f5c\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5904\u7406\u51fd\u6570\uff0c\u5982\\crmeb\\services\\easywechat\\v3pay\\PayClient.php\u4e2d\uff0c\u6dfb\u52a0\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u589e\u52a0\u63a5\u53e3\u5e38\u91cf\n\/\/\u6dfb\u52a0\u5206\u5e10\u63a5\u6536\u65b9-\u670d\u52a1\u5546\u6a21\u5f0f by yi716\r\n    const API_PROFITSHAREING_RECEIVERS_ADD_URL = 'v3\/profitsharing\/receivers\/add';\r\n    \/\/\u5220\u9664\u5206\u5e10\u63a5\u6536\u65b9-\u670d\u52a1\u5546\u6a21\u5f0f by yi716\r\n    const API_PROFITSHAREING_RECEIVERS_DEL_URL = 'v3\/profitsharing\/receivers\/delete';\r\n    \/\/\u8bf7\u6c42\u5206\u5e10-\u670d\u52a1\u5546\u6a21\u5f0f  by yi716\r\n    const API_PROFITSHAREING_ORDERS_URL = 'v3\/profitsharing\/orders';\r\n    \/\/\u67e5\u8be2\u5206\u5e10\u7ed3\u679c-\u670d\u52a1\u5546 by yi716\r\n    const API_PROFITSHAREING_ORDERS_SHOW_URL = 'v3\/profitsharing\/orders\/{out_order_no}';\r\n    \/\/\u8bf7\u6c42\u5206\u5e10\u9000\u56de-\u670d\u52a1\u5546\u6a21\u5f0f  by yi716\r\n    const API_PROFITSHAREING_RETURN_URL = 'v3\/profitsharing\/return-orders';\n\n\/*\n    *   \u6dfb\u52a0\u5206\u5e10\u63a5\u6536\u65b9-\u670d\u52a1\u5546\u6a21\u5f0f   by yi716\n    *   type 1:\u7528\u6237\uff0c\u5b50\u5546\u6237OPENID 2:\u5546\u6237\u53f7\n    *\/\n    public function receiversAdd($type = 1, $account = '', $name='', $relation_type = 'SUPPLIER'){\n        \n        $type == 1 ? 'PERSONAL_SUB_OPENID' : 'MERCHANT_ID';\n        \n        \/\/$this->app&#91;'config']&#91;'v3_payment']&#91;'mer_type'];\n        \n        $data = &#91;\n            'appid' => $this->app&#91;'config']&#91;'v3_payment']&#91;'sp_appid'],\n            'sub_appid' => $this->app&#91;'config']&#91;'miniprog']&#91;'appid'],\n            'sub_mchid' => $this->app&#91;'config']&#91;'v3_payment']&#91;'sub_mch_id'],\n            'type' => ($type == 1) ? 'PERSONAL_SUB_OPENID' : 'MERCHANT_ID',\n            'account' => $account,\n            'relation_type' => $relation_type,\n        ];\n        if ($type == 2){\n            $data&#91;'name'] = self::getEncrypt($name);\n        }\n        \n        $datas = &#91;'json' => $data];\n        $res = $this->request(self::API_PROFITSHAREING_RECEIVERS_ADD_URL, 'POST', $datas);\n        \n        if (array_key_exists('message', $res)) {\n            throw new PayException($res&#91;'message']);\n        }\n        return $res;\n    }\n    \n    private function getEncrypt($str) {\n      \/\/$str\u662f\u5f85\u52a0\u5bc6\u5b57\u7b26\u4e32 \n      $public_key_path = $this->app&#91;'config']&#91;'v3_payment']&#91;'sub_key_path'];\n      $public_key = file_get_contents($public_key_path);\n      \/\/$public_key = file_get_contents($this->app&#91;'config']&#91;'v3_payment']&#91;'cert_path']);\n      $encrypted = '';\n      if (openssl_public_encrypt($str, $encrypted, $public_key, OPENSSL_PKCS1_OAEP_PADDING)) {\n        $sign = base64_encode($encrypted);\n      } else {\n        throw new PayException('encrypt failed');\n      } \n      return $sign;\n    }<\/code><\/pre>\n\n\n\n<p><strong>\u76f8\u5173\u7684\u5751\uff1a<\/strong><\/p>\n\n\n\n<p>1\u3001\u5f53\u7528\u6237\u89d2\u8272\u4e3a\u5546\u6237\u65f6\uff0c\u9700\u8981\u4e0a\u62a5name\u5b57\u6bb5\u3002<\/p>\n\n\n\n<p style=\"font-style:normal;font-weight:400\">2\u3001name\u5b57\u6bb5\u9700\u8981\u52a0\u5bc6\uff0c\u5b98\u65b9\u6587\u6863\u662f\u53ef\u91c7\u7528\u3010\u5fae\u4fe1\u652f\u4ed8\u516c\u94a5ID\u3011\u6216\u3010\u5fae\u4fe1\u652f\u4ed8\u5e73\u53f0\u8bc1\u4e66\u5e8f\u5217\u53f7\u3011\u8fdb\u884c\u52a0\u5bc6\uff0c\u4f46\u662f\u5fae\u4fe1\u652f\u4ed8\u516c\u94a5ID\u529f\u80fd\u5728V3\u73af\u5883\u4e0b\u5df2\u4e0d\u5b58\u5728\uff0c\u6240\u4ee5\u9700\u8981\u91c7\u7528\u5fae\u4fe1\u652f\u4ed8\u5e73\u53f0\u8bc1\u4e66\u5e8f\u5217\u53f7\uff0c<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u670d\u52a1\u5546\u6a21\u5f0f\u4e0b\uff0c\u662f\u9700\u8981\u4ee5\u670d\u52a1\u7aef\u7684\u8bc1\u4e66\u548c\u5bc6\u94a5\u6765\u4ea7\u751f\u7684\u3002<\/mark><\/strong><\/p>\n\n\n\n<p>\u8bc1\u4e66\u4e0b\u8f7d\u6587\u6863\u5730\u5740\uff1a<a href=\"https:\/\/pay.weixin.qq.com\/doc\/v3\/merchant\/4012068814\"><a href=\"https:\/\/pay.weixin.qq.com\/doc\/v3\/merchant\/4012068814\">\u5e73\u53f0\u8bc1\u4e66\u7b80\u4ecb\u53ca\u4f7f\u7528\u8bf4\u660e_\u5e73\u53f0\u8bc1\u4e66|\u5fae\u4fe1\u652f\u4ed8\u5546\u6237\u6587\u6863\u4e2d\u5fc3<\/a><\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u589e\u52a0\u5fae\u4fe1\u652f\u4ed8\u5206\u5e10\u529f\u80fd \u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/pay.weixin.qq.com\/doc\/v3\/part [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts\/618"}],"collection":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=618"}],"version-history":[{"count":0,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts\/618\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}