Commit 818850ce authored by liudong1993's avatar liudong1993

单品包邮

parent 80f3c96f
......@@ -103,6 +103,10 @@ namespace Mall.Model.Extend.Product
/// 佣金金额
/// </summary>
public decimal CommissionPrice { get; set; }
/// <summary>
/// 正常商品金额
/// </summary>
public decimal NorGoodsMoney { get; set; }
/// <summary>
/// 积分赠送
......
......@@ -1400,6 +1400,8 @@ namespace Mall.Module.Product
item.Final_Price = gmodel.MemberPrice * (item.Number ?? 0);
item.NorGoodsMoney = item.Final_Price ?? 0;//计算运费用
#region 积分
if (umodel.Integral > 0 && gmodel.PointsDeduction > 0 && integralModel.IntegralNum > 0)
{
......@@ -1556,95 +1558,6 @@ namespace Mall.Module.Product
}
#endregion
#region 运费
decimal Express = 0;
if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
if (!((gmodel.FullNumPinkage > 0 && item.Number >= gmodel.FullNumPinkage) || (gmodel.FullMoneyPinkage > 0 && item.Final_Price >= gmodel.FullMoneyPinkage)))
{
int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0)
{
FreightId2 = DefFreightId;
}
if (FreightId2 > 0)
{
var rulesModel = rulesList.Where(x => x.ID == FreightId2).FirstOrDefault();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList2 = priceList.Where(x => x.RulesId == FreightId2).ToList();
if (priceList2.Any())
{
var priceIds = priceList2.Select(x => x.ID).ToList();
var regionList2 = regionList.Where(x => priceIds.Contains(x.RulesPriceId)).ToList();
var regionModel = regionList2.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null)
{
var pmodel = priceList2.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
else
{
//重量计费
int TotalW = (item.Number ?? 0) * GoodsWeight;
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((TotalW - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
}
}
}
}
}
}
TotalExpress += Express;
item.Final_Price += Express;
#endregion
Total_integral_price += (item.IntegralMoney ?? 0);
Total_use_integral += (item.IntegralNumber ?? 0);
TotalGoodsMoney += item.Final_Price ?? 0;
......@@ -1653,8 +1566,7 @@ namespace Mall.Module.Product
item.Unit_Price = gmodel.SellingPrice ?? 0;
item.Original_Price = gmodel.OriginalPrice ?? 0;
item.MemberPrice = gmodel.MemberPrice;
item.GoodsWeight = GoodsWeight;
item.Express = Express;
item.GoodsWeight = GoodsWeight;
item.IntegralMoney = integral_price;
item.IntegralNumber = use_integral;
item.Attr_list = attr_list;
......@@ -1744,6 +1656,99 @@ namespace Mall.Module.Product
TotalGoodsMoney -= couponMoney;//总价格需减去优惠券金额
}
#region 运费
decimal Express = 0;
if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
//计算总和
int exNum = demodel.DetailList.Where(x => x.GoodsId == item.GoodsId).Sum(x => x.Number ?? 0);
decimal exMoney = demodel.DetailList.Where(x => x.GoodsId == item.GoodsId).Sum(x => x.NorGoodsMoney);
if (!((gmodel.FullNumPinkage > 0 && exNum >= gmodel.FullNumPinkage) || (gmodel.FullMoneyPinkage > 0 && exMoney >= gmodel.FullMoneyPinkage)))
{
int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0)
{
FreightId2 = DefFreightId;
}
if (FreightId2 > 0)
{
var rulesModel = rulesList.Where(x => x.ID == FreightId2).FirstOrDefault();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList2 = priceList.Where(x => x.RulesId == FreightId2).ToList();
if (priceList2.Any())
{
var priceIds = priceList2.Select(x => x.ID).ToList();
var regionList2 = regionList.Where(x => priceIds.Contains(x.RulesPriceId)).ToList();
var regionModel = regionList2.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null)
{
var pmodel = priceList2.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
else
{
//重量计费
int TotalW = (item.Number ?? 0) * (item.GoodsWeight ?? 0);
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((TotalW - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
}
}
}
}
}
}
TotalExpress += Express;
item.Final_Price += Express;
item.Express = Express;
#endregion
var areaGoods = AreaList.Where(x => x.GoodsId == item.GoodsId).ToList();
bool address_disabled = false;
if (demodel.DeliveryMethod != OrderDeliveryMethodEnum.VerificationShop)
......@@ -2414,95 +2419,10 @@ namespace Mall.Module.Product
item.Final_Price = (gmodel.SellingPrice ?? 0) * (item.Number ?? 0);
}
#endregion
#region 运费
decimal Express = 0;
if (demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
if (!((gmodel.FullNumPinkage > 0 && item.Number >= gmodel.FullNumPinkage) || (gmodel.FullMoneyPinkage > 0 && item.Final_Price >= gmodel.FullMoneyPinkage)))
{
int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0)
{
FreightId2 = DefFreightId;
}
if (FreightId2 > 0)
{
var rulesModel = rulesList.Where(x => x.ID == FreightId2).FirstOrDefault();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList2 = priceList.Where(x => x.RulesId == FreightId2).ToList();
if (priceList2.Any())
{
var priceIds = priceList2.Select(x => x.ID).ToList();
var regionList2 = regionList.Where(x => priceIds.Contains(x.RulesPriceId)).ToList();
var regionModel = regionList2.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null)
{
var pmodel = priceList2.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
else
{
//重量计费
int TotalW = (item.Number ?? 0) * GoodsWeight;
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((TotalW - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
}
}
}
}
}
}
TotalExpress += Express;
#endregion
item.NorGoodsMoney = item.Final_Price ?? 0;//用于计算 运费的 202-08-05 ld
item.GoodsWeight = GoodsWeight;
item.FreightMoney = Express;
item.Unit_Price = gmodel.SellingPrice ?? 0;
item.Original_Price = (item.Unit_Price) * (item.Number);
......@@ -2735,6 +2655,98 @@ namespace Mall.Module.Product
TotalMoney -= (item.CouponMoney ?? 0);//总价格需减去优惠券金额
item.Final_Price -= (item.CouponMoney ?? 0);
}
#region 运费
decimal Express = 0;
if (demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
//计算总和
int exNum = demodel.DetailList.Where(x => x.GoodsId == item.GoodsId).Sum(x => x.Number ?? 0);
decimal exMoney = demodel.DetailList.Where(x => x.GoodsId == item.GoodsId).Sum(x => x.NorGoodsMoney);
if (!((gmodel.FullNumPinkage > 0 && exNum >= gmodel.FullNumPinkage) || (gmodel.FullMoneyPinkage > 0 && exMoney >= gmodel.FullMoneyPinkage)))
{
int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0)
{
FreightId2 = DefFreightId;
}
if (FreightId2 > 0)
{
var rulesModel = rulesList.Where(x => x.ID == FreightId2).FirstOrDefault();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList2 = priceList.Where(x => x.RulesId == FreightId2).ToList();
if (priceList2.Any())
{
var priceIds = priceList2.Select(x => x.ID).ToList();
var regionList2 = regionList.Where(x => priceIds.Contains(x.RulesPriceId)).ToList();
var regionModel = regionList2.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null)
{
var pmodel = priceList2.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
else
{
//重量计费
int TotalW = (item.Number ?? 0) * (item.GoodsWeight ?? 0);
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((TotalW - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
}
}
}
}
}
}
TotalExpress += Express;
#endregion
item.FreightMoney = Express;
}
}
if (demodel.FreightMoney != TotalExpress)
......
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