1557492053 1 year ago
parent
commit
7401617ddf
2 changed files with 21 additions and 3 deletions
  1. 3 3
      application/api/service/MassagerService.php
  2. 18 0
      application/common.php

+ 3 - 3
application/api/service/MassagerService.php

@@ -6,14 +6,13 @@ namespace app\api\service;
 
 use app\admin\model\dynamic\Dynamic;
 use app\admin\model\dynamic\Like;
-use app\api\model\massager\Massager;
 use app\api\model\massager\Collect;
 use app\api\model\massager\Comment;
+use app\api\model\massager\Massager;
 use app\api\model\massager\Work;
 use app\api\model\massager\WorkPeriod;
 use app\api\model\order\Order;
 use app\api\model\service\Service;
-use redis\RedisClient;
 
 class MassagerService extends BaseService
 {
@@ -257,7 +256,8 @@ class MassagerService extends BaseService
         $query = $serviceModel
             ->where([
                 "level" => $massager["level"],
-                "type" => \E_SERVICE_TYPE::App
+                "type" => \E_SERVICE_TYPE::App,
+                "p_code" => parse_area($massager['city_code'])['p_code']
             ]);
         if ($is_add_clock != 1) {
             $query->where("is_add_clock", 0);

+ 18 - 0
application/common.php

@@ -863,5 +863,23 @@ if (!function_exists('upload_pic')) {
     }
 }
 
+function parse_area($area_code)
+{
 
+    $result = [
+        'p_code' => null,
+        'city_code' => null,
+        'county_code' => null
+    ];
+    if (strlen((string)$area_code) != 6)
+        return $result;
+    $result['p_code'] = (int)($area_code / 1000) * 1000;
+    if ($area_code % 1000 > 0) {
+        $result['city_code'] = (int)($area_code / 100) * 100;
+    }
+    if ($area_code % 100 > 0) {
+        $result['county_code'] = $area_code;
+    }
+    return $result;
+}