Bläddra i källkod

add 服务区

liugc 1 år sedan
förälder
incheckning
35936374de

+ 108 - 0
app/adminapi/controller/service_area/ServiceAreaController.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\service_area;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\service_area\ServiceAreaLists;
+use app\adminapi\logic\service_area\ServiceAreaLogic;
+use app\adminapi\validate\service_area\ServiceAreaValidate;
+
+
+/**
+ * ServiceArea控制器
+ * Class ServiceAreaController
+ * @package app\adminapi\controller
+ */
+class ServiceAreaController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function lists()
+    {
+        return $this->dataLists(new ServiceAreaLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function add()
+    {
+        $params = (new ServiceAreaValidate())->post()->goCheck('add');
+        $result = ServiceAreaLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(ServiceAreaLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function edit()
+    {
+        $params = (new ServiceAreaValidate())->post()->goCheck('edit');
+        $result = ServiceAreaLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(ServiceAreaLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function delete()
+    {
+        $params = (new ServiceAreaValidate())->post()->goCheck('delete');
+        ServiceAreaLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function detail()
+    {
+        $params = (new ServiceAreaValidate())->goCheck('detail');
+        $result = ServiceAreaLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 1 - 1
app/adminapi/lists/master_worker/MasterWorkerLists.php

@@ -47,7 +47,7 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
     {
     {
         // 派单搜索条件 - 工程师接单状态
         // 派单搜索条件 - 工程师接单状态
         return [
         return [
-            '=' => ['mw.sn', 'mw.real_name', 'mw.account', 'mw.password', 'mw.mobile', 'mw.sex', 'mw.channel', 'mw.is_disable', 'mw.is_new_user', 'mw.create_time', 'mw.update_time', 'mw.accept_order_status', 'mw.cooperation','mw.audit_state', 'mw.work_status'],
+            '=' => ['mw.sn', 'mw.real_name', 'mw.city', 'mw.account', 'mw.password', 'mw.mobile', 'mw.sex', 'mw.channel', 'mw.is_disable', 'mw.is_new_user', 'mw.create_time', 'mw.update_time', 'mw.accept_order_status', 'mw.cooperation','mw.audit_state', 'mw.work_status'],
             //'in' => ['mw.time_period']
             //'in' => ['mw.time_period']
         ];
         ];
     }
     }

+ 79 - 0
app/adminapi/lists/service_area/ServiceAreaLists.php

@@ -0,0 +1,79 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\service_area;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\service_area\ServiceArea;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * ServiceArea列表
+ * Class ServiceAreaLists
+ * @package app\adminapi\lists
+ */
+class ServiceAreaLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['province', 'city','county'],
+            '%like%' => ['area_name', 'service_name'],
+            '<' => [ 'distance']
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function lists(): array
+    {
+        return ServiceArea::where($this->searchWhere)
+            ->field(['id', 'province', 'city','county', 'area_name', 'service_name', 'lon', 'lat', 'distance'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function count(): int
+    {
+        return ServiceArea::where($this->searchWhere)->count();
+    }
+
+}

+ 1 - 1
app/adminapi/lists/works/ServiceWorkLists.php

@@ -42,7 +42,7 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
     public function setSearch(): array
     public function setSearch(): array
     {
     {
         return [
         return [
-            '=' => ['id','work_sn', 'real_name', 'mobile', 'address', 'title', 'category_type', 'base_service_fee', 'service_fee', 'work_status', 'service_status',  'data_type',  'finished_images', 'master_worker_id', 'work_amount','work_type','appoint_approval','refund_approval'],
+            '=' => ['id','work_sn', 'real_name', 'mobile', 'address', 'title', 'category_type', 'base_service_fee', 'service_fee', 'work_status', 'service_status',  'data_type',  'finished_images', 'master_worker_id', 'work_amount','work_type','appoint_approval','refund_approval', 'city'],
 
 
         ];
         ];
     }
     }

+ 6 - 0
app/adminapi/logic/master_worker/MasterWorkerLogic.php

@@ -65,6 +65,9 @@ class MasterWorkerLogic extends BaseLogic
                 'lon' => $params['lon'],
                 'lon' => $params['lon'],
                 'lat' => $params['lat'],
                 'lat' => $params['lat'],
                 'distance' => $params['distance'],
                 'distance' => $params['distance'],
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'area_name' => $params['area_name'],
                 'cooperation' => $params['cooperation']??0,
                 'cooperation' => $params['cooperation']??0,
                 'time_period' => $params['time_period']??'',
                 'time_period' => $params['time_period']??'',
                 'work_status' => $params['work_status']??0,
                 'work_status' => $params['work_status']??0,
@@ -123,6 +126,9 @@ class MasterWorkerLogic extends BaseLogic
                 'lon' => $params['lon'],
                 'lon' => $params['lon'],
                 'lat' => $params['lat'],
                 'lat' => $params['lat'],
                 'distance' => $params['distance'],
                 'distance' => $params['distance'],
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'area_name' => $params['area_name'],
                 'earnest_money' => $params['earnest_money'],
                 'earnest_money' => $params['earnest_money'],
                 'earnest_money_usable' => $params['earnest_money_usable'],
                 'earnest_money_usable' => $params['earnest_money_usable'],
                 'earnest_money_freeze' => $params['earnest_money_freeze'],
                 'earnest_money_freeze' => $params['earnest_money_freeze'],

+ 7 - 0
app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php

@@ -59,7 +59,9 @@ class MasterWorkerRegisterLogic extends BaseLogic
             MasterWorkerRegister::create([
             MasterWorkerRegister::create([
                 'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                 'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                 'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
                 'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
+                'province' => $params['province'],
                 'city' => $params['city'],
                 'city' => $params['city'],
+                'area_name' => $params['area_name'],
                 'vehicle_type' => $params['vehicle_type'],
                 'vehicle_type' => $params['vehicle_type'],
                 'name' => $params['name'],
                 'name' => $params['name'],
                 'age' => $params['age'],
                 'age' => $params['age'],
@@ -94,7 +96,9 @@ class MasterWorkerRegisterLogic extends BaseLogic
             $updata = [
             $updata = [
                 'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                 'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                 'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
                 'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
+                'province' => $params['province'],
                 'city' => $params['city'],
                 'city' => $params['city'],
+                'area_name' => $params['area_name'],
                 'vehicle_type' => $params['vehicle_type'],
                 'vehicle_type' => $params['vehicle_type'],
                 'name' => $params['name'],
                 'name' => $params['name'],
                 'age' => $params['age'],
                 'age' => $params['age'],
@@ -145,6 +149,9 @@ class MasterWorkerRegisterLogic extends BaseLogic
                 'channel' => 1,
                 'channel' => 1,
                 'lon' => $params['lon']??0,
                 'lon' => $params['lon']??0,
                 'lat' => $params['lat']??0,
                 'lat' => $params['lat']??0,
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'area_name' => $params['area_name'],
             ]);
             ]);
         }
         }
         return $masterWorker->id;
         return $masterWorker->id;

+ 120 - 0
app/adminapi/logic/service_area/ServiceAreaLogic.php

@@ -0,0 +1,120 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\service_area;
+
+
+use app\common\model\service_area\ServiceArea;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * ServiceArea逻辑
+ * Class ServiceAreaLogic
+ * @package app\adminapi\logic
+ */
+class ServiceAreaLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            ServiceArea::create([
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'county' => $params['county'],
+                'area_name' => $params['area_name'],
+                'service_name' => $params['service_name'],
+                'lon' => $params['lon'],
+                'lat' => $params['lat'],
+                'distance' => $params['distance'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            ServiceArea::where('id', $params['id'])->update([
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'county' => $params['county'],
+                'area_name' => $params['area_name'],
+                'service_name' => $params['service_name'],
+                'lon' => $params['lon'],
+                'lat' => $params['lat'],
+                'distance' => $params['distance'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public static function delete(array $params): bool
+    {
+        return ServiceArea::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public static function detail($params): array
+    {
+        return ServiceArea::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 106 - 0
app/adminapi/validate/service_area/ServiceAreaValidate.php

@@ -0,0 +1,106 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\service_area;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * ServiceArea验证器
+ * Class ServiceAreaValidate
+ * @package app\adminapi\validate
+ */
+class ServiceAreaValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'province' => 'require',
+        'city' => 'require',
+        'lon' => 'require',
+        'lat' => 'require',
+        'distance' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'province' => '省',
+        'city' => '城市',
+        'lon' => '经度',
+        'lat' => '维度',
+        'distance' => '服务范围',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return ServiceAreaValidate
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['province','city','lon','lat','distance']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return ServiceAreaValidate
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','province','city','lon','lat','distance']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return ServiceAreaValidate
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return ServiceAreaValidate
+     * @author likeadmin
+     * @date 2024/12/23 09:48
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 20 - 15
app/api/logic/ServiceOrderLogic.php

@@ -24,6 +24,7 @@ use app\common\model\orders\RechargeOrder;
 use app\common\model\property\PropertyActivity;
 use app\common\model\property\PropertyActivity;
 use app\common\model\recharge\OrderGoods;
 use app\common\model\recharge\OrderGoods;
 use app\common\model\refund\RefundRecord;
 use app\common\model\refund\RefundRecord;
+use app\common\model\service_area\ServiceArea;
 use app\common\model\spare_part\SparePart;
 use app\common\model\spare_part\SparePart;
 use app\common\model\works\ServiceWork;
 use app\common\model\works\ServiceWork;
 use app\common\model\works\ServiceWorkAppointmentLog;
 use app\common\model\works\ServiceWorkAppointmentLog;
@@ -43,25 +44,26 @@ class ServiceOrderLogic extends BaseLogic
 {
 {
 
 
     /**
     /**
-     * 判断是否在某服务区
+     * 判断是否在某服务区 返回服务区城市信息
      * @param $params
      * @param $params
      * @return bool
      * @return bool
      */
      */
-    public static function isService($params)
+    public static function isService($params):array
     {
     {
         // 查询服务区所有的地点
         // 查询服务区所有的地点
-        $rules = MasterWorkerRule::where('scene_id',MasterWorkerRule::SCENE_SERVICE)->column('description','id');
-        //$masters = [];
-        foreach ($rules as $key=>$value){
-            $rule = explode(',',$value);
-            //$masters[] = ['id'=>$key,'lon'=>$rule[0],'lat'=>$rule[1],'radius'=>$rule[2]];
-            $distance = round(DistributeLeafletsService::haversineDistance($params['lat'], $params['lon'], $rule[1], $rule[0]), 2);
-            if($distance <= (float)$rule[2]){
-                return true;
+        $rules = ServiceArea::column('*','id');
+        foreach ($rules as $value){
+            $distance = round(DistributeLeafletsService::haversineDistance($params['lat'], $params['lon'], $value['lat'], $value['lon']), 2);
+            if($distance <= (float)$value['distance']){
+                return [
+                    'province'=>$value['province'],
+                    'city'=>$value['city'],
+                    'county'=>$value['county'],
+                    'area_name'=>$value['area_name']
+                ];
             }
             }
         }
         }
-        self::setError('已超出服务区域!');
-        return false;
+        throw new Exception('已超出服务区域!');
     }
     }
 
 
     /**
     /**
@@ -74,9 +76,7 @@ class ServiceOrderLogic extends BaseLogic
         Db::startTrans();
         Db::startTrans();
         try {
         try {
             // 订单位置是否在服务区内
             // 订单位置是否在服务区内
-            if(!self::isService($params)){
-                throw new Exception('已超出服务区域!');
-            }
+            $areas = self::isService($params);
             $goods = Goods::findOrEmpty($params['goods_id']);
             $goods = Goods::findOrEmpty($params['goods_id']);
             if($goods->isEmpty()){
             if($goods->isEmpty()){
                 throw new Exception('产品不存在!');
                 throw new Exception('产品不存在!');
@@ -141,6 +141,11 @@ class ServiceOrderLogic extends BaseLogic
                 'real_name' => $params['contact_people'],
                 'real_name' => $params['contact_people'],
                 'mobile' => $params['contact_number'],
                 'mobile' => $params['contact_number'],
                 'address' => $params['address'],
                 'address' => $params['address'],
+
+                'province' => $areas['province']??0,
+                'city' => $areas['city']??0,
+                'area_name' => $areas['area_name']??'',
+
                 'title' => $goods->goods_name,
                 'title' => $goods->goods_name,
                 'category_type' => $goods['category_type'],
                 'category_type' => $goods['category_type'],
                 'goods_category_ids' => $goods['goods_category_ids'],
                 'goods_category_ids' => $goods['goods_category_ids'],

+ 13 - 2
app/common.php

@@ -1,5 +1,6 @@
 <?php
 <?php
 // 应用公共文件
 // 应用公共文件
+use app\common\model\setting\PostageRegion;
 use app\common\service\FileService;
 use app\common\service\FileService;
 use think\helper\Str;
 use think\helper\Str;
 
 
@@ -135,11 +136,11 @@ function get_tree_ids($data,$pid = 0, $idField = 'id',$pidField = 'pid')
     }
     }
     return $child;
     return $child;
 }
 }
-function get_top_parent_info($data, $id, $idField = 'id', $pidField = 'pid')
+function get_top_parent_info($data, $id, $idField = 'id', $pidField = 'pid' , $parentLevel = 0)
 {
 {
     foreach ($data as $item) {
     foreach ($data as $item) {
         if ($item[$idField] == $id) {
         if ($item[$idField] == $id) {
-            if ($item[$pidField] == 0) {
+            if ($item[$pidField] == $parentLevel) {
                 return $item;
                 return $item;
             } else {
             } else {
                 return get_top_parent_info($data, $item[$pidField], $idField, $pidField);
                 return get_top_parent_info($data, $item[$pidField], $idField, $pidField);
@@ -417,3 +418,13 @@ function asteriskString($str) {
         return $str;
         return $str;
     }
     }
 }
 }
+
+function getPostageRegion() {
+    $lists = cache('postageRegion');
+    if(empty($lists)){
+        $lists = PostageRegion::field(['*'])->select()->toArray();
+        cache('postageRegion',$lists);
+    }
+    return $lists;
+}
+

+ 12 - 1
app/common/logic/TableDataLogic.php

@@ -26,6 +26,7 @@ use app\common\model\refund\RefundLog;
 use app\common\model\refund\RefundRecord;
 use app\common\model\refund\RefundRecord;
 use app\common\model\sale\Sale;
 use app\common\model\sale\Sale;
 use app\common\model\sale\SaleGroup;
 use app\common\model\sale\SaleGroup;
+use app\common\model\setting\PostageRegion;
 use app\common\service\pay\AliPayService;
 use app\common\service\pay\AliPayService;
 use app\common\service\pay\WeChatPayService;
 use app\common\service\pay\WeChatPayService;
 
 
@@ -89,5 +90,15 @@ class TableDataLogic extends BaseLogic
         return EquityConfig::where('id','>',0)->field('id,equity_name as name,id as value,"data_table_equityConfig" as type_value')->select()->toArray();
         return EquityConfig::where('id','>',0)->field('id,equity_name as name,id as value,"data_table_equityConfig" as type_value')->select()->toArray();
     }
     }
 
 
-
+    public static function postageRegion(): array
+    {
+        // 缓存优化
+        $data = cache('labelPostageRegion');
+        if(empty($data)){
+            $lists = getPostageRegion();
+            $data = linear_to_tree($lists, 'children', 'id', 'pid');
+            cache('labelPostageRegion',$data);
+        }
+        return $data;
+    }
 }
 }

+ 34 - 0
app/common/model/service_area/ServiceArea.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\service_area;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * ServiceArea模型
+ * Class ServiceArea
+ * @package app\common\model
+ */
+class ServiceArea extends BaseModel
+{
+    
+    protected $name = 'service_area';
+    
+
+    
+}

+ 11 - 1
app/workerapi/logic/LoginLogic.php

@@ -10,6 +10,7 @@ use app\common\model\master_worker\MasterWorkerAgree;
 use app\common\model\master_worker\MasterWorkerAuth;
 use app\common\model\master_worker\MasterWorkerAuth;
 use app\common\model\master_worker\MasterWorkerInfo;
 use app\common\model\master_worker\MasterWorkerInfo;
 use app\common\model\master_worker_register\MasterWorkerRegister;
 use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\model\setting\PostageRegion;
 use app\common\service\FileService;
 use app\common\service\FileService;
 use app\common\service\sms\SmsDriver;
 use app\common\service\sms\SmsDriver;
 use app\common\service\wechat\WeChatMnpService;
 use app\common\service\wechat\WeChatMnpService;
@@ -63,6 +64,11 @@ class LoginLogic extends BaseLogic
     public static function register(array $params)
     public static function register(array $params)
     {
     {
         try {
         try {
+            // 通过 $params['city'] 查询省市区
+            $postageRegion = array_column(getPostageRegion(), null, 'id');
+            $params['province'] = $postageRegion[$params['city']]['pid'];
+            $params['province'] && $params['area_name'] = $postageRegion[$params['province']]['name'].$postageRegion[$params['city']]['name'];
+
             $master = MasterWorkerRegister::where('mobile',$params['mobile'])->findOrEmpty();
             $master = MasterWorkerRegister::where('mobile',$params['mobile'])->findOrEmpty();
 
 
             if(!$master->isEmpty() and $master->status==1){
             if(!$master->isEmpty() and $master->status==1){
@@ -78,7 +84,9 @@ class LoginLogic extends BaseLogic
                     'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                     'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                     'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
                     'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
                     'other_exp_name' => (isset($params['other_exp_name']) && isset($params['other_exp_type']) && $params['other_exp_type'] == 4)?$params['other_exp_name']:'',
                     'other_exp_name' => (isset($params['other_exp_name']) && isset($params['other_exp_type']) && $params['other_exp_type'] == 4)?$params['other_exp_name']:'',
-                    'city' => $params['city'],
+                    'province' => $params['province']??0,
+                    'city' => $params['city']??0,
+                    'area_name' => $params['area_name']??'',
                     'vehicle_type' => $params['vehicle_type'],
                     'vehicle_type' => $params['vehicle_type'],
                     'name' => $params['name'],
                     'name' => $params['name'],
                     'age' => $params['age'],
                     'age' => $params['age'],
@@ -97,7 +105,9 @@ class LoginLogic extends BaseLogic
                     'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                     'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
                     'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
                     'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
                     'other_exp_name' => (isset($params['other_exp_name']) && isset($params['other_exp_type']) && $params['other_exp_type'] == 4)?$params['other_exp_name']:'',
                     'other_exp_name' => (isset($params['other_exp_name']) && isset($params['other_exp_type']) && $params['other_exp_type'] == 4)?$params['other_exp_name']:'',
+                    'province' => $params['province'],
                     'city' => $params['city'],
                     'city' => $params['city'],
+                    'area_name' => $params['area_name'],
                     'vehicle_type' => $params['vehicle_type'],
                     'vehicle_type' => $params['vehicle_type'],
                     'name' => $params['name'],
                     'name' => $params['name'],
                     'age' => $params['age'],
                     'age' => $params['age'],