3 Commits
1.0.1 ... 1.0.3

Author SHA1 Message Date
32b76b30d9 调整日志 2021-07-23 14:32:06 +08:00
bdf46a01ec 调整config 2021-07-22 11:06:20 +08:00
a34d344110 修改http 2021-05-26 17:14:36 +08:00
6 changed files with 111 additions and 41 deletions

View File

@@ -11,11 +11,11 @@ return [
'uri' => [ 'uri' => [
'unicom' => [ 'unicom' => [
//下单 //下单
'order' => 'https://www.unicompayment.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8', 'order' => 'https://epay.10010.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8',
//查询 //查询
'query' => 'https://www.unicompayment.com/CashierWeb/query/order.htm?reqCharSet=UTF-8', 'query' => 'https://epay.10010.com/CashierWeb/query/order.htm?reqCharSet=UTF-8',
//单笔退款 //单笔退款
'refund' => 'https://www.unicompayment.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8', 'refund' => 'https://epay.10010.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8',
], ],
'ysd' => [ 'ysd' => [
'order' => env('APP_URL', 'https://card.ysd-bs.com'), 'order' => env('APP_URL', 'https://card.ysd-bs.com'),

View File

@@ -139,7 +139,7 @@ class Init
$result = (bool) openssl_verify($signStr, $sign, $pub_key_id, 'SHA256'); $result = (bool) openssl_verify($signStr, $sign, $pub_key_id, 'SHA256');
openssl_free_key($pub_key_id); openssl_free_key($pub_key_id);
} else { } else {
throw new \Exception('钥格式有误'); throw new \Exception('钥格式有误');
} }
return $result; return $result;
@@ -315,11 +315,15 @@ class Init
parse_str($content, $data); parse_str($content, $data);
$this->data = $data;
if ($data['transRet'] != 'SUCCESS') { if ($data['transRet'] != 'SUCCESS') {
$this->code = false; $this->code = false;
$this->message = $data['resultDis']; $this->message = $data['resultDis'];
} }
$this->code = true;
} else { } else {
$this->code = false; $this->code = false;
$this->message = '接口错误 Post'; $this->message = '接口错误 Post';

View File

@@ -17,6 +17,7 @@ class Sign extends Init
// $signMsg = str_replace('\\', '', $signMsg); // $signMsg = str_replace('\\', '', $signMsg);
$signMsg = str_replace(' ', '+', $signMsg); $signMsg = str_replace(' ', '+', $signMsg);
$this->sign = $signMsg; $this->sign = $signMsg;
info($this->sign);
return $this->checkSign(); return $this->checkSign();

17
src/Model/Wounicom.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace XuanChen\WoUnicom\Model;
use Illuminate\Database\Eloquent\Model;
class Wounicom extends Model
{
protected $guarded = [];
public $casts = [
'source' => 'json',
'outsource' => 'json',
];
}

46
src/Traits/Log.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
namespace XuanChen\WoUnicom\Traits;
use XuanChen\WoUnicom\Model\Wounicom as LogModel;
trait Log
{
public $log;
/**
* Notes: 输入日志
* @Author: 玄尘
* @Date : 2021/5/11 15:58
* @param $data
*/
public function createLog($data, $str)
{
return $this->log = LogModel::create([
'orderId' => $data['orderid'],
'payFloodId' => $data['payfloodid'],
'payResult' => $data['payresult'],
'payBalance' => $data['paybalance'],
'paymentBalanceDetail' => $data['paymentbalancedetail'],
'respTime' => $data['resptime'],
'source' => [
'data' => $data,
'check_sign' => $str,
],
]);
}
/**
* Notes: 更新
* @Author: 玄尘
* @Date : 2021/7/23 11:03
* @param $data
*/
public function updateLog($data)
{
$this->log->outsource = $data;
$this->log->save();
}
}

View File

@@ -3,12 +3,16 @@
namespace XuanChen\WoUnicom; namespace XuanChen\WoUnicom;
use App\Models\Payment; use App\Models\Payment;
use App\Models\Welfare;
use App\Models\WelfareOrder;
use App\Models\WelfarePayment;
use Carbon\Carbon; use Carbon\Carbon;
use XuanChen\WoUnicom\Action\Init; use XuanChen\WoUnicom\Action\Init;
use XuanChen\WoUnicom\Action\Order; use XuanChen\WoUnicom\Action\Order;
use XuanChen\WoUnicom\Action\Query; use XuanChen\WoUnicom\Action\Query;
use XuanChen\WoUnicom\Action\Refund; use XuanChen\WoUnicom\Action\Refund;
use XuanChen\WoUnicom\Action\Sign; use XuanChen\WoUnicom\Action\Sign;
use XuanChen\WoUnicom\Traits\Log;
/** /**
* 沃钱包支付 * 沃钱包支付
@@ -16,6 +20,8 @@ use XuanChen\WoUnicom\Action\Sign;
class WoUnicom class WoUnicom
{ {
use Log;
/** /**
* Notes: 下单 * Notes: 下单
* @Author: 玄尘 * @Author: 玄尘
@@ -89,54 +95,50 @@ class WoUnicom
$res = $this->sign()->setParams($data)->start(); $res = $this->sign()->setParams($data)->start();
//日志 //日志
$this->unicomLog($data, $res); $this->createLog($data, $res);
//验签成功 //验签成功
if ($res === true) { if ($res === true) {
$order = \App\Models\Order::where('orderid', $data['orderid'])->first(); //福利订单
if ($order && $order->state == 'UNPAY') { if (str_contains($data['orderid'], 'WEAL')) {
$payment = \App\Models\Payment::where('orderable_type', get_class($order)) $order = WelfareOrder::where('orderid', $data['orderid'])->first();
->where('orderable_id', $order->id) if ($order && $order->status == 'UNPAY') {
->latest() $payment = $order->payment;
->first();
$payment->paid([
'type' => 'UNICOM',
'payfloodid' => $data['payfloodid'],
]);
$order->paid();
}
} else {
$order = \App\Models\Order::where('orderid', $data['orderid'])->first();
if ($order && $order->state == 'UNPAY') {
$payment = \App\Models\Payment::where('orderable_type', get_class($order))
->where('orderable_id', $order->id)
->latest()
->first();
$payment->state = 'SUCCESS';
$payment->out_trade_no = $data['payfloodid'];
$payment->type = 'UNICOM';
$payment->paid_at = Carbon::now();
$payment->save();
$order->paid();
}
$payment->state = 'SUCCESS';
$payment->out_trade_no = $data['payfloodid'];
$payment->type = 'UNICOM';
$payment->paid_at = Carbon::now();
$payment->save();
$order->paid();
} }
$this->updateLog(['SUCCESS']);
return 'SUCCESS'; return 'SUCCESS';
} else { } else {
$this->updateLog(['验签失败']);
return '验签失败'; return '验签失败';
} }
} }
/**
* Notes: 输入日志
* @Author: 玄尘
* @Date : 2021/5/11 15:58
* @param $data
*/
public function unicomLog($data, $str)
{
$inputData = [
'orderId' => $data['orderid'],
'payFloodId' => $data['payfloodid'],
'payResult' => $data['payresult'],
'payBalance' => $data['paybalance'],
'paymentBalanceDetail' => $data['paymentbalancedetail'],
'respTime' => $data['resptime'],
'source' => [
'data' => $data,
'check_sign' => $str,
],
];
return \App\Models\Wounicom::create($inputData);
}
} }