From aa65a783f51618f910b1288e092787c129e55224 Mon Sep 17 00:00:00 2001
From: zm <zm@iemsoft.cn>
Date: Mon, 05 Apr 2021 11:50:14 +0800
Subject: [PATCH] 1提货卡号导入模板修改成xls文件,不再支持csv, 2兑换时,按电话号查询地址,如果订单表未查到,增加功能:从地址表查询地址和收件人姓名

---
 forms/common/CommonUser.php |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/forms/common/CommonUser.php b/forms/common/CommonUser.php
index 65f1385..deb0e0c 100644
--- a/forms/common/CommonUser.php
+++ b/forms/common/CommonUser.php
@@ -14,6 +14,7 @@
 use app\models\UserIdentity;
 use app\models\UserInfo;
 use app\models\Order;
+use app\models\Address;
 
 class CommonUser
 {
@@ -228,6 +229,7 @@
     public static function getUserAndAddressByMobile($keyword)
     {
         $keyword = trim($keyword);
+        $newList = [];
 
         $query = Order::find()->alias('o')->where([
             'AND',
@@ -236,14 +238,28 @@
         ]);
 
         $list = $query->orderBy(['created_at'=>SORT_DESC])->limit(1)->all();
-
-        $newList = [];
-        /** @var User[] $list */
-        foreach ($list as $k => $v) {
-            $newList[] = [
-                'name' => $v->name,
-                'address' => $v->address,
-            ];
+        if(count($list) == 0){
+            $query = Address::find()->alias('o')->where([
+                'AND',
+                ['o.mobile' => $keyword],
+                ['o.is_delete' => '0'],
+            ]);
+            $list = $query->orderBy(['created_at'=>SORT_DESC])->limit(1)->all();
+            /** @var User[] $list */
+            foreach ($list as $k => $v) {
+                $newList[] = [
+                    'name' => $v->name,
+                    'address' => $v->province.' '.$v->city.' '.$v->district.' '.$v->detail,
+                ];
+            }
+        }else{
+            /** @var User[] $list */
+            foreach ($list as $k => $v) {
+                $newList[] = [
+                    'name' => $v->name,
+                    'address' => $v->address,
+                ];
+            }
         }
         return [
             'list' => $newList,

--
Gitblit v1.8.0