|
@@ -5,6 +5,7 @@ use App\Models\CustomAddr as Model;
|
|
|
use App\Http\Requests\Api\CustomAddr as Request;
|
|
|
use App\Models\City;
|
|
|
use App\Models\Custom;
|
|
|
+use App\Models\WeiBan\Follow as WeiBanFollow;
|
|
|
|
|
|
/**
|
|
|
* 客户地址
|
|
@@ -173,5 +174,72 @@ class CustomAddr extends Api{
|
|
|
return json_send(['code'=>'success','msg'=>'保存成功','data'=>['id'=>$id]]);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取用户地址信息 /api/custom_addr/get_remark_addr
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function get_remark_addr(Custom $Custom,City $City,WeiBanFollow $WeiBanFollow){
|
|
|
+ // 接口验签
|
|
|
+ // $this->verify_sign();
|
|
|
+ // 检查登录
|
|
|
+ $uid = $this->checkLogin();
|
|
|
+ // 获取客户城市ID
|
|
|
+ $custom = $Custom->getOne($uid);
|
|
|
+ // 数据组合
|
|
|
+ $data = ['contact_province'=>'','contact_city'=>'','contact_area'=>'','contact_addr'=>'','contact_name'=>'','contact_shop'=>'','contact_phone'=>'','shop_type'=>1];
|
|
|
+ // 如果不存在用户信息
|
|
|
+ if( !$custom ) return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
|
|
|
+ // 省份
|
|
|
+ $data['contact_phone'] = $custom['phone'];
|
|
|
+ // 获取用户城市信息
|
|
|
+ $city = $City->getOne($custom['city_id']);
|
|
|
+ // 如果有城市信息
|
|
|
+ if( !$city ) return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
|
|
|
+ // 获取上级城市/省份
|
|
|
+ $parentCity = $City->getOne($city['pid']);
|
|
|
+ // 如果上级是省辖,获取省份
|
|
|
+ if( isset($parentCity['name']) && $parentCity['name'] == '直辖县级' ) $parentCity = $City->getOne($parentCity['pid']);
|
|
|
+ // 如果有获取到省份信息
|
|
|
+ if( !$parentCity ) return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
|
|
|
+ // 省份
|
|
|
+ $data['contact_province'] = $parentCity['name'];
|
|
|
+ // 省份
|
|
|
+ $data['contact_city'] = $city['name'];
|
|
|
+ // 如果用户没有绑定对应的微伴账号
|
|
|
+ if( !$custom['weiban_extid'] ) return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
|
|
|
+ // 获取客服对应的备注等信息
|
|
|
+ $follow = $WeiBanFollow->getListByWeibanExtid($custom['weiban_extid']);
|
|
|
+ // 获取备注列表
|
|
|
+ $remark = array_filter(array_column($follow,'remark'),function($value) {return !empty($value);});
|
|
|
+ // 获取备注列表
|
|
|
+ $contactShop = array_filter(array_column($follow,'remark_corp_name'),function($value) {return !empty($value);});
|
|
|
+ // 如果有备注信息
|
|
|
+ if( isset($remark[0]) ) $data['contact_name'] = $remark[0];
|
|
|
+ // 如果有备注信息
|
|
|
+ if( isset($contactShop[0]) ) $data['contact_shop'] = $contactShop[0];
|
|
|
+ // 返回结果
|
|
|
+ return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取可能性地址 /api/custom_addr/get_guess_addr
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function get_guess_addr(Request $request,Model $Model){
|
|
|
+ // 接口验签
|
|
|
+ // $this->verify_sign();
|
|
|
+ // 检查登录
|
|
|
+ $uid = $this->checkLogin();
|
|
|
+ // 接收参数
|
|
|
+ $request->scene('get_guess_addr')->validate();
|
|
|
+ // 接收参数
|
|
|
+ $contactShop = request('contact_shop','');
|
|
|
+ // 获取参数
|
|
|
+ $map = [['contact_shop','LIKE','%'.$contactShop.'%']];
|
|
|
+ // 查询
|
|
|
+ $list = $Model->query()->where($map)->limit('20')->get(['contact_province','contact_city','contact_area','contact_addr','contact_shop','shop_type'])->toArray();
|
|
|
+ // 返回结果
|
|
|
+ return json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
|
|
|
+ }
|
|
|
|
|
|
}
|