Commit 78988958 authored by liudong1993's avatar liudong1993

结算全局包邮

parent cabad9cb
...@@ -33,4 +33,14 @@ namespace Mall.Model.Extend.BaseSetUp ...@@ -33,4 +33,14 @@ namespace Mall.Model.Extend.BaseSetUp
/// </summary> /// </summary>
public int CategoryId { get; set; } public int CategoryId { get; set; }
} }
/// <summary>
/// 包邮满足的订单商品
/// </summary>
public class FreeShippingGoodsDetail {
public int FreeShipping { get; set; }
public string Name { get; set; }
public int GoodsId { get; set; }
public string SpecificationKey { get; set; }
}
} }
...@@ -1637,8 +1637,10 @@ namespace Mall.Module.Product ...@@ -1637,8 +1637,10 @@ namespace Mall.Module.Product
} }
#region 处理全局包邮 #region 处理全局包邮
List<RB_FreeShipping_Extend> freeShippingList = new List<RB_FreeShipping_Extend>(); List<RB_FreeShipping_Extend> freeShippingList = new List<RB_FreeShipping_Extend>();
List<FreeShippingGoodsDetail> SatisfiedGoodsList = new List<FreeShippingGoodsDetail>();//可包邮的商品
if (YFCategoryList.Any()) { if (YFCategoryList.Any()) {
string categoryIds = string.Join(",", YFCategoryList.Distinct()); YFCategoryList = YFCategoryList.Distinct().ToList();
string categoryIds = string.Join(",", YFCategoryList);
freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, CategoryIds = categoryIds }); freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, CategoryIds = categoryIds });
} }
#endregion #endregion
...@@ -1681,12 +1683,103 @@ namespace Mall.Module.Product ...@@ -1681,12 +1683,103 @@ namespace Mall.Module.Product
#region 运费 #region 运费
decimal Express = 0; decimal Express = 0;
string FreeShippingDescription = "";
if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution) if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{ {
//计算总和 //计算总和
int exNum = demodel.DetailList.Where(x => x.GoodsId == item.GoodsId).Sum(x => x.Number ?? 0); 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); 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)))
{
bool IsFreeShipping = false;
if ((gmodel.FullMoneyPinkage ?? 0) == 0 && (gmodel.FullNumPinkage ?? 0) == 0 && YFCategoryList.Any())
{
//查找全局包邮规则
if (freeShippingList != null && freeShippingList.Any())
{
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();
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 || 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 sglist = SatisfiedGoodsList.Where(x => x.FreeShipping != fullNumPinkageModel.ID).ToList();
var nosglist = SatisfiedGoodsList.Where(x => x.FreeShipping == fullNumPinkageModel.ID).ToList();
if (sglist.Any())
{
//看着商品是否包含在这里面
if (sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).Any())
{
IsFreeShipping = true;
FreeShippingDescription = sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name;
}
}
else
{
//查询出规格下所有的分类
List<int> GZCList = new List<int>();
if (fullNumPinkageModel.CategoryId >= 0)
{
GZCList = freeShippingList.Where(x => x.ID == fullNumPinkageModel.ID).Select(x => x.CategoryId).ToList();
}
//根据分类 查询出所有的订单商品
foreach (var qitem in demodel.DetailList)
{
if (!nosglist.Where(x => x.GoodsId == qitem.GoodsId && x.SpecificationKey == qitem.SpecificationSort).Any())
{
string Name = fullNumPinkageModel.Name;
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())
{
SatisfiedGoodsList.Add(new FreeShippingGoodsDetail()
{
FreeShipping = fullNumPinkageModel.ID,
Name = Name,
GoodsId = qitem.GoodsId ?? 0,
SpecificationKey = qitem.NewSpecificationSort
});
}
}
else
{
SatisfiedGoodsList.Add(new FreeShippingGoodsDetail()
{
FreeShipping = fullNumPinkageModel.ID,
Name = Name,
GoodsId = qitem.GoodsId ?? 0,
SpecificationKey = qitem.NewSpecificationSort
});
}
}
}
//看着商品是否包含在这里面
if (SatisfiedGoodsList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).Any())
{
IsFreeShipping = true;
FreeShippingDescription = SatisfiedGoodsList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name;
}
}
}
}
}
if (IsFreeShipping == false)
{ {
int FreightId2 = gmodel.FreightId ?? 0; int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0) if (gmodel.FreightId == 0)
...@@ -1766,25 +1859,6 @@ namespace Mall.Module.Product ...@@ -1766,25 +1859,6 @@ namespace Mall.Module.Product
} }
} }
} }
else {
if ((gmodel.FullMoneyPinkage ?? 0) == 0 && (gmodel.FullNumPinkage ?? 0) == 0 && YFCategoryList.Any()) {
//查找全局包邮规则
//if (freeShippingList != null && freeShippingList.Any())
//{
// var nowcategory = categoryList.Where(x => x.GoodsId == item.GoodsId).Select(x => x.CategoryId);
// var fullNumPinkageModel = freeShippingList.Where(x => nowcategory.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0).OrderBy(x => x.FullNumPinkage).FirstOrDefault();
// if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
// {
// fullNumPinkageModel = freeShippingList.Where(x => x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0).OrderBy(x => x.FullMoneyPinkage).FirstOrDefault();
// }
// item.FreeShippingModel = (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0) ? new RB_FreeShipping_Extend() : fullNumPinkageModel;
//}
//else
//{
// item.FreeShippingModel = new RB_FreeShipping_Extend();
//}
}
} }
} }
TotalExpress += Express; TotalExpress += Express;
...@@ -1832,6 +1906,7 @@ namespace Mall.Module.Product ...@@ -1832,6 +1906,7 @@ namespace Mall.Module.Product
address_disabled, address_disabled,
pieces = gmodel.FullNumPinkage,//满件包邮 pieces = gmodel.FullNumPinkage,//满件包邮
forehead = gmodel.FullMoneyPinkage,//满额包邮 forehead = gmodel.FullMoneyPinkage,//满额包邮
freeShippingDescription = FreeShippingDescription,
freight_id = gmodel.FreightId, freight_id = gmodel.FreightId,
express_price = item.Express, express_price = item.Express,
unit_price = item.Unit_Price, unit_price = item.Unit_Price,
......
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