sifangpay/app/ServicePay/TransCard/ExampleCard.php

56 lines
1.5 KiB
PHP

<?php
namespace App\ServicePay\TransCard;
use App\Models\Order;
class ExampleCard extends BaseCard
{
public function message($msg)
{
$this->msg = $msg;
$this->analysisMsg();
}
private function analysisMsg(){
$pattern = '/[0-9]{10,}|[0-9]{1,}\.[0-9]{1,2}/';
preg_match_all($pattern, $this->msg, $matches, PREG_PATTERN_ORDER);
if ($matches[0]) {
$this->orderInfo = [
'from_card' => $matches[0][1],
'pay_money' => $matches[0][0],
'order_number' => $matches[0][2],
];
}
}
// 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_at', '<', $t)
->where('order_money', $order_money)
->where('ewm_account', $ewm_account)
// ->whereIn('status', [0, 2])
->orderBy('id', 'desc')->first();
}
}