Commit 163b0873 authored by liudong1993's avatar liudong1993

下单 全局包邮

parent 2d131a62
...@@ -23,6 +23,10 @@ namespace Mall.Model.Entity.Product ...@@ -23,6 +23,10 @@ namespace Mall.Model.Entity.Product
get; get;
set; set;
} }
/// <summary>
/// 规则id
/// </summary>
public int? FreeshippingId { get; set; }
/// <summary> /// <summary>
/// 订单商品id /// 订单商品id
......
...@@ -39,6 +39,7 @@ namespace Mall.Model.Extend.BaseSetUp ...@@ -39,6 +39,7 @@ namespace Mall.Model.Extend.BaseSetUp
/// </summary> /// </summary>
public class FreeShippingGoodsDetail { public class FreeShippingGoodsDetail {
public int FreeShipping { get; set; } public int FreeShipping { get; set; }
public int CategoryId { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int GoodsId { get; set; } public int GoodsId { get; set; }
public string SpecificationKey { get; set; } public string SpecificationKey { get; set; }
......
...@@ -229,6 +229,10 @@ namespace Mall.Module.Product ...@@ -229,6 +229,10 @@ namespace Mall.Module.Product
/// </summary> /// </summary>
private readonly RB_SupplierCommissionRepository supplierCommissionRepository = new RB_SupplierCommissionRepository(); private readonly RB_SupplierCommissionRepository supplierCommissionRepository = new RB_SupplierCommissionRepository();
private RB_FreeShippingRepository freeShippingRepository = new RB_FreeShippingRepository(); private RB_FreeShippingRepository freeShippingRepository = new RB_FreeShippingRepository();
/// <summary>
/// 全局包邮记录
/// </summary>
private RB_Goods_OrderDetailFreeShippingRepository orderDetailFreeShippingRepository = new RB_Goods_OrderDetailFreeShippingRepository();
#region 购物车 #region 购物车
...@@ -1714,8 +1718,8 @@ namespace Mall.Module.Product ...@@ -1714,8 +1718,8 @@ namespace Mall.Module.Product
if (fullNumPinkageModel != null) if (fullNumPinkageModel != null)
{ {
//看所有商品是否满足该规则 //看所有商品是否满足该规则
var sglist = SatisfiedGoodsList.Where(x => x.FreeShipping != fullNumPinkageModel.ID).ToList(); var sglist = SatisfiedGoodsList.Where(x => x.FreeShipping == fullNumPinkageModel.ID).ToList();
var nosglist = SatisfiedGoodsList.Where(x => x.FreeShipping == fullNumPinkageModel.ID).ToList(); var nosglist = SatisfiedGoodsList.Where(x => x.FreeShipping != fullNumPinkageModel.ID).ToList();
if (sglist.Any()) if (sglist.Any())
{ {
//看着商品是否包含在这里面 //看着商品是否包含在这里面
...@@ -1727,52 +1731,50 @@ namespace Mall.Module.Product ...@@ -1727,52 +1731,50 @@ namespace Mall.Module.Product
} }
else else
{ {
//查询出规格下所有的分类 //根据 查询出所有的订单商品
List<int> GZCList = new List<int>();
if (fullNumPinkageModel.CategoryId > 0)
{
GZCList = freeShippingList.Where(x => x.ID == fullNumPinkageModel.ID).Select(x => x.CategoryId).ToList();
}
//根据分类 查询出所有的订单商品
var SatisfiedGoodsList2 = new List<FreeShippingGoodsDetail>(); var SatisfiedGoodsList2 = new List<FreeShippingGoodsDetail>();
foreach (var qitem in demodel.DetailList) foreach (var qitem in demodel.DetailList)
{ {
if (!nosglist.Where(x => x.GoodsId == qitem.GoodsId && x.SpecificationKey == qitem.SpecificationSort).Any()) var qgmodel = gList.Where(x => x.Id == qitem.GoodsId).FirstOrDefault();
if (qgmodel != null && qgmodel.GoodsStatus == 1 && (qgmodel.FullMoneyPinkage ?? 0) == 0 && (qgmodel.FullNumPinkage ?? 0) == 0)
{ {
string Name = fullNumPinkageModel.Name; if (!nosglist.Where(x => x.GoodsId == qitem.GoodsId && x.SpecificationKey == qitem.SpecificationSort).Any())
if (fullNumPinkageModel.FullNumPinkage > 0) {
Name += ":满" + fullNumPinkageModel.FullNumPinkage + "件包邮";
}
else if(fullNumPinkageModel.FullMoneyPinkage > 0) {
Name += ":满" + fullNumPinkageModel.FullMoneyPinkage + "元包邮";
}
if (GZCList.Any())
{ {
if (qitem.CategoryIdList.Where(x => GZCList.Contains(x)).Any()) var fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
if (fpkModel == null || fpkModel.ID <= 0)
{ {
fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fpkModel == null || fpkModel.ID <= 0)
{
fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fpkModel == null || fpkModel.ID <= 0)
{
fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fpkModel != null && fpkModel.ID == fullNumPinkageModel.ID) {
//是同一包邮规则里的
string Name = fullNumPinkageModel.Name;
if (fullNumPinkageModel.FullNumPinkage > 0)
{
Name += ":满" + fullNumPinkageModel.FullNumPinkage + "件包邮";
}
else if (fullNumPinkageModel.FullMoneyPinkage > 0)
{
Name += ":满" + fullNumPinkageModel.FullMoneyPinkage + "元包邮";
}
SatisfiedGoodsList2.Add(new FreeShippingGoodsDetail() SatisfiedGoodsList2.Add(new FreeShippingGoodsDetail()
{ {
FreeShipping = fullNumPinkageModel.ID, FreeShipping = fullNumPinkageModel.ID,
Name = Name, Name = Name,
GoodsId = qitem.GoodsId ?? 0, GoodsId = qitem.GoodsId ?? 0,
SpecificationKey = qitem.NewSpecificationSort, SpecificationKey = qitem.SpecificationSort,
Number = qitem.Number ?? 0, Number = qitem.Number ?? 0,
Money = qitem.NorGoodsMoney Money = qitem.NorGoodsMoney
}); });
} }
} }
else
{
SatisfiedGoodsList2.Add(new FreeShippingGoodsDetail()
{
FreeShipping = fullNumPinkageModel.ID,
Name = Name,
GoodsId = qitem.GoodsId ?? 0,
SpecificationKey = qitem.NewSpecificationSort,
Number = qitem.Number ?? 0,
Money = qitem.NorGoodsMoney
});
}
} }
} }
if (SatisfiedGoodsList2.Any()) if (SatisfiedGoodsList2.Any())
...@@ -1780,7 +1782,7 @@ namespace Mall.Module.Product ...@@ -1780,7 +1782,7 @@ namespace Mall.Module.Product
//看是否满足包邮 //看是否满足包邮
if (fullNumPinkageModel.FullNumPinkage > 0) if (fullNumPinkageModel.FullNumPinkage > 0)
{ {
if (SatisfiedGoodsList2.Sum(x => x.Number) > fullNumPinkageModel.FullNumPinkage) if (SatisfiedGoodsList2.Sum(x => x.Number) >= fullNumPinkageModel.FullNumPinkage)
{ {
FreeShipping_Use = true; FreeShipping_Use = true;
SatisfiedGoodsList.AddRange(SatisfiedGoodsList2); SatisfiedGoodsList.AddRange(SatisfiedGoodsList2);
...@@ -1788,7 +1790,7 @@ namespace Mall.Module.Product ...@@ -1788,7 +1790,7 @@ namespace Mall.Module.Product
} }
else if (fullNumPinkageModel.FullMoneyPinkage > 0) else if (fullNumPinkageModel.FullMoneyPinkage > 0)
{ {
if (SatisfiedGoodsList2.Sum(x => x.Money) > fullNumPinkageModel.FullMoneyPinkage) if (SatisfiedGoodsList2.Sum(x => x.Money) >= fullNumPinkageModel.FullMoneyPinkage)
{ {
FreeShipping_Use = true; FreeShipping_Use = true;
SatisfiedGoodsList.AddRange(SatisfiedGoodsList2); SatisfiedGoodsList.AddRange(SatisfiedGoodsList2);
...@@ -2392,6 +2394,7 @@ namespace Mall.Module.Product ...@@ -2392,6 +2394,7 @@ namespace Mall.Module.Product
} }
} }
#endregion #endregion
List<FreeShippingGoodsDetail> SatisfiedGoodsList = new List<FreeShippingGoodsDetail>();//可包邮的商品
if (demodel.DetailList.Any()) if (demodel.DetailList.Any())
{ {
//积分 //积分
...@@ -2489,7 +2492,8 @@ namespace Mall.Module.Product ...@@ -2489,7 +2492,8 @@ namespace Mall.Module.Product
#endregion #endregion
} }
} }
List<int> YFCategoryList = new List<int>();//全局适配 分类
var mallbaseModel = mallBaseRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_MallBase_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
foreach (var item in demodel.DetailList) foreach (var item in demodel.DetailList)
{ {
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault(); var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
...@@ -2499,6 +2503,10 @@ namespace Mall.Module.Product ...@@ -2499,6 +2503,10 @@ namespace Mall.Module.Product
} }
var categoryList = clist.Where(x => x.GoodsId == item.GoodsId).ToList(); var categoryList = clist.Where(x => x.GoodsId == item.GoodsId).ToList();
if ((mallbaseModel?.IsFreeShipping ?? 0) == 1 && (gmodel.FullMoneyPinkage ?? 0) == 0 && (gmodel.FullNumPinkage ?? 0) == 0)
{
YFCategoryList.AddRange(categoryList.Select(x => x.CategoryId ?? 0).ToList());
}
item.InventoryNum = gmodel.InventoryNum ?? 0; item.InventoryNum = gmodel.InventoryNum ?? 0;
item.CommissionPrice = gmodel.Commission;// 粉象 返佣金额 item.CommissionPrice = gmodel.Commission;// 粉象 返佣金额
...@@ -2508,7 +2516,7 @@ namespace Mall.Module.Product ...@@ -2508,7 +2516,7 @@ namespace Mall.Module.Product
item.PresentFXMonth = gmodel.PresentFXMonth ?? 0; item.PresentFXMonth = gmodel.PresentFXMonth ?? 0;
item.ProductCode = gmodel.GoodsNumbers; item.ProductCode = gmodel.GoodsNumbers;
item.CategoryIdList = categoryList.Select(x => x.CategoryId ?? 0).ToList(); item.CategoryIdList = categoryList.Select(x => x.CategoryId ?? 0).ToList();
int GoodsWeight = gmodel.GoodsWeight ?? 0;//商品重量 int GoodsWeight = gmodel.GoodsWeight ?? 0;//商品重量
#region 规格 #region 规格
//验证规格是否已失效 //验证规格是否已失效
...@@ -2801,6 +2809,15 @@ namespace Mall.Module.Product ...@@ -2801,6 +2809,15 @@ namespace Mall.Module.Product
} }
} }
} }
#region 处理全局包邮
List<RB_FreeShipping_Extend> freeShippingList = new List<RB_FreeShipping_Extend>();
if (YFCategoryList.Any())
{
YFCategoryList = YFCategoryList.Distinct().ToList();
string categoryIds = string.Join(",", YFCategoryList);
freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, CategoryIds = categoryIds });
}
#endregion
foreach (var item in demodel.DetailList) foreach (var item in demodel.DetailList)
{ {
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault(); var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
...@@ -2827,77 +2844,193 @@ namespace Mall.Module.Product ...@@ -2827,77 +2844,193 @@ namespace Mall.Module.Product
decimal exMoney = demodel.DetailList.Where(x => x.GoodsId == item.GoodsId).Sum(x => x.NorGoodsMoney); 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))) if (!((gmodel.FullNumPinkage > 0 && exNum >= gmodel.FullNumPinkage) || (gmodel.FullMoneyPinkage > 0 && exMoney >= gmodel.FullMoneyPinkage)))
{ {
int FreightId2 = gmodel.FreightId ?? 0; bool FreeShipping_Use = false;
if (gmodel.FreightId == 0) if ((gmodel.FullMoneyPinkage ?? 0) == 0 && (gmodel.FullNumPinkage ?? 0) == 0 && YFCategoryList.Any())
{
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 (freeShippingList != null && freeShippingList.Any())
if (priceList2.Any())
{ {
var priceIds = priceList2.Select(x => x.ID).ToList(); var fullNumPinkageModel = freeShippingList.Where(x => item.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
var regionList2 = regionList.Where(x => priceIds.Contains(x.RulesPriceId)).ToList(); if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
{
var regionModel = regionList2.Where(x => disList.Contains(x.RegionId)).FirstOrDefault(); fullNumPinkageModel = freeShippingList.Where(x => item.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
if (regionModel != null) }
if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
{
fullNumPinkageModel = freeShippingList.Where(x => item.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
{
fullNumPinkageModel = freeShippingList.Where(x => item.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fullNumPinkageModel != null)
{ {
var pmodel = priceList2.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault(); //看所有商品是否满足该规则
if (pmodel != null && rulesModel != null) var sglist = SatisfiedGoodsList.Where(x => x.FreeShipping == fullNumPinkageModel.ID).ToList();
var nosglist = SatisfiedGoodsList.Where(x => x.FreeShipping != fullNumPinkageModel.ID).ToList();
if (sglist.Any())
{ {
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num) //看着商品是否包含在这里面
if (sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).Any())
{ {
//按件计费 FreeShipping_Use = true;
if (item.Number <= pmodel.First) item.FreeShippingRemarks = sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name;
{ }
Express = pmodel.FirstPrice; }
} else
else {
//根据 查询出所有的订单商品
var SatisfiedGoodsList2 = new List<FreeShippingGoodsDetail>();
foreach (var qitem in demodel.DetailList)
{
var qgmodel = gList.Where(x => x.Id == qitem.GoodsId).FirstOrDefault();
if (qgmodel != null && qgmodel.GoodsStatus == 1 && (qgmodel.FullMoneyPinkage ?? 0) == 0 && (qgmodel.FullNumPinkage ?? 0) == 0)
{ {
if (pmodel.Second > 0) if (!nosglist.Where(x => x.GoodsId == qitem.GoodsId && x.SpecificationKey == qitem.SpecificationSort).Any())
{ {
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0) var fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
if (fpkModel == null || fpkModel.ID <= 0)
{ {
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice; fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
} }
else if (fpkModel == null || fpkModel.ID <= 0)
{ {
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice; fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fpkModel == null || fpkModel.ID <= 0)
{
fpkModel = freeShippingList.Where(x => qitem.CategoryIdList.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fpkModel != null && fpkModel.ID == fullNumPinkageModel.ID)
{
//是同一包邮规则里的
string Name = fullNumPinkageModel.Name;
if (fullNumPinkageModel.FullNumPinkage > 0)
{
Name += ":满" + fullNumPinkageModel.FullNumPinkage + "件包邮";
}
else if (fullNumPinkageModel.FullMoneyPinkage > 0)
{
Name += ":满" + fullNumPinkageModel.FullMoneyPinkage + "元包邮";
}
SatisfiedGoodsList2.Add(new FreeShippingGoodsDetail()
{
FreeShipping = fullNumPinkageModel.ID,
Name = Name,
GoodsId = qitem.GoodsId ?? 0,
SpecificationKey = qitem.SpecificationSort,
Number = qitem.Number ?? 0,
Money = qitem.NorGoodsMoney,
CategoryId = fullNumPinkageModel.CategoryId
});
} }
}
else
{
Express = pmodel.FirstPrice;
} }
} }
} }
else if (SatisfiedGoodsList2.Any())
{ {
//重量计费 //看是否满足包邮
int TotalW = (item.Number ?? 0) * (item.GoodsWeight ?? 0); if (fullNumPinkageModel.FullNumPinkage > 0)
if (TotalW <= pmodel.First)
{ {
Express = pmodel.FirstPrice; if (SatisfiedGoodsList2.Sum(x => x.Number) >= fullNumPinkageModel.FullNumPinkage)
{
FreeShipping_Use = true;
SatisfiedGoodsList.AddRange(SatisfiedGoodsList2);
}
} }
else else if (fullNumPinkageModel.FullMoneyPinkage > 0)
{ {
if (pmodel.Second > 0) if (SatisfiedGoodsList2.Sum(x => x.Money) >= fullNumPinkageModel.FullMoneyPinkage)
{
FreeShipping_Use = true;
SatisfiedGoodsList.AddRange(SatisfiedGoodsList2);
}
}
}
//看着商品是否包含在这里面
if (SatisfiedGoodsList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).Any())
{
item.FreeShippingRemarks = SatisfiedGoodsList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name;
}
}
}
}
}
if (FreeShipping_Use == false)
{
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)
{ {
if ((TotalW - pmodel.First) % pmodel.Second == 0) Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{ {
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice; 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 else
{ {
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice; Express = pmodel.FirstPrice;
} }
} }
else }
else
{
//重量计费
int TotalW = (item.Number ?? 0) * (item.GoodsWeight ?? 0);
if (TotalW <= pmodel.First)
{ {
Express = pmodel.FirstPrice; 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;
}
}
} }
} }
} }
...@@ -2939,7 +3072,8 @@ namespace Mall.Module.Product ...@@ -2939,7 +3072,8 @@ namespace Mall.Module.Product
if (OrderId > 0) if (OrderId > 0)
{ {
//插入订单明细+ 商品库存更新 //插入订单明细+ 商品库存更新
InsertOrderDetail(demodel, trans, OrderId); InsertOrderDetail(demodel, trans, OrderId, SatisfiedGoodsList);
//用户订单数增加 //用户订单数增加
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_User_Extend.OrderNum),(umodel.OrderNum??0)+1} { nameof(RB_Member_User_Extend.OrderNum),(umodel.OrderNum??0)+1}
...@@ -4363,7 +4497,7 @@ namespace Mall.Module.Product ...@@ -4363,7 +4497,7 @@ namespace Mall.Module.Product
/// <param name="demodel"></param> /// <param name="demodel"></param>
/// <param name="trans"></param> /// <param name="trans"></param>
/// <param name="OrderId"></param> /// <param name="OrderId"></param>
private void InsertOrderDetail(RB_Goods_Order_Extend demodel, System.Data.IDbTransaction trans, int OrderId) private void InsertOrderDetail(RB_Goods_Order_Extend demodel, System.Data.IDbTransaction trans, int OrderId, List<FreeShippingGoodsDetail> SatisfiedGoodsList)
{ {
foreach (var item in demodel.DetailList) foreach (var item in demodel.DetailList)
{ {
...@@ -4410,9 +4544,31 @@ namespace Mall.Module.Product ...@@ -4410,9 +4544,31 @@ namespace Mall.Module.Product
FreightCostMoney = 0, FreightCostMoney = 0,
FreightFinanceId = 0, FreightFinanceId = 0,
PresentFXGrade = item.PresentFXGrade, PresentFXGrade = item.PresentFXGrade,
PresentFXMonth = item.PresentFXMonth PresentFXMonth = item.PresentFXMonth,
FreeShippingRemarks = item.FreeShippingRemarks
}, trans); }, trans);
item.Id = detailId; item.Id = detailId;
if (detailId > 0 && SatisfiedGoodsList.Any()) {
//插入适配的包邮规则
var fsmodel = SatisfiedGoodsList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault();
if (fsmodel!=null)
{
orderDetailFreeShippingRepository.Insert(new RB_Goods_OrderDetailFreeShipping()
{
FreeshippingId = fsmodel.FreeShipping,
Category = fsmodel.CategoryId,
CreateDate = DateTime.Now,
FullMoneyPinkage = 0,
FullNumPinkage = 0,
Id = 0,
MallBaseId = demodel.MallBaseId,
Name = fsmodel.Name,
OrderDetailId = detailId,
Status = 0,
TenantId = demodel.TenantId
}, trans);
}
}
//更新商品数量 //更新商品数量
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......
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