Commit 1e544ca5 authored by liudong1993's avatar liudong1993

同商品 多规格 运费问题

parent 24bbb3f6
......@@ -1985,6 +1985,8 @@ namespace Mall.Module.Product
freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, CategoryIds = categoryIds });
}
#endregion
List<int> ExpressGoodsId = new List<int>();
//赋值
foreach (var item in demodel.DetailList)
{
......@@ -2026,6 +2028,7 @@ namespace Mall.Module.Product
decimal Express = 0;
string FreeShippingDescription = "";
bool FreeShipping_Use = false;
bool ExpressIsReckon = false;//多规格情况,同一商品
if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
//计算总和
......@@ -2176,7 +2179,7 @@ namespace Mall.Module.Product
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
if (exNum <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
......@@ -2184,13 +2187,13 @@ namespace Mall.Module.Product
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
if ((exNum - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
Express = pmodel.FirstPrice + ((exNum - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
Express = pmodel.FirstPrice + ((exNum - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
......@@ -2202,7 +2205,7 @@ namespace Mall.Module.Product
else
{
//重量计费
int TotalW = (item.Number ?? 0) * (item.GoodsWeight ?? 0);
int TotalW = exNum * (item.GoodsWeight ?? 0);
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
......@@ -2230,13 +2233,26 @@ namespace Mall.Module.Product
}
}
}
if (exNum != item.Number)
{
if (!ExpressGoodsId.Contains(item.GoodsId ?? 0))
{
ExpressGoodsId.Add(item.GoodsId ?? 0);
}
else {
ExpressIsReckon = true;
}
}
}
}
}
if (!ExpressIsReckon)
{
TotalExpress += Express;
item.Final_Price += Express;
item.Express = Express;
TotalGoodsMoney += Express;
}
#endregion
var areaGoods = AreaList.Where(x => x.GoodsId == item.GoodsId).ToList();
......@@ -3359,6 +3375,7 @@ namespace Mall.Module.Product
freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, CategoryIds = categoryIds });
}
#endregion
List<int> ExpressGoodsId = new List<int>();//同商品 多规格
foreach (var item in demodel.DetailList)
{
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
......@@ -3383,6 +3400,8 @@ namespace Mall.Module.Product
#region 运费
decimal Express = 0;
decimal TExpress = 0;
bool ExpressIsReckon = false;
if (demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
//计算总和
......@@ -3528,7 +3547,7 @@ namespace Mall.Module.Product
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
if (exNum <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
......@@ -3536,13 +3555,13 @@ namespace Mall.Module.Product
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
if ((exNum - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
Express = pmodel.FirstPrice + ((exNum - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
Express = pmodel.FirstPrice + ((exNum - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
......@@ -3554,7 +3573,7 @@ namespace Mall.Module.Product
else
{
//重量计费
int TotalW = (item.Number ?? 0) * (item.GoodsWeight ?? 0);
int TotalW = exNum * (item.GoodsWeight ?? 0);
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
......@@ -3582,10 +3601,26 @@ namespace Mall.Module.Product
}
}
}
TExpress = Express;
if (exNum != item.Number)
{
Express = Math.Round(Express * (item.Number ?? 0) / exNum, 2, MidpointRounding.AwayFromZero);
if (!ExpressGoodsId.Contains(item.GoodsId ?? 0))
{
ExpressGoodsId.Add(item.GoodsId ?? 0);
}
else
{
ExpressIsReckon = true;
}
}
TotalExpress += Express;
}
}
}
if (!ExpressIsReckon)
{
TotalExpress += TExpress;
}
#endregion
item.FreightMoney = Express;
......
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