Jelajahi Sumber

零售发跑腿,收件人号码为空bug修复没改好,重新优化修改

shizhongqi 9 bulan lalu
induk
melakukan
802b8b1112

+ 5 - 4
common/components/delivery/services/DispatchService.php

@@ -6,6 +6,7 @@ use bizGhs\express\classes\DeliveryAuthTokenClass;
 use bizGhs\order\classes\OrderItemClass;
 use common\components\delivery\helpers\HttpClient;
 use common\components\delivery\services\adapter\{DadaAdapter,
+    Functions,
     ShansongAdapter,
     HuolalaAdapter,
     FengniaoAdapter,
@@ -303,7 +304,7 @@ class DispatchService
                         'district_name' => $order['dist'],
                         'house_number' => $order['floor'],
                         'contacts_name' => $order['customName'],
-                        'contacts_phone_no' => isset($order['customMobile'])&&!empty($order['customMobile']) ? $order['customMobile'] : isset($order['receiveMobile'])&&!empty($order['receiveMobile']) ? $order['receiveMobile'] : $order['bookMobile'],
+                        'contacts_phone_no' => Functions::getMobile($order),
                         'lat_lon' => ['lat' => (float)$order['lat'], 'lon' => (float)$order['long']],
                     ]
                 ],
@@ -347,7 +348,7 @@ class DispatchService
         return [
             'platform' => 'fengniao',
             'partner_order_code' => $order['orderSn'],
-            'receiver_primary_phone' => isset($order['customMobile'])&&!empty($order['customMobile']) ? $order['customMobile'] : isset($order['receiveMobile'])&&!empty($order['receiveMobile']) ? $order['receiveMobile'] : $order['bookMobile'],
+            'receiver_primary_phone' => Functions::getMobile($order),
             'receiver_name' => $order['customName'],
             'receiver_latitude' => (float)$order['lat'],
             'receiver_longitude' => (float)$order['long'],
@@ -386,7 +387,7 @@ class DispatchService
                     'toAddress' => $order['address'],
                     'toAddressDetail' => $order['floor'],
                     'toReceiverName' => $order['customName'],
-                    'toMobile' => isset($order['customMobile'])&&!empty($order['customMobile']) ? $order['customMobile'] : isset($order['receiveMobile'])&&!empty($order['receiveMobile']) ? $order['receiveMobile'] : $order['bookMobile'],
+                    'toMobile' => Functions::getMobile($order),
                     'toLatitude' => (float)$order['lat'],
                     'toLongitude' => (float)$order['long'],
                     'goodType' => 7,
@@ -493,7 +494,7 @@ class DispatchService
             'receiver_lng' => (float)$order['long'],
             'callback' => $callbackUrl,
             'cargo_weight' => isset($order['weight']) ? (float)$order['weight'] : 1.0,
-            'receiver_phone' => isset($order['customMobile'])&&!empty($order['customMobile']) ? $order['customMobile'] : isset($order['receiveMobile'])&&!empty($order['receiveMobile']) ? $order['receiveMobile'] : $order['bookMobile'],
+            'receiver_phone' => Functions::getMobile($order),
             'tips' => 0,
             'info' => $order['remark'] ?? '',
             'product_list' => $productList,

+ 1 - 1
common/components/delivery/services/adapter/FengniaoAdapter.php

@@ -101,7 +101,7 @@ class FengniaoAdapter extends Fengniao implements Adapter
         $orderData = [
             //'out_shop_code' => $params['mainId'], // 当使用门店发单 out_shop_code 和 chain_store_id 必填1个
             'partner_order_code' => $order['orderSn'],
-            'receiver_primary_phone' => isset($order['customMobile'])&&!empty($order['customMobile']) ? $order['customMobile'] : isset($order['receiveMobile'])&&!empty($order['receiveMobile']) ? $order['receiveMobile'] : $order['bookMobile'],
+            'receiver_primary_phone' => Functions::getMobile($order),
             'receiver_name' => $order['customName'],
             'receiver_latitude' => (float)$order['lat'],
             'receiver_longitude' => (float)$order['long'],

+ 20 - 0
common/components/delivery/services/adapter/Functions.php

@@ -0,0 +1,20 @@
+<?php
+namespace common\components\delivery\services\adapter;
+
+Class Functions {
+    public static function getMobile($order){
+        if(isset($order['customMobile']) && $order['customMobile'] != '') {
+            return $order['customMobile'];
+        }
+
+        if(isset($order['receiveMobile']) && $order['receiveMobile'] != '') {
+            return $order['receiveMobile'];
+        }
+
+        if(isset($order['bookMobile']) && $order['bookMobile'] != '') {
+            return $order['bookMobile'];
+        }
+
+        return false;
+    }
+}

+ 1 - 1
common/components/delivery/services/adapter/HuolalaAdapter.php

@@ -222,7 +222,7 @@ class HuolalaAdapter extends Huolala implements Adapter
                      'district_name' => $order['dist'],
                      'house_number' => $order['floor'],
                      'contacts_name' => $order['customName'],
-                     'contacts_phone_no' => isset($order['customMobile'])&&!empty($order['customMobile']) ? $order['customMobile'] : isset($order['receiveMobile'])&&!empty($order['receiveMobile']) ? $order['receiveMobile'] : $order['bookMobile'],
+                     'contacts_phone_no' => Functions::getMobile($order),
                  ]
             ],
             'vehicle_std' => $params['vehicle_std'],