stanley-king преди 1 година
родител
ревизия
40b04aec0c
променени са 1 файла, в които са добавени 6 реда и са изтрити 6 реда
  1. 6 6
      helper/refill/api/xyz/leyou/RefillOil.php

+ 6 - 6
helper/refill/api/xyz/leyou/RefillOil.php

@@ -69,14 +69,14 @@ class RefillOil extends refill\IRefillOil
 
     public function query($refill_info)
     {
-        $waterno_by_voucher = function ($voucher): string
+        $extract_official_sn = function ($voucher): string
         {
             $matches = [];
-            $ret = preg_match("/\:(\d+)/", $voucher, $matches);
-            if ($ret === 1 && !empty($matches)) {
+            if (preg_match("/\:(\d+)/", $voucher, $matches)) {
                 return $matches[1];
+            } else {
+                return '';
             }
-            return '';
         };
 
         $params['username'] = config::USER_NAME;
@@ -99,8 +99,8 @@ class RefillOil extends refill\IRefillOil
             {
                 $status = $resp['data']['status'];
                 if ($status === 5) {
-                    $updata['official_sn'] = $waterno_by_voucher($resp['data']['voucher']);
-                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $official_sn = $extract_official_sn($resp['data']['voucher']);
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $official_sn]);
                     $order_state = ORDER_STATE_SUCCESS;
                 } elseif ($status === 6) {
                     $order_state = ORDER_STATE_CANCEL;