wang jun 2 år sedan
förälder
incheckning
53c36e099d

+ 6 - 6
application/api/logic/MealLogic.php

@@ -19,7 +19,7 @@ class MealLogic
      */
     public function getcenterlist($arr)
     {
-        $fillfields = ['lat', 'long'];
+        $fillfields = ['gcj_lat', 'gcj_long'];
         foreach ($fillfields as $key => $value) {
             if (!isset($arr[$value]) || empty($arr[$value])) {
                 return backarr(0, "参数缺少");
@@ -27,8 +27,8 @@ class MealLogic
         }
         $page = isset($arr['page']) && is_numeric($arr['page']) && !empty($arr['page']) && $arr['page'] > 0 ? $arr['page'] : 1;
         $size = isset($arr['size']) && is_numeric($arr['size']) && !empty($arr['size']) && $arr['size'] > 0 ? $arr['size'] : 10;
-        $lat = $arr['lat'];
-        $long = $arr['long'];
+        $lat = $arr['gcj_lat'];
+        $long = $arr['gcj_long'];
 
         $where = ['is_active' => 1];
         $m_m = new MealcenterModel();
@@ -112,7 +112,7 @@ class MealLogic
         try {
             $m_ua = new UserAddressModel();
             if (!isset($arr['address_id']) || empty($arr['address_id'])) {
-                $fillfields = ['receiver_address', 'address', 'receiver_name', 'receiver_telno', 'lat', 'long'];
+                $fillfields = ['receiver_address', 'address', 'receiver_name', 'receiver_telno', 'gcj_lat', 'gcj_long'];
                 foreach ($fillfields as $key => $value) {
                     if (!isset($arr[$value]) || empty($arr[$value])) {
                         throw new \Exception("参数缺少");
@@ -123,8 +123,8 @@ class MealLogic
                     'address' => $arr['address'],
                     'receiver_name' => $arr['receiver_name'],
                     'receiver_telno' => $arr['receiver_telno'],
-                    'lat' => $arr['lat'],
-                    'long' => $arr['long'],
+                    'lat' => $arr['gcj_lat'],
+                    'long' => $arr['gcj_long'],
                     'user_id' => $userid,
                 ];
                 $uaid = $m_ua->insertData($insertData);

+ 3 - 3
application/api/logic/UserLogic.php

@@ -109,7 +109,7 @@ class UserLogic
      */
     public function editaddress($arr)
     {
-        $fillfields = ['receiver_address', 'address', 'receiver_name', 'receiver_telno', 'lat', 'long', 'user_id'];
+        $fillfields = ['receiver_address', 'address', 'receiver_name', 'receiver_telno', 'gcj_lat', 'gcj_long', 'user_id'];
         foreach ($fillfields as $key => $value) {
             if (!isset($arr[$value]) || empty($arr[$value])) {
                 return backarr(0, "参数缺少");
@@ -221,9 +221,9 @@ class UserLogic
         if (!empty($userid)) {
             $where['userid'] = $userid;
         }
-        if(isset($arr['is_active'])){
+        if (isset($arr['is_active'])) {
             $where['is_active'] = $arr['is_active'];
-        }   
+        }
         $m_ua = new UserAddressModel();
         $count = $m_ua->getList($where, 'count');
         if ($count <= 0) {

+ 42 - 0
application/common.php

@@ -121,3 +121,45 @@ function xmltoarr($xml)
     $arr = json_decode(json_encode($arr), true);
     return $arr;
 }
+//为cp后台请求验证token
+function checkToken()
+{
+    $l_w = new app\admin\logic\webmanger();
+    $token = request()->server('HTTP_TOKEN');
+    $param = ['token' => $token];
+    $result = $l_w->queryinfobytoken($param);
+    if (1 != $result['status']) {
+        $str = backjson2(0, '登录失效', $result['data']);
+        exit($str);
+    }
+    return $result['data'];
+}
+//判断是否是手机号
+function isMoblid($tel)
+{
+    if (preg_match("/^1[3-9]{1}\d{9}$/", $tel)) {
+        return true;
+    } else {
+        return false;
+    }
+}
+//curl 请假
+function curl_request($url, $data = null, $header = [])
+{
+    //$headerArray = array("Content-type:application/json;charset='utf-8'", "Accept:application/json");
+    $curl = curl_init();
+    curl_setopt($curl, CURLOPT_URL, $url);
+    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
+    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
+    if (!empty($data)) {
+        curl_setopt($curl, CURLOPT_POST, true);
+        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+    }
+    $output = curl_exec($curl);
+    curl_close($curl);
+    $res = json_decode($output, true);
+    return $res;
+}

+ 4 - 4
application/common/model/MealcenterModel.php

@@ -83,8 +83,8 @@ class MealcenterModel extends Model
 
     public function getlistbycoord($where, $page = 1, $size = 0)
     {
-        $long = $where['long'];
-        $lat = $where['lat'];
+        $long = $where['gcj_long'];
+        $lat = $where['gcj_lat'];
         $startinex = ($page - 1) * $size;
         $sql = "
             select * from
@@ -93,8 +93,8 @@ class MealcenterModel extends Model
                 m.*,
                 st_distance_sphere(
                     point(
-                    CAST(m.long AS decimal(11,8)),
-                    CAST(m.lat AS decimal(11,8))
+                    CAST(m.gcj_long AS decimal(11,8)),
+                    CAST(m.gcj_lat AS decimal(11,8))
                     ),
                     point(
                     CAST(" . $long . " AS decimal(11,8)),