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(); } }