|
|
@@ -17,6 +17,7 @@ namespace app\adminapi\logic\master_worker;
|
|
|
|
|
|
use app\common\model\master_worker\MasterWorker;
|
|
|
use app\common\model\master_worker\MasterWorkerTeam;
|
|
|
+use app\common\model\service_area\ServiceArea;
|
|
|
use app\common\logic\BaseLogic;
|
|
|
use think\facade\Db;
|
|
|
|
|
|
@@ -51,6 +52,15 @@ class MasterWorkerTeamLogic extends BaseLogic
|
|
|
}
|
|
|
$params['goods_category_ids'] = implode(',',$ids);
|
|
|
}
|
|
|
+ $service_area_id = 0;
|
|
|
+ if (!empty($params['lon']) && !empty($params['lat'])) {
|
|
|
+ $serviceArea = ServiceArea::isService(['lon' => $params['lon'], 'lat' => $params['lat']]);
|
|
|
+ if (empty($serviceArea)) {
|
|
|
+ self::setError('您所选的位置已超出服务区域!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $service_area_id = $serviceArea['id'];
|
|
|
+ }
|
|
|
|
|
|
MasterWorkerTeam::where('tenant_id', $params['tenant_id'])->value('id') && throw new \Exception('该租户已有团队');
|
|
|
$masterWorkerTeam = MasterWorkerTeam::create([
|
|
|
@@ -58,6 +68,7 @@ class MasterWorkerTeamLogic extends BaseLogic
|
|
|
'master_worker_id' => $params['master_worker_id'],
|
|
|
'tenant_id' => $params['tenant_id']??0,
|
|
|
'city' => $params['city']??0,
|
|
|
+ 'service_area_id' => $service_area_id,
|
|
|
'area_name' => $params['area_name']??'',
|
|
|
'lon' => $params['lon']??0,
|
|
|
'lat' => $params['lat']??0,
|
|
|
@@ -102,6 +113,17 @@ class MasterWorkerTeamLogic extends BaseLogic
|
|
|
if(($masterWorkerTeam['master_worker_id'] != $params['master_worker_id']) && $masterWorker['team_id']){
|
|
|
throw new \Exception('该师傅已加入团队,请先退出团队');
|
|
|
}
|
|
|
+
|
|
|
+ $service_area_id = 0;
|
|
|
+ if (!empty($params['lon']) && !empty($params['lat'])) {
|
|
|
+ $serviceArea = ServiceArea::isService(['lon' => $params['lon'], 'lat' => $params['lat']]);
|
|
|
+ if (empty($serviceArea)) {
|
|
|
+ self::setError('您所选的位置已超出服务区域!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $service_area_id = $serviceArea['id'];
|
|
|
+ }
|
|
|
+
|
|
|
if($params['goods_category_ids']){
|
|
|
foreach ($params['goods_category_ids'] as $val){
|
|
|
is_array($val)?($ids[] = end($val)):($ids[] = $val);
|
|
|
@@ -121,6 +143,7 @@ class MasterWorkerTeamLogic extends BaseLogic
|
|
|
'master_worker_id' => $params['master_worker_id'],
|
|
|
'tenant_id' => $params['tenant_id']??0,
|
|
|
'city' => $params['city'],
|
|
|
+ 'service_area_id' => $service_area_id,
|
|
|
'area_name' => $params['area_name'],
|
|
|
'lon' => $params['lon'],
|
|
|
'lat' => $params['lat'],
|