7 Commits
1.0.3 ... 1.0.9

Author SHA1 Message Date
6ce0c48aec 增加适配联通活动 2022-03-09 10:16:51 +08:00
ccaccbd129 修不过 2022-02-24 13:35:08 +08:00
b677771328 微调 2022-02-23 17:06:50 +08:00
e640647709 删除无用代码 2021-08-13 13:06:01 +08:00
f49481ad29 修改字符串判断 2021-08-13 09:39:26 +08:00
3d867be82d 微调 2021-08-12 17:06:57 +08:00
a803fc2f1d 增加查询接口 2021-08-12 16:43:15 +08:00
5 changed files with 120 additions and 41 deletions

View File

@@ -156,8 +156,7 @@ class Init
{
$signStr = $this->getSignString();
$private_key = $this->getPrivate();
$privKeyId = openssl_get_privatekey($private_key);
$privKeyId = openssl_get_privatekey($private_key);
if (!$privKeyId) {
throw new \Exception('私钥格式有误');
@@ -301,7 +300,6 @@ class Init
}
$client = new Client();
try {
$response = $client->request('POST', $url, [
'form_params' => $paramArray,
@@ -312,26 +310,27 @@ class Init
if ($response->getStatusCode() == 200) {
$body = $response->getBody();
$content = str_replace(["\r\n", "\n", "\r", '/n', "\\n",], '&', $body->getContents());
parse_str($content, $data);
$this->data = $data;
if ($data['transRet'] != 'SUCCESS') {
$this->code = false;
$this->message = $data['resultDis'];
if (isset($data['queryResult']) && $data['queryResult'] != 'SUCCESS') {
throw new \Exception('返回的数据错误');
}
if (isset($data['transRet']) && $data['transRet'] != 'SUCCESS') {
throw new \Exception($data['resultDis']);
}
$this->code = true;
} else {
$this->code = false;
$this->message = '接口错误 Post';
throw new \Exception('未正常返回数据');
}
} catch (\Exception $exception) {
$this->code = false;
$this->message = '接口错误 Post' . $exception->getMessage();
$this->message = '接口错误 ' . $exception->getMessage();
}
}

View File

@@ -13,6 +13,28 @@ class Query extends Init
public function start()
{
$this->setIsLower(false);
$this->addData();
$this->setSignData();
$url = config('wounicom.uri.unicom.query');
$this->sendPost($this->params, $url);
return $this->respond();
}
public function addData()
{
$order = $this->params;
$data = [
'merNo' => $this->merNo,
'orderNo' => $order->orderid,
'orderDate' => $order->created_at->format('Ymd'),
'charSet' => 'UTF-8',
'signType' => config('wounicom.signType'),
];
$this->params = $data;
}

View File

@@ -35,7 +35,7 @@ class Refund extends Init
'orderDate' => $order->created_at->format('Ymd'),
'payJournl' => $order->payment->out_trade_no,
'merReqTime' => Carbon::now()->format('YmdHis'),
'amount' => -1,
'amount' => $order->payment->amount * 100,
'reason' => '退款',
'signType' => 'RSA_SHA256',
];

View File

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

View File

@@ -2,11 +2,16 @@
namespace XuanChen\WoUnicom;
use App\Helpers\Helper;
use App\Models\ActivitySchoolOrder;
use App\Models\ActivityPetroOrder;
use App\Models\ActivityUnicomOrder;
use App\Models\Payment;
use App\Models\Welfare;
use App\Models\WelfareOrder;
use App\Models\WelfarePayment;
use Carbon\Carbon;
use Illuminate\Support\Str;
use XuanChen\WoUnicom\Action\Init;
use XuanChen\WoUnicom\Action\Order;
use XuanChen\WoUnicom\Action\Query;
@@ -24,6 +29,7 @@ class WoUnicom
/**
* Notes: 下单
*
* @Author: 玄尘
* @Date : 2021/4/30 9:36
* @return \XuanChen\WoUnicom\Action\Order
@@ -39,17 +45,22 @@ class WoUnicom
/**
* Notes: 查询订单
*
* @Author: 玄尘
* @Date : 2021/4/30 9:39
* @return \XuanChen\WoUnicom\Action\Query
*/
public function query()
{
return (new Query());
$action = new Query();
$action->setConfig();
return $action;
}
/**
* Notes: 退款
*
* @Author: 玄尘
* @Date : 2021/4/30 9:37
*/
@@ -64,6 +75,7 @@ class WoUnicom
/**
* Notes: 验签
*
* @Author: 玄尘
* @Date : 2021/5/11 11:51
* @param $params
@@ -78,6 +90,7 @@ class WoUnicom
/**
* Notes: 回调数据
*
* @Author: 玄尘
* @Date : 2021/5/11 15:54
* @param $params
@@ -99,44 +112,90 @@ class WoUnicom
//验签成功
if ($res === true) {
$channel = Helper::getChannel($data['orderid']);
switch ($channel) {
case 'welfare':
$order = WelfareOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->status == 'UNPAY') {
$payment = $order->payment;
//福利订单
if (str_contains($data['orderid'], 'WEAL')) {
$order = WelfareOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->status == 'UNPAY') {
$payment = $order->payment;
$payment->paid([
'type' => 'UNICOM',
'payfloodid' => $data['payfloodid'],
]);
$order->paid();
}
break;
case 'school':
$order = ActivitySchoolOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->state == 'UNPAY') {
$payment = Payment::where('orderable_type', get_class($order))
->where('orderable_id', $order->id)
->latest()
->first();
$payment->paid([
'type' => 'UNICOM',
'payfloodid' => $data['payfloodid'],
]);
$order->paid();
}
$payment->state = 'SUCCESS';
$payment->out_trade_no = $data['payfloodid'];
$payment->type = 'UNICOM';
$payment->paid_at = Carbon::now();
$payment->save();
$order->paid();
}
break;
case 'petro':
$order = ActivityPetroOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->state == 'UNPAY') {
$payment = Payment::where('orderable_type', get_class($order))
->where('orderable_id', $order->id)
->latest()
->first();
} else {
$order = \App\Models\Order::where('orderid', $data['orderid'])->first();
$payment->state = 'SUCCESS';
$payment->out_trade_no = $data['payfloodid'];
$payment->type = 'UNICOM';
$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)
->latest()
->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();
}
break;
case 'web':
default:
$order = \App\Models\Order::where('orderid', $data['orderid'])->first();
if ($order && $order->state == 'UNPAY') {
$payment = 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();
}
break;
}
$this->updateLog(['SUCCESS']);
return 'SUCCESS';
} else {
$this->updateLog(['验签失败']);
return '验签失败';
}
}