地址优化

This commit is contained in:
devil 2020-01-30 12:11:40 +08:00
parent ddadd3dc49
commit e159204a2f
2 changed files with 31 additions and 0 deletions

View File

@ -1217,6 +1217,21 @@ class BuyService
*/
private static function OrderAddressInsert($order_id, $user_id, $address)
{
// 坐标处理
if(in_array(APPLICATION_CLIENT_TYPE, config('shopxo.coordinate_transformation')))
{
// 坐标转换 火星(高德,谷歌,腾讯坐标) 转 百度
if(isset($address['lng']) && isset($address['lat']) && $address['lng'] > 0 && $address['lat'] > 0)
{
$map = \base\GeoTransUtil::GcjToBd($address['lng'], $address['lat']);
if(isset($map['lng']) && isset($map['lat']))
{
$address['lng'] = $map['lng'];
$address['lat'] = $map['lat'];
}
}
}
// 订单收货地址
$data = [
'order_id' => $order_id,

View File

@ -454,6 +454,22 @@ class UserService
$is_default = false;
foreach($data as &$v)
{
// 坐标处理
if(in_array(APPLICATION_CLIENT_TYPE, config('shopxo.coordinate_transformation')))
{
// 坐标转换 百度转火星(高德,谷歌,腾讯坐标)
if(isset($v['lng']) && isset($v['lat']) && $v['lng'] > 0 && $v['lat'] > 0)
{
$map = \base\GeoTransUtil::BdToGcj($v['lng'], $v['lat']);
if(isset($map['lng']) && isset($map['lat']))
{
$v['lng'] = $map['lng'];
$v['lat'] = $map['lat'];
}
}
}
// 地区
$v['province_name'] = RegionService::RegionName($v['province']);
$v['city_name'] = RegionService::RegionName($v['city']);
$v['county_name'] = RegionService::RegionName($v['county']);