mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:43:26 +08:00
【修复】修复同城配送坐标计算错误的问题。
This commit is contained in:
@@ -721,20 +721,17 @@ namespace CoreCms.Net.Services
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var store = await _storeServices.QueryByClauseAsync(p => p.isDefault == true);
|
//var store = await _storeServices.QueryByClauseAsync(p => p.isDefault == true);
|
||||||
if (store == null)
|
//if (store == null)
|
||||||
|
//{
|
||||||
|
// return true;
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(userShip.longitude) || string.IsNullOrEmpty(userShip.latitude))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(userShip.longitude) || string.IsNullOrEmpty(userShip.latitude) || string.IsNullOrEmpty(store.longitude) || string.IsNullOrEmpty(store.latitude))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//第一种调用方法
|
|
||||||
var result = MapHelper.GetDistance(Convert.ToDouble(userShip.latitude.Trim()), Convert.ToDouble(userShip.longitude.Trim()), Convert.ToDouble(store.latitude.Trim()), Convert.ToDouble(store.longitude.Trim()));
|
|
||||||
|
|
||||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||||
var intraCityServiceBy2Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceBy2KM).ObjectToDecimal(0);
|
var intraCityServiceBy2Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceBy2KM).ObjectToDecimal(0);
|
||||||
var intraCityServiceBy5Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceBy5KM).ObjectToDecimal(0);
|
var intraCityServiceBy5Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceBy5KM).ObjectToDecimal(0);
|
||||||
@@ -743,6 +740,24 @@ namespace CoreCms.Net.Services
|
|||||||
var intraCityServiceBy20Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceBy20KM).ObjectToDecimal(0);
|
var intraCityServiceBy20Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceBy20KM).ObjectToDecimal(0);
|
||||||
var intraCityServiceByExceed20Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceByExceed20KM).ObjectToDecimal(0);
|
var intraCityServiceByExceed20Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceByExceed20KM).ObjectToDecimal(0);
|
||||||
|
|
||||||
|
|
||||||
|
var reshipCoordinate = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ReshipCoordinate);
|
||||||
|
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(reshipCoordinate))
|
||||||
|
{
|
||||||
|
var reshipCoordinateArr = reshipCoordinate.Split(",");
|
||||||
|
if (reshipCoordinateArr.Length != 2)
|
||||||
|
{
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = MapHelper.GetDistance(Convert.ToDouble(userShip.latitude.Trim()), Convert.ToDouble(userShip.longitude.Trim()), Convert.ToDouble(reshipCoordinateArr[0].Trim()), Convert.ToDouble(reshipCoordinateArr[1].Trim()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result is >= 0 and <= 2)
|
if (result is >= 0 and <= 2)
|
||||||
cartDto.costFreight = intraCityServiceBy2Km;
|
cartDto.costFreight = intraCityServiceBy2Km;
|
||||||
else if (result is > 2 and <= 5)
|
else if (result is > 2 and <= 5)
|
||||||
@@ -765,6 +780,19 @@ namespace CoreCms.Net.Services
|
|||||||
{
|
{
|
||||||
cartDto.costFreight = 0;
|
cartDto.costFreight = 0;
|
||||||
}
|
}
|
||||||
|
cartDto.error = new WebApiCallBack()
|
||||||
|
{
|
||||||
|
status = true,
|
||||||
|
msg = "运费计算成功",
|
||||||
|
data = result,
|
||||||
|
otherData = new
|
||||||
|
{
|
||||||
|
userShiplatitude = userShip.latitude,
|
||||||
|
userShiplongitude = userShip.longitude,
|
||||||
|
reshipCoordinate
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
cartDto.amount = Math.Round(cartDto.amount + cartDto.costFreight, 2);
|
cartDto.amount = Math.Round(cartDto.amount + cartDto.costFreight, 2);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user