Commit 824d0e27 authored by liudong1993's avatar liudong1993

结算 - 全局包邮

parent e0ff19cc
...@@ -42,5 +42,7 @@ namespace Mall.Model.Extend.BaseSetUp ...@@ -42,5 +42,7 @@ namespace Mall.Model.Extend.BaseSetUp
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; }
public int Number { get; set; }
public decimal Money { get; set; }
} }
} }
...@@ -1182,6 +1182,7 @@ namespace Mall.Module.Product ...@@ -1182,6 +1182,7 @@ namespace Mall.Module.Product
bool IsPointsDeduction = false;//是否有商品可使用积分抵扣 bool IsPointsDeduction = false;//是否有商品可使用积分抵扣
bool address_enable = true;//地址Ok bool address_enable = true;//地址Ok
List<object> goods_list = new List<object>(); List<object> goods_list = new List<object>();
List<FreeShippingGoodsDetail> SatisfiedGoodsList = new List<FreeShippingGoodsDetail>();//可包邮的商品
if (demodel.DetailList.Any()) if (demodel.DetailList.Any())
{ {
string GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId)); string GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId));
...@@ -1638,7 +1639,6 @@ namespace Mall.Module.Product ...@@ -1638,7 +1639,6 @@ 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()) {
YFCategoryList = YFCategoryList.Distinct().ToList(); YFCategoryList = YFCategoryList.Distinct().ToList();
string categoryIds = string.Join(",", YFCategoryList); string categoryIds = string.Join(",", YFCategoryList);
...@@ -1685,6 +1685,7 @@ namespace Mall.Module.Product ...@@ -1685,6 +1685,7 @@ namespace Mall.Module.Product
#region 运费 #region 运费
decimal Express = 0; decimal Express = 0;
string FreeShippingDescription = ""; string FreeShippingDescription = "";
bool FreeShipping_Use = false;
if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution) if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{ {
//计算总和 //计算总和
...@@ -1692,7 +1693,6 @@ namespace Mall.Module.Product ...@@ -1692,7 +1693,6 @@ 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)))
{ {
bool IsFreeShipping = false;
if ((gmodel.FullMoneyPinkage ?? 0) == 0 && (gmodel.FullNumPinkage ?? 0) == 0 && YFCategoryList.Any()) if ((gmodel.FullMoneyPinkage ?? 0) == 0 && (gmodel.FullNumPinkage ?? 0) == 0 && YFCategoryList.Any())
{ {
//查找全局包邮规则 //查找全局包邮规则
...@@ -1721,7 +1721,7 @@ namespace Mall.Module.Product ...@@ -1721,7 +1721,7 @@ namespace Mall.Module.Product
//看着商品是否包含在这里面 //看着商品是否包含在这里面
if (sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).Any()) if (sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).Any())
{ {
IsFreeShipping = true; FreeShipping_Use = true;
FreeShippingDescription = sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name; FreeShippingDescription = sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name;
} }
} }
...@@ -1729,11 +1729,12 @@ namespace Mall.Module.Product ...@@ -1729,11 +1729,12 @@ namespace Mall.Module.Product
{ {
//查询出规格下所有的分类 //查询出规格下所有的分类
List<int> GZCList = new List<int>(); List<int> GZCList = new List<int>();
if (fullNumPinkageModel.CategoryId >= 0) if (fullNumPinkageModel.CategoryId > 0)
{ {
GZCList = freeShippingList.Where(x => x.ID == fullNumPinkageModel.ID).Select(x => x.CategoryId).ToList(); GZCList = freeShippingList.Where(x => x.ID == fullNumPinkageModel.ID).Select(x => x.CategoryId).ToList();
} }
//根据分类 查询出所有的订单商品 //根据分类 查询出所有的订单商品
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()) if (!nosglist.Where(x => x.GoodsId == qitem.GoodsId && x.SpecificationKey == qitem.SpecificationSort).Any())
...@@ -1749,38 +1750,62 @@ namespace Mall.Module.Product ...@@ -1749,38 +1750,62 @@ namespace Mall.Module.Product
{ {
if (qitem.CategoryIdList.Where(x => GZCList.Contains(x)).Any()) if (qitem.CategoryIdList.Where(x => GZCList.Contains(x)).Any())
{ {
SatisfiedGoodsList.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.NewSpecificationSort,
Number = qitem.Number ?? 0,
Money = qitem.NorGoodsMoney
}); });
} }
} }
else else
{ {
SatisfiedGoodsList.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.NewSpecificationSort,
Number = qitem.Number ?? 0,
Money = qitem.NorGoodsMoney
}); });
} }
} }
} }
if (SatisfiedGoodsList2.Any())
{
//看是否满足包邮
if (fullNumPinkageModel.FullNumPinkage > 0)
{
if (SatisfiedGoodsList2.Sum(x => x.Number) > fullNumPinkageModel.FullNumPinkage)
{
FreeShipping_Use = true;
SatisfiedGoodsList.AddRange(SatisfiedGoodsList2);
}
}
else if (fullNumPinkageModel.FullMoneyPinkage > 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()) 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; FreeShippingDescription = SatisfiedGoodsList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name;
} }
} }
} }
} }
} }
if (IsFreeShipping == false) if (FreeShipping_Use == false)
{ {
int FreightId2 = gmodel.FreightId ?? 0; int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0) if (gmodel.FreightId == 0)
...@@ -1908,6 +1933,7 @@ namespace Mall.Module.Product ...@@ -1908,6 +1933,7 @@ namespace Mall.Module.Product
pieces = gmodel.FullNumPinkage,//满件包邮 pieces = gmodel.FullNumPinkage,//满件包邮
forehead = gmodel.FullMoneyPinkage,//满额包邮 forehead = gmodel.FullMoneyPinkage,//满额包邮
freeShippingDescription = FreeShippingDescription, freeShippingDescription = FreeShippingDescription,
freeShipping_Use = FreeShipping_Use,
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,
...@@ -1997,6 +2023,21 @@ namespace Mall.Module.Product ...@@ -1997,6 +2023,21 @@ namespace Mall.Module.Product
use_num = Total_use_integral, use_num = Total_use_integral,
deduction_price = Total_integral_price deduction_price = Total_integral_price
}; };
//满足全局包邮的规则
List<object> PinkageList = new List<object>();
if (SatisfiedGoodsList.Any()) {
var Names = SatisfiedGoodsList.Select(x => x.Name).Distinct().ToList();
foreach (var item in Names) {
int TNumber = SatisfiedGoodsList.Where(x => x.Name == item).Sum(x => x.Number);
decimal TMoney = SatisfiedGoodsList.Where(x => x.Name == item).Sum(x => x.Money);
PinkageList.Add(new
{
Name = item,
TNumber,
TMoney
});
}
}
mch_list.Add(new mch_list.Add(new
{ {
...@@ -2006,6 +2047,7 @@ namespace Mall.Module.Product ...@@ -2006,6 +2047,7 @@ namespace Mall.Module.Product
name = minModel?.MallName ?? "" name = minModel?.MallName ?? ""
}, },
goods_list, goods_list,
pinkageList = PinkageList,
express_price = TotalExpress, express_price = TotalExpress,
remark = "", remark = "",
//order_form_data= [], //order_form_data= [],
......
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