Commit 983ee5f4 authored by 黄奎's avatar 黄奎

新增商品分类

parent 164c3848
...@@ -181,7 +181,8 @@ namespace Mall.Module.Product ...@@ -181,7 +181,8 @@ namespace Mall.Module.Product
{ {
var rmodel = product_RecommendRepository.GetList(new RB_Product_Recommend_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); var rmodel = product_RecommendRepository.GetList(new RB_Product_Recommend_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
RecommendStatus = 2; RecommendStatus = 2;
if (rmodel == null) { if (rmodel == null)
{
return new List<RB_Goods_Extend>(); return new List<RB_Goods_Extend>();
} }
pageSize = rmodel.DetailRecommendNum ?? 0; pageSize = rmodel.DetailRecommendNum ?? 0;
...@@ -209,7 +210,8 @@ namespace Mall.Module.Product ...@@ -209,7 +210,8 @@ namespace Mall.Module.Product
} }
} }
} }
else if (demodel.RecommendType == 3) { else if (demodel.RecommendType == 3)
{
RecommendStatus = rmodel.CommentRecommentStatus ?? 2; RecommendStatus = rmodel.CommentRecommentStatus ?? 2;
if (rmodel.CommentRecommentStatus != 1) if (rmodel.CommentRecommentStatus != 1)
{ {
...@@ -229,12 +231,15 @@ namespace Mall.Module.Product ...@@ -229,12 +231,15 @@ namespace Mall.Module.Product
List<RB_Goods_Extend> RList = list; List<RB_Goods_Extend> RList = list;
if (list.Any()) if (list.Any())
{ {
if (demodel.RecommendType == 2 && rmodel.IsOrderRecommend == 1 && !string.IsNullOrEmpty(rmodel.OrderProductIds)) { if (demodel.RecommendType == 2 && rmodel.IsOrderRecommend == 1 && !string.IsNullOrEmpty(rmodel.OrderProductIds))
{
List<int> gidList = JsonConvert.DeserializeObject<List<int>>(rmodel.OrderProductIds); List<int> gidList = JsonConvert.DeserializeObject<List<int>>(rmodel.OrderProductIds);
var gList = gidList.Where(x => list.Select(y => y.Id).Contains(x)).Take(10).ToList(); var gList = gidList.Where(x => list.Select(y => y.Id).Contains(x)).Take(10).ToList();
if (gList.Any()) { if (gList.Any())
{
RList = new List<RB_Goods_Extend>(); RList = new List<RB_Goods_Extend>();
foreach (var item in gList) { foreach (var item in gList)
{
RList.Add(list.Where(x => x.Id == item).FirstOrDefault()); RList.Add(list.Where(x => x.Id == item).FirstOrDefault());
} }
} }
...@@ -373,7 +378,8 @@ namespace Mall.Module.Product ...@@ -373,7 +378,8 @@ namespace Mall.Module.Product
} }
} }
} }
else if (model.IsDefaultService == 1) { else if (model.IsDefaultService == 1)
{
var slist = product_ServiceRepository.GetList(new RB_Product_Service_Extend() { IsDefault = 1, TenantId = TenantId, MallBaseId = MallBaseId }); var slist = product_ServiceRepository.GetList(new RB_Product_Service_Extend() { IsDefault = 1, TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in slist) foreach (var item in slist)
{ {
...@@ -383,7 +389,7 @@ namespace Mall.Module.Product ...@@ -383,7 +389,7 @@ namespace Mall.Module.Product
Name = item.Name Name = item.Name
}); });
} }
} }
//表单 //表单
if (model.FormsId > 0) if (model.FormsId > 0)
{ {
...@@ -471,7 +477,8 @@ namespace Mall.Module.Product ...@@ -471,7 +477,8 @@ namespace Mall.Module.Product
{ {
model.Express = pmodel.FirstPrice; model.Express = pmodel.FirstPrice;
} }
else { else
{
//重量计费 //重量计费
int TotalW = model.GoodsWeight ?? 0; int TotalW = model.GoodsWeight ?? 0;
if (TotalW <= pmodel.First) if (TotalW <= pmodel.First)
...@@ -495,7 +502,7 @@ namespace Mall.Module.Product ...@@ -495,7 +502,7 @@ namespace Mall.Module.Product
{ {
model.Express = pmodel.FirstPrice; model.Express = pmodel.FirstPrice;
} }
} }
} }
} }
} }
...@@ -510,22 +517,28 @@ namespace Mall.Module.Product ...@@ -510,22 +517,28 @@ namespace Mall.Module.Product
{ {
//获取分销商信息 //获取分销商信息
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, UserId = UserId, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault(); 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 (disModel != null)
{
var BasicsModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = TenantId, MallBaseId = MallBaseId }).FirstOrDefault(); var BasicsModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = TenantId, MallBaseId = MallBaseId }).FirstOrDefault();
if (model.SeparateDistribution == 1) { if (model.SeparateDistribution == 1)
{
var dcList = model.DistributionCommissionList.Where(x => x.DistributorGrade == disModel.GradeId).ToList(); var dcList = model.DistributionCommissionList.Where(x => x.DistributorGrade == disModel.GradeId).ToList();
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1) { if ((BasicsModel?.IsCommissionResidue ?? 2) == 1)
{
model.MaxShare = dcList.Max(x => (x.OneCommission ?? 0) + (x.TwoCommission ?? 0) + (x.ThreeCommission ?? 0)); model.MaxShare = dcList.Max(x => (x.OneCommission ?? 0) + (x.TwoCommission ?? 0) + (x.ThreeCommission ?? 0));
} }
else { else
{
model.MaxShare = dcList.Max(x => x.OneCommission ?? 0); model.MaxShare = dcList.Max(x => x.OneCommission ?? 0);
} }
// 这里需注意,可能需要分销 是否提所有返佣控制 // 这里需注意,可能需要分销 是否提所有返佣控制
if (model.SeparateDistributionMoneyType == 1) { if (model.SeparateDistributionMoneyType == 1)
{
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero); model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
} }
} }
else { else
{
if (disModel.GradeId == 0) if (disModel.GradeId == 0)
{ {
//拿分销基础配置 //拿分销基础配置
...@@ -542,10 +555,12 @@ namespace Mall.Module.Product ...@@ -542,10 +555,12 @@ namespace Mall.Module.Product
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero); model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
} }
} }
else if (disModel.GradeId > 0) { else if (disModel.GradeId > 0)
{
//获取分销商等级 //获取分销商等级
var disgradeModel = distributor_GradeRepository.GetEntity(disModel.GradeId); var disgradeModel = distributor_GradeRepository.GetEntity(disModel.GradeId);
if (disgradeModel != null) { if (disgradeModel != null)
{
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1) if ((BasicsModel?.IsCommissionResidue ?? 2) == 1)
{ {
model.MaxShare = (disgradeModel?.OneCommission ?? 0) + (disgradeModel?.TwoCommission ?? 0) + (disgradeModel?.ThreeCommission ?? 0); model.MaxShare = (disgradeModel?.OneCommission ?? 0) + (disgradeModel?.TwoCommission ?? 0) + (disgradeModel?.ThreeCommission ?? 0);
...@@ -581,7 +596,8 @@ namespace Mall.Module.Product ...@@ -581,7 +596,8 @@ namespace Mall.Module.Product
if (list.Any()) if (list.Any())
{ {
List<int> MaterialIds = new List<int>(); List<int> MaterialIds = new List<int>();
foreach (var item in list) { foreach (var item in list)
{
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]") if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{ {
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage); List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage);
...@@ -594,7 +610,8 @@ namespace Mall.Module.Product ...@@ -594,7 +610,8 @@ namespace Mall.Module.Product
var categoryList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var categoryList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var speciList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var speciList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var speciVList = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var speciVList = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (speciVList.Any()) { if (speciVList.Any())
{
MaterialIds.AddRange(speciVList.Where(x => x.Image > 0).Select(x => x.Image ?? 0)); MaterialIds.AddRange(speciVList.Where(x => x.Image > 0).Select(x => x.Image ?? 0));
} }
if (MaterialIds.Any()) if (MaterialIds.Any())
...@@ -651,7 +668,7 @@ namespace Mall.Module.Product ...@@ -651,7 +668,7 @@ namespace Mall.Module.Product
item.SpecificationPriceList = speciPList.Where(x => x.GoodsId == item.Id).ToList(); item.SpecificationPriceList = speciPList.Where(x => x.GoodsId == item.Id).ToList();
MaxSellMoney = item.SpecificationPriceList.Max(x => x.SellingPrice ?? 0); MaxSellMoney = item.SpecificationPriceList.Max(x => x.SellingPrice ?? 0);
} }
if (item.CustomShareImage > 0) if (item.CustomShareImage > 0)
{ {
item.CustomShareImagePath = material_InfoRepository.GetEntity(item.CustomShareImage)?.Path ?? ""; item.CustomShareImagePath = material_InfoRepository.GetEntity(item.CustomShareImage)?.Path ?? "";
...@@ -685,8 +702,9 @@ namespace Mall.Module.Product ...@@ -685,8 +702,9 @@ namespace Mall.Module.Product
/// </summary> /// </summary>
/// <param name="dmodel"></param> /// <param name="dmodel"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Material_Group_Extend> GetMaterialGroupList(RB_Material_Group_Extend dmodel) { public List<RB_Material_Group_Extend> GetMaterialGroupList(RB_Material_Group_Extend dmodel)
var list= material_GroupRepository.GetList(dmodel); {
var list = material_GroupRepository.GetList(dmodel);
return list; return list;
} }
...@@ -728,7 +746,8 @@ namespace Mall.Module.Product ...@@ -728,7 +746,8 @@ namespace Mall.Module.Product
}; };
return material_GroupRepository.Update(keyValues, wheres); return material_GroupRepository.Update(keyValues, wheres);
} }
else { else
{
return material_GroupRepository.Insert(demodel) > 0; return material_GroupRepository.Insert(demodel) > 0;
} }
} }
...@@ -755,7 +774,8 @@ namespace Mall.Module.Product ...@@ -755,7 +774,8 @@ namespace Mall.Module.Product
}; };
return material_InfoRepository.Update(keyValues, wheres); return material_InfoRepository.Update(keyValues, wheres);
} }
else { else
{
return material_InfoRepository.Insert(demodel) > 0; return material_InfoRepository.Insert(demodel) > 0;
} }
} }
...@@ -770,7 +790,8 @@ namespace Mall.Module.Product ...@@ -770,7 +790,8 @@ namespace Mall.Module.Product
public bool SetMaterialGroupRecycled(int groupId, string uid, int mallBaseId) public bool SetMaterialGroupRecycled(int groupId, string uid, int mallBaseId)
{ {
var gmodel = material_GroupRepository.GetEntity(groupId); var gmodel = material_GroupRepository.GetEntity(groupId);
if (gmodel == null) { if (gmodel == null)
{
return false; return false;
} }
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
...@@ -795,7 +816,8 @@ namespace Mall.Module.Product ...@@ -795,7 +816,8 @@ namespace Mall.Module.Product
}, },
}; };
bool flag = material_GroupRepository.Update(keyValues, wheres); bool flag = material_GroupRepository.Update(keyValues, wheres);
if (flag) { if (flag)
{
//分组下所有素材全回收 //分组下所有素材全回收
material_InfoRepository.SetMaterialInfoRecycled(groupId, Convert.ToInt32(uid), mallBaseId); material_InfoRepository.SetMaterialInfoRecycled(groupId, Convert.ToInt32(uid), mallBaseId);
} }
...@@ -816,7 +838,8 @@ namespace Mall.Module.Product ...@@ -816,7 +838,8 @@ namespace Mall.Module.Product
{ {
return false; return false;
} }
if (gmodel.Recycled != 2) { if (gmodel.Recycled != 2)
{
return false; return false;
} }
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
...@@ -841,7 +864,8 @@ namespace Mall.Module.Product ...@@ -841,7 +864,8 @@ namespace Mall.Module.Product
}, },
}; };
bool flag = material_GroupRepository.Update(keyValues, wheres); bool flag = material_GroupRepository.Update(keyValues, wheres);
if (flag) { if (flag)
{
//删除分组下所有的素材 //删除分组下所有的素材
material_InfoRepository.DelMaterialInfo("", uid, mallBaseId, groupId); material_InfoRepository.DelMaterialInfo("", uid, mallBaseId, groupId);
} }
...@@ -935,7 +959,8 @@ namespace Mall.Module.Product ...@@ -935,7 +959,8 @@ namespace Mall.Module.Product
var glist = material_GroupRepository.GetList(new RB_Material_Group_Extend() { GroupIds = string.Join(",", list.Select(x => x.GroupId).Distinct()), TenantId = Convert.ToInt32(uid), MallBaseId = mallBaseId }); var glist = material_GroupRepository.GetList(new RB_Material_Group_Extend() { GroupIds = string.Join(",", list.Select(x => x.GroupId).Distinct()), TenantId = Convert.ToInt32(uid), MallBaseId = mallBaseId });
if (glist.Where(x => x.Recycled == 2).Any()) if (glist.Where(x => x.Recycled == 2).Any())
{ {
foreach (var item in glist.Where(x => x.Recycled == 2)) { foreach (var item in glist.Where(x => x.Recycled == 2))
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Material_Group.Recycled),1}, { nameof(RB_Material_Group.Recycled),1},
{ nameof(RB_Material_Group.UpdateDate),DateTime.Now}, { nameof(RB_Material_Group.UpdateDate),DateTime.Now},
...@@ -960,7 +985,8 @@ namespace Mall.Module.Product ...@@ -960,7 +985,8 @@ namespace Mall.Module.Product
material_GroupRepository.Update(keyValues, wheres, trans); material_GroupRepository.Update(keyValues, wheres, trans);
} }
} }
foreach (var item in list) { foreach (var item in list)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Material_Info.Recycled),1}, { nameof(RB_Material_Info.Recycled),1},
{ nameof(RB_Material_Info.UpdateDate),DateTime.Now}, { nameof(RB_Material_Info.UpdateDate),DateTime.Now},
...@@ -1008,7 +1034,8 @@ namespace Mall.Module.Product ...@@ -1008,7 +1034,8 @@ namespace Mall.Module.Product
public bool SetMaterialInfoTransfer(string materialIds, int groupId, int Type, string uid, int mallBaseId) public bool SetMaterialInfoTransfer(string materialIds, int groupId, int Type, string uid, int mallBaseId)
{ {
var gmodel = material_GroupRepository.GetEntity(groupId); var gmodel = material_GroupRepository.GetEntity(groupId);
if (gmodel == null) { if (gmodel == null)
{
return false; return false;
} }
if (gmodel.Status == 1 || gmodel.Recycled == 2 || gmodel.Type != Type) if (gmodel.Status == 1 || gmodel.Recycled == 2 || gmodel.Type != Type)
...@@ -1033,17 +1060,20 @@ namespace Mall.Module.Product ...@@ -1033,17 +1060,20 @@ namespace Mall.Module.Product
public List<RB_Product_Category_Extend> GetProductCategoryPageList(int pageIndex, int pageSize, out long count, RB_Product_Category_Extend demodel) public List<RB_Product_Category_Extend> GetProductCategoryPageList(int pageIndex, int pageSize, out long count, RB_Product_Category_Extend demodel)
{ {
var list = product_CategoryRepository.GetPageList(pageIndex, pageSize, out count, demodel); var list = product_CategoryRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) { if (list.Any())
{
List<int> ImgIds = new List<int>(); List<int> ImgIds = new List<int>();
ImgIds.AddRange(list.Select(x => x.Icon ?? 0).Distinct()); ImgIds.AddRange(list.Select(x => x.Icon ?? 0).Distinct());
ImgIds.AddRange(list.Select(x => x.BigIcon ?? 0).Distinct()); ImgIds.AddRange(list.Select(x => x.BigIcon ?? 0).Distinct());
ImgIds.AddRange(list.Select(x => x.AdvertisingImage ?? 0).Distinct()); ImgIds.AddRange(list.Select(x => x.AdvertisingImage ?? 0).Distinct());
List<RB_Material_Info_Extend> mlist = new List<RB_Material_Info_Extend>(); List<RB_Material_Info_Extend> mlist = new List<RB_Material_Info_Extend>();
if (ImgIds.Any()) { if (ImgIds.Any())
{
mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = string.Join(",", ImgIds), TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = string.Join(",", ImgIds), TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
} }
foreach (var item in list) { foreach (var item in list)
{
item.IconPath = mlist.Where(x => x.Id == item.Icon).FirstOrDefault()?.Path ?? ""; item.IconPath = mlist.Where(x => x.Id == item.Icon).FirstOrDefault()?.Path ?? "";
item.BigIconPath = mlist.Where(x => x.Id == item.BigIcon).FirstOrDefault()?.Path ?? ""; item.BigIconPath = mlist.Where(x => x.Id == item.BigIcon).FirstOrDefault()?.Path ?? "";
item.AdvertisingImagePath = mlist.Where(x => x.Id == item.AdvertisingImage).FirstOrDefault()?.Path ?? ""; item.AdvertisingImagePath = mlist.Where(x => x.Id == item.AdvertisingImage).FirstOrDefault()?.Path ?? "";
...@@ -1065,7 +1095,8 @@ namespace Mall.Module.Product ...@@ -1065,7 +1095,8 @@ namespace Mall.Module.Product
try try
{ {
var list = GetProductCategoryForALLChlid(categoryId, tenantId, mallBaseId); var list = GetProductCategoryForALLChlid(categoryId, tenantId, mallBaseId);
foreach (var item in list) { foreach (var item in list)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Product_Category.Status),1}, { nameof(RB_Product_Category.Status),1},
{ nameof(RB_Product_Category.UpdateDate),DateTime.Now}, { nameof(RB_Product_Category.UpdateDate),DateTime.Now},
...@@ -1136,7 +1167,8 @@ namespace Mall.Module.Product ...@@ -1136,7 +1167,8 @@ namespace Mall.Module.Product
}; };
return product_CategoryStyleRepository.Update(keyValues, wheres); return product_CategoryStyleRepository.Update(keyValues, wheres);
} }
else { else
{
return product_CategoryStyleRepository.Insert(demodel) > 0; return product_CategoryStyleRepository.Insert(demodel) > 0;
} }
} }
...@@ -1212,7 +1244,7 @@ namespace Mall.Module.Product ...@@ -1212,7 +1244,7 @@ namespace Mall.Module.Product
item.AdvertisingImagePath = mlist.Where(x => x.Id == item.AdvertisingImage).FirstOrDefault()?.Path ?? ""; item.AdvertisingImagePath = mlist.Where(x => x.Id == item.AdvertisingImage).FirstOrDefault()?.Path ?? "";
} }
list = list.OrderBy(x => x.Sort).ThenBy(x => x.Id).ToList(); list = list.OrderBy(x => x.Sort).ThenBy(x => x.Id).ToList();
treeList = GetProductCategoryChildTree(list, 0); treeList = GetProductCategoryChildTree(list, 0);
} }
return treeList; return treeList;
...@@ -1224,10 +1256,12 @@ namespace Mall.Module.Product ...@@ -1224,10 +1256,12 @@ namespace Mall.Module.Product
/// <param name="list"></param> /// <param name="list"></param>
/// <param name="parentId"></param> /// <param name="parentId"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Product_CategoryTree> GetProductCategoryChildTree(List<RB_Product_Category_Extend> list, int parentId) { public List<RB_Product_CategoryTree> GetProductCategoryChildTree(List<RB_Product_Category_Extend> list, int parentId)
{
List<RB_Product_CategoryTree> RList = new List<RB_Product_CategoryTree>(); List<RB_Product_CategoryTree> RList = new List<RB_Product_CategoryTree>();
var CList = list.Where(x => x.ParentId == parentId).ToList(); var CList = list.Where(x => x.ParentId == parentId).ToList();
foreach (var item in CList) { foreach (var item in CList)
{
var cmodel = new RB_Product_CategoryTree var cmodel = new RB_Product_CategoryTree
{ {
Id = item.Id, Id = item.Id,
...@@ -1273,9 +1307,11 @@ namespace Mall.Module.Product ...@@ -1273,9 +1307,11 @@ namespace Mall.Module.Product
else else
{ {
int Id = product_CategoryRepository.Insert(demodel); int Id = product_CategoryRepository.Insert(demodel);
if (Id > 0) { if (Id > 0)
{
int RootId = Id; int RootId = Id;
if (demodel.ParentId > 0) { if (demodel.ParentId > 0)
{
var pmodel = product_CategoryRepository.GetEntity(demodel.ParentId); var pmodel = product_CategoryRepository.GetEntity(demodel.ParentId);
RootId = pmodel?.RootId ?? 0; RootId = pmodel?.RootId ?? 0;
} }
...@@ -1312,17 +1348,19 @@ namespace Mall.Module.Product ...@@ -1312,17 +1348,19 @@ namespace Mall.Module.Product
List<RB_Material_Info_Extend> mlist = new List<RB_Material_Info_Extend>(); List<RB_Material_Info_Extend> mlist = new List<RB_Material_Info_Extend>();
if (ImgIds.Any()) if (ImgIds.Any())
{ {
mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = string.Join(",", ImgIds)}); mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = string.Join(",", ImgIds) });
} }
model.IconPath = mlist.Where(x => x.Id == model.Icon).FirstOrDefault()?.Path ?? ""; model.IconPath = mlist.Where(x => x.Id == model.Icon).FirstOrDefault()?.Path ?? "";
model.BigIconPath = mlist.Where(x => x.Id == model.BigIcon).FirstOrDefault()?.Path ?? ""; model.BigIconPath = mlist.Where(x => x.Id == model.BigIcon).FirstOrDefault()?.Path ?? "";
model.AdvertisingImagePath = mlist.Where(x => x.Id == model.AdvertisingImage).FirstOrDefault()?.Path ?? ""; model.AdvertisingImagePath = mlist.Where(x => x.Id == model.AdvertisingImage).FirstOrDefault()?.Path ?? "";
var p1Model = product_CategoryRepository.GetEntity(model?.ParentId); var p1Model = product_CategoryRepository.GetEntity(model?.ParentId);
if (p1Model != null) { if (p1Model != null)
{
model.Parent1Name = p1Model.Name; model.Parent1Name = p1Model.Name;
var p2Model = product_CategoryRepository.GetEntity(p1Model?.ParentId); var p2Model = product_CategoryRepository.GetEntity(p1Model?.ParentId);
if (p2Model != null) { if (p2Model != null)
{
model.Parent1Name = p2Model.Name; model.Parent1Name = p2Model.Name;
model.Parent2Name = p1Model.Name;//黄媛媛要求 1表示1级 2表示2级 model.Parent2Name = p1Model.Name;//黄媛媛要求 1表示1级 2表示2级
} }
...@@ -1337,7 +1375,7 @@ namespace Mall.Module.Product ...@@ -1337,7 +1375,7 @@ namespace Mall.Module.Product
/// <param name="tid"></param> /// <param name="tid"></param>
/// <param name="mid"></param> /// <param name="mid"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Product_Category_Extend> GetProductCategoryForALLChlid(int categoryId,int tid,int mid) public List<RB_Product_Category_Extend> GetProductCategoryForALLChlid(int categoryId, int tid, int mid)
{ {
var model = product_CategoryRepository.GetEntity(categoryId); var model = product_CategoryRepository.GetEntity(categoryId);
var list = product_CategoryRepository.GetList(new RB_Product_Category_Extend() { RootId = model.RootId, TenantId = tid, MallBaseId = mid }); var list = product_CategoryRepository.GetList(new RB_Product_Category_Extend() { RootId = model.RootId, TenantId = tid, MallBaseId = mid });
...@@ -1346,6 +1384,16 @@ namespace Mall.Module.Product ...@@ -1346,6 +1384,16 @@ namespace Mall.Module.Product
return RList; return RList;
} }
/// <summary>
/// 获取分类列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Product_Category_Extend> GetCategoryListModule(RB_Product_Category_Extend dmodel)
{
return product_CategoryRepository.GetList(dmodel);
}
/// <summary> /// <summary>
/// 获取所有子集 /// 获取所有子集
/// </summary> /// </summary>
...@@ -1357,7 +1405,8 @@ namespace Mall.Module.Product ...@@ -1357,7 +1405,8 @@ namespace Mall.Module.Product
List<RB_Product_Category_Extend> RList = new List<RB_Product_Category_Extend>(); List<RB_Product_Category_Extend> RList = new List<RB_Product_Category_Extend>();
var list2 = list.Where(x => x.ParentId == id).ToList(); var list2 = list.Where(x => x.ParentId == id).ToList();
RList.AddRange(list2); RList.AddRange(list2);
foreach (var item in list2) { foreach (var item in list2)
{
RList.AddRange(GetProductCategoryALLChild(list, item.Id)); RList.AddRange(GetProductCategoryALLChild(list, item.Id));
} }
return RList; return RList;
...@@ -1396,10 +1445,11 @@ namespace Mall.Module.Product ...@@ -1396,10 +1445,11 @@ namespace Mall.Module.Product
{ nameof(RB_Product_Category.UpdateDate),DateTime.Now}, { nameof(RB_Product_Category.UpdateDate),DateTime.Now},
}; };
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper()
{
FiledName=nameof(RB_Product_Category.Id), FiledName=nameof(RB_Product_Category.Id),
FiledValue=cmodel.Id, FiledValue=cmodel.Id,
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
bool flag = product_CategoryRepository.Update(keyValues, wheres, trans); bool flag = product_CategoryRepository.Update(keyValues, wheres, trans);
...@@ -1447,14 +1497,16 @@ namespace Mall.Module.Product ...@@ -1447,14 +1497,16 @@ namespace Mall.Module.Product
public List<RB_Product_Specification_Extend> GetProducSpecificationPageList(int pageIndex, int pageSize, out long count, RB_Product_Specification_Extend demodel) public List<RB_Product_Specification_Extend> GetProducSpecificationPageList(int pageIndex, int pageSize, out long count, RB_Product_Specification_Extend demodel)
{ {
var list = product_SpecificationRepository.GetPageList(pageIndex, pageSize, out count, demodel); var list = product_SpecificationRepository.GetPageList(pageIndex, pageSize, out count, demodel);
foreach (var item in list) { foreach (var item in list)
{
item.SpecList = new List<string>(); item.SpecList = new List<string>();
if (!string.IsNullOrEmpty(item.Content)) { if (!string.IsNullOrEmpty(item.Content))
{
item.SpecList = JsonConvert.DeserializeObject<List<string>>(item.Content); item.SpecList = JsonConvert.DeserializeObject<List<string>>(item.Content);
} }
} }
return list; return list;
} }
/// <summary> /// <summary>
/// 获取规格列表 /// 获取规格列表
...@@ -1498,7 +1550,8 @@ namespace Mall.Module.Product ...@@ -1498,7 +1550,8 @@ namespace Mall.Module.Product
}; };
return product_SpecificationRepository.Update(keyValues, wheres); return product_SpecificationRepository.Update(keyValues, wheres);
} }
else { else
{
return product_SpecificationRepository.Insert(demodel) > 0; return product_SpecificationRepository.Insert(demodel) > 0;
} }
} }
...@@ -1550,13 +1603,16 @@ namespace Mall.Module.Product ...@@ -1550,13 +1603,16 @@ namespace Mall.Module.Product
public List<RB_Product_QuickBuy_Extend> GetProductQuickBuyPageList(int pageIndex, int pageSize, out long count, RB_Product_QuickBuy_Extend demodel) public List<RB_Product_QuickBuy_Extend> GetProductQuickBuyPageList(int pageIndex, int pageSize, out long count, RB_Product_QuickBuy_Extend demodel)
{ {
var list = product_QuickBuyRepository.GetPageList(pageIndex, pageSize, out count, demodel); var list = product_QuickBuyRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) { if (list.Any())
{
string imgids = string.Join(",", list.Where(x => x.Icon > 0).Select(x => x.Icon)); string imgids = string.Join(",", list.Where(x => x.Icon > 0).Select(x => x.Icon));
List<RB_Material_Info_Extend> mlist = new List<RB_Material_Info_Extend>(); List<RB_Material_Info_Extend> mlist = new List<RB_Material_Info_Extend>();
if (!string.IsNullOrEmpty(imgids)) { if (!string.IsNullOrEmpty(imgids))
{
mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = imgids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = imgids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
} }
foreach (var item in list) { foreach (var item in list)
{
item.IconPath = mlist.Where(x => x.Id == item.Icon).FirstOrDefault()?.Path ?? ""; item.IconPath = mlist.Where(x => x.Id == item.Icon).FirstOrDefault()?.Path ?? "";
} }
} }
...@@ -1619,8 +1675,10 @@ namespace Mall.Module.Product ...@@ -1619,8 +1675,10 @@ namespace Mall.Module.Product
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
if (id > 0) { if (id > 0)
wheres.Add(new WhereHelper() { {
wheres.Add(new WhereHelper()
{
FiledName = nameof(RB_Product_QuickBuy.Id), FiledName = nameof(RB_Product_QuickBuy.Id),
FiledValue = id, FiledValue = id,
OperatorEnum = OperatorEnum.NotEqual OperatorEnum = OperatorEnum.NotEqual
...@@ -1662,10 +1720,11 @@ namespace Mall.Module.Product ...@@ -1662,10 +1720,11 @@ namespace Mall.Module.Product
}; };
return product_QuickBuyRepository.Update(keyValues, wheres); return product_QuickBuyRepository.Update(keyValues, wheres);
} }
else { else
{
return product_QuickBuyRepository.Insert(demodel) > 0; return product_QuickBuyRepository.Insert(demodel) > 0;
} }
} }
/// <summary> /// <summary>
/// 删除快速购买 /// 删除快速购买
...@@ -1712,15 +1771,17 @@ namespace Mall.Module.Product ...@@ -1712,15 +1771,17 @@ namespace Mall.Module.Product
public RB_Product_Recommend_Extend GetProductRecommendSetInfo(int tenantId, int mallBaseId) public RB_Product_Recommend_Extend GetProductRecommendSetInfo(int tenantId, int mallBaseId)
{ {
var model = product_RecommendRepository.GetList(new RB_Product_Recommend_Extend() { TenantId = tenantId, MallBaseId = mallBaseId }).FirstOrDefault(); var model = product_RecommendRepository.GetList(new RB_Product_Recommend_Extend() { TenantId = tenantId, MallBaseId = mallBaseId }).FirstOrDefault();
if (model == null) { if (model == null)
{
return new RB_Product_Recommend_Extend(); return new RB_Product_Recommend_Extend();
} }
model.OrderProductList = new List<RB_ProductRecommendModel>(); model.OrderProductList = new List<RB_ProductRecommendModel>();
if (model.IsOrderRecommend == 1 && !string.IsNullOrEmpty(model.OrderProductIds)) { if (model.IsOrderRecommend == 1 && !string.IsNullOrEmpty(model.OrderProductIds))
{
//查询商品 //查询商品
var glist = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = model.OrderProductIds, TenantId = tenantId, MallBaseId = mallBaseId }); var glist = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = model.OrderProductIds, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in glist) foreach (var item in glist)
{ {
//轮播图 //轮播图
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]") if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{ {
...@@ -1729,7 +1790,8 @@ namespace Mall.Module.Product ...@@ -1729,7 +1790,8 @@ namespace Mall.Module.Product
item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? ""; item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? "";
} }
} }
foreach (var item in glist) { foreach (var item in glist)
{
model.OrderProductList.Add(new RB_ProductRecommendModel() model.OrderProductList.Add(new RB_ProductRecommendModel()
{ {
Id = item.Id, Id = item.Id,
...@@ -1739,7 +1801,8 @@ namespace Mall.Module.Product ...@@ -1739,7 +1801,8 @@ namespace Mall.Module.Product
} }
} }
model.CommentProductList = new List<RB_ProductRecommendModel>(); model.CommentProductList = new List<RB_ProductRecommendModel>();
if (model.IsCommentRecommend == 1 && !string.IsNullOrEmpty(model.CommentProductIds)) { if (model.IsCommentRecommend == 1 && !string.IsNullOrEmpty(model.CommentProductIds))
{
var glist = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = model.CommentProductIds, TenantId = tenantId, MallBaseId = mallBaseId }); var glist = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = model.CommentProductIds, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in glist) foreach (var item in glist)
{ {
...@@ -1793,7 +1856,8 @@ namespace Mall.Module.Product ...@@ -1793,7 +1856,8 @@ namespace Mall.Module.Product
}; };
return product_RecommendRepository.Update(keyValues, wheres); return product_RecommendRepository.Update(keyValues, wheres);
} }
else { else
{
return product_RecommendRepository.Insert(demodel) > 0; return product_RecommendRepository.Insert(demodel) > 0;
} }
} }
...@@ -1845,7 +1909,8 @@ namespace Mall.Module.Product ...@@ -1845,7 +1909,8 @@ namespace Mall.Module.Product
if (demodel.UpdateType == 1) if (demodel.UpdateType == 1)
{ //只更新默认状态 { //只更新默认状态
var model = product_ServiceRepository.GetEntity(demodel.Id); var model = product_ServiceRepository.GetEntity(demodel.Id);
if (model == null) { if (model == null)
{
return false; return false;
} }
keyValues = new Dictionary<string, object>() keyValues = new Dictionary<string, object>()
...@@ -1934,15 +1999,18 @@ namespace Mall.Module.Product ...@@ -1934,15 +1999,18 @@ namespace Mall.Module.Product
public List<RB_Goods_Extend> GetProductGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel) public List<RB_Goods_Extend> GetProductGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{ {
var list = goodsRepository.GetPageList(pageIndex, pageSize, out count, demodel); var list = goodsRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) { if (list.Any())
{
//查询分类 //查询分类
string ids = string.Join(",", list.Select(x => x.Id)); string ids = string.Join(",", list.Select(x => x.Id));
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in list) { foreach (var item in list)
{
item.CategoryList = clist.Where(x => x.GoodsId == item.Id).ToList(); item.CategoryList = clist.Where(x => x.GoodsId == item.Id).ToList();
//轮播图 //轮播图
item.CoverImage = ""; item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]") { if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage); List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage);
//封面图 //封面图
item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? ""; item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? "";
...@@ -2055,13 +2123,15 @@ namespace Mall.Module.Product ...@@ -2055,13 +2123,15 @@ namespace Mall.Module.Product
} }
}; };
bool flag = goodsRepository.Update(keyValues, wheres, trans); bool flag = goodsRepository.Update(keyValues, wheres, trans);
if (flag) { if (flag)
{
#region 修改分类 #region 修改分类
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var insertList = demodel.CategoryList.Where(x => !clist.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList(); var insertList = demodel.CategoryList.Where(x => !clist.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
//var updateList = clist.Where(x => demodel.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList(); //var updateList = clist.Where(x => demodel.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
var deleteList = clist.Where(x => !demodel.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList(); var deleteList = clist.Where(x => !demodel.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
foreach (var item in insertList) { foreach (var item in insertList)
{
goods_CategoryRepository.Insert(new RB_Goods_Category() goods_CategoryRepository.Insert(new RB_Goods_Category()
{ {
CategoryId = item.CategoryId, CategoryId = item.CategoryId,
...@@ -2073,7 +2143,8 @@ namespace Mall.Module.Product ...@@ -2073,7 +2143,8 @@ namespace Mall.Module.Product
TenantId = demodel.TenantId TenantId = demodel.TenantId
}, trans); }, trans);
} }
foreach (var item in deleteList) { foreach (var item in deleteList)
{
goods_CategoryRepository.Delete(item.Id, trans); goods_CategoryRepository.Delete(item.Id, trans);
} }
#endregion #endregion
...@@ -2147,7 +2218,8 @@ namespace Mall.Module.Product ...@@ -2147,7 +2218,8 @@ namespace Mall.Module.Product
//更新 //更新
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in slist) { foreach (var item in slist)
{
var supmodel = demodel.SpecificationList.Where(x => x.Id == item.Id).FirstOrDefault(); var supmodel = demodel.SpecificationList.Where(x => x.Id == item.Id).FirstOrDefault();
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() { Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_Specification.EnabledImage),supmodel.EnabledImage}, { nameof(RB_Goods_Specification.EnabledImage),supmodel.EnabledImage},
...@@ -2162,7 +2234,8 @@ namespace Mall.Module.Product ...@@ -2162,7 +2234,8 @@ namespace Mall.Module.Product
} }
}; };
bool flag1 = goods_SpecificationRepository.Update(keyValues1, wheres1, trans); bool flag1 = goods_SpecificationRepository.Update(keyValues1, wheres1, trans);
if (flag1) { if (flag1)
{
var sv2list = svlist.Where(x => x.SpecificationId == item.Id).ToList(); var sv2list = svlist.Where(x => x.SpecificationId == item.Id).ToList();
if (sv2list.Count() != supmodel.SpecificationValueList.Count() || sv2list.Count() != supmodel.SpecificationValueList.Where(x => x.Id > 0).Count()) if (sv2list.Count() != supmodel.SpecificationValueList.Count() || sv2list.Count() != supmodel.SpecificationValueList.Where(x => x.Id > 0).Count())
{ {
...@@ -2184,7 +2257,8 @@ namespace Mall.Module.Product ...@@ -2184,7 +2257,8 @@ namespace Mall.Module.Product
}, trans); }, trans);
} }
} }
else { else
{
foreach (var qitem in sv2list) foreach (var qitem in sv2list)
{ {
var supModel1 = supmodel.SpecificationValueList.Where(x => x.Id == qitem.Id).FirstOrDefault(); var supModel1 = supmodel.SpecificationValueList.Where(x => x.Id == qitem.Id).FirstOrDefault();
...@@ -2228,8 +2302,10 @@ namespace Mall.Module.Product ...@@ -2228,8 +2302,10 @@ namespace Mall.Module.Product
}, trans); }, trans);
} }
} }
else { else
foreach (var item in splist) { {
foreach (var item in splist)
{
var pupmodel = demodel.SpecificationPriceList.Where(x => x.SpecificationSort == item.SpecificationSort).FirstOrDefault(); var pupmodel = demodel.SpecificationPriceList.Where(x => x.SpecificationSort == item.SpecificationSort).FirstOrDefault();
if (item.SellingPrice != pupmodel.SellingPrice || item.InventoryNum != pupmodel.InventoryNum || item.GoodsNumbers != pupmodel.GoodsNumbers || item.GoodsWeight != pupmodel.GoodsWeight) if (item.SellingPrice != pupmodel.SellingPrice || item.InventoryNum != pupmodel.InventoryNum || item.GoodsNumbers != pupmodel.GoodsNumbers || item.GoodsWeight != pupmodel.GoodsWeight)
{ {
...@@ -2280,10 +2356,11 @@ namespace Mall.Module.Product ...@@ -2280,10 +2356,11 @@ namespace Mall.Module.Product
#endregion #endregion
//修改卡卷 //修改卡卷
#region 修改分销佣金 #region 修改分销佣金
if (demodel.SeparateDistribution == 1) { if (demodel.SeparateDistribution == 1)
{
//价格新增/更新 //价格新增/更新
var dclist = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var dclist = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (dclist.Count() != demodel.DistributionCommissionList.Count() if (dclist.Count() != demodel.DistributionCommissionList.Count()
|| dclist.Count() != demodel.DistributionCommissionList.Where(x => dclist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count() || dclist.Count() != demodel.DistributionCommissionList.Where(x => dclist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count()
|| dclist.Select(x => x.DistributorGrade).Distinct().Count() != demodel.DistributionCommissionList.Select(x => x.DistributorGrade).Distinct().Count() || dclist.Select(x => x.DistributorGrade).Distinct().Count() != demodel.DistributionCommissionList.Select(x => x.DistributorGrade).Distinct().Count()
|| dclist.Select(x => x.DistributorGrade).Distinct().Count() != dclist.Select(x => x.DistributorGrade).Distinct().Where(x => demodel.DistributionCommissionList.Select(y => y.DistributorGrade).Distinct().Contains(x)).Count()) || dclist.Select(x => x.DistributorGrade).Distinct().Count() != dclist.Select(x => x.DistributorGrade).Distinct().Where(x => demodel.DistributionCommissionList.Select(y => y.DistributorGrade).Distinct().Contains(x)).Count())
...@@ -2310,7 +2387,7 @@ namespace Mall.Module.Product ...@@ -2310,7 +2387,7 @@ namespace Mall.Module.Product
} }
else else
{ {
foreach (var item in dclist) foreach (var item in dclist)
{ {
var pupmodel = demodel.DistributionCommissionList.Where(x => x.SpecificationSort == item.SpecificationSort && x.DistributorGrade == item.DistributorGrade).FirstOrDefault(); var pupmodel = demodel.DistributionCommissionList.Where(x => x.SpecificationSort == item.SpecificationSort && x.DistributorGrade == item.DistributorGrade).FirstOrDefault();
...@@ -2335,7 +2412,8 @@ namespace Mall.Module.Product ...@@ -2335,7 +2412,8 @@ namespace Mall.Module.Product
} }
#endregion #endregion
#region 修改会员价格 #region 修改会员价格
if (demodel.EnjoyMember == 1 && demodel.SeparateSetMember == 1) { if (demodel.EnjoyMember == 1 && demodel.SeparateSetMember == 1)
{
var mplist = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var mplist = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (mplist.Count() != demodel.MemberPriceList.Count() if (mplist.Count() != demodel.MemberPriceList.Count()
|| mplist.Count() != demodel.MemberPriceList.Where(x => mplist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count() || mplist.Count() != demodel.MemberPriceList.Where(x => mplist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count()
...@@ -2386,12 +2464,15 @@ namespace Mall.Module.Product ...@@ -2386,12 +2464,15 @@ namespace Mall.Module.Product
#endregion #endregion
} }
} }
else { else
{
int Id = goodsRepository.Insert(demodel, trans); int Id = goodsRepository.Insert(demodel, trans);
bool flag = Id > 0; bool flag = Id > 0;
if (flag) { if (flag)
{
//插入分类 //插入分类
foreach (var item in demodel.CategoryList) { foreach (var item in demodel.CategoryList)
{
goods_CategoryRepository.Insert(new RB_Goods_Category() goods_CategoryRepository.Insert(new RB_Goods_Category()
{ {
CategoryId = item.CategoryId, CategoryId = item.CategoryId,
...@@ -2404,9 +2485,11 @@ namespace Mall.Module.Product ...@@ -2404,9 +2485,11 @@ namespace Mall.Module.Product
}, trans); }, trans);
} }
//插入规格 //插入规格
if (demodel.IsCustomSpecification == 1) { if (demodel.IsCustomSpecification == 1)
foreach (var item in demodel.SpecificationList) { {
int sid= goods_SpecificationRepository.Insert(new RB_Goods_Specification() foreach (var item in demodel.SpecificationList)
{
int sid = goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{ {
CreateDate = demodel.CreateDate, CreateDate = demodel.CreateDate,
EnabledImage = item.EnabledImage, EnabledImage = item.EnabledImage,
...@@ -2438,7 +2521,8 @@ namespace Mall.Module.Product ...@@ -2438,7 +2521,8 @@ namespace Mall.Module.Product
} }
} }
} }
foreach (var item in demodel.SpecificationPriceList) { foreach (var item in demodel.SpecificationPriceList)
{
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice() goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{ {
CreateDate = demodel.CreateDate, CreateDate = demodel.CreateDate,
...@@ -2457,7 +2541,8 @@ namespace Mall.Module.Product ...@@ -2457,7 +2541,8 @@ namespace Mall.Module.Product
} }
} }
//插入区域 //插入区域
foreach (var item in demodel.AreaList) { foreach (var item in demodel.AreaList)
{
goods_AreaRepository.Insert(new RB_Goods_Area() goods_AreaRepository.Insert(new RB_Goods_Area()
{ {
AreaId = item.AreaId, AreaId = item.AreaId,
...@@ -2472,7 +2557,8 @@ namespace Mall.Module.Product ...@@ -2472,7 +2557,8 @@ namespace Mall.Module.Product
} }
//插入卡卷 //插入卡卷
//插入分销佣金 //插入分销佣金
if (demodel.SeparateDistribution == 1) { if (demodel.SeparateDistribution == 1)
{
foreach (var item in demodel.DistributionCommissionList) foreach (var item in demodel.DistributionCommissionList)
{ {
goods_DistributionCommissionRepository.Insert(new RB_Goods_DistributionCommission() goods_DistributionCommissionRepository.Insert(new RB_Goods_DistributionCommission()
...@@ -2493,7 +2579,8 @@ namespace Mall.Module.Product ...@@ -2493,7 +2579,8 @@ namespace Mall.Module.Product
} }
} }
//插入会员价格 //插入会员价格
if (demodel.EnjoyMember == 1 && demodel.SeparateSetMember == 1) { if (demodel.EnjoyMember == 1 && demodel.SeparateSetMember == 1)
{
foreach (var item in demodel.MemberPriceList) foreach (var item in demodel.MemberPriceList)
{ {
goods_MemberPriceRepository.Insert(new RB_Goods_MemberPrice() goods_MemberPriceRepository.Insert(new RB_Goods_MemberPrice()
...@@ -2529,32 +2616,39 @@ namespace Mall.Module.Product ...@@ -2529,32 +2616,39 @@ namespace Mall.Module.Product
/// </summary> /// </summary>
/// <param name="goodsId"></param> /// <param name="goodsId"></param>
/// <returns></returns> /// <returns></returns>
public RB_Goods_Extend GetProductGoodsInfo(int goodsId,int TenantId,int MallBaseId) public RB_Goods_Extend GetProductGoodsInfo(int goodsId, int TenantId, int MallBaseId)
{ {
var model = goodsRepository.GetEntity(goodsId).RefMapperTo<RB_Goods_Extend>(); var model = goodsRepository.GetEntity(goodsId).RefMapperTo<RB_Goods_Extend>();
if (model == null || model.TenantId != TenantId || model.MallBaseId != MallBaseId){ if (model == null || model.TenantId != TenantId || model.MallBaseId != MallBaseId)
{
return null; return null;
} }
model.CategoryList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.CategoryList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
model.SpecificationList = new List<RB_Goods_Specification_Extend>(); model.SpecificationList = new List<RB_Goods_Specification_Extend>();
model.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>(); model.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
if (model.IsCustomSpecification == 1) { if (model.IsCustomSpecification == 1)
{
model.SpecificationList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.SpecificationList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (model.SpecificationList.Any()) { if (model.SpecificationList.Any())
{
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (svlist.Where(x => x.Image > 0).Any()) { if (svlist.Where(x => x.Image > 0).Any())
{
string imgIds = string.Join(",", svlist.Where(x => x.Image > 0).Select(x => x.Image).Distinct()); string imgIds = string.Join(",", svlist.Where(x => x.Image > 0).Select(x => x.Image).Distinct());
var mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = imgIds, TenantId = TenantId, MallBaseId = MallBaseId }); var mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = imgIds, TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in svlist.Where(x => x.Image > 0)) { foreach (var item in svlist.Where(x => x.Image > 0))
{
item.ImagePath = mlist.Where(x => x.Id == item.Image).FirstOrDefault()?.Path ?? ""; item.ImagePath = mlist.Where(x => x.Id == item.Image).FirstOrDefault()?.Path ?? "";
} }
} }
foreach (var item in model.SpecificationList) { foreach (var item in model.SpecificationList)
{
item.SpecificationValueList = svlist.Where(x => x.SpecificationId == item.Id).ToList(); 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 }); model.SpecificationPriceList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in model.SpecificationPriceList) { foreach (var item in model.SpecificationPriceList)
{
if (!string.IsNullOrEmpty(item.SpecificationSort)) if (!string.IsNullOrEmpty(item.SpecificationSort))
{ {
var ssarr = item.SpecificationSort.Split(':'); var ssarr = item.SpecificationSort.Split(':');
...@@ -2578,17 +2672,21 @@ namespace Mall.Module.Product ...@@ -2578,17 +2672,21 @@ namespace Mall.Module.Product
} }
} }
model.AreaList = new List<RB_Goods_Area_Extend>(); model.AreaList = new List<RB_Goods_Area_Extend>();
if (model.IsAreaBuy == 1) { if (model.IsAreaBuy == 1)
{
model.AreaList = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.AreaList = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
} }
model.DistributionCommissionList = new List<RB_Goods_DistributionCommission_Extend>(); model.DistributionCommissionList = new List<RB_Goods_DistributionCommission_Extend>();
model.DistributionCommissionTreeList = new List<RB_Goods_DistributionCommission_Extend>(); model.DistributionCommissionTreeList = new List<RB_Goods_DistributionCommission_Extend>();
if (model.SeparateDistribution == 1) { if (model.SeparateDistribution == 1)
{
model.DistributionCommissionList = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.DistributionCommissionList = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (model.DistributionCommissionList.Any()) { if (model.DistributionCommissionList.Any())
{
var KeyList = model.DistributionCommissionList.Select(x => x.SpecificationSort ?? "").Distinct().ToList(); var KeyList = model.DistributionCommissionList.Select(x => x.SpecificationSort ?? "").Distinct().ToList();
foreach (var qitem in KeyList) { foreach (var qitem in KeyList)
{
var treemodel = model.DistributionCommissionList.Where(x => (x.SpecificationSort ?? "") == qitem).FirstOrDefault(); var treemodel = model.DistributionCommissionList.Where(x => (x.SpecificationSort ?? "") == qitem).FirstOrDefault();
treemodel.GradeCommissionList = model.DistributionCommissionList.Where(x => (x.SpecificationSort ?? "") == qitem).ToList(); treemodel.GradeCommissionList = model.DistributionCommissionList.Where(x => (x.SpecificationSort ?? "") == qitem).ToList();
if (model.SeparateDistributionType == 2) if (model.SeparateDistributionType == 2)
...@@ -2620,7 +2718,8 @@ namespace Mall.Module.Product ...@@ -2620,7 +2718,8 @@ namespace Mall.Module.Product
} }
model.MemberPriceList = new List<RB_Goods_MemberPrice_Extend>(); model.MemberPriceList = new List<RB_Goods_MemberPrice_Extend>();
model.MemberPriceTreeList = new List<RB_Goods_MemberPrice_Extend>(); model.MemberPriceTreeList = new List<RB_Goods_MemberPrice_Extend>();
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1){ if (model.EnjoyMember == 1 && model.SeparateSetMember == 1)
{
model.MemberPriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.MemberPriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (model.MemberPriceList.Any()) if (model.MemberPriceList.Any())
{ {
...@@ -2659,7 +2758,8 @@ namespace Mall.Module.Product ...@@ -2659,7 +2758,8 @@ namespace Mall.Module.Product
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(model.CarouselImage); List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(model.CarouselImage);
//轮播图 //轮播图
var mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = string.Join(",", CarouselIdList), TenantId = TenantId, MallBaseId = MallBaseId }); var mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { MaterialIds = string.Join(",", CarouselIdList), TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in CarouselIdList) { foreach (var item in CarouselIdList)
{
var cmodel = mlist.Where(x => x.Id == item).FirstOrDefault(); var cmodel = mlist.Where(x => x.Id == item).FirstOrDefault();
model.CarouselImageList.Add(new RB_ImageCommonModel() model.CarouselImageList.Add(new RB_ImageCommonModel()
{ {
...@@ -2669,17 +2769,20 @@ namespace Mall.Module.Product ...@@ -2669,17 +2769,20 @@ namespace Mall.Module.Product
}); });
} }
} }
if (model.CustomShareImage > 0) { if (model.CustomShareImage > 0)
{
model.CustomShareImagePath = material_InfoRepository.GetEntity(model.CustomShareImage)?.Path ?? ""; model.CustomShareImagePath = material_InfoRepository.GetEntity(model.CustomShareImage)?.Path ?? "";
} }
//服务列表 //服务列表
model.ServiceList = new List<RB_ImageCommonModel>(); model.ServiceList = new List<RB_ImageCommonModel>();
if (model.IsDefaultService == 2) if (model.IsDefaultService == 2)
{ {
if (!string.IsNullOrEmpty(model.GoodsService) && model.GoodsService != "[]") { if (!string.IsNullOrEmpty(model.GoodsService) && model.GoodsService != "[]")
{
List<int> ServiceIds = JsonConvert.DeserializeObject<List<int>>(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 }); var slist = product_ServiceRepository.GetList(new RB_Product_Service_Extend() { ServiceIds = string.Join(",", ServiceIds), TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in slist) { foreach (var item in slist)
{
model.ServiceList.Add(new RB_ImageCommonModel() model.ServiceList.Add(new RB_ImageCommonModel()
{ {
Id = item.Id, Id = item.Id,
...@@ -2693,7 +2796,8 @@ namespace Mall.Module.Product ...@@ -2693,7 +2796,8 @@ namespace Mall.Module.Product
{ {
model.FreightName = logistics_RulesRepository.GetEntity(model.FreightId)?.RulesName ?? ""; model.FreightName = logistics_RulesRepository.GetEntity(model.FreightId)?.RulesName ?? "";
} }
else { else
{
model.FreightName = "默认运费"; model.FreightName = "默认运费";
} }
//表单 //表单
...@@ -2701,7 +2805,8 @@ namespace Mall.Module.Product ...@@ -2701,7 +2805,8 @@ namespace Mall.Module.Product
{ {
model.FormsName = "未建表"; model.FormsName = "未建表";
} }
else { else
{
model.FormsName = "默认表单"; model.FormsName = "默认表单";
} }
...@@ -2736,14 +2841,16 @@ namespace Mall.Module.Product ...@@ -2736,14 +2841,16 @@ namespace Mall.Module.Product
else if (type == 3) else if (type == 3)
{ {
var model = goodsRepository.GetEntity(goodsId); var model = goodsRepository.GetEntity(goodsId);
if (model == null) { if (model == null)
{
return false; return false;
} }
keyValues = new Dictionary<string, object>() { keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.IsQuickBuy),model.IsQuickBuy==1?2:1} { nameof(RB_Goods.IsQuickBuy),model.IsQuickBuy==1?2:1}
}; };
} }
else { else
{
return false; return false;
} }
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
......
...@@ -19,6 +19,7 @@ using Mall.CacheKey; ...@@ -19,6 +19,7 @@ using Mall.CacheKey;
using Mall.Common.Plugin; using Mall.Common.Plugin;
using Mall.Common.Enum.MallBase; using Mall.Common.Enum.MallBase;
using Mall.Model.Entity.User; using Mall.Model.Entity.User;
using Mall.Module.Product;
namespace Mall.WebApi.Controllers.User namespace Mall.WebApi.Controllers.User
{ {
...@@ -68,6 +69,11 @@ namespace Mall.WebApi.Controllers.User ...@@ -68,6 +69,11 @@ namespace Mall.WebApi.Controllers.User
/// </summary> /// </summary>
private Module.User.EmployeeModule employeeModule = new Module.User.EmployeeModule(); private Module.User.EmployeeModule employeeModule = new Module.User.EmployeeModule();
/// <summary>
/// 产品处理类
/// </summary>
private ProductModule productModule = new ProductModule();
#region 商户信息 #region 商户信息
/// <summary> /// <summary>
...@@ -504,49 +510,55 @@ namespace Mall.WebApi.Controllers.User ...@@ -504,49 +510,55 @@ namespace Mall.WebApi.Controllers.User
name="常用", name="常用",
list= normalList list= normalList
}); });
productModule.GetCategoryListModule(new Model.Extend.Product.RB_Product_Category_Extend() { MallBaseId = RequestParm.MallBaseId, TenantId = RequestParm.TenantId, Tier = 1 });
List<object> catList = new List<object>(); List<object> catList = new List<object>();
catList.Add(new catList.Add(new
{ {
key = "cat", key = "cat",
name = "所有分类", name = "所有分类",
relation_id = 0, relation_id = 0,
is_edit = 0 is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
}); });
catList.Add(new catList.Add(new
{ {
key = "cat", key = "cat",
name = "赞羊严选", name = "赞羊严选",
relation_id = 9120, relation_id = 9120,
is_edit = 0 is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
}); });
catList.Add(new catList.Add(new
{ {
key = "cat", key = "cat",
name = "严选旅游", name = "严选旅游",
relation_id = 10235, relation_id = 10235,
is_edit = 0 is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
}); });
catList.Add(new catList.Add(new
{ {
key = "cat", key = "cat",
name = "台湾严选", name = "台湾严选",
relation_id = 10250, relation_id = 10250,
is_edit = 0 is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
}); });
catList.Add(new catList.Add(new
{ {
key = "cat", key = "cat",
name = "日韩严选", name = "日韩严选",
relation_id = 10252, relation_id = 10252,
is_edit = 0 is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
}); });
catList.Add(new catList.Add(new
{ {
key = "cat", key = "cat",
name = "欧洲严选", name = "欧洲严选",
relation_id = 10253, relation_id = 10253,
is_edit = 0 is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
}); });
resultList.Add(new resultList.Add(new
{ {
......
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