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

新增商品分类

parent 164c3848
......@@ -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();
RecommendStatus = 2;
if (rmodel == null) {
if (rmodel == null)
{
return new List<RB_Goods_Extend>();
}
pageSize = rmodel.DetailRecommendNum ?? 0;
......@@ -209,7 +210,8 @@ namespace Mall.Module.Product
}
}
}
else if (demodel.RecommendType == 3) {
else if (demodel.RecommendType == 3)
{
RecommendStatus = rmodel.CommentRecommentStatus ?? 2;
if (rmodel.CommentRecommentStatus != 1)
{
......@@ -229,12 +231,15 @@ namespace Mall.Module.Product
List<RB_Goods_Extend> RList = list;
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);
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>();
foreach (var item in gList) {
foreach (var item in gList)
{
RList.Add(list.Where(x => x.Id == item).FirstOrDefault());
}
}
......@@ -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 });
foreach (var item in slist)
{
......@@ -471,7 +477,8 @@ namespace Mall.Module.Product
{
model.Express = pmodel.FirstPrice;
}
else {
else
{
//重量计费
int TotalW = model.GoodsWeight ?? 0;
if (TotalW <= pmodel.First)
......@@ -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();
if (disModel != null) {
if (disModel != null)
{
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();
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1) {
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1)
{
model.MaxShare = dcList.Max(x => (x.OneCommission ?? 0) + (x.TwoCommission ?? 0) + (x.ThreeCommission ?? 0));
}
else {
else
{
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);
}
}
else {
else
{
if (disModel.GradeId == 0)
{
//拿分销基础配置
......@@ -542,10 +555,12 @@ namespace Mall.Module.Product
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);
if (disgradeModel != null) {
if (disgradeModel != null)
{
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1)
{
model.MaxShare = (disgradeModel?.OneCommission ?? 0) + (disgradeModel?.TwoCommission ?? 0) + (disgradeModel?.ThreeCommission ?? 0);
......@@ -581,7 +596,8 @@ namespace Mall.Module.Product
if (list.Any())
{
List<int> MaterialIds = new List<int>();
foreach (var item in list) {
foreach (var item in list)
{
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage);
......@@ -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 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 });
if (speciVList.Any()) {
if (speciVList.Any())
{
MaterialIds.AddRange(speciVList.Where(x => x.Image > 0).Select(x => x.Image ?? 0));
}
if (MaterialIds.Any())
......@@ -685,8 +702,9 @@ namespace Mall.Module.Product
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Material_Group_Extend> GetMaterialGroupList(RB_Material_Group_Extend dmodel) {
var list= material_GroupRepository.GetList(dmodel);
public List<RB_Material_Group_Extend> GetMaterialGroupList(RB_Material_Group_Extend dmodel)
{
var list = material_GroupRepository.GetList(dmodel);
return list;
}
......@@ -728,7 +746,8 @@ namespace Mall.Module.Product
};
return material_GroupRepository.Update(keyValues, wheres);
}
else {
else
{
return material_GroupRepository.Insert(demodel) > 0;
}
}
......@@ -755,7 +774,8 @@ namespace Mall.Module.Product
};
return material_InfoRepository.Update(keyValues, wheres);
}
else {
else
{
return material_InfoRepository.Insert(demodel) > 0;
}
}
......@@ -770,7 +790,8 @@ namespace Mall.Module.Product
public bool SetMaterialGroupRecycled(int groupId, string uid, int mallBaseId)
{
var gmodel = material_GroupRepository.GetEntity(groupId);
if (gmodel == null) {
if (gmodel == null)
{
return false;
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -795,7 +816,8 @@ namespace Mall.Module.Product
},
};
bool flag = material_GroupRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//分组下所有素材全回收
material_InfoRepository.SetMaterialInfoRecycled(groupId, Convert.ToInt32(uid), mallBaseId);
}
......@@ -816,7 +838,8 @@ namespace Mall.Module.Product
{
return false;
}
if (gmodel.Recycled != 2) {
if (gmodel.Recycled != 2)
{
return false;
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -841,7 +864,8 @@ namespace Mall.Module.Product
},
};
bool flag = material_GroupRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//删除分组下所有的素材
material_InfoRepository.DelMaterialInfo("", uid, mallBaseId, groupId);
}
......@@ -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 });
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>() {
{ nameof(RB_Material_Group.Recycled),1},
{ nameof(RB_Material_Group.UpdateDate),DateTime.Now},
......@@ -960,7 +985,8 @@ namespace Mall.Module.Product
material_GroupRepository.Update(keyValues, wheres, trans);
}
}
foreach (var item in list) {
foreach (var item in list)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Material_Info.Recycled),1},
{ nameof(RB_Material_Info.UpdateDate),DateTime.Now},
......@@ -1008,7 +1034,8 @@ namespace Mall.Module.Product
public bool SetMaterialInfoTransfer(string materialIds, int groupId, int Type, string uid, int mallBaseId)
{
var gmodel = material_GroupRepository.GetEntity(groupId);
if (gmodel == null) {
if (gmodel == null)
{
return false;
}
if (gmodel.Status == 1 || gmodel.Recycled == 2 || gmodel.Type != Type)
......@@ -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)
{
var list = product_CategoryRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) {
if (list.Any())
{
List<int> ImgIds = new List<int>();
ImgIds.AddRange(list.Select(x => x.Icon ?? 0).Distinct());
ImgIds.AddRange(list.Select(x => x.BigIcon ?? 0).Distinct());
ImgIds.AddRange(list.Select(x => x.AdvertisingImage ?? 0).Distinct());
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 });
}
foreach (var item in list) {
foreach (var item in list)
{
item.IconPath = mlist.Where(x => x.Id == item.Icon).FirstOrDefault()?.Path ?? "";
item.BigIconPath = mlist.Where(x => x.Id == item.BigIcon).FirstOrDefault()?.Path ?? "";
item.AdvertisingImagePath = mlist.Where(x => x.Id == item.AdvertisingImage).FirstOrDefault()?.Path ?? "";
......@@ -1065,7 +1095,8 @@ namespace Mall.Module.Product
try
{
var list = GetProductCategoryForALLChlid(categoryId, tenantId, mallBaseId);
foreach (var item in list) {
foreach (var item in list)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Product_Category.Status),1},
{ nameof(RB_Product_Category.UpdateDate),DateTime.Now},
......@@ -1136,7 +1167,8 @@ namespace Mall.Module.Product
};
return product_CategoryStyleRepository.Update(keyValues, wheres);
}
else {
else
{
return product_CategoryStyleRepository.Insert(demodel) > 0;
}
}
......@@ -1224,10 +1256,12 @@ namespace Mall.Module.Product
/// <param name="list"></param>
/// <param name="parentId"></param>
/// <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>();
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
{
Id = item.Id,
......@@ -1273,9 +1307,11 @@ namespace Mall.Module.Product
else
{
int Id = product_CategoryRepository.Insert(demodel);
if (Id > 0) {
if (Id > 0)
{
int RootId = Id;
if (demodel.ParentId > 0) {
if (demodel.ParentId > 0)
{
var pmodel = product_CategoryRepository.GetEntity(demodel.ParentId);
RootId = pmodel?.RootId ?? 0;
}
......@@ -1312,17 +1348,19 @@ namespace Mall.Module.Product
List<RB_Material_Info_Extend> mlist = new List<RB_Material_Info_Extend>();
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.BigIconPath = mlist.Where(x => x.Id == model.BigIcon).FirstOrDefault()?.Path ?? "";
model.AdvertisingImagePath = mlist.Where(x => x.Id == model.AdvertisingImage).FirstOrDefault()?.Path ?? "";
var p1Model = product_CategoryRepository.GetEntity(model?.ParentId);
if (p1Model != null) {
if (p1Model != null)
{
model.Parent1Name = p1Model.Name;
var p2Model = product_CategoryRepository.GetEntity(p1Model?.ParentId);
if (p2Model != null) {
if (p2Model != null)
{
model.Parent1Name = p2Model.Name;
model.Parent2Name = p1Model.Name;//黄媛媛要求 1表示1级 2表示2级
}
......@@ -1337,7 +1375,7 @@ namespace Mall.Module.Product
/// <param name="tid"></param>
/// <param name="mid"></param>
/// <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 list = product_CategoryRepository.GetList(new RB_Product_Category_Extend() { RootId = model.RootId, TenantId = tid, MallBaseId = mid });
......@@ -1346,6 +1384,16 @@ namespace Mall.Module.Product
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>
......@@ -1357,7 +1405,8 @@ namespace Mall.Module.Product
List<RB_Product_Category_Extend> RList = new List<RB_Product_Category_Extend>();
var list2 = list.Where(x => x.ParentId == id).ToList();
RList.AddRange(list2);
foreach (var item in list2) {
foreach (var item in list2)
{
RList.AddRange(GetProductCategoryALLChild(list, item.Id));
}
return RList;
......@@ -1396,7 +1445,8 @@ namespace Mall.Module.Product
{ nameof(RB_Product_Category.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
new WhereHelper()
{
FiledName=nameof(RB_Product_Category.Id),
FiledValue=cmodel.Id,
OperatorEnum=OperatorEnum.Equal
......@@ -1447,9 +1497,11 @@ namespace Mall.Module.Product
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);
foreach (var item in list) {
foreach (var item in list)
{
item.SpecList = new List<string>();
if (!string.IsNullOrEmpty(item.Content)) {
if (!string.IsNullOrEmpty(item.Content))
{
item.SpecList = JsonConvert.DeserializeObject<List<string>>(item.Content);
}
}
......@@ -1498,7 +1550,8 @@ namespace Mall.Module.Product
};
return product_SpecificationRepository.Update(keyValues, wheres);
}
else {
else
{
return product_SpecificationRepository.Insert(demodel) > 0;
}
}
......@@ -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)
{
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));
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 });
}
foreach (var item in list) {
foreach (var item in list)
{
item.IconPath = mlist.Where(x => x.Id == item.Icon).FirstOrDefault()?.Path ?? "";
}
}
......@@ -1619,8 +1675,10 @@ namespace Mall.Module.Product
OperatorEnum=OperatorEnum.Equal
}
};
if (id > 0) {
wheres.Add(new WhereHelper() {
if (id > 0)
{
wheres.Add(new WhereHelper()
{
FiledName = nameof(RB_Product_QuickBuy.Id),
FiledValue = id,
OperatorEnum = OperatorEnum.NotEqual
......@@ -1662,7 +1720,8 @@ namespace Mall.Module.Product
};
return product_QuickBuyRepository.Update(keyValues, wheres);
}
else {
else
{
return product_QuickBuyRepository.Insert(demodel) > 0;
}
}
......@@ -1712,11 +1771,13 @@ namespace Mall.Module.Product
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();
if (model == null) {
if (model == null)
{
return new RB_Product_Recommend_Extend();
}
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 });
foreach (var item in glist)
......@@ -1729,7 +1790,8 @@ namespace Mall.Module.Product
item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? "";
}
}
foreach (var item in glist) {
foreach (var item in glist)
{
model.OrderProductList.Add(new RB_ProductRecommendModel()
{
Id = item.Id,
......@@ -1739,7 +1801,8 @@ namespace Mall.Module.Product
}
}
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 });
foreach (var item in glist)
{
......@@ -1793,7 +1856,8 @@ namespace Mall.Module.Product
};
return product_RecommendRepository.Update(keyValues, wheres);
}
else {
else
{
return product_RecommendRepository.Insert(demodel) > 0;
}
}
......@@ -1845,7 +1909,8 @@ namespace Mall.Module.Product
if (demodel.UpdateType == 1)
{ //只更新默认状态
var model = product_ServiceRepository.GetEntity(demodel.Id);
if (model == null) {
if (model == null)
{
return false;
}
keyValues = new Dictionary<string, object>()
......@@ -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)
{
var list = goodsRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) {
if (list.Any())
{
//查询分类
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 });
foreach (var item in list) {
foreach (var item in list)
{
item.CategoryList = clist.Where(x => x.GoodsId == item.Id).ToList();
//轮播图
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);
//封面图
item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? "";
......@@ -2055,13 +2123,15 @@ namespace Mall.Module.Product
}
};
bool flag = goodsRepository.Update(keyValues, wheres, trans);
if (flag) {
if (flag)
{
#region 修改分类
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 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();
foreach (var item in insertList) {
foreach (var item in insertList)
{
goods_CategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item.CategoryId,
......@@ -2073,7 +2143,8 @@ namespace Mall.Module.Product
TenantId = demodel.TenantId
}, trans);
}
foreach (var item in deleteList) {
foreach (var item in deleteList)
{
goods_CategoryRepository.Delete(item.Id, trans);
}
#endregion
......@@ -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 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();
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_Specification.EnabledImage),supmodel.EnabledImage},
......@@ -2162,7 +2234,8 @@ namespace Mall.Module.Product
}
};
bool flag1 = goods_SpecificationRepository.Update(keyValues1, wheres1, trans);
if (flag1) {
if (flag1)
{
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())
{
......@@ -2184,7 +2257,8 @@ namespace Mall.Module.Product
}, trans);
}
}
else {
else
{
foreach (var qitem in sv2list)
{
var supModel1 = supmodel.SpecificationValueList.Where(x => x.Id == qitem.Id).FirstOrDefault();
......@@ -2228,8 +2302,10 @@ namespace Mall.Module.Product
}, trans);
}
}
else {
foreach (var item in splist) {
else
{
foreach (var item in splist)
{
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)
{
......@@ -2280,7 +2356,8 @@ namespace Mall.Module.Product
#endregion
//修改卡卷
#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 });
if (dclist.Count() != demodel.DistributionCommissionList.Count()
......@@ -2335,7 +2412,8 @@ namespace Mall.Module.Product
}
#endregion
#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 });
if (mplist.Count() != demodel.MemberPriceList.Count()
|| mplist.Count() != demodel.MemberPriceList.Where(x => mplist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count()
......@@ -2386,12 +2464,15 @@ namespace Mall.Module.Product
#endregion
}
}
else {
else
{
int Id = goodsRepository.Insert(demodel, trans);
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()
{
CategoryId = item.CategoryId,
......@@ -2404,9 +2485,11 @@ namespace Mall.Module.Product
}, trans);
}
//插入规格
if (demodel.IsCustomSpecification == 1) {
foreach (var item in demodel.SpecificationList) {
int sid= goods_SpecificationRepository.Insert(new RB_Goods_Specification()
if (demodel.IsCustomSpecification == 1)
{
foreach (var item in demodel.SpecificationList)
{
int sid = goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{
CreateDate = demodel.CreateDate,
EnabledImage = item.EnabledImage,
......@@ -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()
{
CreateDate = demodel.CreateDate,
......@@ -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()
{
AreaId = item.AreaId,
......@@ -2472,7 +2557,8 @@ namespace Mall.Module.Product
}
//插入卡卷
//插入分销佣金
if (demodel.SeparateDistribution == 1) {
if (demodel.SeparateDistribution == 1)
{
foreach (var item in demodel.DistributionCommissionList)
{
goods_DistributionCommissionRepository.Insert(new RB_Goods_DistributionCommission()
......@@ -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)
{
goods_MemberPriceRepository.Insert(new RB_Goods_MemberPrice()
......@@ -2529,32 +2616,39 @@ namespace Mall.Module.Product
/// </summary>
/// <param name="goodsId"></param>
/// <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>();
if (model == null || model.TenantId != TenantId || model.MallBaseId != MallBaseId){
if (model == null || model.TenantId != TenantId || model.MallBaseId != MallBaseId)
{
return null;
}
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.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 });
if (model.SpecificationList.Any()) {
if (model.SpecificationList.Any())
{
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());
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 ?? "";
}
}
foreach (var item in model.SpecificationList) {
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 });
foreach (var item in model.SpecificationPriceList) {
foreach (var item in model.SpecificationPriceList)
{
if (!string.IsNullOrEmpty(item.SpecificationSort))
{
var ssarr = item.SpecificationSort.Split(':');
......@@ -2578,17 +2672,21 @@ namespace Mall.Module.Product
}
}
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.DistributionCommissionList = 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 });
if (model.DistributionCommissionList.Any()) {
if (model.DistributionCommissionList.Any())
{
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();
treemodel.GradeCommissionList = model.DistributionCommissionList.Where(x => (x.SpecificationSort ?? "") == qitem).ToList();
if (model.SeparateDistributionType == 2)
......@@ -2620,7 +2718,8 @@ namespace Mall.Module.Product
}
model.MemberPriceList = 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 });
if (model.MemberPriceList.Any())
{
......@@ -2659,7 +2758,8 @@ namespace Mall.Module.Product
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 });
foreach (var item in CarouselIdList) {
foreach (var item in CarouselIdList)
{
var cmodel = mlist.Where(x => x.Id == item).FirstOrDefault();
model.CarouselImageList.Add(new RB_ImageCommonModel()
{
......@@ -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.ServiceList = new List<RB_ImageCommonModel>();
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);
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()
{
Id = item.Id,
......@@ -2693,7 +2796,8 @@ namespace Mall.Module.Product
{
model.FreightName = logistics_RulesRepository.GetEntity(model.FreightId)?.RulesName ?? "";
}
else {
else
{
model.FreightName = "默认运费";
}
//表单
......@@ -2701,7 +2805,8 @@ namespace Mall.Module.Product
{
model.FormsName = "未建表";
}
else {
else
{
model.FormsName = "默认表单";
}
......@@ -2736,14 +2841,16 @@ namespace Mall.Module.Product
else if (type == 3)
{
var model = goodsRepository.GetEntity(goodsId);
if (model == null) {
if (model == null)
{
return false;
}
keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.IsQuickBuy),model.IsQuickBuy==1?2:1}
};
}
else {
else
{
return false;
}
List<WhereHelper> wheres = new List<WhereHelper>() {
......
......@@ -19,6 +19,7 @@ using Mall.CacheKey;
using Mall.Common.Plugin;
using Mall.Common.Enum.MallBase;
using Mall.Model.Entity.User;
using Mall.Module.Product;
namespace Mall.WebApi.Controllers.User
{
......@@ -68,6 +69,11 @@ namespace Mall.WebApi.Controllers.User
/// </summary>
private Module.User.EmployeeModule employeeModule = new Module.User.EmployeeModule();
/// <summary>
/// 产品处理类
/// </summary>
private ProductModule productModule = new ProductModule();
#region 商户信息
/// <summary>
......@@ -504,49 +510,55 @@ namespace Mall.WebApi.Controllers.User
name="常用",
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>();
catList.Add(new
{
key = "cat",
name = "所有分类",
relation_id = 0,
is_edit = 0
is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
});
catList.Add(new
{
key = "cat",
name = "赞羊严选",
relation_id = 9120,
is_edit = 0
is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
});
catList.Add(new
{
key = "cat",
name = "严选旅游",
relation_id = 10235,
is_edit = 0
is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
});
catList.Add(new
{
key = "cat",
name = "台湾严选",
relation_id = 10250,
is_edit = 0
is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
});
catList.Add(new
{
key = "cat",
name = "日韩严选",
relation_id = 10252,
is_edit = 0
is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
});
catList.Add(new
{
key = "cat",
name = "欧洲严选",
relation_id = 10253,
is_edit = 0
is_edit = 0,
imgBg = Common.Config.GetOssFileUrl + "/Static/cat-bg.png"
});
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