【修复】修复同城配送坐标计算错误的问题。

This commit is contained in:
jianweie code
2024-08-30 21:28:50 +08:00
parent c2446b01c5
commit 04f2ff5d36

View File

@@ -721,20 +721,17 @@ namespace CoreCms.Net.Services
{
return true;
}
var store = await _storeServices.QueryByClauseAsync(p => p.isDefault == true);
if (store == null)
//var store = await _storeServices.QueryByClauseAsync(p => p.isDefault == true);
//if (store == null)
//{
// return true;
//}
if (string.IsNullOrEmpty(userShip.longitude) || string.IsNullOrEmpty(userShip.latitude))
{
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 intraCityServiceBy2Km = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IntraCityServiceBy2KM).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 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)
cartDto.costFreight = intraCityServiceBy2Km;
else if (result is > 2 and <= 5)
@@ -765,6 +780,19 @@ namespace CoreCms.Net.Services
{
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);
}
return true;