Commit 2ebb5782 authored by 吴春's avatar 吴春

Merge branch 'HK' of http://gitlab.oytour.com/Kui2/mall.oytour.com into sdzq

parents 7cfdc92b b1205eb8
...@@ -358,5 +358,10 @@ namespace Mall.Model.Extend.Product ...@@ -358,5 +358,10 @@ namespace Mall.Model.Extend.Product
/// 服务人员姓名 /// 服务人员姓名
/// </summary> /// </summary>
public string ServicepersonalName { get; set; } public string ServicepersonalName { get; set; }
/// <summary>
/// 订单商品所属门店
/// </summary>
public int StoresIds { get; set; }
} }
} }
...@@ -18,6 +18,7 @@ using Mall.Model.Extend.Education; ...@@ -18,6 +18,7 @@ using Mall.Model.Extend.Education;
using Mall.Model.Extend.Finance; using Mall.Model.Extend.Finance;
using Mall.Model.Extend.GuideCar; using Mall.Model.Extend.GuideCar;
using Mall.Model.Extend.Product; using Mall.Model.Extend.Product;
using Mall.Model.Extend.Reserve;
using Mall.Model.Extend.User; using Mall.Model.Extend.User;
using Mall.Module.User; using Mall.Module.User;
using Mall.Repository; using Mall.Repository;
...@@ -4761,20 +4762,15 @@ namespace Mall.Module.Product ...@@ -4761,20 +4762,15 @@ namespace Mall.Module.Product
message = "您在黑名单状态无法下单,请联系管理员核实"; message = "您在黑名单状态无法下单,请联系管理员核实";
return false; return false;
} }
List<int> disList = new List<int>();
disList.Add(demodel.Province ?? 0);
disList.Add(demodel.City ?? 0);
disList.Add(demodel.District ?? 0);
var goodModel = goodsRepository.GetEntity(demodel.GoodsId);
decimal TotalExpress = 0;
decimal TotalMoney = 0; decimal TotalMoney = 0;
string GoodsIds = ""; string GoodsIds = "";
int TotalIntegralNumber = 0;//总使用积分 int TotalIntegralNumber = 0;//总使用积分
decimal TotalIntegralMoney = 0;//总使用积分抵扣金额 decimal TotalIntegralMoney = 0;//总使用积分抵扣金额
List<RB_Goods_CouponModel> GoodsCouponList = new List<RB_Goods_CouponModel>();//商品优惠卷 价格(每个商品优惠的价格) List<RB_Goods_CouponModel> GoodsCouponList = new List<RB_Goods_CouponModel>();//商品优惠卷 价格(每个商品优惠的价格)
decimal CouponsMoney = 0;//优惠卷验证 decimal CouponsMoney = 0;//优惠卷验证
decimal EducationMoney = 0;//课程卡抵扣金额
int EducationNum = 0;//课程卡抵扣数量
#region 优惠卷初始化 #region 优惠卷初始化
List<RB_Member_DiscountCoupon_Extend> cList = new List<RB_Member_DiscountCoupon_Extend>(); List<RB_Member_DiscountCoupon_Extend> cList = new List<RB_Member_DiscountCoupon_Extend>();
List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Extend> dcList = new List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Extend>(); List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Extend> dcList = new List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Extend>();
...@@ -4814,142 +4810,66 @@ namespace Mall.Module.Product ...@@ -4814,142 +4810,66 @@ namespace Mall.Module.Product
} }
} }
#endregion #endregion
List<FreeShippingGoodsDetail> SatisfiedGoodsList = new List<FreeShippingGoodsDetail>();//可包邮的商品
if (demodel.DetailList.Any()) #region 课程卡初始化
List<RB_Education_MemberCoupon_Extend> eList = new List<RB_Education_MemberCoupon_Extend>();
List<RB_Education_Coupon_Extend> deList = new List<RB_Education_Coupon_Extend>();
List<RB_Education_CouponProduct_Extend> edcpList = new List<RB_Education_CouponProduct_Extend>();
if (demodel.Use_Education_Id > 0)
{ {
//积分 if (demodel.User_Coupon_Id > 0)
Model.Entity.MarketingCenter.RB_Integral_Settings integralModel = new Model.Entity.MarketingCenter.RB_Integral_Settings();
if (demodel.Use_Integral == 1 && umodel.Integral > 0)
{ {
integralModel = integral_SettingsRepository.GetIntegralSettingsList(new Model.Entity.MarketingCenter.RB_Integral_Settings() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); message = "套餐卡与优惠券不能同时使用";
return false;
} }
int DefFreightId = 0;//默认运费id if (demodel.Use_Integral > 0)
GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId));
var gList = goodsRepository.GetList(new RB_Goods_Extend()
{ {
GoodsIds = GoodsIds, message = "套餐卡与积分抵扣不能同时使用";
TenantId = demodel.TenantId, return false;
MallBaseId = demodel.MallBaseId, }
GoodsClassify = 3 eList = education_MemberCouponRepository.GetList(new RB_Education_MemberCoupon_Extend() { Ids = (demodel.Use_Education_Id ?? 0).ToString(), UserId = umodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
}); if (eList.Any())
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var speciPList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var mpriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
List<Model.Extend.BaseSetUp.RB_Logistics_Rules_Extend> rulesList = new List<Model.Extend.BaseSetUp.RB_Logistics_Rules_Extend>();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList = new List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend>();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend> regionList = new List<Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend>();
if (gList.Any() && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{ {
List<int> FreightIdList = new List<int>(); var educationModel = eList.FirstOrDefault();
if (gList.Where(x => x.FreightId > 0).Any()) if (educationModel.HeXiao <= educationModel.UseHeXiao)
{ {
FreightIdList.AddRange(gList.Where(x => x.FreightId > 0).Select(x => x.FreightId ?? 0).ToList()); message = "套餐卡剩余次数不足";
} return false;
if (gList.Where(x => x.FreightId == 0).Any())
{
//查询默认
DefFreightId = logistics_RulesRepository.GetLogisticsRulesList(new Model.Extend.BaseSetUp.RB_Logistics_Rules_Extend() { IsDefault = 1, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault()?.ID ?? 0;
FreightIdList.Add(DefFreightId);
}
if (FreightIdList.Any())
{
rulesList = logistics_RulesRepository.GetLogisticsRulesList(new Model.Extend.BaseSetUp.RB_Logistics_Rules_Extend() { RulesIds = string.Join(",", FreightIdList), TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
priceList = logistics_RulesPriceRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, RulesIds = string.Join(",", FreightIdList) });
if (priceList.Any())
{
string priceIds = string.Join(",", priceList.Select(x => x.ID));
regionList = logistics_RulesRegionRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, PriceIds = priceIds });
}
} }
string cIds = string.Join(",", eList.Select(x => x.CouponId).Distinct());
} deList = education_CouponRepository.GetDiscountCouponList(new RB_Education_Coupon_Extend() { CouponIds = cIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, true);
var OrderGoodsNumList = new List<RB_Goods_Order_Extend>(); edcpList = education_CouponProductRepository.GetListByDiscountCouponIds(new Model.Entity.Education.RB_Education_Coupon() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, cIds, true);
bool IsLimitOk = false; if (deList.Any())
if (gList.Where(x => x.LimitBuyGoodsNum > 0).Any())
{
IsLimitOk = true;
string LimitGoodsIds = string.Join(",", gList.Where(x => x.LimitBuyGoodsNum > 0).Select(x => x.Id));
//查询用户该商品已下单数量
OrderGoodsNumList = goods_OrderRepository.GetUserOrderGoodsNum(demodel.UserId ?? 0, LimitGoodsIds, demodel.TenantId, demodel.MallBaseId);
}
var OrderNumList = new List<RB_Goods_Order_Extend>();
if (gList.Where(x => x.LimitBuyOrderNum > 0).Any())
{
IsLimitOk = true;
string LimitGoodsIds = string.Join(",", gList.Where(x => x.LimitBuyOrderNum > 0).Select(x => x.Id));
//查询用户该商品已下单数量
OrderNumList = goods_OrderRepository.GetUserOrderNum(demodel.UserId ?? 0, LimitGoodsIds, demodel.TenantId, demodel.MallBaseId);
}
//验证限购
if (OrderGoodsNumList.Any() || OrderNumList.Any())
{
List<int> GoodsIdList = demodel.DetailList.Select(x => x.GoodsId ?? 0).Distinct().ToList();
foreach (var item in GoodsIdList)
{ {
int GoodsNum = demodel.DetailList.Where(x => x.GoodsId == item).Sum(x => x.Number ?? 0); foreach (var item in eList)
var gmodel = gList.Where(x => x.Id == item).FirstOrDefault();
if (gmodel == null || gmodel.GoodsStatus != 1)
{
message = "有商品不存在或者商品已失效";
return false;
}
#region 验证商品限购,订单限购
if (gmodel.LimitBuyGoodsNum > 0)
{
var ogModel = OrderGoodsNumList.Where(x => x.GoodsId == gmodel.Id).FirstOrDefault();
if (ogModel != null)
{
if (ogModel.GoodsTotalNum + GoodsNum > (gmodel.LimitBuyGoodsNum ?? 0))
{
message = "该商品限购" + (gmodel.LimitBuyGoodsNum ?? 0) + "件,您已购买" + ogModel.GoodsTotalNum + "件";
return false;
}
}
}
if (gmodel.LimitBuyOrderNum > 0)
{ {
var ogModel = OrderNumList.Where(x => x.GoodsId == gmodel.Id).FirstOrDefault(); if (item.CouponId > 0)
if (ogModel != null)
{ {
if (ogModel.OrderNum + 1 > (gmodel.LimitBuyOrderNum ?? 0)) if (!deList.Where(x => x.ID == item.CouponId).Any())
{ {
message = "该商品订单限购" + (gmodel.LimitBuyOrderNum ?? 0) + "单,您已购买" + ogModel.OrderNum + "单"; message = "课程卡不存在,请核实后再试";
return false; return false;
} }
} }
} }
#endregion
} }
} }
else if (IsLimitOk) }
#endregion
if (demodel.DetailList.Any())
{
//积分
Model.Entity.MarketingCenter.RB_Integral_Settings integralModel = new Model.Entity.MarketingCenter.RB_Integral_Settings();
if (demodel.Use_Integral == 1 && umodel.Integral > 0)
{ {
List<int> GoodsIdList = demodel.DetailList.Select(x => x.GoodsId ?? 0).Distinct().ToList(); integralModel = integral_SettingsRepository.GetIntegralSettingsList(new Model.Entity.MarketingCenter.RB_Integral_Settings() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
foreach (var item in GoodsIdList)
{
int GoodsNum = demodel.DetailList.Where(x => x.GoodsId == item).Sum(x => x.Number ?? 0);
var gmodel = gList.Where(x => x.Id == item).FirstOrDefault();
if (gmodel == null || gmodel.GoodsStatus != 1)
{
message = "有商品不存在或者商品已失效";
return false;
}
#region 验证商品限购,订单限购
if (gmodel.LimitBuyGoodsNum > 0)
{
if (GoodsNum > (gmodel.LimitBuyGoodsNum ?? 0))
{
message = "该商品限购" + (gmodel.LimitBuyGoodsNum ?? 0) + "件";
return false;
}
}
#endregion
}
} }
List<int> YFCategoryList = new List<int>();//全局适配 分类 GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId));
var mallbaseModel = mallBaseRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_MallBase_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); var gList = goodsRepository.GetListForCommission(new RB_Goods_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, 3);
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var mpriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
#region 微店价格 #region 微店价格
RB_SmallShops_Info_Extend smallModel = new RB_SmallShops_Info_Extend(); RB_SmallShops_Info_Extend smallModel = new RB_SmallShops_Info_Extend();
...@@ -4969,157 +4889,60 @@ namespace Mall.Module.Product ...@@ -4969,157 +4889,60 @@ namespace Mall.Module.Product
message = "有商品不存在或者商品已失效"; message = "有商品不存在或者商品已失效";
return false; return false;
} }
if (gmodel.PresentFXGrade > 0) if (gmodel.GoodsClassify != 3)
{ {
//是赠送VIP商品 message = "有非线下服务类商品";
if (demodel.DetailList.Count() > 1) return false;
{
//多商品
message = "VIP商品不能与其他商品同时下单,请先购买VIP商品";
return false;
}
var disModel = distributor_InfoRepository.GetListForSingle(new RB_Distributor_Info_Extend() { UserId = umodel.Id }).FirstOrDefault();
if (disModel != null)
{
var fxgradeList = distributor_FXGradeRepository.GetList(new RB_Distributor_FXGrade_Extend() { TenantId = umodel.TenantId, MallBaseId = umodel.MallBaseId });
fxgradeList = fxgradeList.Where(x => x.IsGuest == 1 || x.IsGuest == 3).ToList();
if (!fxgradeList.Select(x => x.Id).Contains(disModel.FXGradeId ?? 0))
{
message = "您当前等级无法购买VIP商品";
return false;
}
}
} }
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.CommissionPrice = gmodel.Commission;// 粉象 返佣金额 item.CommissionPrice = gmodel.Commission;// 粉象 返佣金额
item.CostMoney = (gmodel.IsCustomSpecification == 2) ? (gmodel.CostPrice ?? 0) : (speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).FirstOrDefault()?.CostMoney ?? 0);//gmodel.CostPrice ?? 0; item.CostMoney = (gmodel.CostPrice ?? 0);
item.Specification = "[]";
item.SpecificationSort = "0";
item.PresentFXGrade = gmodel.PresentFXGrade ?? 0;//赠送粉象分销等级 item.PresentFXGrade = gmodel.PresentFXGrade ?? 0;//赠送粉象分销等级
item.PresentFXMonth = gmodel.PresentFXMonth ?? 0; item.PresentFXMonth = gmodel.PresentFXMonth ?? 0;
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;//商品重量
#region 规格 #region 规格
//验证规格是否已失效 item.SmallShopsCostPrice = gmodel.SellingPrice ?? 0;
if (gmodel.IsCustomSpecification == 1) if (demodel.SmallShopsId > 0)
{
if (string.IsNullOrEmpty(item.SpecificationSort))
{
message = "有商品已失效,请重新下单";
return false;
}
if (!speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).Any())
{
message = "有商品已失效,请重新下单";
return false;
}
}
else
{
if (!string.IsNullOrEmpty(item.SpecificationSort))
{
message = "有商品已失效,请重新下单";
return false;
}
}
if (!string.IsNullOrEmpty(item.SpecificationSort))
{ {
var speciPModel = speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).FirstOrDefault(); if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.GoodsId == item.GoodsId && x.UpPrice > 0).Any())
gmodel.SellingPrice = speciPModel?.SellingPrice ?? 0;
gmodel.InventoryNum = speciPModel?.InventoryNum ?? 0;
GoodsWeight = speciPModel?.GoodsWeight ?? 0;
item.InventoryNum = speciPModel?.InventoryNum ?? 0;
item.SpeciPriceId = speciPModel?.Id ?? 0;
item.ProductCode = speciPModel?.GoodsNumbers ?? "";
if (item.Number > speciPModel.InventoryNum)
{
message = "商品库存不足:" + gmodel.Name;
return false;
}
item.CommissionPrice = speciPModel?.Commission ?? 0;
item.SmallShopsCostPrice = gmodel.SellingPrice ?? 0;
if (demodel.SmallShopsId > 0)
{ {
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.GoodsId == item.GoodsId && x.UpPrice > 0).Any()) var sspModel = smallPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == "").FirstOrDefault();
if (sspModel != null)
{ {
var sspModel = smallPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault(); //单商品设置的
if (sspModel != null) if (sspModel.PriceType == 1)
{ {
//单商品设置的 gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
if (sspModel.PriceType == 1)
{
gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
}
else if (sspModel.PriceType == 2)
{
gmodel.SellingPrice += (sspModel.UpPrice ?? 0);
}
} }
else else if (sspModel.PriceType == 2)
{ {
if ((smallModel.UpPrice ?? 0) > 0) gmodel.SellingPrice += (sspModel.UpPrice ?? 0);
{
if (smallModel.PriceType == 1)
{
gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
gmodel.SellingPrice += (smallModel.UpPrice ?? 0);
}
}
} }
} }
} else
}
else
{
item.SmallShopsCostPrice = gmodel.SellingPrice ?? 0;
if (demodel.SmallShopsId > 0)
{
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.GoodsId == item.GoodsId && x.UpPrice > 0).Any())
{ {
var sspModel = smallPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == "").FirstOrDefault(); if ((smallModel.UpPrice ?? 0) > 0)
if (sspModel != null)
{ {
//单商品设置的 if (smallModel.PriceType == 1)
if (sspModel.PriceType == 1)
{ {
gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100); gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
} }
else if (sspModel.PriceType == 2) else if (smallModel.PriceType == 2)
{ {
gmodel.SellingPrice += (sspModel.UpPrice ?? 0); gmodel.SellingPrice += (smallModel.UpPrice ?? 0);
}
}
else
{
if ((smallModel.UpPrice ?? 0) > 0)
{
if (smallModel.PriceType == 1)
{
gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
gmodel.SellingPrice += (smallModel.UpPrice ?? 0);
}
} }
} }
} }
} }
} }
#endregion #endregion
#region 会员价格 #region 会员价格
gmodel.MemberPrice = gmodel.SellingPrice ?? 0; gmodel.MemberPrice = gmodel.SellingPrice ?? 0;
if (umodel.MemberGrade > 0) if (umodel.MemberGrade > 0)
...@@ -5193,8 +5016,6 @@ namespace Mall.Module.Product ...@@ -5193,8 +5016,6 @@ namespace Mall.Module.Product
#endregion #endregion
item.SmallShopsCostPrice = (item.SmallShopsCostPrice ?? 0) * (item.Number ?? 0); item.SmallShopsCostPrice = (item.SmallShopsCostPrice ?? 0) * (item.Number ?? 0);
item.NorGoodsMoney = item.Final_Price ?? 0;//用于计算 运费的 202-08-05 ld
item.GoodsWeight = GoodsWeight;
item.Unit_Price = gmodel.SellingPrice ?? 0; item.Unit_Price = gmodel.SellingPrice ?? 0;
item.Original_Price = (item.Unit_Price) * (item.Number); item.Original_Price = (item.Unit_Price) * (item.Number);
...@@ -5329,349 +5150,201 @@ namespace Mall.Module.Product ...@@ -5329,349 +5150,201 @@ namespace Mall.Module.Product
{ {
GoodsCouponList.Add(new RB_Goods_CouponModel() GoodsCouponList.Add(new RB_Goods_CouponModel()
{ {
GoodsId = item.GoodsId ?? 0, GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort, Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0, TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0 CouponMoney = 0
}); });
}
}
else
{
GoodsCouponList.Add(new RB_Goods_CouponModel()
{
GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
}
}
}
#endregion
TotalMoney += (item.Final_Price ?? 0);
item.OrderType = OrderTypeEnum.OfflineService;
item.GoodServiceTime = goodModel?.ServiceTime ?? 0;
item.GoodsName = gmodel.Name;
item.CoverImage = "";
if (!string.IsNullOrEmpty(gmodel.CarouselImage) && gmodel.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(gmodel.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
item.SeparateDistribution = gmodel.SeparateDistribution;
item.SeparateDistributionType = gmodel.SeparateDistributionType;
item.SeparateDistributionMoneyType = gmodel.SeparateDistributionMoneyType;
item.IntegralPresent = gmodel.IntegralPresent;
item.IntegralPresentType = gmodel.IntegralPresentType;
}
if (demodel.User_Coupon_Id > 0 && GoodsCouponList.Any())
{
decimal FinalMoney = GoodsCouponList.Sum(x => x.TotalMoney);
var ccmodel = cList.Where(x => x.Id == demodel.User_Coupon_Id).FirstOrDefault();
var dcModel = dcList.Where(x => x.ID == (ccmodel?.CouponId ?? 0)).FirstOrDefault();
if (dcModel == null)
{
message = "优惠卷不存在,亲核实后再试";
return false;
}
if (dcModel.MinConsumePrice > 0)
{
if (FinalMoney < dcModel.MinConsumePrice)
{
FinalMoney = 0;
}
}
if (dcModel.CouponType == Common.Enum.MarketingCenter.CouponTypeEnum.FullReduction && FinalMoney > 0)
{
CouponsMoney = dcModel.DiscountsPrice;
}
else if (dcModel.CouponType == Common.Enum.MarketingCenter.CouponTypeEnum.Discount && FinalMoney > 0)
{
decimal disMoney = Math.Round(FinalMoney * (10 - dcModel.DiscountsPrice) / 10, 2, MidpointRounding.AwayFromZero);
if (dcModel.MaxDiscountsPrice > 0 && dcModel.MaxDiscountsPrice < disMoney)
{
disMoney = dcModel.MaxDiscountsPrice;
}
CouponsMoney = disMoney;
}
//每个商品优惠券分摊金额
if (CouponsMoney > 0)
{
foreach (var item in GoodsCouponList)
{
item.CouponMoney = Math.Round((item.TotalMoney / FinalMoney) * CouponsMoney, 2, MidpointRounding.AwayFromZero);
}
if (CouponsMoney != GoodsCouponList.Sum(x => x.CouponMoney))
{
//四舍五入存在差值
decimal diffMoney = CouponsMoney - GoodsCouponList.Sum(x => x.CouponMoney);
var gcModel = GoodsCouponList.OrderBy(x => x.CouponMoney).Take(1).FirstOrDefault();
gcModel.CouponMoney += diffMoney;
}
}
}
#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
List<int> ExpressGoodsId = new List<int>();//同商品 多规格
foreach (var item in demodel.DetailList)
{
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
if (gmodel == null || gmodel.GoodsStatus != 1)
{
continue;
}
item.SupplierId = gmodel.SupplierId;
item.CouponMoney = 0;
var couponModel = GoodsCouponList.Where(x => x.GoodsId == item.GoodsId).FirstOrDefault();
if (couponModel != null)
{
item.CouponMoney = couponModel.CouponMoney;
TotalMoney -= (item.CouponMoney ?? 0);//总价格需减去优惠券金额
item.Final_Price -= (item.CouponMoney ?? 0);
if (IsCommissionCoupons)
{
//通用优惠券
item.SmallShopsCostPrice -= (item.CouponMoney ?? 0);
}
}
#region 运费
decimal Express = 0;
decimal TExpress = 0;
bool ExpressIsReckon = false;
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)))
{
bool FreeShipping_Use = 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())
{
FreeShipping_Use = true;
item.FreeShippingRemarks = sglist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault().Name;
}
}
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 (!nosglist.Where(x => x.GoodsId == qitem.GoodsId && x.SpecificationKey == qitem.SpecificationSort).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()
{
FreeShipping = fullNumPinkageModel.ID,
Name = Name,
GoodsId = qitem.GoodsId ?? 0,
SpecificationKey = qitem.SpecificationSort,
Number = qitem.Number ?? 0,
Money = qitem.NorGoodsMoney,
CategoryId = fullNumPinkageModel.CategoryId
});
}
}
}
}
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())
{
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 (exNum <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((exNum - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + ((exNum - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + ((exNum - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
else
{
//重量计费
int TotalW = exNum * (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;
}
}
}
}
}
}
} }
TExpress = Express; }
if (exNum != item.Number) else
{
GoodsCouponList.Add(new RB_Goods_CouponModel()
{ {
Express = Math.Round(Express * (item.Number ?? 0) / exNum, 2, MidpointRounding.AwayFromZero); GoodsId = item.GoodsId ?? 0,
if (!ExpressGoodsId.Contains(item.GoodsId ?? 0)) Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
}
}
}
#endregion
#region 课程卡
if (demodel.Use_Education_Id > 0)
{
var ccmodel = eList.Where(x => x.Id == demodel.Use_Education_Id).FirstOrDefault();
string couponItem = (ccmodel?.CouponId ?? 0).ToString();
if (!string.IsNullOrEmpty(couponItem))
{
var dcModel = deList.Where(x => x.ID == Convert.ToInt32(couponItem)).FirstOrDefault();
if (dcModel == null)
{
message = "优惠卷不存在,亲核实后再试";
return false;
}
if (dcModel.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Category) //指定分类
{
var categoryList1 = dcpList.Where(x => x.DiscountCouponId == Convert.ToInt32(couponItem) && x.DiscountCouponType == Common.Enum.MarketingCenter.UseTypeEnum.Category).Select(x => x.ProductId).ToList();//获取特殊优惠卷
if (categoryList.Select(x => x.Id).Where(x => categoryList1.Contains(x)).Any())
{
if (dcModel.MaxDiscountsPrice == 0 || dcModel.MaxDiscountsPrice >= (item.Final_Price ?? 0))
{ {
ExpressGoodsId.Add(item.GoodsId ?? 0); GoodsCouponList.Add(new RB_Goods_CouponModel()
{
GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
} }
else }
}
else if (dcModel.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Product)//指定商品
{
var goodsList = dcpList.Where(x => x.DiscountCouponId == Convert.ToInt32(couponItem) && x.DiscountCouponType == Common.Enum.MarketingCenter.UseTypeEnum.Product).Select(x => x.ProductId).ToList();//获取特殊优惠卷
if (goodsList.Contains(item.GoodsId ?? 0))
{
if (dcModel.MaxDiscountsPrice == 0 || dcModel.MaxDiscountsPrice >= (item.Final_Price ?? 0))
{ {
ExpressIsReckon = true; GoodsCouponList.Add(new RB_Goods_CouponModel()
{
GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
} }
} }
} }
else
{
if (dcModel.MaxDiscountsPrice == 0 || dcModel.MaxDiscountsPrice >= (item.Final_Price ?? 0))
{
GoodsCouponList.Add(new RB_Goods_CouponModel()
{
GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
}
}
} }
} }
if (!ExpressIsReckon) #endregion
TotalMoney += (item.Final_Price ?? 0);
item.OrderType = gmodel.GoodsType;
item.GoodsName = gmodel.Name;
item.CoverImage = "";
if (!string.IsNullOrEmpty(gmodel.CarouselImage) && gmodel.CarouselImage != "[]")
{ {
TotalExpress += TExpress; List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(gmodel.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
} }
#endregion item.SeparateDistribution = gmodel.SeparateDistribution;
item.FreightMoney = Express; item.SeparateDistributionType = gmodel.SeparateDistributionType;
item.SeparateDistributionMoneyType = gmodel.SeparateDistributionMoneyType;
item.IntegralPresent = gmodel.IntegralPresent;
item.IntegralPresentType = gmodel.IntegralPresentType;
}
if (demodel.User_Coupon_Id > 0 && GoodsCouponList.Any())
{
decimal FinalMoney = GoodsCouponList.Sum(x => x.TotalMoney);
var ccmodel = cList.Where(x => x.Id == demodel.User_Coupon_Id).FirstOrDefault();
var dcModel = dcList.Where(x => x.ID == (ccmodel?.CouponId ?? 0)).FirstOrDefault();
if (dcModel == null)
{
message = "优惠卷不存在,亲核实后再试";
return false;
}
if (dcModel.MinConsumePrice > 0)
{
if (FinalMoney < dcModel.MinConsumePrice)
{
FinalMoney = 0;
}
}
if (dcModel.CouponType == Common.Enum.MarketingCenter.CouponTypeEnum.FullReduction && FinalMoney > 0)
{
CouponsMoney = dcModel.DiscountsPrice;
}
else if (dcModel.CouponType == Common.Enum.MarketingCenter.CouponTypeEnum.Discount && FinalMoney > 0)
{
decimal disMoney = Math.Round(FinalMoney * (10 - dcModel.DiscountsPrice) / 10, 2, MidpointRounding.AwayFromZero);
if (dcModel.MaxDiscountsPrice > 0 && dcModel.MaxDiscountsPrice < disMoney)
{
disMoney = dcModel.MaxDiscountsPrice;
}
CouponsMoney = disMoney;
}
//每个商品优惠券分摊金额
if (CouponsMoney > 0)
{
foreach (var item in GoodsCouponList)
{
item.CouponMoney = Math.Round((item.TotalMoney / FinalMoney) * CouponsMoney, 2, MidpointRounding.AwayFromZero);
}
if (CouponsMoney != GoodsCouponList.Sum(x => x.CouponMoney))
{
//四舍五入存在差值
decimal diffMoney = CouponsMoney - GoodsCouponList.Sum(x => x.CouponMoney);
var gcModel = GoodsCouponList.OrderBy(x => x.CouponMoney).Take(1).FirstOrDefault();
gcModel.CouponMoney += diffMoney;
}
}
}
if (demodel.Use_Education_Id > 0 && GoodsCouponList.Any())
{
var ccmodel = eList.Where(x => x.Id == demodel.Use_Education_Id).FirstOrDefault();
GoodsCouponList = GoodsCouponList.OrderBy(x => x.TotalMoney).Take(ccmodel.HeXiao - ccmodel.UseHeXiao).ToList();
}
foreach (var item in demodel.DetailList)
{
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
if (gmodel == null || gmodel.GoodsStatus != 1)
{
continue;
}
item.SupplierId = gmodel.SupplierId;
item.CouponMoney = 0;
item.GoodServiceTime = gmodel.ServiceTime;
if (demodel.User_Coupon_Id > 0)
{
var couponModel = GoodsCouponList.Where(x => x.GoodsId == item.GoodsId).FirstOrDefault();
if (couponModel != null)
{
item.CouponMoney = couponModel.CouponMoney;
TotalMoney -= (item.CouponMoney ?? 0);//总价格需减去优惠券金额
item.Final_Price -= (item.CouponMoney ?? 0);
if (IsCommissionCoupons)
{
//通用优惠券
item.SmallShopsCostPrice -= (item.CouponMoney ?? 0);
}
}
}
item.EducationCouponId = 0;
if (demodel.Use_Education_Id > 0)
{
var couponModel = GoodsCouponList.Where(x => x.GoodsId == item.GoodsId).FirstOrDefault();
if (couponModel != null)
{
EducationMoney += couponModel.TotalMoney;
EducationNum += 1;
item.EducationCouponId = demodel.Use_Education_Id;
}
}
item.FreightMoney = 0;
item.CommentGiveIntegral = 0; item.CommentGiveIntegral = 0;
if (gmodel.IntegralComment > 0) if (gmodel.IntegralComment > 0)
{ {
...@@ -5686,9 +5359,9 @@ namespace Mall.Module.Product ...@@ -5686,9 +5359,9 @@ namespace Mall.Module.Product
} }
} }
} }
if (demodel.FreightMoney != TotalExpress) if ((demodel?.EducationMoney??0) != EducationMoney)
{ {
message = "运费不正确"; message = "套餐卡抵扣金额不正确";
return false; return false;
} }
if (CouponsMoney != demodel.CouponMoney) if (CouponsMoney != demodel.CouponMoney)
...@@ -5696,8 +5369,9 @@ namespace Mall.Module.Product ...@@ -5696,8 +5369,9 @@ namespace Mall.Module.Product
message = "优惠金额计算有误"; message = "优惠金额计算有误";
return false; return false;
} }
//验证总额 //验证总额
if (demodel.Income != (TotalMoney + TotalExpress)) if (demodel.Income != (TotalMoney - EducationMoney))
{ {
message = "订单合计金额不正确"; message = "订单合计金额不正确";
return false; return false;
...@@ -5705,28 +5379,27 @@ namespace Mall.Module.Product ...@@ -5705,28 +5379,27 @@ namespace Mall.Module.Product
demodel.PreferPrice = TotalMoney + CouponsMoney; demodel.PreferPrice = TotalMoney + CouponsMoney;
#region 手续费计算 #region 手续费计算
//decimal ServiceCharge = Convert.ToDecimal(Config.SettlementRate) / 100; decimal ServiceCharge = Convert.ToDecimal(Config.SettlementRate) / 100;
//if (ServiceCharge > 0) if (ServiceCharge > 0)
//{ {
// decimal TotalFee = Math.Round((demodel.Income ?? 0) * ServiceCharge, 2, MidpointRounding.AwayFromZero); decimal TotalFee = Math.Round((demodel.Income ?? 0) * ServiceCharge, 2, MidpointRounding.AwayFromZero);
// if (demodel.DetailList.Any()) if (demodel.DetailList.Any())
// { {
// int dcount = demodel.DetailList.Count(); int dcount = demodel.DetailList.Count();
// decimal avgFee = Math.Round(TotalFee / dcount, 2, MidpointRounding.AwayFromZero); decimal avgFee = Math.Round(TotalFee / dcount, 2, MidpointRounding.AwayFromZero);
// foreach (var item in demodel.DetailList) foreach (var item in demodel.DetailList)
// { {
// item.ServiceCharge = avgFee; item.ServiceCharge = avgFee;
// } }
// if (avgFee * dcount != TotalFee) if (avgFee * dcount != TotalFee)
// { {
// //多余的 直接算在第一个商品里 //多余的 直接算在第一个商品里
// var detailmodel = demodel.DetailList.FirstOrDefault(); var detailmodel = demodel.DetailList.FirstOrDefault();
// detailmodel.ServiceCharge += (TotalFee - avgFee * dcount); detailmodel.ServiceCharge += (TotalFee - avgFee * dcount);
// } }
// } }
//} }
#endregion #endregion
try try
{ {
Random R = new Random(); Random R = new Random();
...@@ -5735,6 +5408,14 @@ namespace Mall.Module.Product ...@@ -5735,6 +5408,14 @@ namespace Mall.Module.Product
demodel.PaymentWay = OrderPaymentTypeEnum.OnlinePayment;//先默认在线支付 demodel.PaymentWay = OrderPaymentTypeEnum.OnlinePayment;//先默认在线支付
demodel.Remark ??= ""; demodel.Remark ??= "";
demodel.ApplyForCancelStatus ??= 0; demodel.ApplyForCancelStatus ??= 0;
if (demodel.Income == 0)
{
demodel.OrderStatus = OrderStatusEnum.Completed;
demodel.PaymentTime = DateTime.Now;
demodel.DeliveryTime = DateTime.Now;
demodel.ReceivingTime = DateTime.Now;
demodel.FinishTime = DateTime.Now;
}
int OrderId = goods_OrderRepository.Insert(demodel); int OrderId = goods_OrderRepository.Insert(demodel);
if (OrderId > 0) if (OrderId > 0)
{ {
...@@ -5751,7 +5432,7 @@ namespace Mall.Module.Product ...@@ -5751,7 +5432,7 @@ namespace Mall.Module.Product
} }
#endregion #endregion
//插入订单明细+ 商品库存更新 //插入订单明细+ 商品库存更新
InsertOrderDetail(demodel, null, OrderId, SatisfiedGoodsList); InsertOrderDetail(demodel, null, OrderId, new List<FreeShippingGoodsDetail>());
//用户订单数增加 //用户订单数增加
Dictionary<string, object> keyValues = new Dictionary<string, object>() Dictionary<string, object> keyValues = new Dictionary<string, object>()
...@@ -5764,20 +5445,30 @@ namespace Mall.Module.Product ...@@ -5764,20 +5445,30 @@ namespace Mall.Module.Product
{ {
foreach (var item in cList) foreach (var item in cList)
{ {
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() Dictionary<string, object> keyValues1 = new Dictionary<string, object>()
{ {
{ nameof(RB_Member_DiscountCoupon_Extend.UseDate),DateTime.Now}, { nameof(RB_Member_DiscountCoupon_Extend.UseDate),DateTime.Now},
{ nameof(RB_Member_DiscountCoupon_Extend.UseState),1} { nameof(RB_Member_DiscountCoupon_Extend.UseState),1}
}; };
member_CouponRepository.Update(keyValues1, new WhereHelper(nameof(RB_Member_DiscountCoupon_Extend.Id), item.Id)); List<WhereHelper> wheres1 = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Member_DiscountCoupon_Extend.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
member_CouponRepository.Update(keyValues1, wheres1);
umodel.CouponsNum = (umodel.CouponsNum ?? 0) - 1; umodel.CouponsNum = (umodel.CouponsNum ?? 0) - 1;
} }
if (umodel.CouponsNum < 0) if (umodel.CouponsNum < 0)
{ {
umodel.CouponsNum = 0; umodel.CouponsNum = 0;
} }
keyValues.Add(nameof(RB_Member_User_Extend.CouponsNum), umodel.CouponsNum); keyValues.Add(nameof(RB_Member_User_Extend.CouponsNum), umodel.CouponsNum);
} }
//积分
if (demodel.Use_Integral == 1 && TotalIntegralNumber > 0) if (demodel.Use_Integral == 1 && TotalIntegralNumber > 0)
{ {
keyValues.Add(nameof(RB_Member_User_Extend.Integral), (umodel.Integral ?? 0)); keyValues.Add(nameof(RB_Member_User_Extend.Integral), (umodel.Integral ?? 0));
...@@ -5797,7 +5488,55 @@ namespace Mall.Module.Product ...@@ -5797,7 +5488,55 @@ namespace Mall.Module.Product
OrderId = OrderId OrderId = OrderId
}); });
} }
member_UserRepository.Update(keyValues, new WhereHelper(nameof(RB_Member_User_Extend.Id), umodel.Id));
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Member_User_Extend.Id),
FiledValue=umodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
member_UserRepository.Update(keyValues, wheres);
#region 课程卡使用
if (demodel.Use_Education_Id > 0 && EducationNum > 0)
{
education_MemberUseCouponRepository.Insert(new Model.Entity.Education.RB_Education_MemberUseCoupon()
{
Id = 0,
MallBaseId = demodel.MallBaseId,
MemberCouponId = demodel.Use_Education_Id,
OrderId = OrderId,
Remarks = "",
Status = 0,
TenantId = demodel.TenantId,
UseDate = DateTime.Now,
UserId = demodel.UserId,
UseHeXiao = EducationNum
});
var educationModel = eList.FirstOrDefault();
if (educationModel != null)
{
//更新用户课程卡 已使用数量
Dictionary<string, object> keyValues1 = new Dictionary<string, object>()
{
{ nameof(RB_Education_MemberCoupon_Extend.UseHeXiao),educationModel.UseHeXiao + EducationNum}
};
List<WhereHelper> wheres1 = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Education_MemberCoupon_Extend.Id),
FiledValue=educationModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
education_MemberCouponRepository.Update(keyValues1, wheres1);
}
}
#endregion
//来自购物车的话 需清除购物车数据 //来自购物车的话 需清除购物车数据
if (demodel.IsFormShoppingCart == 1) if (demodel.IsFormShoppingCart == 1)
...@@ -5813,27 +5552,27 @@ namespace Mall.Module.Product ...@@ -5813,27 +5552,27 @@ namespace Mall.Module.Product
{ {
new WhereHelper() new WhereHelper()
{ {
FiledName=nameof(RB_Goods_ShoppingCart.Id), FiledName=nameof(RB_Goods_ShoppingCart.Id),
FiledValue=cartItem, FiledValue=cartItem,
OperatorEnum=OperatorEnum.IN OperatorEnum=OperatorEnum.IN
}, },
new WhereHelper() new WhereHelper()
{ {
FiledName=nameof(RB_Goods_ShoppingCart.UserId), FiledName=nameof(RB_Goods_ShoppingCart.UserId),
FiledValue=demodel.UserId, FiledValue=demodel.UserId,
OperatorEnum=OperatorEnum.IN OperatorEnum=OperatorEnum.IN
}, },
new WhereHelper() new WhereHelper()
{ {
FiledName=nameof(RB_Goods_ShoppingCart.TenantId), FiledName=nameof(RB_Goods_ShoppingCart.TenantId),
FiledValue=demodel.TenantId, FiledValue=demodel.TenantId,
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
}, },
new WhereHelper() new WhereHelper()
{ {
FiledName=nameof(RB_Goods_ShoppingCart.MallBaseId), FiledName=nameof(RB_Goods_ShoppingCart.MallBaseId),
FiledValue=demodel.MallBaseId, FiledValue=demodel.MallBaseId,
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
goods_ShoppingCartRepository.Update(keyValues2, wheres2); goods_ShoppingCartRepository.Update(keyValues2, wheres2);
...@@ -5849,7 +5588,16 @@ namespace Mall.Module.Product ...@@ -5849,7 +5588,16 @@ namespace Mall.Module.Product
{nameof(RB_Member_User_Extend.IsBeDownline),1 }, {nameof(RB_Member_User_Extend.IsBeDownline),1 },
{nameof(RB_Member_User_Extend.BeDownlineDate),DateTime.Now }, {nameof(RB_Member_User_Extend.BeDownlineDate),DateTime.Now },
}; };
member_UserRepository.Update(keyValues1, new WhereHelper(nameof(RB_Member_User_Extend.Id), umodel.Id)); List<WhereHelper> wheres1 = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Member_User_Extend.Id),
FiledValue=umodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
member_UserRepository.Update(keyValues1, wheres1);
} }
//任务执行返佣 失败查看日志,手动返佣(空闲可增加手动返佣接口) //任务执行返佣 失败查看日志,手动返佣(空闲可增加手动返佣接口)
...@@ -5864,7 +5612,7 @@ namespace Mall.Module.Product ...@@ -5864,7 +5612,7 @@ namespace Mall.Module.Product
Id = 0, Id = 0,
Type = 1, Type = 1,
SourceId = OrderId, SourceId = OrderId,
Content = "新增线下服务订单", Content = "新增课程订单",
CreateDate = DateTime.Now, CreateDate = DateTime.Now,
MallBaseId = demodel.MallBaseId, MallBaseId = demodel.MallBaseId,
TenantId = demodel.TenantId TenantId = demodel.TenantId
...@@ -13863,6 +13611,19 @@ namespace Mall.Module.Product ...@@ -13863,6 +13611,19 @@ namespace Mall.Module.Product
public List<RB_Goods_OrderDetail_Extend> GetAppletGoodsWaitCommentPageList(int pageIndex, int pageSize, out long count, RB_Goods_OrderDetail_Extend demodel) public List<RB_Goods_OrderDetail_Extend> GetAppletGoodsWaitCommentPageList(int pageIndex, int pageSize, out long count, RB_Goods_OrderDetail_Extend demodel)
{ {
var list = goods_OrderDetailRepository.GetAppletGoodsWaitCommentPageList(pageIndex, pageSize, out count, demodel); var list = goods_OrderDetailRepository.GetAppletGoodsWaitCommentPageList(pageIndex, pageSize, out count, demodel);
List<RB_Reserve_ServicePersonal_Extend> persionList = new List<RB_Reserve_ServicePersonal_Extend>();
if (list != null && list.Count > 0)
{
string persionIds = string.Join(",", list.Where(qitem => qitem.ServicepersonalId > 0).Select(qitem => qitem.ServicepersonalId));
if (!string.IsNullOrEmpty(persionIds))
{
persionList= reserve_ServicePersonalRepository.GetServicePersonalList(new RB_Reserve_ServicePersonal_Extend()
{
QIds = persionIds
});
}
}
foreach (var item in list) foreach (var item in list)
{ {
item.SpecificationList = new List<string>(); item.SpecificationList = new List<string>();
...@@ -13870,6 +13631,10 @@ namespace Mall.Module.Product ...@@ -13870,6 +13631,10 @@ namespace Mall.Module.Product
{ {
item.SpecificationList = JsonConvert.DeserializeObject<List<string>>(item.Specification); item.SpecificationList = JsonConvert.DeserializeObject<List<string>>(item.Specification);
} }
if (item.ServicepersonalId > 0)
{
item.ServicepersonalName = persionList?.Where(qitem => qitem.ID == item.ServicepersonalId)?.FirstOrDefault()?.Name ?? "";
}
} }
return list; return list;
} }
......
...@@ -650,7 +650,11 @@ where {where} order by o.CreateDate desc"; ...@@ -650,7 +650,11 @@ where {where} order by o.CreateDate desc";
where += $@" and o.{nameof(RB_Goods_Order.UserId)} ={dmodel.UserId}"; where += $@" and o.{nameof(RB_Goods_Order.UserId)} ={dmodel.UserId}";
} }
string sql = $@"SELECT a.*,e.`Name` as CarName,e.CarType as GuideCarType,e.CarClass,f.ColorName as CarColorName,cb.`Name` as CarBrandName,g.RideNum,gcg.Name as GuideName,gcg.GuidePhoto,gcg.WorkYears as GuideWorkYears,gcg.Score as GuideScore,gcg.Telephone as GuideTelephone FROM rb_goods_orderdetail as a string sql = $@"
SELECT a.*,e.`Name` as CarName,e.CarType as GuideCarType,e.CarClass,f.ColorName as CarColorName,cb.`Name` as CarBrandName,g.RideNum
,gcg.Name as GuideName,gcg.GuidePhoto,gcg.WorkYears as GuideWorkYears,gcg.Score as GuideScore,gcg.Telephone as GuideTelephone
,g.StoresIds
FROM rb_goods_orderdetail as a
left join rb_goods_order o on a.OrderId = o.OrderId left join rb_goods_order o on a.OrderId = o.OrderId
LEFT JOIN rb_guidecar_car as e on e.ID=a.CarId LEFT JOIN rb_guidecar_car as e on e.ID=a.CarId
LEFT JOIN rb_guidecar_carbrand as cb on e.CarBrandId=cb.ID LEFT JOIN rb_guidecar_carbrand as cb on e.CarBrandId=cb.ID
......
...@@ -119,6 +119,9 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -119,6 +119,9 @@ namespace Mall.WebApi.Controllers.MallBase
//小程序 //小程序
var mall = new object(); var mall = new object();
//线下服务小程序配置接口
var offlineServiceSetting = new object();
//直播海报配置 //直播海报配置
var liveConfig = new object(); var liveConfig = new object();
...@@ -129,11 +132,12 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -129,11 +132,12 @@ namespace Mall.WebApi.Controllers.MallBase
miniProgram = programModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend() { MiniAppId = MiniAppId }, isGetHomeData: true, isGetNav: 1); miniProgram = programModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend() { MiniAppId = MiniAppId }, isGetHomeData: true, isGetNav: 1);
//基础配置 //基础配置
setting = MallHelper.GetBasicSetting(miniProgram); setting = MallHelper.GetBasicSetting(miniProgram);
//分销基础信息 //分销基础信息
share_setting = MallHelper.GetDistributorBasicsInfo(miniProgram); share_setting = MallHelper.GetDistributorBasicsInfo(miniProgram);
//分销商设置 //分销商设置
share_setting_custom = MallHelper.GetDistributorCustomInfo(miniProgram); share_setting_custom = MallHelper.GetDistributorCustomInfo(miniProgram);
//线下服务配置
offlineServiceSetting = MallHelper.GetOfflineServiceConfig(miniProgram);
} }
#region 首页页面数据解析 #region 首页页面数据解析
...@@ -390,6 +394,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -390,6 +394,7 @@ namespace Mall.WebApi.Controllers.MallBase
expired_at = "0000-00-00 00:00:00", expired_at = "0000-00-00 00:00:00",
option = new List<object>(), option = new List<object>(),
setting, setting,
offlineServiceSetting,
}; };
#region 授权页面热区 #region 授权页面热区
......
...@@ -8,6 +8,7 @@ using Mall.Model.Extend.User; ...@@ -8,6 +8,7 @@ using Mall.Model.Extend.User;
using Mall.Module.BaseSetUp; using Mall.Module.BaseSetUp;
using Mall.Module.MarketingCenter; using Mall.Module.MarketingCenter;
using Mall.Module.Product; using Mall.Module.Product;
using Mall.Module.Reserve;
using Mall.Module.User; using Mall.Module.User;
using Mall.Repository.Product; using Mall.Repository.Product;
using Mall.Repository.User; using Mall.Repository.User;
...@@ -82,6 +83,11 @@ namespace Mall.WebApi.Controllers ...@@ -82,6 +83,11 @@ namespace Mall.WebApi.Controllers
/// </summary> /// </summary>
private static Module.Education.EducationModule educationModule = new Module.Education.EducationModule(); private static Module.Education.EducationModule educationModule = new Module.Education.EducationModule();
/// <summary>
/// 线下服务配置处理类
/// </summary>
private static ReserveModule reserveModule = new ReserveModule();
/// <summary> /// <summary>
/// 解析插件数据为对象 /// 解析插件数据为对象
...@@ -2631,6 +2637,22 @@ namespace Mall.WebApi.Controllers ...@@ -2631,6 +2637,22 @@ namespace Mall.WebApi.Controllers
#endregion #endregion
return share_setting_custom; return share_setting_custom;
} }
/// <summary>
/// 获取线下服务小程序配置
/// </summary>
/// <param name="miniProgram"></param>
/// <returns></returns>
public static object GetOfflineServiceConfig(RB_MiniProgram_Extend miniProgram)
{
var model = reserveModule.GetReserveBaseInfo(Convert.ToInt32(miniProgram.TenantId), miniProgram.MallBaseId);
var obj = new
{
offlineServicePayType = model?.PayTypeList,
offlineServiceOrderStateList = model?.OrderStateList
};
return obj;
}
} }
/// <summary> /// <summary>
......
...@@ -1283,7 +1283,12 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1283,7 +1283,12 @@ namespace Mall.WebApi.Controllers.MallBase
x.CarColorName, x.CarColorName,
x.CarBrandName, x.CarBrandName,
x.GuideName, x.GuideName,
x.GuidePhoto x.GuidePhoto,
x.ServiceDate,
x.ServiceTime,
x.ServicepersonalId,
x.ServicepersonalName,
x.StoresIds,
}); });
return ApiResult.Success("", pagelist); return ApiResult.Success("", pagelist);
} }
......
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