Beispiel #1
0
// 是否可以配送
// 返回是否可以配送,以及距离(米)
func (this *CoverageArea) CanDeliverTo(address string) (bool, int) {
	lng, lat, err := lbs.GetLocation(address)
	if err != nil {
		return false, -1
	}
	return this.CanDeliver(lng, lat)
}
Beispiel #2
0
// 是否可以配送
// 返回是否可以配送,以及距离(米)
func (this *offlineShopImpl) CanDeliverTo(address string) (bool, int) {
	lng, lat, err := lbs.GetLocation(address)
	if err != nil {
		log.Println("[ Go2o][ LBS][ Error] -", err.Error())
		return false, -1
	}
	return this.CanDeliver(lng, lat)
}
Beispiel #3
0
// 获取经维度
func (this *offlineShopImpl) GetLngLat() (float64, float64) {
	if this._lng == 0 || this._lat == 0 {
		//todo: 基于位置获取坐标,已经将坐标存储到数据库中了
		var err error
		this._lng, this._lat, err = lbs.GetLocation(this._shopVal.Location())
		if err != nil {
			log.Println("[ Go2o][ LBS][ Error] -", err.Error())
		}
	}
	return this._lng, this._lat
}
Beispiel #4
0
// 智能选择门店
func (this *orderManagerImpl) SmartChoiceShop(address string) (shop.IShop, error) {
	//todo: 应只选择线下实体店
	//todo: AggregateRootId
	dly := this._deliveryRep.GetDelivery(-1)

	lng, lat, err := lbs.GetLocation(address)
	if err != nil {
		return nil, errors.New("无法识别的地址:" + address)
	}
	var cov delivery.ICoverageArea = dly.GetNearestCoverage(lng, lat)
	if cov == nil {
		return nil, delivery.ErrNotCoveragedArea
	}
	shopId, _, err := dly.GetDeliveryInfo(cov.GetDomainId())
	return this._merchant.ShopManager().GetShop(shopId), err
}