Commit d60c4e45 authored by liuyuzhen's avatar liuyuzhen

地址命中规则修改

parent daf366f9
......@@ -12,8 +12,7 @@ use Our\ApiConst;
class AddressServiceModel extends \Business\AbstractModel {
public function init()
{
public function init(){
}
......@@ -215,29 +214,50 @@ class AddressServiceModel extends \Business\AbstractModel {
$limit = \Our\ApiConst::defaultAddressCount;
//1、判断当前用户的地址列表中是否存在和当前经纬度坐标小于200的地址(当前经纬度是否存在对应收货地址)
$addressList = \Our\RedisHelper::cachedFunction(\Redis\Db8\AddressRedisModel::getInstance(),array(&$addressDao, 'selectByWhere'),array($condition,$columns),\Our\ApiConst::oneHour,array($memberId));
$shootFlag = \Our\ApiConst::zero;//是否找到完全匹配地址
if($addressList){
$newAddressList = array();
foreach($addressList as $addr){
if($tempLatLng['lat']==$addr['lat']&&$tempLatLng['lng']==$addr['lng']){
$address = array();
$address['addressId']= $addr['address_id'];
$address['address']= $addr['address'];
$address['name'] = $addr['name'];
$address['tagType']= $addr['tag_type'];
$address['lng'] = $addr['lng'];
$address['lat'] = $addr['lat'];
$address['cityCode'] = $addr['citycode'];
$choosedAddressId = $addr['addressId'];
$newAddress = $address;
$newAddress['chooseFlag'] = \Our\ApiConst::one;
$sess['currentAddress'] = $newAddress;
$returnAddresses[] = $address;
$shootFlag = \Our\ApiConst::one;
break;
}
$newAddressList[$addr['address_id']] = $addr;
$distince = \Our\CommonExtension::getDistance($tempLatLng['lat'],$tempLatLng['lng'],$addr['lat'],$addr['lng'],1);
$distinceArray[$addr['address_id']]=$distince;
}
$pos = array_search(min($distinceArray), $distinceArray);
$minDistince = $distinceArray[$pos];
if($minDistince<\Our\ApiConst::minDistanceForCurrentPosition){
$address = array();
$address['addressId']= $newAddressList[$pos]['address_id'];
$address['address']= $newAddressList[$pos]['address'];
$address['name'] = $newAddressList[$pos]['name'];
$address['tagType']= $newAddressList[$pos]['tag_type'];
$address['lng'] = $newAddressList[$pos]['lng'];
$address['lat'] = $newAddressList[$pos]['lat'];
$address['cityCode'] = $newAddressList[$pos]['citycode'];
$choosedAddressId = $address['addressId'];
$newAddress = $address;
$newAddress['chooseFlag'] = \Our\ApiConst::one;
$sess['currentAddress'] = $newAddress;
$returnAddresses[] = $address;
//如果没有找到完全匹配地址并且缓存里面的地址页没有命中则可以命中当前选择地址200米范围内的地址
if($shootFlag==\Our\ApiConst::zero&&$currentAddress['chooseFlag']==\Our\ApiConst::zero){
$pos = array_search(min($distinceArray), $distinceArray);
$minDistince = $distinceArray[$pos];
if($minDistince<\Our\ApiConst::minDistanceForCurrentPosition){
$address = array();
$address['addressId']= $newAddressList[$pos]['address_id'];
$address['address']= $newAddressList[$pos]['address'];
$address['name'] = $newAddressList[$pos]['name'];
$address['tagType']= $newAddressList[$pos]['tag_type'];
$address['lng'] = $newAddressList[$pos]['lng'];
$address['lat'] = $newAddressList[$pos]['lat'];
$address['cityCode'] = $newAddressList[$pos]['citycode'];
$choosedAddressId = $address['addressId'];
$newAddress = $address;
$newAddress['chooseFlag'] = \Our\ApiConst::one;
$sess['currentAddress'] = $newAddress;
$returnAddresses[] = $address;
}
}
}
//2、如果不存在,存入当前经纬度作为临时地址,并且取当前用户最近使用过的最多3条地址返回去
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment