From 3f58973c30d32ad336f56eafd7802439dd939268 Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Tue, 5 Sep 2023 10:49:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++ composer.json | 2 +- config/config.php | 18 ++++----- ..._00_000000_create_wo_unicom_webs_table.php | 39 +++++++++++++++++++ src/Action/Init.php | 5 +-- src/Action/Order.php | 2 +- src/Action/Query.php | 4 +- src/Action/Refund.php | 2 +- src/ServiceProvider.php | 5 ++- src/Traits/Log.php | 4 +- src/WoUnicomWeb.php | 24 ++++++++++-- 11 files changed, 92 insertions(+), 23 deletions(-) create mode 100644 database/migrations/0000_00_00_000000_create_wo_unicom_webs_table.php diff --git a/README.md b/README.md index 559f3a7..62fa9c1 100644 --- a/README.md +++ b/README.md @@ -1 +1,11 @@ # 沃支付 WEB收银台支付接口文档 + +测试地址 +支付:https://www.unicompayment.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8 +单笔查询:https://www.unicompayment.com/CashierWeb/query/order.htm?reqCharSet=UTF-8 +单笔订单退款:https://www.unicompayment.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8 + +正式地址 +支付:https://epay.10010.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8 +单笔查询:https://epay.10010.com/CashierWeb/query/order.htm?reqCharSet=UTF-8 +单笔订单退款:https://epay.10010.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8 diff --git a/composer.json b/composer.json index cbf8221..3ba341d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "xuanchen/wounicomweb", - "description": "沃钱包支付-WEB收银台支付接口文档", + "description": "沃钱包支付-驰玖", "license": "MIT", "homepage": "https://git.yuzhankeji.cn/xuanchen/WoUnicomWeb.git", "authors": [ diff --git a/config/config.php b/config/config.php index e0ef789..69231f4 100644 --- a/config/config.php +++ b/config/config.php @@ -1,9 +1,9 @@ env('WO_UNICOM_MERNO', ''),//商户编号 - 'storeName' => env('WO_UNICOM_STORENAME', ''),//商户名 - 'key' => env('WO_UNICOM_KEY', ''),//商户密钥 + 'merNo' => env('WO_UNICOM_WEB_MERNO', ''),//商户编号 + 'storeName' => env('WO_UNICOM_WEB_STORE_NAME', ''),//商户名 + 'key' => env('WO_UNICOM_WEB_KEY', ''),//商户密钥 'signType' => 'RSA_SHA256',//签名方式 'woproductcode' => '',//产品编码 @@ -11,11 +11,11 @@ return [ 'uri' => [ 'unicom' => [ //下单 - 'order' => 'https://epay.10010.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8', + 'order' => 'https://www.unicompayment.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8', //查询 - 'query' => 'https://epay.10010.com/CashierWeb/query/order.htm?reqCharSet=UTF-8', + 'query' => 'https://www.unicompayment.com/CashierWeb/query/order.htm?reqCharSet=UTF-8', //单笔退款 - 'refund' => 'https://epay.10010.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8', + 'refund' => 'https://www.unicompayment.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8', ], 'ysd' => [ 'order' => env('APP_URL', 'https://card.ysd-bs.com'), @@ -25,8 +25,8 @@ return [ //证书地址 'certificate' => [ - 'private' => env('WO_YSD_KEY_PATH', ''),//本地私钥 - 'public' => env('WO_YSD_CERT_PATH', ''),//本地公钥 - 'unicom_public' => env('WO_CERT_PATH', ''),//沃钱包公钥 + 'private' => env('WO_YSD_KEY_WEB_PATH', ''),//本地私钥 + 'public' => env('WO_YSD_CERT_WEB_PATH', ''),//本地公钥 + 'unicom_public' => env('WO_CERT_WEB_PATH', ''),//沃钱包公钥 ], ]; 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 new file mode 100644 index 0000000..8e170db --- /dev/null +++ b/database/migrations/0000_00_00_000000_create_wo_unicom_webs_table.php @@ -0,0 +1,39 @@ +bigIncrements('id'); + $table->string('orderId')->nullable()->comment('订单号'); + $table->string('payFloodId')->nullable()->comment('交易流水号'); + $table->string('payResult')->nullable()->comment('支付结果'); + $table->string('payBalance')->nullable()->comment('支付金额'); + $table->string('paymentBalanceDetail')->nullable()->comment('金额明细'); + $table->string('respTime')->nullable()->comment('支付时间'); + $table->json('source')->nullable(); + $table->json('outsource')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('wo_unicom_webs'); + } +} diff --git a/src/Action/Init.php b/src/Action/Init.php index 426b708..0583d59 100644 --- a/src/Action/Init.php +++ b/src/Action/Init.php @@ -115,7 +115,6 @@ class Init { $sign = $this->getSign(); $this->params['signMsg'] = $sign; - return $this->params; } @@ -197,7 +196,7 @@ class Init ksort($params); $signStr = $this->str2utf8(urldecode(http_build_query($params, '', '|'))); - + $signStr .= '|key='.$this->key; return $signStr; } @@ -207,7 +206,7 @@ class Init * @Author: 玄尘 * @Date : 2021/5/6 8:32 */ - public function getUnicomData($prefix = '$') + public function getUnicomData($prefix = '&') { $str = ''; diff --git a/src/Action/Order.php b/src/Action/Order.php index 1d98ee6..3a0912b 100644 --- a/src/Action/Order.php +++ b/src/Action/Order.php @@ -21,7 +21,7 @@ class Order extends Init $this->addData(); $this->setSignData(); - return $this->getUnicomData(); + return $this->getUnicomData('$'); } /** diff --git a/src/Action/Query.php b/src/Action/Query.php index f70884c..74ed37a 100644 --- a/src/Action/Query.php +++ b/src/Action/Query.php @@ -16,7 +16,7 @@ class Query extends Init $this->setIsLower(false); $this->addData(); $this->setSignData(); - $url = config('wounicomweb.uri.unicom.query'); + $url = config('wounicom.uri.unicom.query'); $this->sendPost($this->params, $url); return $this->respond(); @@ -31,7 +31,7 @@ class Query extends Init 'orderNo' => $order->orderid, 'orderDate' => $order->created_at->format('Ymd'), 'charSet' => 'UTF-8', - 'signType' => config('wounicomweb.signType'), + 'signType' => config('wounicom.signType'), ]; $this->params = $data; diff --git a/src/Action/Refund.php b/src/Action/Refund.php index c34ab28..e3bd0a4 100644 --- a/src/Action/Refund.php +++ b/src/Action/Refund.php @@ -18,7 +18,7 @@ class Refund extends Init $this->reSetParams(); $this->setIsLower(false); $this->setSignData(); - $url = config('wounicomweb.uri.unicom.refund'); + $url = config('wounicom.uri.unicom.refund'); $this->sendPost($this->params, $url); return $this->respond(); diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 446baaf..4f09add 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -16,10 +16,11 @@ class ServiceProvider extends LaravelServiceProvider { if ($this->app->runningInConsole()) { $this->publishes([__DIR__.'/../config/config.php' => config_path('wounicomweb.php')]); + $this->loadMigrationsFrom(__DIR__.'/../database/migrations/'); } $this->app->bind('xuanchen.wounicomweb', function ($app) { - return new WoUnicom(); + return new WoUnicomWeb(); }); } @@ -30,7 +31,7 @@ class ServiceProvider extends LaravelServiceProvider */ public function boot() { - $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'wounicom'); + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'wounicomweb'); } } diff --git a/src/Traits/Log.php b/src/Traits/Log.php index 5735ffc..4bd4e77 100644 --- a/src/Traits/Log.php +++ b/src/Traits/Log.php @@ -2,7 +2,7 @@ namespace XuanChen\WoUnicomWeb\Traits; -use XuanChen\WoUnicomWeb\Model\Wounicom as LogModel; +use XuanChen\WoUnicomWeb\Model\WounicomWeb as LogModel; trait Log { @@ -11,6 +11,7 @@ trait Log /** * Notes: 输入日志 + * * @Author: 玄尘 * @Date : 2021/5/11 15:58 * @param $data @@ -33,6 +34,7 @@ trait Log /** * Notes: 更新 + * * @Author: 玄尘 * @Date : 2021/7/23 11:03 * @param $data diff --git a/src/WoUnicomWeb.php b/src/WoUnicomWeb.php index 8d25276..a739b67 100644 --- a/src/WoUnicomWeb.php +++ b/src/WoUnicomWeb.php @@ -3,6 +3,7 @@ namespace XuanChen\WoUnicomWeb; use App\Helpers\Helper; +use App\Models\ActivityMonthOrder; use App\Models\ActivitySchoolOrder; use App\Models\ActivityPetroOrder; use App\Models\ActivityUnicomOrder; @@ -95,6 +96,7 @@ class WoUnicomWeb */ public function callback($inputs) { + info($inputs); if (empty($inputs)) { return '缺少必要参数'; } @@ -126,7 +128,7 @@ class WoUnicomWeb break; case 'school': $order = ActivitySchoolOrder::where('orderid', $data['orderid'])->first(); - if ($order && $order->state == 'UNPAY') { + if ($order && $order->state == ActivitySchoolOrder::ORDER_UNPAY) { $payment = Payment::where('orderable_type', get_class($order)) ->where('orderable_id', $order->id) ->latest() @@ -142,6 +144,22 @@ class WoUnicomWeb break; case 'petro': $order = ActivityPetroOrder::where('orderid', $data['orderid'])->first(); + if ($order && $order->state == ActivityMonthOrder::ORDER_UNPAY) { + $payment = Payment::where('orderable_type', get_class($order)) + ->where('orderable_id', $order->id) + ->latest() + ->first(); + + $payment->state = Payment::STATE_SUCCESS; + $payment->out_trade_no = $data['payfloodid']; + $payment->type = Payment::TYPT_UNICOM_WEB; + $payment->paid_at = Carbon::now(); + $payment->save(); + $order->paid(); + } + break; + case 'unicom': + $order = ActivityUnicomOrder::where('orderid', $data['orderid'])->first(); if ($order && $order->state == 'UNPAY') { $payment = Payment::where('orderable_type', get_class($order)) ->where('orderable_id', $order->id) @@ -156,8 +174,8 @@ class WoUnicomWeb $order->paid(); } break; - case 'unicom': - $order = ActivityUnicomOrder::where('orderid', $data['orderid'])->first(); + case 'month': + $order = ActivityMonthOrder::where('orderid', $data['orderid'])->first(); if ($order && $order->state == 'UNPAY') { $payment = Payment::where('orderable_type', get_class($order)) ->where('orderable_id', $order->id)