t适配菲律宾短信
This commit is contained in:
parent
44d46810ba
commit
5ea62229f4
|
@ -4,14 +4,13 @@ namespace App\ServicePay;
|
|||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Message;
|
||||
use App\Models\Order;
|
||||
use App\ServicePay\TransCard\ExampleCard;
|
||||
use App\ServicePay\TransCard\FeilvbinCard;
|
||||
use App\ServicePay\TransCard\GetTransInfo;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GuMaPayServices implements PayApiInterface
|
||||
{
|
||||
|
||||
use PayTrait;
|
||||
public $gateway_list;//当前类型的支付通道列表
|
||||
public $pay_type;//支付类型
|
||||
|
@ -146,18 +145,18 @@ class GuMaPayServices implements PayApiInterface
|
|||
|
||||
/**
|
||||
* 取得订单,需要分开处理
|
||||
* @param $ewm_account
|
||||
* @param GetTransInfo $getTrans
|
||||
* @param array $requestArr
|
||||
* @return false|void
|
||||
*/
|
||||
private function getOrder($ewm_account,$order_money)
|
||||
private function getOrderFromMsg(GetTransInfo $getTrans, array $requestArr=[])
|
||||
{
|
||||
$order_money = number_format($order_money, 2, ',', '');
|
||||
//查找未支付的订单
|
||||
$this->order = Order::where('ewm_account', $ewm_account)->where('order_money', $order_money)
|
||||
->whereIn('status', [0,2])->first();
|
||||
//匹配阿拉伯短信
|
||||
|
||||
$this->order=$getTrans->getOrderInfo($requestArr);
|
||||
//订单不存在返回空
|
||||
if (empty($this->order)) {
|
||||
$this->debugLog('订单不存在:' . $ewm_account);
|
||||
$this->debugLog('订单不存在:'.json_encode($getTrans->getInfo()) ,$requestArr);
|
||||
return false;
|
||||
}
|
||||
$this->pay_method = $this->order->gateway_method;//支付方法
|
||||
|
@ -171,7 +170,7 @@ class GuMaPayServices implements PayApiInterface
|
|||
$this->setLogName($pay_type);
|
||||
$this->debugLog('回调原始数据', $allData);
|
||||
(new Message())->addMsg($allData);
|
||||
$card = new ExampleCard();
|
||||
$card = new FeilvbinCard();
|
||||
$card->message($allData['content']);
|
||||
$getTrans = new GetTransInfo($card);
|
||||
$requestArr = $getTrans->getInfo();
|
||||
|
@ -183,10 +182,14 @@ class GuMaPayServices implements PayApiInterface
|
|||
$this->pay_type = $pay_type;
|
||||
$this->request = $request;
|
||||
//取得订单,是否有此订单,如果没有直接返回空
|
||||
$ewm_account = $requestArr['from_card'];
|
||||
//order_money
|
||||
$ewm_account = $requestArr['from_card'];
|
||||
if (is_null($ewm_account)) {
|
||||
return '参数异常';
|
||||
}
|
||||
|
||||
//取得订单
|
||||
$this->getOrder($ewm_account, $requestArr['pay_money']);
|
||||
$this->getOrderFromMsg($getTrans, []);
|
||||
if (empty($this->order)) {
|
||||
return '订单不存在';
|
||||
}
|
||||
|
|
|
@ -8,4 +8,6 @@ abstract class BaseCard
|
|||
abstract public function message($msg);
|
||||
|
||||
abstract public function showInfo();
|
||||
|
||||
abstract public function orderInfo($requestArr);
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\ServicePay\TransCard;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class ExampleCard extends BaseCard
|
||||
{
|
||||
private $orderInfo = [];
|
||||
|
@ -24,7 +26,7 @@ class ExampleCard extends BaseCard
|
|||
}
|
||||
}
|
||||
|
||||
public function showInfo()
|
||||
public function showInfo(): array
|
||||
{
|
||||
$init = [
|
||||
'from_card' => null,
|
||||
|
@ -35,4 +37,19 @@ class ExampleCard extends BaseCard
|
|||
|
||||
return array_merge($init, $this->orderInfo);
|
||||
}
|
||||
|
||||
//获取订单信息
|
||||
public function orderInfo($requestArr)
|
||||
{
|
||||
$showInfo = $this->showInfo();
|
||||
$ewm_account = $showInfo['from_card'];
|
||||
$order_money = $showInfo['pay_money'];
|
||||
$order_money = number_format($order_money, 2, ',', '');
|
||||
//查找未支付的订单
|
||||
$t = date('Y-m-d H:i:s');
|
||||
return Order::where('ewm_account', $ewm_account)
|
||||
->where('order_at', '<', $t)
|
||||
->where('order_money', $order_money)
|
||||
->whereIn('status', [0, 2])->first();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\ServicePay\TransCard;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class FeilvbinCard extends BaseCard
|
||||
{
|
||||
private $orderInfo = [];
|
||||
public function message($msg)
|
||||
{
|
||||
$this->msg = $msg;
|
||||
$pattern= '/(?<=P)\d+\.\d{2}|\d{2}-\d{2}-\d{2}\s\d{2}:\d{2}\s\w{2}|(?<=\s)\d{4}(?=\.)|(?<=No.\s)\d{10,}(?=\.)/';
|
||||
preg_match_all($pattern, $this->msg, $matches, PREG_PATTERN_ORDER);
|
||||
if ($matches[0]) {
|
||||
$this->orderInfo = [
|
||||
'pay_money' => $matches[0][0],
|
||||
'from_card' => $matches[0][1],
|
||||
'sms_date' => $matches[0][3],
|
||||
'order_number' => $matches[0][4],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function showInfo(): array
|
||||
{
|
||||
$init = [
|
||||
'from_card' => null,
|
||||
'pay_money' => null,
|
||||
'remark' => null,
|
||||
'order_number' => null,
|
||||
];
|
||||
|
||||
return array_merge($init, $this->orderInfo);
|
||||
}
|
||||
|
||||
public function orderInfo($requestArr)
|
||||
{
|
||||
$showInfo = $this->showInfo();
|
||||
$ewm_account = $showInfo['from_card'];
|
||||
$order_money = $showInfo['pay_money'];
|
||||
$order_money = number_format($order_money, 2, ',', '');
|
||||
//查找未支付的订单
|
||||
$t = date('Y-m-d H:i:s');
|
||||
return Order::where('order_money', $order_money)
|
||||
->where('order_at', '<', $t)
|
||||
->whereRaw('substr(ewm_account,-4,4)=?',[$ewm_account])
|
||||
->whereIn('status', [0, 2])->first();
|
||||
}
|
||||
}
|
|
@ -22,4 +22,12 @@ class GetTransInfo
|
|||
{
|
||||
return $this->card->showInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $requestArr
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrderInfo($requestArr){
|
||||
return $this->card->orderInfo($requestArr);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue