Commit 3800934c authored by 吴春's avatar 吴春

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

parents 69f66bab d0eecf82
......@@ -16,6 +16,7 @@ using Mall.Model.Query;
using Mall.Repository;
using Mall.Repository.BaseSetUp;
using Mall.Repository.Product;
using Mall.Repository.Reserve;
using Mall.Repository.User;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
......@@ -193,7 +194,10 @@ namespace Mall.Module.Product
/// </summary>
private readonly RB_Goods_WK_CourseStudyRepository goods_WK_CourseStudyRepository = new RB_Goods_WK_CourseStudyRepository();
/// <summary>
/// 服务人员仓储仓储层对象
/// </summary>
private readonly RB_Reserve_ServicePersonalRepository reserve_ServicePersonalRepository = new RB_Reserve_ServicePersonalRepository();
#region 小程序接口
......@@ -242,10 +246,11 @@ namespace Mall.Module.Product
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <param name="IsGetShare">1-获取分销佣金</param>
/// <param name="GoodsClassify">商品类型</param>
/// <returns></returns>
public List<RB_Goods_Extend> GetAppletGoodsPageListForZY(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel, int IsGetShare = 0)
public List<RB_Goods_Extend> GetAppletGoodsPageListForZY(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel, int IsGetShare = 0, int GoodsClassify = 0)
{
var list = goodsRepository.GetAppletGoodsPageList(pageIndex, pageSize, out count, demodel);
var list = goodsRepository.GetAppletGoodsPageList(pageIndex, pageSize, out count, demodel,GoodsClassify:GoodsClassify);
if (list.Any())
{
var SpecificationList = new List<RB_Goods_Specification_Extend>();
......@@ -2558,6 +2563,1046 @@ namespace Mall.Module.Product
#endregion
}
/// <summary>
/// 获取线下服务商品预定详情
/// </summary>
/// <param name="goodsId">商品编号</param>
/// <param name="UserId">用户编号</param>
/// <param name="SmallShopsId">微店编号</param>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <param name="storeId">门店编号</param>
/// <returns></returns>
public object GetAppletOfflineGoodsInfoModule(int goodsId, int UserId, int SmallShopsId, int TenantId, int MallBaseId,int storeId=0)
{
var model = goodsRepository.GetEntity(goodsId).RefMapperTo<RB_Goods_Extend>();
if (model == null || model.TenantId != TenantId || model.MallBaseId != MallBaseId)
{
return null;
}
else
{
model.CoverImage = "";
if (!string.IsNullOrEmpty(model.CarouselImage) && model.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(model.CarouselImage);
//封面图
model.CoverImage = CarouselIdList[0];
}
}
//小程序名称
model.MallName = programRepository.GetEntity(model.MallBaseId)?.MallName ?? "";
RB_Member_User_Extend userModel = new RB_Member_User_Extend();
if (UserId > 0)
{
userModel = GetMemberUserInfo(UserId);
if (SmallShopsId == 0)
{
SmallShopsId = userModel.SmallShopId;
}
}
#region 基本信息
//查询分类
model.CategoryList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
//2020-08-05 根据分类查找商品对应的分类包邮规则 add by :W
#region 微店价格
RB_SmallShops_Info smallModel = new RB_SmallShops_Info();
List<RB_SmallShops_Price_Extend> smallPList = new List<RB_SmallShops_Price_Extend>();
if (SmallShopsId > 0)
{
smallModel = smallShops_InfoRepository.GetEntity(SmallShopsId);
smallPList = smallShops_PriceRepository.GetList(new RB_SmallShops_Price_Extend() { SmallShopsId = SmallShopsId, GoodsId = goodsId });
if (((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.UpPrice > 0).Any()))
{
var sspModel = smallPList.Where(x => x.SpecificationKey == "").FirstOrDefault();
if (sspModel != null)
{
//单商品设置的
if (sspModel.PriceType == 1)
{
model.SellingPrice = (model.SellingPrice ?? 0) + Math.Ceiling((model.SellingPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
model.OriginalPrice = (model.OriginalPrice ?? 0) + Math.Ceiling((model.OriginalPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
}
else if (sspModel.PriceType == 2)
{
model.SellingPrice = (model.SellingPrice ?? 0) + (sspModel.UpPrice ?? 0);
model.OriginalPrice = (model.OriginalPrice ?? 0) + (sspModel.UpPrice ?? 0);
}
}
else
{
if ((smallModel.UpPrice ?? 0) > 0)
{
if (smallModel.PriceType == 1)
{
model.SellingPrice = (model.SellingPrice ?? 0) + Math.Ceiling((model.SellingPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
model.OriginalPrice = (model.OriginalPrice ?? 0) + Math.Ceiling((model.OriginalPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
model.SellingPrice = (model.SellingPrice ?? 0) + (smallModel.UpPrice ?? 0);
model.OriginalPrice = (model.OriginalPrice ?? 0) + (smallModel.UpPrice ?? 0);
}
}
}
}
}
#endregion
//最大售价
decimal MaxSellMoney = model.SellingPrice ?? 0;
model.SpecificationList = new List<RB_Goods_Specification_Extend>();
model.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
if (model.IsCustomSpecification == 1)
{
model.SpecificationList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (model.SpecificationList.Any())
{
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in svlist)
{
item.ImagePath = item.Image;
}
foreach (var item in model.SpecificationList)
{
item.SpecificationValueList = svlist.Where(x => x.SpecificationId == item.Id).ToList();
}
}
model.SpecificationPriceList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (SmallShopsId > 0)
{
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.UpPrice > 0).Any())
{
foreach (var item in model.SpecificationPriceList)
{
var sspModel = smallPList.Where(x => x.SpecificationKey == item.SpecificationSort).FirstOrDefault();
if (sspModel != null)
{
//单商品设置的
if (sspModel.PriceType == 1)
{
item.SellingPrice = (item.SellingPrice ?? 0) + Math.Ceiling((item.SellingPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
}
else if (sspModel.PriceType == 2)
{
item.SellingPrice = (item.SellingPrice ?? 0) + (sspModel.UpPrice ?? 0);
}
}
else
{
if ((smallModel.UpPrice ?? 0) > 0)
{
if (smallModel.PriceType == 1)
{
item.SellingPrice = (item.SellingPrice ?? 0) + Math.Ceiling((item.SellingPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
item.SellingPrice = (item.SellingPrice ?? 0) + (smallModel.UpPrice ?? 0);
}
}
}
}
}
}
MaxSellMoney = model.SpecificationPriceList.Max(x => x.SellingPrice ?? 0);
model.SellingPrice = model.SpecificationPriceList.Min(x => x.SellingPrice ?? 0);
decimal MaxPrice = MaxSellMoney + Math.Ceiling(MaxSellMoney / 10);
if (MaxPrice > model.OriginalPrice)
{
model.OriginalPrice = MaxPrice;
}
}
//区域
model.AreaList = new List<RB_Goods_Area_Extend>();
if (model.IsAreaBuy == 1)
{
model.AreaList = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
}
//返佣
model.DistributionCommissionList = new List<RB_Goods_DistributionCommission_Extend>();
if (model.SeparateDistribution == 1)
{
model.DistributionCommissionList = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
}
//会员价格
model.MemberPriceList = new List<RB_Goods_MemberPrice_Extend>();
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1)
{
model.MemberPriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
}
#region 微店处理会员价格
if (model.MemberPriceList.Any() && SmallShopsId > 0)
{
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.UpPrice > 0).Any())
{
foreach (var item in model.MemberPriceList)
{
var sspModel = smallPList.Where(x => x.SpecificationKey == item.SpecificationSort).FirstOrDefault();
if (sspModel != null)
{
//单商品设置的
if (sspModel.PriceType == 1)
{
item.MemberPrice = (item.MemberPrice ?? 0) + Math.Ceiling((item.MemberPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
}
else if (sspModel.PriceType == 2)
{
item.MemberPrice = (item.MemberPrice ?? 0) + (sspModel.UpPrice ?? 0);
}
}
else
{
if ((smallModel.UpPrice ?? 0) > 0)
{
if (smallModel.PriceType == 1)
{
item.MemberPrice = (item.MemberPrice ?? 0) + Math.Ceiling((item.MemberPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
item.MemberPrice = (item.MemberPrice ?? 0) + (smallModel.UpPrice ?? 0);
}
}
}
}
}
}
#endregion
//轮播
model.CarouselImageList = new List<RB_ImageCommonModel>();
if (!string.IsNullOrWhiteSpace(model.VideoAddress))
{
model.CarouselImageList.Add(new RB_ImageCommonModel()
{
Id = 0,
Name = "",
Type = 1,
Path = model.VideoAddress
});
}
if (!string.IsNullOrEmpty(model.CarouselImage) && model.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(model.CarouselImage);
//轮播图
foreach (var item in CarouselIdList)
{
model.CarouselImageList.Add(new RB_ImageCommonModel()
{
Id = 0,
Name = "",
Path = item
});
}
}
model.CustomShareImagePath = model.CustomShareImage;
//服务列表
model.ServiceList = new List<RB_ImageCommonModel>();
if (model.IsDefaultService == 2)
{
if (!string.IsNullOrEmpty(model.GoodsService) && model.GoodsService != "[]")
{
List<int> ServiceIds = JsonConvert.DeserializeObject<List<int>>(model.GoodsService);
var slist = product_ServiceRepository.GetList(new RB_Product_Service_Extend() { ServiceIds = string.Join(",", ServiceIds), TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in slist)
{
model.ServiceList.Add(new RB_ImageCommonModel()
{
Id = item.Id,
Name = item.Name
});
}
}
}
else if (model.IsDefaultService == 1)
{
var slist = product_ServiceRepository.GetList(new RB_Product_Service_Extend() { IsDefault = 1, TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in slist)
{
model.ServiceList.Add(new RB_ImageCommonModel()
{
Id = item.Id,
Name = item.Name
});
}
}
//表单
if (model.FormsId > 0)
{
model.FormsName = "未建表";
}
else
{
model.FormsName = "默认表单";
}
#endregion
#region 是否收藏
model.Favorite = false;
if (UserId > 0)
{
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper(nameof(RB_Member_Collection_Extend.UserId),UserId),
new WhereHelper(nameof(RB_Member_Collection_Extend.GoodsId),goodsId) ,
new WhereHelper(nameof(RB_Member_Collection_Extend.TenantId),TenantId),
new WhereHelper(nameof(RB_Member_Collection_Extend.MallBaseId),MallBaseId),
};
if (member_CollectionRepository.Exists(wheres))
{
model.Favorite = true;
}
}
#endregion
#region 快递费用
//运费
Model.Entity.BaseSetUp.RB_Logistics_Rules rulesModel = new Model.Entity.BaseSetUp.RB_Logistics_Rules();
if (model.FreightId > 0)
{
rulesModel = logistics_RulesRepository.GetEntity(model.FreightId);
model.FreightName = rulesModel?.RulesName ?? "";
}
else
{
model.FreightName = "默认运费";
}
model.Express = 0;
if (UserId > 0 && model.FreightId >= 0)
{
int FreightId = model.FreightId ?? 0;
if (model.FreightId == 0)
{
//查询默认
FreightId = logistics_RulesRepository.GetLogisticsRulesList(new Model.Extend.BaseSetUp.RB_Logistics_Rules_Extend() { IsDefault = 1, TenantId = TenantId, MallBaseId = MallBaseId }).FirstOrDefault()?.ID ?? 0;
}
if (FreightId > 0)
{
var samodel = member_ShippingAddressRepository.GetList(new RB_Member_ShippingAddress_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, UserId = UserId, IsDefault = 1 }).FirstOrDefault();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList1 = logistics_RulesPriceRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, RulesId = FreightId });
if (priceList1.Any() && samodel != null)
{
string priceIds = string.Join(",", priceList1.Select(x => x.ID));
var regionList = logistics_RulesRegionRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, PriceIds = priceIds });
List<int> disList = new List<int>();
disList.Add(samodel.Province ?? 0);
disList.Add(samodel.City ?? 0);
disList.Add(samodel.District ?? 0);
var regionModel = regionList.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null)
{
var pmodel = priceList1.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
model.Express = pmodel.FirstPrice;
}
else
{
//重量计费
int TotalW = model.GoodsWeight ?? 0;
if (TotalW <= pmodel.First)
{
model.Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((TotalW - pmodel.First) % pmodel.Second == 0)
{
model.Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
model.Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
model.Express = pmodel.FirstPrice;
}
}
}
}
}
}
}
}
#endregion
#region 最高返佣
model.MaxShare = 0;
decimal MyBuyCommission = 0;//自购返利
var BasicsModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = TenantId, MallBaseId = MallBaseId }).FirstOrDefault();
if (UserId > 0)
{
//获取分销商信息
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, UserId = UserId, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault();
if (disModel != null)
{
if ((BasicsModel?.IsEnableFXGrade ?? 2) == 1)
{
if ((model.PresentFXGrade ?? 0) == 0)
{
var FXList = distributor_FXGradeRepository.GetList(new RB_Distributor_FXGrade_Extend() { TenantId = TenantId, MallBaseId = MallBaseId });
if (FXList.Any() && FXList.Where(x => x.IsGuest == 1).Any())
{
var FXModel = FXList.Where(x => x.Id == disModel.FXGradeId).FirstOrDefault();
var PModel = FXList.Where(x => x.IsGuest == 1).FirstOrDefault();
if (FXModel != null && PModel != null)
{
decimal CRate = 0;
if (FXModel.Id == PModel.Id)
{
CRate = FXModel.SiblingRatio ?? 0;
}
else
{
CRate = (FXModel.CommissionRatio ?? 0) - (PModel.CommissionRatio ?? 0);
}
if (model.IsCustomSpecification == 1)
{
var dcModel = model.SpecificationPriceList.OrderByDescending(x => x.Commission).FirstOrDefault();
if (dcModel.Commission > 0)
{
if (FXModel.DecimalType == 1)
{
model.MaxShare = Math.Ceiling(dcModel.Commission * CRate / 100);
MyBuyCommission = Math.Ceiling(dcModel.Commission * (FXModel.CommissionRatio ?? 0) / 100);
}
else
{
model.MaxShare = Math.Ceiling(dcModel.Commission * CRate) / 100;
MyBuyCommission = Math.Ceiling(dcModel.Commission * (FXModel.CommissionRatio ?? 0)) / 100;
}
}
}
else
{
if (model.Commission > 0)
{
if (FXModel.DecimalType == 1)
{
model.MaxShare = Math.Ceiling(model.Commission * CRate / 100);
MyBuyCommission = Math.Ceiling(model.Commission * (FXModel.CommissionRatio ?? 0) / 100);
}
else
{
model.MaxShare = Math.Ceiling(model.Commission * CRate) / 100;
MyBuyCommission = Math.Ceiling(model.Commission * (FXModel.CommissionRatio ?? 0)) / 100;
}
}
}
}
}
}
else
{
//是否展示分享vip佣金
var fxcommissionList = distributor_FXCommissionRepository.GetFXCommissionList(new RB_Distributor_FXCommission_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, FXGradeId = disModel.FXGradeId ?? 0 });
if (fxcommissionList.Any())
{
model.MaxShare = fxcommissionList.Max(x => x.CommissionPrice ?? 0);
}
}
}
else
{
//判断是否开启和平返佣
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper(nameof(RB_Distributor_HPCommission.Status),0),
new WhereHelper(nameof(RB_Distributor_HPCommission.Enabled),1),
new WhereHelper(nameof(RB_Distributor_HPCommission.TenantId),TenantId),
new WhereHelper(nameof(RB_Distributor_HPCommission.MallBaseId),MallBaseId)
};
if (distributor_HPCommissionRepository.Exists(wheres))
{
//获取和平分销返佣
if (disModel.HPGradeId > 0 && model.CostPrice > 0)
{
string categoryids = string.Join(",", model.CategoryList.Select(x => x.CategoryId));
var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { Enabled = 1, CategoryIdsT = categoryids, TenantId = TenantId, MallBaseId = MallBaseId });
if (hpcList.Any())
{
RB_Distributor_HPCommission_Extend hpcModel;
if (hpcList.Where(x => x.IsCommon != 1).Any())
{
//有使用非通用返佣
hpcModel = hpcList.Where(x => x.IsCommon != 1).FirstOrDefault();
}
else
{
//查询通用返佣
hpcModel = hpcList.Where(x => x.IsCommon == 1).FirstOrDefault();
}
//查询所有返佣比例
var gList = distributor_HPGradeRatioRepository.GetList(new RB_Distributor_HPGradeRatio_Extend() { CommissionId = hpcModel.Id, TenantId = TenantId, MallBaseId = MallBaseId });
var ratioModel = gList.Where(x => x.GradeId == disModel.HPGradeId).FirstOrDefault();
decimal MPrice = (model.CostPrice ?? 0) / (1 - ((ratioModel.CommissionRatio ?? 0) / 100));
model.MaxShare = MaxSellMoney - MPrice > 0 ? MaxSellMoney - MPrice : 0;
if (hpcModel.DecimalType == 1)
{
model.MaxShare = Math.Ceiling(model.MaxShare);
}
else if (hpcModel.DecimalType == 2)
{
model.MaxShare = Math.Ceiling(model.MaxShare * 100) / 100;
}
}
}
}
else
{
if (model.SeparateDistribution == 1)
{
var dcList = model.DistributionCommissionList.Where(x => x.DistributorGrade == disModel.GradeId).ToList();
model.MaxShare = dcList.Max(x => x.OneCommission ?? 0);
// 这里需注意,可能需要分销 是否提所有返佣控制
if (model.SeparateDistributionMoneyType == 1)
{
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
}
}
else
{
if (disModel.GradeId == 0)
{
model.MaxShare = BasicsModel?.OneCommission ?? 0;
if ((BasicsModel?.DistributorCommissionType ?? 2) == 1)
{
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
}
}
else if (disModel.GradeId > 0)
{
//获取分销商等级
var disgradeModel = distributor_GradeRepository.GetEntity(disModel.GradeId);
if (disgradeModel != null)
{
model.MaxShare = disgradeModel?.OneCommission ?? 0;
if ((disgradeModel?.DistributionCommissionType ?? 2) == 1)
{
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
}
}
}
}
}
}
}
}
#endregion
#region 最外层组装参数
List<RB_Member_Grade_Extend> memeberList = new List<RB_Member_Grade_Extend>();
if (UserId > 0)
{
if (userModel.MemberGrade > 0)
{
memeberList = GetMemberGradeList(new RB_Member_Grade_Extend() { Enabled = 1, TenantId = TenantId, MallBaseId = MallBaseId });
}
}
#region 组装价格
List<object> priceList = new List<object>();
if (model.IsCustomSpecification == 1)
{
if (model.SpecificationPriceList.Any() && model.SpecificationList.Any())
{
List<RB_Goods_Specification_Extend> SpecificationListToPrice = new List<RB_Goods_Specification_Extend>();
List<RB_Goods_SpecificationValue_Extend> SpecificationValueListToPrice = new List<RB_Goods_SpecificationValue_Extend>();
bool IsHaveSellingPriceZero = false;
if (model.SpecificationPriceList.Where(x => x.SellingPrice > 0).Count() != model.SpecificationPriceList.Count())
{
//有数量为0的
IsHaveSellingPriceZero = true;
}
foreach (var item in model.SpecificationPriceList.Where(x => x.SellingPrice > 0))
{
var ssarr = item.SpecificationSort.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = model.SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
List<object> attr_list = new List<object>();
for (int i = 0; i < ssarr.Length; i++)
{
var smodel = model.SpecificationList[i];
if (IsHaveSellingPriceZero && !SpecificationListToPrice.Where(x => x.Id == smodel.Id).Any())
{
SpecificationListToPrice.Add(smodel);
}
var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
if (IsHaveSellingPriceZero && !SpecificationValueListToPrice.Where(x => x.Id == svmodel.Id).Any())
{
SpecificationValueListToPrice.Add(svmodel);
}
attr_list.Add(new
{
attr_group_name = smodel.Name,
attr_group_id = smodel.Sort,
attr_id = svmodel.Id,
attr_name = svmodel.Name
});
}
decimal price_member = item.SellingPrice ?? 0;//未设会员价格的话 就为销售价格
List<object> member_price_list = new List<object>();
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1)
{
if (model.MemberPriceList.Any())
{
var mlist = model.MemberPriceList.Where(x => x.SpecificationSort == item.SpecificationSort).ToList();
foreach (var qitem in mlist)
{
member_price_list.Add(new
{
member_grade = qitem.MemberGrade,
member_price = qitem.MemberPrice
});
}
if (UserId > 0 && userModel.MemberGrade > 0)
{
var gmodel = mlist.Where(x => x.MemberGrade == userModel.MemberGrade).FirstOrDefault();
price_member = gmodel.MemberPrice ?? 0;
}
else
{
price_member = mlist.Max(x => x.MemberPrice ?? 0);
}
}
}
else
{
//根据会员等级查找会员价格
foreach (var qitem in memeberList)
{
var mprice = Math.Round((item.SellingPrice ?? 0) * (qitem.Discount ?? 0) / 10, 2, MidpointRounding.AwayFromZero);
member_price_list.Add(new
{
member_grade = qitem.Grade,
member_price = mprice
});
}
if (UserId > 0 && userModel.MemberGrade > 0 && memeberList.Any())
{
var gmodel = memeberList.Where(x => x.Grade == userModel.MemberGrade).FirstOrDefault();
price_member = Math.Round((model.SellingPrice ?? 0) * (gmodel?.Discount ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
}
else if (memeberList.Any())
{
price_member = Math.Round((model.SellingPrice ?? 0) * (memeberList.Max(x => x.Discount) ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
}
}
priceList.Add(new
{
id = item.Id,
goods_id = model.Id,
sign_id = item.SpecificationSort,
stock = item.InventoryNum,
price = item.SellingPrice,
no = item.GoodsNumbers,
weight = item.GoodsWeight,
pic_url,
is_delete = item.Status,
attr_list,
price_member,
member_price_list
});
}
//当只有一组规格项目时
if (IsHaveSellingPriceZero && SpecificationListToPrice.Any() && model.SpecificationList.Count() == 1)
{
foreach (var item in SpecificationListToPrice)
{
item.SpecificationValueList = SpecificationValueListToPrice.Where(x => x.SpecificationId == item.Id).OrderBy(x => x.Sort).ToList();
}
SpecificationListToPrice = SpecificationListToPrice.Where(x => x.SpecificationValueList.Any()).ToList();
//有价格小于等于0的 在前端展示时 需屏蔽掉
model.SpecificationList = SpecificationListToPrice;
}
}
}
else
{
decimal price_member = model.SellingPrice ?? 0;//未设会员价格的话 就为销售价格
List<object> member_price_list = new List<object>();
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1)
{
if (model.MemberPriceList.Any())
{
var mlist = model.MemberPriceList;
foreach (var qitem in mlist)
{
member_price_list.Add(new
{
member_grade = qitem.MemberGrade,
member_price = qitem.MemberPrice
});
}
if (UserId > 0 && userModel.MemberGrade > 0)
{
var gmodel = mlist.Where(x => x.MemberGrade == userModel.MemberGrade).FirstOrDefault();
price_member = gmodel.MemberPrice ?? 0;
}
else
{
price_member = mlist.Max(x => x.MemberPrice ?? 0);
}
}
}
else
{
//根据会员等级查找会员价格
foreach (var qitem in memeberList)
{
var mprice = Math.Round((model.SellingPrice ?? 0) * (qitem.Discount ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
member_price_list.Add(new
{
member_grade = qitem.Grade,
member_price = mprice
});
}
if (UserId > 0 && userModel.MemberGrade > 0 && memeberList.Any())
{
var gmodel = memeberList.Where(x => x.Grade == userModel.MemberGrade).FirstOrDefault();
price_member = Math.Round((model.SellingPrice ?? 0) * (gmodel?.Discount ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
}
else if (memeberList.Any())
{
price_member = Math.Round((model.SellingPrice ?? 0) * (memeberList.Max(x => x.Discount) ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
}
}
priceList.Add(new
{
id = 0,
goods_id = model.Id,
sign_id = "",
stock = model.InventoryNum,
price = model.SellingPrice ?? 0,
no = model.GoodsNumbers,
weight = model.GoodsWeight,
pic_url = "",
is_delete = 0,
attr_list = new List<object>(){ new
{
attr_group_name = "规格",
attr_group_id = 0,
attr_id = 0,
attr_name = model.DefaultSpecificationName
} },
price_member,
isChooseServicePerson= model.IsChooseServicePerson,
depositMoney= model.DepositMoney,
member_price_list
});
}
#endregion
#region 赠送积分
int Integral = 0;
if (model.IntegralPresent > 0)
{
Integral = model.IntegralPresent ?? 0;
if (model.IntegralPresentType == 1)
{
Integral = Convert.ToInt32(Math.Floor((model.SellingPrice ?? 0) * (model.IntegralPresent ?? 0) / 100));
}
}
int CommentIntegral = 0;
if (model.IntegralComment > 0)
{
CommentIntegral = model.IntegralComment ?? 0;
if (model.IntegralCommentType == 1)
{
CommentIntegral = Convert.ToInt32(Math.Floor((model.SellingPrice ?? 0) * (model.IntegralComment ?? 0) / 100));
}
}
#endregion
#region 赠送vip会员
string PresentFXGradeMsg = "";
if ((BasicsModel?.IsEnableFXGrade ?? 2) == 1)
{
if (model.PresentFXGrade > 0)
{
var fxmodel = distributor_FXGradeRepository.GetEntity(model.PresentFXGrade);
if (fxmodel != null)
{
PresentFXGradeMsg = "购买后赠送" + fxmodel.GradeName + " ";
if (model.PresentFXMonth > 0)
{
PresentFXGradeMsg += (model.PresentFXMonth ?? 0) + "个月";
}
}
}
}
#endregion
#region 会员价格
decimal price_member_max = 0, price_member_min = 0, price_min = 0, price_max = 0;
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1 && model.MemberPriceList.Any())
{
price_member_min = model.MemberPriceList.Min(x => x.MemberPrice ?? 0);
price_member_max = model.MemberPriceList.Max(x => x.MemberPrice ?? 0);
if (userModel.MemberGrade > 0)
{
price_min = model.MemberPriceList.Where(x => x.MemberGrade == userModel.MemberGrade).Min(x => x.MemberPrice ?? 0);
price_max = model.MemberPriceList.Where(x => x.MemberGrade == userModel.MemberGrade).Max(x => x.MemberPrice ?? 0);
}
}
else
{
if (model.IsCustomSpecification == 1)
{
price_member_min = price_min = model.SpecificationPriceList.Where(x => x.SellingPrice > 0).Min(x => x.SellingPrice ?? 0);
price_member_max = price_max = model.SpecificationPriceList.Where(x => x.SellingPrice > 0).Max(x => x.SellingPrice ?? 0);
}
else
{
price_member_min = price_member_max = price_min = price_max = model.SellingPrice ?? 0;
}
if (memeberList.Any())
{
List<decimal> pricelist = new List<decimal>();
foreach (var item in memeberList)
{
pricelist.Add(price_member_min * (item.Discount ?? 10) / 10);
pricelist.Add(price_member_max * (item.Discount ?? 10) / 10);
}
price_member_min = pricelist.Min(x => x);
price_member_max = pricelist.Max(x => x);
if (userModel.MemberGrade > 0)
{
if (price_min > (model.SellingPrice ?? 0)) { price_min = model.SellingPrice ?? 0; }
if (price_max < (model.SellingPrice ?? 0)) { price_max = model.SellingPrice ?? 0; }
price_min = price_member_min * (memeberList.Where(x => x.Id == userModel.MemberGrade).FirstOrDefault()?.Discount ?? 10) / 10;
price_max = price_member_max * (memeberList.Where(x => x.Id == userModel.MemberGrade).FirstOrDefault()?.Discount ?? 10) / 10;
}
}
}
price_member_max = Math.Round(price_member_max, 2, MidpointRounding.AwayFromZero);
price_member_min = Math.Round(price_member_min, 2, MidpointRounding.AwayFromZero);
price_min = price_member_min;
price_max = price_member_max;
#endregion
#region 订单信息
int payment_people = 0, payment_num = 0, payment_order = 0;//订单用户 商品数量 订单数量
decimal payment_amount = 0;//订单总金额
GetGoodsOrderPeopleInfo(out payment_amount, out payment_num, out payment_order, out payment_people, goodsId);
#endregion
#region 返回参数
string shipping = "";
if (model.FullNumPinkage > 0)
{
shipping += "单品满" + model.FullNumPinkage + "件包邮";
}
if (model.FullMoneyPinkage > 0)
{
if (model.FullNumPinkage > 0)
{
shipping += ",单品满¥" + model.FullMoneyPinkage.Value.ToString("#0.00") + "包邮";
}
else
{
shipping += "单品满¥" + model.FullMoneyPinkage.Value.ToString("#0.00") + "包邮";
}
}
string limit = "";
if (model.AreaList.Any())
{
limit = "仅限" + string.Join(",", model.AreaList.Select(x => x.AreaName)) + "购买";
}
int IsAllowShare = 1;
if (model.CategoryList.Where(x => x.IsForeignShare == 2).Any())
{
IsAllowShare = 2;
}
if ((model.IsCustomSpecification ?? 2) != 1)
{
var VauleL = new List<RB_Goods_SpecificationValue_Extend>
{
new RB_Goods_SpecificationValue_Extend()
{
Sort = 0,
Name = model.DefaultSpecificationName,
ImagePath = ""
}
};
model.SpecificationList = new List<RB_Goods_Specification_Extend>
{
new RB_Goods_Specification_Extend()
{
Sort = 0,
Name = "规格",
SpecificationValueList = VauleL
}
};
}
var servicePersionList= reserve_ServicePersonalRepository.GetServicePersonalList(new Model.Extend.Reserve.RB_Reserve_ServicePersonal_Extend()
{
StoreId = storeId,
})?.ToList()??new List<Model.Extend.Reserve.RB_Reserve_ServicePersonal_Extend>();
return new
{
goods = new
{
id = model.Id,
mall_id = model.MallBaseId,
mch_id = model.TenantId,//暂 商户id
status = model.GoodsStatus,
isAllowShare = IsAllowShare,//是否可以分享
advertising = model.Advertising,//广告词
price = model.SellingPrice,
sendArea = model.SendArea,
use_attr = model.IsCustomSpecification,
attr_groups = model.SpecificationList.Select(x => new
{
attr_group_id = x.Sort,
attr_group_name = x.Name,
attr_list = x.SpecificationValueList.Select(z => new
{
attr_id = z.Sort,
attr_name = z.Name,
pic_url = z.ImagePath
})
}),
goods_stock = model.InventoryNum,
virtual_sales = (model.SalesNum ?? 0),
confine_count = model.LimitBuyGoodsNum,
pieces = model.FullNumPinkage,//满件包邮
forehead = model.FullMoneyPinkage,//满额包邮
freight_id = model.FreightId,
give_integral = model.IntegralPresent,
give_integral_type = model.IntegralPresentType,
forehead_integral = model.PointsDeduction,//暂 积分抵扣
forehead_integral_type = model.PointsDeductionType,//暂 积分抵扣类型
accumulative = model.IsMultipleDeduction,//多件抵扣
individual_share = userModel?.IsDistributor ?? 2,// 是否分销商
attr_setting_type = model.SeparateDistributionType,//分销类型
is_level = model.EnjoyMember,//是否销售会员价格
is_level_alone = model.SeparateSetMember,//是否单独设置会员价
share_type = model.SeparateDistributionMoneyType,//分销佣金类型
app_share_pic = model.CustomShareImagePath,
app_share_title = model.CustomShareTitles,
is_default_services = model.IsDefaultService,
sort = model.Sort,
created_at = model.CreateDate.HasValue ? model.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
updated_at = model.UpdateDate.HasValue ? model.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
is_delete = model.Status,
payment_people,//用户数量
payment_num,//商品数量
payment_amount,//销售总额
payment_order,//订单数量
confine_order_count = model.LimitBuyOrderNum,
is_area_limit = model.IsAreaBuy,
form_id = model.FormsId,
sales = (model.SalesNum ?? 0) + payment_num,//已售出数量 + 订单商品数量//
name = model.Name,
original_price = model.OriginalPrice,
cover_pic = model.CoverImage,
unit = model.Unit,
detail = model.GoodsDetails,
video_url = model.VideoAddress,
level_show = (userModel?.MemberGrade ?? 0) > 0 ? 1 : 2,//是否显示会员价
is_sales = model.GoodsStatus == 1 && model.InventoryNum > 0 ? 1 : 2,//是否可购买
attr = priceList,
goods_no = model.GoodsNumbers,
goods_weight = model.GoodsWeight,
services = model.ServiceList.Select(x => new
{
id = x.Id,
name = x.Name
}),
price_min,
price_max,
pic_url = model.CarouselImageList.Select(x => new
{
id = x.Id,
pic_url = x.Path,
type = x.Type
}),
share = model.MaxShare,//分销佣金
myBuyCommission = MyBuyCommission,//粉象模式 自购返利
favorite = model.Favorite,//是否收藏
goods_marketing = new
{
limit,
pickup = "",
shipping
},
goods_marketing_award = new
{
integral = new
{
title = Integral > 0 ? "购买可得" + Integral + "积分" : ""
},
commentIntegral = new
{
title = CommentIntegral > 0 ? "购买并评论可得" + Integral + "积分" : ""
},
PresentFXGradeMsg
},
express = model.Express,//快递费用 读取默认收货地址 如果没有为0 如果有 根据商品运费匹配 找出快递费用
price_member_max,
price_member_min,
extra_quick_share = new
{
share_pic = model.CarouselImageList.Select(x => new
{
id = x.Id,
pic_url = x.Path
}),
share_text = model.Name,
mall_name = model.MallName,
format_time = model.UpdateDate.HasValue ? model.UpdateDate.Value.ToString("yyyy-MM-dd") : ""
},
is_quick_shop = model.IsQuickBuy,
is_sell_well = model.IsSellWell,
is_negotiable = model.IsGoodsNegotiable,
marketingLogo = model.MarketingLogo,
//分类
cats = model.CategoryList.Select(x => new
{
x.CategoryId,
x.CategoryName
}),
video_type = model.VideoType,
isChooseServicePerson=model.IsChooseServicePerson,
depositMoney=model.DepositMoney,
persionList = servicePersionList?.Where(qitem => qitem.ServiceStatus == 1).Select(qitem => new
{
qitem.ServiceLogo,
qitem.Score,
qitem.Name,
qitem.Major,
Gender = qitem.Gender.ToInt()
})
},
delivery = ""
};
#endregion
#endregion
}
/// <summary>
/// 获取小程序商品视频分页列表
/// </summary>
......
......@@ -571,7 +571,7 @@ where {where} group by g.Id order by {orderBy}";
}
if (!string.IsNullOrEmpty(dmodel.StoresIds))
{
where += $@" and locate('{dmodel.StoresIds}',g.{nameof(RB_Goods_Extend.StoresIds)})";
where += $@" and locate(',{dmodel.StoresIds},', CONCAT(',',g.{nameof(RB_Goods_Extend.StoresIds)},',') )";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
......@@ -798,6 +798,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <param name="GoodsClassify">商品类型</param>
/// <returns></returns>
public List<RB_Goods_Extend> GetAppletGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend dmodel, int GoodsClassify = 0)
{
......@@ -872,6 +873,11 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
where += $@" and g.{nameof(RB_Goods_Extend.GoodsPageType)} in(0,2)";
}
}
//HK 新加参数
if (!string.IsNullOrEmpty(dmodel.StoresIds))
{
where += $@" AND locate(',{dmodel.StoresIds},',CONCAT(',',g.{nameof(RB_Goods_Extend.StoresIds)}, ','))";
}
//默认综合【升序】
string orderBy = $" order by g.{nameof(RB_Goods_Extend.Sort)} asc";
//上架时间【降序】
......
......@@ -137,12 +137,14 @@ LEFT JOIN (SELECT ServicePersonalId,COUNT(*) as CommentNum from rb_goods_commen
{
builder.Append($" AND {nameof(RB_Reserve_ServicePersonal_Extend.Name)} like '%{query.Name}%'");
}
if (query.ServiceStatus > 0)
{
builder.Append($" AND {nameof(RB_Reserve_ServicePersonal_Extend.ServiceStatus)}={query.ServiceStatus}");
}
if (query.StoreId > 0)
{
builder.Append($" AND {nameof(RB_Reserve_ServicePersonal_Extend.StoreId)}={query.StoreId}");
}
}
return Get<RB_Reserve_ServicePersonal_Extend>(builder.ToString()).ToList();
}
......
......@@ -184,6 +184,13 @@ namespace Mall.WebApi.Controllers.MallBase
{
demodel.SmallShopsId = newParms.GetInt("ERPSmallShopId");
}
int GoodsClassify = 0;
//HK 2020-10-30新增
if (newParms.GetInt("StoreId") > 0)
{
demodel.StoresIds = newParms.GetInt("StoreId").ToString();
GoodsClassify = 3;
}
demodel.UserId = UserId;
//HK2020-09-07新增
int IsGetShare = newParms.GetInt("IsGetShare");
......@@ -200,7 +207,7 @@ namespace Mall.WebApi.Controllers.MallBase
demodel.SmallShopsId = userModel.SmallShopId;
}
}
var list = productModule.GetAppletGoodsPageListForZY(pagelist.pageIndex, pagelist.pageSize, out long count, demodel,IsGetShare:IsGetShare);
var list = productModule.GetAppletGoodsPageListForZY(pagelist.pageIndex, pagelist.pageSize, out long count, demodel,IsGetShare:IsGetShare,GoodsClassify: GoodsClassify);
List<object> RList = new List<object>();
if (list.Any())
{
......@@ -362,7 +369,9 @@ namespace Mall.WebApi.Controllers.MallBase
goods_num = model.InventoryNum,
marketingLogo= model.MarketingLogo,
video_type=model.VideoType,
erpgoodobj=model.ERPGoodObj
erpgoodobj=model.ERPGoodObj,
isChooseServicePerson= model.IsChooseServicePerson,
depositMoney= model.DepositMoney,
});
}
}
......@@ -396,6 +405,32 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Success("", Robj);
}
/// <summary>
/// 预定页面详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletOfflineGoodsInfo(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
return ApiResult.ParamIsNull();
}
JObject prams = JObject.Parse(req.msg.ToString());
int GoodsId = prams.GetInt("GoodsId", 0);
int StoreId = prams.GetInt("StoreId", 0);
if (GoodsId <= 0|| StoreId<=0)
{
return ApiResult.ParamIsNull();
}
int UserId = req.UserId;
var Robj = productModule.GetAppletOfflineGoodsInfoModule(GoodsId, UserId, req.SmallShopsId, req.TenantId, req.MallBaseId, storeId: StoreId);
return ApiResult.Success("", Robj);
}
/// <summary>
/// 获取小程序商品详情备份
/// </summary>
......
......@@ -115,24 +115,14 @@ namespace Mall.WebApi.Controllers.Product
return ApiResult.Failed("请选择还车时间");
}
//if (demodel.RegionId == 0)
//{
// return ApiResult.Failed("请选择区信息");
//}
//else
//{
//}
DateTime tempStartTime = Convert.ToDateTime(demodel.StartTime);
DateTime tempEndTime = Convert.ToDateTime(demodel.EndTime);
if (demodel.CarType.HasValue && (demodel.CarType == Common.Enum.Goods.GuideCarGoodsTypeEnum.JJ || demodel.CarType == Common.Enum.Goods.GuideCarGoodsTypeEnum.SJ))
{
demodel.UseDay = 1;
}
else {
else
{
if (tempStartTime.ToString("yyyy-MM-dd") == tempEndTime.ToString("yyyy-MM-dd"))//判断使用天数是否是0.5天/1天
{
TimeSpan sp = tempEndTime.Subtract(tempStartTime);
......
......@@ -704,10 +704,6 @@ namespace Mall.WebApi.Controllers.MallBase
var req = RequestParm;
var userInfo = AppletUserInfo;
RB_Goods_Order_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Order_Extend>(req.msg.ToString());
if (string.IsNullOrEmpty(demodel.Consignee))
{
return ApiResult.ParamIsNull("请传递联系人");
}
if (string.IsNullOrEmpty(demodel.Mobile))
{
return ApiResult.ParamIsNull("请传递联系人手机号码");
......
......@@ -135,8 +135,21 @@ namespace Mall.WebApi.Controllers.Reserve
var storeModel = contentModule.GetStoresListModule(new RB_Stores_Extend()
{
Id = storeId,
MallBaseId = parms.MallBaseId
MallBaseId = parms.MallBaseId,
CurrentPosition=position
}, isFirst: true)?.FirstOrDefault();
string serviceTime = "";
if (storeModel != null)
{
if (storeModel.IsAllDay == 1)
{
serviceTime = "全天";
}
else
{
serviceTime = storeModel.StartTime + "-" + storeModel.EndTime;
}
}
object result = new
{
storeInfo = new
......@@ -148,7 +161,15 @@ namespace Mall.WebApi.Controllers.Reserve
distance = storeModel?.KM,
storeScore = storeModel?.Score,
storeCoverImg = storeModel?.CoverImg,
storeNavImg = storeModel?.NavImg
storeNavImg = storeModel?.NavImg,
storeIntro= storeModel?.Intro,
storeProject= storeModel?.ServiceProject,
storeServiceTime= serviceTime,
consumptionObj = new
{
consumptionStoreId = 0,
consumptionStoreName = "HK门店"
}
},
};
return ApiResult.Success(data: result);
......
......@@ -532,7 +532,7 @@ namespace Mall.WebApi.Controllers.Reserve
}
foreach (var item in MGradeList)
{
var defaultModel = demodel.MemberPriceList.Where(x => x.MemberGrade == item.Id).FirstOrDefault();
var defaultModel = demodel.MemberPriceList.Where(x => x.MemberGrade == item.Grade).FirstOrDefault();
if (defaultModel == null)
{
return ApiResult.ParamIsNull("会员价格" + item.Name + "不存在");
......
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