From 95e1f4a163634f3828f006af03e7e41d4f9c9f53 Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Wed, 6 Sep 2023 11:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0000_00_00_000000_create_wo_unicom_webs_table.php | 4 ++-- src/Action/Init.php | 7 +++++-- src/Action/Order.php | 3 ++- src/Action/Query.php | 9 ++++----- src/Action/Refund.php | 9 +++++---- src/Model/WounicomWeb.php | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/database/migrations/0000_00_00_000000_create_wo_unicom_webs_table.php b/database/migrations/0000_00_00_000000_create_wo_unicom_webs_table.php index 8e170db..01a9265 100644 --- a/database/migrations/0000_00_00_000000_create_wo_unicom_webs_table.php +++ b/database/migrations/0000_00_00_000000_create_wo_unicom_webs_table.php @@ -13,7 +13,7 @@ class CreateWoUnicomWebsTable extends Migration */ public function up() { - Schema::create('wo_unicom_webs', function (Blueprint $table) { + Schema::create('wounicom_webs', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('orderId')->nullable()->comment('订单号'); $table->string('payFloodId')->nullable()->comment('交易流水号'); @@ -34,6 +34,6 @@ class CreateWoUnicomWebsTable extends Migration */ public function down() { - Schema::dropIfExists('wo_unicom_webs'); + Schema::dropIfExists('wounicom_webs'); } } diff --git a/src/Action/Init.php b/src/Action/Init.php index 0583d59..9444df6 100644 --- a/src/Action/Init.php +++ b/src/Action/Init.php @@ -161,6 +161,7 @@ class Init public function getSign(): string { $signStr = $this->getSignString(); + $private_key = $this->getPrivate(); $privKeyId = openssl_get_privatekey($private_key); @@ -196,7 +197,9 @@ class Init ksort($params); $signStr = $this->str2utf8(urldecode(http_build_query($params, '', '|'))); - $signStr .= '|key='.$this->key; + $this->signStr = $signStr; + +// $signStr .= '|key='.$this->key; return $signStr; } @@ -319,8 +322,8 @@ class Init if ($response->getStatusCode() == 200) { $body = $response->getBody(); $content = str_replace(["\r\n", "\n", "\r", '/n', "\\n",], '&', $body->getContents()); - parse_str($content, $data); + parse_str($content, $data); $this->data = $data; if (isset($data['queryResult']) && $data['queryResult'] != 'SUCCESS') { diff --git a/src/Action/Order.php b/src/Action/Order.php index 3a0912b..ee7452d 100644 --- a/src/Action/Order.php +++ b/src/Action/Order.php @@ -20,7 +20,8 @@ class Order extends Init { $this->addData(); $this->setSignData(); - +// dump($this); +// dump($this->params); return $this->getUnicomData('$'); } diff --git a/src/Action/Query.php b/src/Action/Query.php index 74ed37a..249635d 100644 --- a/src/Action/Query.php +++ b/src/Action/Query.php @@ -4,6 +4,7 @@ namespace XuanChen\WoUnicomWeb\Action; /** * Class Order 查询 + * * @Author : 玄尘 * @Date : 2021/4/30 9:34 * @package XuanChen\Coupon\Action @@ -16,7 +17,7 @@ class Query extends Init $this->setIsLower(false); $this->addData(); $this->setSignData(); - $url = config('wounicom.uri.unicom.query'); + $url = config('wounicomweb.uri.unicom.query'); $this->sendPost($this->params, $url); return $this->respond(); @@ -25,17 +26,15 @@ class Query extends Init public function addData() { $order = $this->params; - - $data = [ + $data = [ 'merNo' => $this->merNo, 'orderNo' => $order->orderid, 'orderDate' => $order->created_at->format('Ymd'), 'charSet' => 'UTF-8', - 'signType' => config('wounicom.signType'), + 'signType' => config('wounicomweb.signType'), ]; $this->params = $data; - } } diff --git a/src/Action/Refund.php b/src/Action/Refund.php index e3bd0a4..add956b 100644 --- a/src/Action/Refund.php +++ b/src/Action/Refund.php @@ -6,6 +6,7 @@ use Carbon\Carbon; /** * Class Order 退款 + * * @Author : 玄尘 * @Date : 2021/4/30 9:34 * @package XuanChen\Coupon\Action @@ -18,7 +19,7 @@ class Refund extends Init $this->reSetParams(); $this->setIsLower(false); $this->setSignData(); - $url = config('wounicom.uri.unicom.refund'); + $url = config('wounicomweb.uri.unicom.refund'); $this->sendPost($this->params, $url); return $this->respond(); @@ -29,15 +30,15 @@ class Refund extends Init $order = $this->params; $data = [ - 'refundReqJournl' => 'R' . date('YmdHis') . sprintf('%06d', rand(1, 999999999)), + 'refundReqJournl' => 'R'.date('YmdHis').sprintf('%06d', rand(1, 999999999)), 'merNo' => $this->merNo, 'orderNo' => $order->orderid, 'orderDate' => $order->created_at->format('Ymd'), 'payJournl' => $order->payment->out_trade_no, 'merReqTime' => Carbon::now()->format('YmdHis'), - 'amount' => $order->payment->amount * 100, + 'amount' => bcmul($order->payment->amount,100), 'reason' => '退款', - 'signType' => 'RSA_SHA256', + 'signType' => config('wounicomweb.signType'), ]; $this->params = $data; diff --git a/src/Model/WounicomWeb.php b/src/Model/WounicomWeb.php index 1c9cce8..247b9de 100644 --- a/src/Model/WounicomWeb.php +++ b/src/Model/WounicomWeb.php @@ -8,7 +8,7 @@ class WounicomWeb extends Model { protected $guarded = []; - + public $casts = [ 'source' => 'json', 'outsource' => 'json',