Commit c5f20f75 authored by liudong1993's avatar liudong1993

商品管理

parent 1eb51310
using Mall.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mall.Common.Enum.Goods
{
/// <summary>
/// 司导商品类型枚举
/// </summary>
public enum GuideCarGoodsTypeEnum
{
/// <summary>
/// 接机
/// </summary>
[EnumField("接机")]
JJ = 1,
/// <summary>
/// 送机
/// </summary>
[EnumField("送机")]
SJ = 2,
/// <summary>
/// 市区
/// </summary>
[EnumField("市区")]
SQ = 3,
/// <summary>
/// 周边
/// </summary>
[EnumField("周边")]
ZB = 4,
/// <summary>
/// 线路用车
/// </summary>
[EnumField("线路用车")]
Line = 5
}
}
...@@ -459,5 +459,61 @@ namespace Mall.Model.Entity.Product ...@@ -459,5 +459,61 @@ namespace Mall.Model.Entity.Product
/// 发货地 /// 发货地
/// </summary> /// </summary>
public string SendArea { get; set; } public string SendArea { get; set; }
/// <summary>
/// 商品分类 0正常商品 1司导商品
/// </summary>
public int GoodsClassify { get; set; }
/// <summary>
/// 站点id
/// </summary>
public int? SiteId { get; set; }
/// <summary>
/// 导游id
/// </summary>
public int? GuideId { get; set; }
/// <summary>
/// 车辆id
/// </summary>
public int? CarId { get; set; }
/// <summary>
/// 车颜色id
/// </summary>
public int? CarColorId { get; set; }
/// <summary>
/// 车牌号
/// </summary>
public string CarNumber { get; set; }
/// <summary>
/// 车购买年份
/// </summary>
public string CarBuyYear { get; set; }
/// <summary>
/// 服务类型 枚举
/// </summary>
public GuideCarGoodsTypeEnum? CarType { get; set; }
/// <summary>
/// 使用日期 天
/// </summary>
public decimal? UserDay { get; set; }
/// <summary>
/// 线路名称
/// </summary>
public string LineName { get; set; }
/// <summary>
/// 关联城市或景点
/// </summary>
public string LineDescription { get; set; }
/// <summary>
/// 是否拼座 1是 2否
/// </summary>
public int? IsSpell { get; set; }
/// <summary>
/// 乘坐人数
/// </summary>
public int? RideNum { get; set; }
/// <summary>
/// 提前预定时间
/// </summary>
public int? AdvanceDay { get; set; }
} }
} }
using VT.FW.DB;
using Mall.Common.Enum.Goods;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 司导可预定实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_TargetDate
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int GoodsId
{
get;
set;
}
/// <summary>
/// 可预定日期
/// </summary>
public DateTime? Date { get; set; }
}
}
...@@ -15,6 +15,14 @@ namespace Mall.Model.Extend.Product ...@@ -15,6 +15,14 @@ namespace Mall.Model.Extend.Product
[DB(ConnectionName = "DefaultConnection")] [DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Extend : RB_Goods public class RB_Goods_Extend : RB_Goods
{ {
/// <summary>
/// 可预定日期
/// </summary>
public List<RB_Goods_TargetDate_Extend> TargetDateList { get; set; }
/// <summary>
/// 线路描述list
/// </summary>
public List<string> LineDescriptionList { get; set; }
/// <summary> /// <summary>
/// 微店id /// 微店id
/// </summary> /// </summary>
......
using VT.FW.DB;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Extend.BaseSetUp;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品可预定日期表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_TargetDate_Extend : RB_Goods_TargetDate
{
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
}
}
...@@ -46,6 +46,10 @@ namespace Mall.Module.Product ...@@ -46,6 +46,10 @@ namespace Mall.Module.Product
/// </summary> /// </summary>
private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository(); private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository();
/// <summary> /// <summary>
/// 商品可预定日期
/// </summary>
private readonly RB_Goods_TargetDateRepository goods_TargetDateRepository = new RB_Goods_TargetDateRepository();
/// <summary>
/// 商品日志 /// 商品日志
/// </summary> /// </summary>
private readonly RB_Goods_LogRepository goods_LogRepository = new RB_Goods_LogRepository(); private readonly RB_Goods_LogRepository goods_LogRepository = new RB_Goods_LogRepository();
...@@ -194,7 +198,7 @@ namespace Mall.Module.Product ...@@ -194,7 +198,7 @@ namespace Mall.Module.Product
var model = guideCar_BaseRepository.GetList(new RB_GuideCar_Base_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); var model = guideCar_BaseRepository.GetList(new RB_GuideCar_Base_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
if (model == null) if (model == null)
{ {
return guideCar_BaseRepository.Insert(demodel); return guideCar_BaseRepository.Insert(demodel) > 0;
} }
else { else {
model.UpdateBy = demodel.UpdateBy; model.UpdateBy = demodel.UpdateBy;
...@@ -212,6 +216,785 @@ namespace Mall.Module.Product ...@@ -212,6 +216,785 @@ namespace Mall.Module.Product
} }
} }
/// <summary>
/// 获取会员等级列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Member_Grade_Extend> GetMemberGradeList(RB_Member_Grade_Extend dmodel)
{
var list = member_GradeRepository.GetList(dmodel);
return list;
}
/// <summary>
/// 获取分销等级列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Distributor_Grade_Extend> GetDistributorGradeList(RB_Distributor_Grade_Extend demodel)
{
var list = distributor_GradeRepository.GetList(demodel);
return list;
}
#endregion
#region 商品管理
/// <summary>
/// 获取后台商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetProductGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{
var list = goodsRepository.GetPageListForCar(pageIndex, pageSize, out count, demodel);
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 });
var olist = goods_OrderRepository.GetGoodsOrderNum(ids);
foreach (var item in list)
{
item.CategoryList = clist.Where(x => x.GoodsId == item.Id).ToList();
//轮播图
item.CoverImage = "";
item.CarouselImageList = new List<RB_ImageCommonModel>();
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
//轮播图
foreach (var qitem in CarouselIdList)
{
item.CarouselImageList.Add(new RB_ImageCommonModel()
{
Id = 0,
Name = "",
Path = qitem
});
}
}
item.GoodsBuyNum = olist.Where(x => x.GoodsId == item.Id).FirstOrDefault()?.OrderNum ?? 0;
}
}
return list;
}
/// <summary>
/// 获取商品详情
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
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)
{
return null;
}
model.CategoryList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
model.AreaList = new List<RB_Goods_Area_Extend>();
if (model.IsAreaBuy == 1)
{
model.AreaList = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
}
model.DistributionCommissionList = new List<RB_Goods_DistributionCommission_Extend>();
model.DistributionCommissionTreeList = new List<RB_Goods_DistributionCommission_Extend>();
if (model.SeparateDistribution == 1)
{
model.DistributionCommissionList = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (model.DistributionCommissionList.Any())
{
int SortNum = 1;
//获取分销商启用等级
var dgradeList = distributor_GradeRepository.GetList(new RB_Distributor_Grade_Extend() { Enabled = 1, TenantId = TenantId, MallBaseId = MallBaseId });
dgradeList.Add(new RB_Distributor_Grade_Extend()
{
Grade = 0,
Name = "默认等级",
Id = 0
});
string zdgradeStr = string.Join(",", dgradeList.Select(x => x.Id).OrderBy(x => x));
string ndgradeStr = string.Join(",", model.DistributionCommissionList.Select(x => x.DistributorGrade).Distinct().OrderBy(x => x));
var KeyList = model.DistributionCommissionList.Select(x => x.SpecificationSort ?? "").Distinct().ToList();
if (zdgradeStr == ndgradeStr)
{
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)
{
if (!string.IsNullOrEmpty(qitem))
{
var ssarr = qitem.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = model.SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
List<object> AttrList = new List<object>();
for (int i = 0; i < ssarr.Length; i++)
{
var smodel = model.SpecificationList[i];
var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
AttrList.Add(new
{
SName = smodel.Name,
SId = smodel.Id,
SVId = svmodel.Sort,
SVName = svmodel.Name
});
}
treemodel.AttrList = AttrList;
}
}
treemodel.Sort = SortNum;
treemodel.GradeCommissionList = treemodel.GradeCommissionList.OrderBy(x => x.DistributorGrade).ToList();
model.DistributionCommissionTreeList.Add(treemodel);
}
}
else
{//分销商等级有变更
foreach (var qitem in KeyList)
{
var treemodel = model.DistributionCommissionList.Where(x => (x.SpecificationSort ?? "") == qitem).FirstOrDefault();
treemodel.GradeCommissionList = new List<RB_Goods_DistributionCommission_Extend>();
var gradeCommList = model.DistributionCommissionList.Where(x => (x.SpecificationSort ?? "") == qitem).ToList();
dgradeList = dgradeList.OrderByDescending(x => x.Grade).ToList();
foreach (var grade in dgradeList)
{
var gradeMList = gradeCommList.Where(x => x.DistributorGrade == grade.Id && x.SpecificationSort == qitem);
if (gradeMList.Any())
{
treemodel.GradeCommissionList.AddRange(gradeMList);
}
else
{
//表示新的
treemodel.GradeCommissionList.Add(new RB_Goods_DistributionCommission_Extend()
{
DistributorGrade = grade.Id,
OneCommission = 0,
TwoCommission = 0,
ThreeCommission = 0
});
}
}
if (model.SeparateDistributionType == 2)
{
if (!string.IsNullOrEmpty(qitem))
{
var ssarr = qitem.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = model.SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
List<object> AttrList = new List<object>();
for (int i = 0; i < ssarr.Length; i++)
{
var smodel = model.SpecificationList[i];
var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
AttrList.Add(new
{
SName = smodel.Name,
SId = smodel.Id,
SVId = svmodel.Sort,
SVName = svmodel.Name
});
}
treemodel.AttrList = AttrList;
}
}
treemodel.Sort = SortNum;
treemodel.GradeCommissionList = treemodel.GradeCommissionList.OrderBy(x => x.DistributorGrade).ToList();
model.DistributionCommissionTreeList.Add(treemodel);
}
}
SortNum++;
if (model.DistributionCommissionTreeList.Any())
{
//倒序排一次
model.DistributionCommissionTreeList = model.DistributionCommissionTreeList.OrderByDescending(x => x.Sort).ToList();
}
}
}
model.MemberPriceList = new List<RB_Goods_MemberPrice_Extend>();
model.MemberPriceTreeList = new List<RB_Goods_MemberPrice_Extend>();
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1)
{
model.MemberPriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
if (model.MemberPriceList.Any())
{
int SortNum = 1;
var mgradeList = member_GradeRepository.GetList(new RB_Member_Grade_Extend() { Enabled = 1, TenantId = 1, MallBaseId = 1 });
string zdgradeStr = string.Join(",", mgradeList.Select(x => x.Id).OrderBy(x => x));
string ndgradeStr = string.Join(",", model.MemberPriceList.Select(x => x.MemberGrade).Distinct().OrderBy(x => x));
if (zdgradeStr == ndgradeStr)
{
var KeyList = model.MemberPriceList.Select(x => x.SpecificationSort ?? "").Distinct().ToList();
foreach (var qitem in KeyList)
{
var treemodel = model.MemberPriceList.Where(x => (x.SpecificationSort ?? "") == qitem).FirstOrDefault();
treemodel.GradePriceList = model.MemberPriceList.Where(x => (x.SpecificationSort ?? "") == qitem).ToList();
if (!string.IsNullOrEmpty(qitem))
{
var ssarr = qitem.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = model.SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
List<object> AttrList = new List<object>();
for (int i = 0; i < ssarr.Length; i++)
{
var smodel = model.SpecificationList[i];
var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
AttrList.Add(new
{
SName = smodel.Name,
SId = smodel.Id,
SVId = svmodel.Sort,
SVName = svmodel.Name
});
}
treemodel.AttrList = AttrList;
}
treemodel.Sort = SortNum;
treemodel.GradePriceList = treemodel.GradePriceList.OrderBy(x => x.MemberGrade).ToList();
model.MemberPriceTreeList.Add(treemodel);
}
}
else
{//会员等级有变更
var KeyList = model.MemberPriceList.Select(x => x.SpecificationSort ?? "").Distinct().ToList();
foreach (var qitem in KeyList)
{
var treemodel = model.MemberPriceList.Where(x => (x.SpecificationSort ?? "") == qitem).FirstOrDefault();
//treemodel.GradePriceList = model.MemberPriceList.Where(x => (x.SpecificationSort ?? "") == qitem).ToList();
treemodel.GradePriceList = new List<RB_Goods_MemberPrice_Extend>() { };
var gradePrice = model.MemberPriceList.Where(x => (x.SpecificationSort ?? "") == qitem).ToList();
mgradeList = mgradeList.OrderByDescending(x => x.Grade).ToList();
foreach (var grade in mgradeList)
{
var gradeMList = gradePrice.Where(x => x.MemberGrade == grade.Id && x.SpecificationSort == qitem);
if (gradeMList.Any())
{
treemodel.GradePriceList.AddRange(gradeMList);
}
else
{
//表示新的
treemodel.GradePriceList.Add(new RB_Goods_MemberPrice_Extend()
{
MemberGrade = grade.Id,
MemberPrice = 0,
});
}
}
if (!string.IsNullOrEmpty(qitem))
{
var ssarr = qitem.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = model.SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
List<object> AttrList = new List<object>();
for (int i = 0; i < ssarr.Length; i++)
{
var smodel = model.SpecificationList[i];
var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
AttrList.Add(new
{
SName = smodel.Name,
SId = smodel.Id,
SVId = svmodel.Sort,
SVName = svmodel.Name
});
}
treemodel.AttrList = AttrList;
}
treemodel.Sort = SortNum;
treemodel.GradePriceList = treemodel.GradePriceList.OrderBy(x => x.MemberGrade).ToList();
model.MemberPriceTreeList.Add(treemodel);
}
}
SortNum++;
if (model.MemberPriceTreeList.Any())
{
//倒序排一次
model.MemberPriceTreeList = model.MemberPriceTreeList.OrderByDescending(x => x.Sort).ToList();
}
}
}
model.CarouselImageList = new List<RB_ImageCommonModel>();
if (!string.IsNullOrEmpty(model.CarouselImage) && model.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(model.CarouselImage);
//轮播图
foreach (var item in CarouselIdList)
{
model.CarouselImageList.Add(new RB_ImageCommonModel()
{
Id = 0,
Name = "",
Path = item
});
}
}
model.CustomShareImagePath = model.CustomShareImage;
#region 可预定日期
model.TargetDateList = goods_TargetDateRepository.GetList(new RB_Goods_TargetDate_Extend() { GoodsId = goodsId });
#endregion
if (!string.IsNullOrEmpty(model.LineDescription) && model.LineDescription != "[]") {
model.LineDescriptionList = JsonConvert.DeserializeObject<List<string>>(model.LineDescription);
}
return model;
}
/// <summary>
/// 新增修改商品信息
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool SetProductGoodsInfo(RB_Goods_Extend demodel)
{
var goodsModel = new RB_Goods();
if (demodel.Id > 0)
{
goodsModel = goodsRepository.GetEntity(demodel.Id);
if (goodsModel == null)
{
return false;
}
}
try
{
if (demodel.Id > 0)
{
//修改
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Name),demodel.Name},
{ nameof(RB_Goods.CarouselImage),demodel.CarouselImage},
{ nameof(RB_Goods.VideoAddress),demodel.VideoAddress},
{ nameof(RB_Goods.CustomShareTitles),demodel.CustomShareTitles},
{ nameof(RB_Goods.CustomShareImage),demodel.CustomShareImage},
{ nameof(RB_Goods.GoodsStatus),demodel.GoodsStatus},
{ nameof(RB_Goods.InventoryNum),demodel.InventoryNum},
{ nameof(RB_Goods.DefaultSpecificationName),demodel.DefaultSpecificationName},
{ nameof(RB_Goods.IsCustomSpecification),demodel.IsCustomSpecification},
{ nameof(RB_Goods.Sort),demodel.Sort},
{ nameof(RB_Goods.SellingPrice),demodel.SellingPrice},
{ nameof(RB_Goods.OriginalPrice),demodel.OriginalPrice},
{ nameof(RB_Goods.Unit),demodel.Unit},
{ nameof(RB_Goods.CostPrice),demodel.CostPrice},
{ nameof(RB_Goods.IsGoodsNegotiable),demodel.IsGoodsNegotiable},
{ nameof(RB_Goods.SalesNum),demodel.SalesNum},
{ nameof(RB_Goods.GoodsNumbers),demodel.GoodsNumbers},
{ nameof(RB_Goods.GoodsWeight),demodel.GoodsWeight},
{ nameof(RB_Goods.IsDefaultService),demodel.IsDefaultService},
{ nameof(RB_Goods.GoodsService),demodel.GoodsService},
{ nameof(RB_Goods.FreightId),demodel.FreightId},
{ nameof(RB_Goods.FormsId),demodel.FormsId},
{ nameof(RB_Goods.LimitBuyGoodsNum),demodel.LimitBuyGoodsNum},
{ nameof(RB_Goods.LimitBuyOrderNum),demodel.LimitBuyOrderNum},
{ nameof(RB_Goods.FullNumPinkage),demodel.FullNumPinkage},
{ nameof(RB_Goods.FullMoneyPinkage),demodel.FullMoneyPinkage},
{ nameof(RB_Goods.IsAreaBuy),demodel.IsAreaBuy},
{ nameof(RB_Goods.IntegralPresent),demodel.IntegralPresent},
{ nameof(RB_Goods.IntegralPresentType),demodel.IntegralPresentType},
{ nameof(RB_Goods.PointsDeduction),demodel.PointsDeduction},
{ nameof(RB_Goods.PointsDeductionType),demodel.PointsDeductionType},
{ nameof(RB_Goods.IsMultipleDeduction),demodel.IsMultipleDeduction},
{ nameof(RB_Goods.GoodsDetails),demodel.GoodsDetails},
{ nameof(RB_Goods.UpdateDate),demodel.UpdateDate},
{ nameof(RB_Goods.SeparateDistribution),demodel.SeparateDistribution},
{ nameof(RB_Goods.SeparateDistributionType),demodel.SeparateDistributionType},
{ nameof(RB_Goods.SeparateDistributionMoneyType),demodel.SeparateDistributionMoneyType},
{ nameof(RB_Goods.EnjoyMember),demodel.EnjoyMember},
{ nameof(RB_Goods.SeparateSetMember),demodel.SeparateSetMember},
{ nameof(RB_Goods.IsQuickBuy),demodel.IsQuickBuy},
{ nameof(RB_Goods.SupplierId),demodel.SupplierId},
{ nameof(RB_Goods.IsProxy),demodel.IsProxy},
{ nameof(RB_Goods.ProxyType),demodel.ProxyType},
{ nameof(RB_Goods.ProxyRises),demodel.ProxyRises},
{ nameof(RB_Goods.ProxyMoney),demodel.ProxyMoney},
{ nameof(RB_Goods.Commission),demodel.Commission},
{ nameof(RB_Goods.PresentFXGrade),demodel.PresentFXGrade},
{ nameof(RB_Goods.PresentFXMonth),demodel.PresentFXMonth},
{ nameof(RB_Goods.Advertising),demodel.Advertising},
{ nameof(RB_Goods.SubName),demodel.SubName},
{ nameof(RB_Goods.MarketingLogo),demodel.MarketingLogo},
{ nameof(RB_Goods.IsLiveGoods),demodel.IsLiveGoods},
{ nameof(RB_Goods.ShelvesDate),demodel.ShelvesDate },
{ nameof(RB_Goods.DownDate),demodel.DownDate },
{ nameof(RB_Goods.SendArea),demodel.SendArea },
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=demodel.Id,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.TenantId),
FiledValue=demodel.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.MallBaseId),
FiledValue=demodel.MallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = goodsRepository.Update(keyValues, wheres);
if (flag)
{
#region 修改可预定日期
var tdlist = goods_TargetDateRepository.GetList(new RB_Goods_TargetDate_Extend() { GoodsId = demodel.Id });
var tdinsertList = demodel.TargetDateList.Where(x => !tdlist.Select(y => y.Date).Contains(x.Date)).ToList();
var tddeleteList = tdlist.Where(x => !demodel.TargetDateList.Select(y => y.Date).Contains(x.Date)).ToList();
foreach (var item in tdinsertList) {
goods_TargetDateRepository.Insert(new RB_Goods_TargetDate()
{
Id = 0,
GoodsId = demodel.Id,
Date = item.Date
});
}
foreach (var item in tddeleteList) {
goods_TargetDateRepository.Delete(item);
}
#endregion
#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 deleteList = clist.Where(x => !demodel.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
foreach (var item in insertList)
{
goods_CategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item.CategoryId,
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
});
}
foreach (var item in deleteList)
{
goods_CategoryRepository.Delete(item.Id);
}
#endregion
#region 修改区域
var alist = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var insertList1 = demodel.AreaList.Where(x => !alist.Select(y => y.AreaId).Contains(x.AreaId)).ToList();
var deleteList1 = alist.Where(x => !demodel.AreaList.Select(y => y.AreaId).Contains(x.AreaId)).ToList();
foreach (var item in insertList1)
{
goods_AreaRepository.Insert(new RB_Goods_Area()
{
AreaId = item.AreaId,
AreaType = item.AreaType,
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
});
}
foreach (var item in deleteList1)
{
goods_AreaRepository.Delete(item.Id);
}
#endregion
#region 修改分销佣金
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()
|| 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() != dclist.Select(x => x.DistributorGrade).Distinct().Where(x => demodel.DistributionCommissionList.Select(y => y.DistributorGrade).Distinct().Contains(x)).Count())
{
goods_DistributionCommissionRepository.DeleteBatch(dclist);
foreach (var item in demodel.DistributionCommissionList)
{
goods_DistributionCommissionRepository.Insert(new RB_Goods_DistributionCommission()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
DistributorGrade = item.DistributorGrade,
OneCommission = item.OneCommission,
ThreeCommission = item.ThreeCommission,
TwoCommission = item.TwoCommission,
MallBaseId = demodel.MallBaseId,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
});
}
}
else
{
foreach (var item in dclist)
{
var pupmodel = demodel.DistributionCommissionList.Where(x => x.SpecificationSort == item.SpecificationSort && x.DistributorGrade == item.DistributorGrade).FirstOrDefault();
if (item.OneCommission != pupmodel.OneCommission || item.TwoCommission != pupmodel.TwoCommission || item.ThreeCommission != pupmodel.ThreeCommission)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_DistributionCommission.OneCommission),pupmodel.OneCommission},
{ nameof(RB_Goods_DistributionCommission.TwoCommission),pupmodel.TwoCommission},
{ nameof(RB_Goods_DistributionCommission.ThreeCommission),pupmodel.ThreeCommission}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_DistributionCommission.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_DistributionCommissionRepository.Update(keyValues1, wheres1);
}
}
}
}
#endregion
#region 修改会员价格
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()
|| mplist.Select(x => x.MemberGrade).Distinct().Count() != demodel.MemberPriceList.Select(x => x.MemberGrade).Distinct().Count()
|| mplist.Select(x => x.MemberGrade).Distinct().Count() != mplist.Select(x => x.MemberGrade).Distinct().Where(x => demodel.MemberPriceList.Select(y => y.MemberGrade).Distinct().Contains(x)).Count())
{
goods_MemberPriceRepository.DeleteBatch(mplist);
foreach (var item in demodel.MemberPriceList)
{
goods_MemberPriceRepository.Insert(new RB_Goods_MemberPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
MemberGrade = item.MemberGrade,
MemberPrice = item.MemberPrice,
MallBaseId = demodel.MallBaseId,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
});
}
}
else
{
foreach (var item in mplist)
{
var pupmodel = demodel.MemberPriceList.Where(x => x.SpecificationSort == item.SpecificationSort && x.MemberGrade == item.MemberGrade).FirstOrDefault();
if (item.MemberPrice != pupmodel.MemberPrice)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_MemberPrice.MemberPrice),pupmodel.MemberPrice}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_MemberPrice.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_MemberPriceRepository.Update(keyValues1, wheres1);
}
}
}
}
#endregion
}
}
else
{
int Id = goodsRepository.Insert(demodel);
bool flag = Id > 0;
if (flag)
{
//插入可预定日期
foreach (var item in demodel.TargetDateList) {
goods_TargetDateRepository.Insert(new RB_Goods_TargetDate()
{
Id = 0,
GoodsId = Id,
Date = item.Date
});
}
//插入分类
foreach (var item in demodel.CategoryList)
{
goods_CategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item.CategoryId,
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
});
}
//插入区域
foreach (var item in demodel.AreaList)
{
goods_AreaRepository.Insert(new RB_Goods_Area()
{
AreaId = item.AreaId,
AreaType = item.AreaType,
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
});
}
//插入分销佣金
if (demodel.SeparateDistribution == 1)
{
foreach (var item in demodel.DistributionCommissionList)
{
goods_DistributionCommissionRepository.Insert(new RB_Goods_DistributionCommission()
{
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
DistributorGrade = item.DistributorGrade,
OneCommission = item.OneCommission,
ThreeCommission = item.ThreeCommission,
TwoCommission = item.TwoCommission,
MallBaseId = demodel.MallBaseId,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
});
}
}
//插入会员价格
if (demodel.EnjoyMember == 1 && demodel.SeparateSetMember == 1)
{
foreach (var item in demodel.MemberPriceList)
{
goods_MemberPriceRepository.Insert(new RB_Goods_MemberPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
MemberGrade = item.MemberGrade,
MemberPrice = item.MemberPrice,
MallBaseId = demodel.MallBaseId,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
});
}
}
}
}
return true;
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetProductGoodsInfoSD:" + Common.Plugin.JsonHelper.Serialize(demodel));
return false;
}
}
/// <summary>
/// 删除商品
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool DelProcudtGoodsInfo(int goodsId, int tenantId, int mallBaseId)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Status),1},
{ nameof(RB_Goods.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=goodsId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return goodsRepository.Update(keyValues, wheres);
}
/// <summary>
/// 设置商品上下架
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SetGoodsStatusInfo(int goodsId, int tenantId, int mallBaseId)
{
var goodsModel = goodsRepository.GetEntity(goodsId);
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.GoodsStatus),(goodsModel?.GoodsStatus??0)==1?2:1},
{ nameof(RB_Goods.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=goodsId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return goodsRepository.Update(keyValues, wheres);
}
#endregion #endregion
......
...@@ -7,7 +7,7 @@ using System.Text; ...@@ -7,7 +7,7 @@ using System.Text;
namespace Mall.Repository.GuideCar namespace Mall.Repository.GuideCar
{ {
public class RB_GuideCar_BaseRepository : BaseRepository<RB_GuideCar_Base> public class RB_GuideCar_BaseRepository : BaseRepository<RB_GuideCar_Base>
{ {
/// <summary> /// <summary>
...@@ -18,7 +18,7 @@ namespace Mall.Repository.GuideCar ...@@ -18,7 +18,7 @@ namespace Mall.Repository.GuideCar
public List<RB_GuideCar_Base_Extend> GetList(RB_GuideCar_Base_Extend dmodel) public List<RB_GuideCar_Base_Extend> GetList(RB_GuideCar_Base_Extend dmodel)
{ {
string where = $" 1=1 "; string where = $" 1=1 ";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and {nameof(RB_GuideCar_Base.TenantId)}={dmodel.TenantId}"; where += $@" and {nameof(RB_GuideCar_Base.TenantId)}={dmodel.TenantId}";
} }
......
...@@ -23,7 +23,7 @@ namespace Mall.Repository.Product ...@@ -23,7 +23,7 @@ namespace Mall.Repository.Product
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -136,7 +136,7 @@ where {where} group by g.Id order by {orderBy}"; ...@@ -136,7 +136,7 @@ where {where} group by g.Id order by {orderBy}";
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetList(RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetList(RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -200,7 +200,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc"; ...@@ -200,7 +200,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetSingleList(RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetSingleList(RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -253,7 +253,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc"; ...@@ -253,7 +253,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetSingleListForGoodsId(RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetSingleListForGoodsId(RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -306,7 +306,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc"; ...@@ -306,7 +306,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetSingleListForGoodsSubName(RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetSingleListForGoodsSubName(RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -362,7 +362,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc"; ...@@ -362,7 +362,7 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetAppletGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetAppletGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -489,7 +489,7 @@ WHERE {where} group by g.Id {orderBy}"; ...@@ -489,7 +489,7 @@ WHERE {where} group by g.Id {orderBy}";
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetMemberCollectGoodsPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetMemberCollectGoodsPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and col.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and col.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
where += $" and col.Type=1 and col.UserId={dmodel.UserId} and g.{nameof(RB_Goods_Extend.Status)}=0 and g.{nameof(RB_Goods_Extend.GoodsStatus)}=1"; where += $" and col.Type=1 and col.UserId={dmodel.UserId} and g.{nameof(RB_Goods_Extend.Status)}=0 and g.{nameof(RB_Goods_Extend.GoodsStatus)}=1";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
...@@ -542,7 +542,7 @@ where {where} group by g.Id order by col.Id desc"; ...@@ -542,7 +542,7 @@ where {where} group by g.Id order by col.Id desc";
public List<RB_Goods_Extend> GetGoodsInventoryNumList(RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetGoodsInventoryNumList(RB_Goods_Extend dmodel)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -575,5 +575,242 @@ where {where} group by g.Id order by col.Id desc"; ...@@ -575,5 +575,242 @@ where {where} group by g.Id order by col.Id desc";
string sql = $@"UPDATE rb_goods SET Id={newGoodsId} WHERE Id={oldGoodsId}"; string sql = $@"UPDATE rb_goods SET Id={newGoodsId} WHERE Id={oldGoodsId}";
return Execute(sql, trans) > 0; return Execute(sql, trans) > 0;
} }
#region 司导商品
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Extend> GetPageListForCar(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel)
{
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=1";
if (dmodel.TenantId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.NotTenantId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}<>{dmodel.NotTenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (dmodel.GoodsStatus > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1)
{
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.CategoryIds))
{
where += $@" and c.{nameof(RB_Goods_Category.CategoryId)} in({dmodel.CategoryIds})";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
if (dmodel.IsProcurement > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.IsProcurement)}={dmodel.IsProcurement}";
}
if (dmodel.IsProxy > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.IsProxy)}={dmodel.IsProxy}";
}
if (dmodel.SupplierId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.SupplierId)}={dmodel.SupplierId}";
}
string orderBy = " g.CreateDate desc";
if (dmodel.OrderBy == 1)
{
//id升序
orderBy = " g.Id asc";
}
else if (dmodel.OrderBy == 2)
{
//id降序
orderBy = " g.Id desc";
}
else if (dmodel.OrderBy == 3)
{
//排序升序
orderBy = " g.Sort asc";
}
else if (dmodel.OrderBy == 4)
{
//排序降序
orderBy = " g.Sort desc";
}
else if (dmodel.OrderBy == 5)
{
//售价升序
orderBy = " g.SellingPrice asc";
}
else if (dmodel.OrderBy == 6)
{
//售价降序
orderBy = " g.SellingPrice desc";
}
else if (dmodel.OrderBy == 7)
{
//库存升序
orderBy = " g.InventoryNum asc";
}
else if (dmodel.OrderBy == 8)
{
//库存降序
orderBy = " g.InventoryNum desc";
}
string sql = $@"select g.* from RB_Goods g
inner join rb_goods_category c on g.Id=c.GoodsId
where {where} group by g.Id order by {orderBy}";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetListForCar(RB_Goods_Extend dmodel)
{
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=1";
if (dmodel.TenantId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (dmodel.GoodsStatus > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1)
{
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.CategoryIds))
{
where += $@" and c.{nameof(RB_Goods_Category.CategoryId)} in({dmodel.CategoryIds})";
}
if (!string.IsNullOrEmpty(dmodel.SupplierIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.SupplierId)} in({dmodel.SupplierIds})";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
if (dmodel.SupplierId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.SupplierId)}={dmodel.SupplierId}";
}
string sql = $@"
SELECT g.*,C.CategoryId
FROM RB_Goods g INNER JOIN rb_goods_category c on g.Id=c.GoodsId
WHERE {where} group by g.Id order by g.CreateDate desc";
return Get<RB_Goods_Extend>(sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetSingleListForCar(RB_Goods_Extend dmodel)
{
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=1";
if (dmodel.TenantId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (!string.IsNullOrEmpty(dmodel.GoodsNameStr))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} in ({dmodel.GoodsNameStr})";
}
if (dmodel.GoodsStatus > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1)
{
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
string sql = $@"select g.* from RB_Goods g where {where}";
return Get<RB_Goods_Extend>(sql).ToList();
}
#endregion
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品可预定日期仓储层
/// </summary>
public class RB_Goods_TargetDateRepository : BaseRepository<RB_Goods_TargetDate>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_TargetDate_Extend> GetList(RB_Goods_TargetDate_Extend dmodel)
{
string where = $" 1=1 and Date >= '{DateTime.Now.ToString("yyyy-MM-dd")}'";
if (dmodel.Id > 0) {
where += $@" and {nameof(RB_Goods_TargetDate.Id)}={dmodel.Id}";
}
if (dmodel.GoodsId > 0) {
where += $@" and {nameof(RB_Goods_TargetDate.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and {nameof(RB_Goods_TargetDate.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"select * from RB_Goods_TargetDate where {where} order by Date asc";
return Get<RB_Goods_TargetDate_Extend>(sql).ToList();
}
}
}
...@@ -72,8 +72,462 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -72,8 +72,462 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed(); return ApiResult.Failed();
} }
} }
#endregion
#region 商品管理
/// <summary>
/// 商品后台分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetGoodsPageList()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
JObject parameters = JObject.Parse(RequestParm.msg.ToString());
RB_Goods_Extend demodel = new RB_Goods_Extend()
{
Name = parameters.GetStringValue("Name"),
GoodsStatus = parameters.GetInt("GoodsStatus"),
CategoryIds = parameters.GetStringValue("CategoryIds"),
Id = parameters.GetInt("Id"),
StartTime = parameters.GetStringValue("StartTime"),
EndTime = parameters.GetStringValue("EndTime"),
OrderBy = parameters.GetInt("OrderBy")
};
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
var list = guideCarModule.GetProductGoodsPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Name,
x.Sort,
x.CoverImage,
CategoryList = x.CategoryList.Select(y => new { y.Id, y.CategoryName }),
x.SellingPrice,
x.GoodsBuyNum,
x.GoodsStatus,
x.TenantId,
x.MallBaseId,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取商品详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetGoodsInfo()
{
var req = RequestParm;
JObject prams = JObject.Parse(req.msg.ToString());
int GoodsId = prams.GetInt("GoodsId", 0);
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull();
}
var model = guideCarModule.GetProductGoodsInfo(GoodsId, req.TenantId, req.MallBaseId);
return ApiResult.Success("", new
{
model?.Id,
model?.Name,
model?.CarouselImageList,
model?.VideoAddress,
model?.CustomShareTitles,
model?.CustomShareImage,
model?.GoodsStatus,
model?.Sort,
model?.SellingPrice,
model?.OriginalPrice,
model?.CostPrice,
model?.IsAreaBuy,
model?.IntegralPresent,
model?.IntegralPresentType,
model?.PointsDeduction,
model?.PointsDeductionType,
model?.IsMultipleDeduction,
model?.GoodsDetails,
model?.SeparateDistribution,
model?.SeparateDistributionType,
model?.SeparateDistributionMoneyType,
model?.EnjoyMember,
model?.SeparateSetMember,
model?.SupplierId,
model?.Commission,
model?.IsLiveGoods,
CategoryList = model?.CategoryList.Select(x => new
{
x.Id,
x.CategoryId,
x.CategoryName
}),
AreaList = model?.AreaList.Select(x => new
{
x.Id,
x.AreaId,
x.AreaName,
x.AreaType
}),
DistributionCommissionList = model?.DistributionCommissionList.Select(x => new
{
x.Id,
x.DistributorGrade,
x.OneCommission,
x.SpecificationSort,
x.ThreeCommission,
x.TwoCommission
}),
DistributionCommissionTreeList = model?.DistributionCommissionTreeList.Select(x => new
{
x.Id,
x.SpecificationSort,
x.AttrList,
GradeCommissionList = x.GradeCommissionList.Select(y => new
{
y.DistributorGrade,
y.OneCommission,
y.ThreeCommission,
y.TwoCommission
})
}),
MemberPriceList = model?.MemberPriceList.Select(x => new
{
x.Id,
x.MemberGrade,
x.MemberPrice,
x.SpecificationSort
}),
MemberPriceTreeList = model?.MemberPriceTreeList.Select(x => new
{
x.Id,
x.SpecificationSort,
x.AttrList,
GradePriceList = x.GradePriceList.Select(y => new
{
y.MemberGrade,
y.MemberPrice
})
}),
model?.Advertising,
model?.SubName,
model?.MarketingLogo,
model?.SiteId,
model?.GuideId,
model?.CarId,
model?.CarColorId,
model?.CarNumber,
model?.CarBuyYear,
model?.CarType,
CarTypeName = model?.CarType.GetEnumName(),
model?.UserDay,
model?.LineName,
model?.LineDescriptionList,
model?.IsSpell,
model?.RideNum,
model?.AdvanceDay,
model?.TargetDateList
});
}
/// <summary>
/// 新增修改商品信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetGoodsInfo()
{
var parms = RequestParm;
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(parms.msg.ToString());
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
if (string.IsNullOrEmpty(demodel.Name))
{
return ApiResult.ParamIsNull("请输入商品名称");
}
if (demodel.CarouselImageList == null || !demodel.CarouselImageList.Any())
{
return ApiResult.ParamIsNull("请添加商品轮播图");
}
demodel.CarouselImage = JsonConvert.SerializeObject(demodel.CarouselImageList.Select(x => x.Path));
if ((demodel.SellingPrice ?? 0) < 0)
{
return ApiResult.ParamIsNull("请输入售价");
}
if ((demodel.OriginalPrice ?? 0) <= 0)
{
return ApiResult.ParamIsNull("请输入原价");
}
#region 司导项验证
if ((demodel.SiteId ?? 0) <= 0) {
return ApiResult.ParamIsNull("请选择站点");
}
if ((demodel.GuideId ?? 0) <= 0) {
return ApiResult.ParamIsNull("请选择导游");
}
if ((demodel.CarId ?? 0) <= 0) {
return ApiResult.ParamIsNull("请选择车辆信息");
}
if ((demodel.CarColorId ?? 0) <= 0) {
return ApiResult.ParamIsNull("请选择车辆颜色");
}
if (string.IsNullOrEmpty(demodel.CarNumber)) {
return ApiResult.ParamIsNull("请输入车牌号");
}
if (string.IsNullOrEmpty(demodel.CarBuyYear)) {
return ApiResult.ParamIsNull("请输入车辆购买年限");
}
if ((demodel.CarType ?? 0) <= 0) {
return ApiResult.ParamIsNull("请选择服务类型");
}
if (demodel.CarType == Common.Enum.Goods.GuideCarGoodsTypeEnum.SQ || demodel.CarType == Common.Enum.Goods.GuideCarGoodsTypeEnum.ZB || demodel.CarType == Common.Enum.Goods.GuideCarGoodsTypeEnum.Line) {
if ((demodel.UserDay ?? 0) <= 0) {
return ApiResult.ParamIsNull("请输入使用时间");
}
if (demodel.CarType == Common.Enum.Goods.GuideCarGoodsTypeEnum.Line) {
if (string.IsNullOrEmpty(demodel.LineName)) {
return ApiResult.ParamIsNull("请输入线路名称");
}
demodel.LineDescription = "";
if (demodel.LineDescriptionList != null && demodel.LineDescriptionList.Any()) {
demodel.LineDescription = JsonConvert.SerializeObject(demodel.LineDescriptionList);
}
}
}
if ((demodel.RideNum ?? 0) <= 0) {
return ApiResult.ParamIsNull("请输入可乘坐人数");
}
demodel.IsSpell ??= 1;
demodel.AdvanceDay ??= 0;
#endregion
demodel.IsCustomSpecification ??= 2;
demodel.InventoryNum ??= 0;
List<Model.Extend.User.RB_Distributor_Grade_Extend> DGradeList = null;
List<Model.Extend.User.RB_Member_Grade_Extend> MGradeList = null;
#region 默认值
demodel.VideoAddress ??= "";
demodel.CustomShareTitles ??= "";
demodel.CustomShareImage ??= "";
demodel.GoodsStatus ??= 2;
demodel.DefaultSpecificationName ??= "";
demodel.Sort ??= 0;
demodel.CostPrice ??= 0;
demodel.IsGoodsNegotiable ??= 2;
demodel.SalesNum ??= 0;
demodel.GoodsNumbers ??= "";
demodel.GoodsWeight ??= 0;
demodel.IsDefaultService ??= 1;
if (demodel.IsDefaultService == 2)
{
if (demodel.ServiceList == null || !demodel.ServiceList.Any())
{
return ApiResult.ParamIsNull("请选择商品服务");
}
demodel.GoodsService = JsonConvert.SerializeObject(demodel.ServiceList.Select(x => x.Id));
}
else
{
demodel.GoodsService = "[]";
}
demodel.FreightId ??= 0;
demodel.FormsId ??= 0;
demodel.LimitBuyGoodsNum ??= -1;
demodel.LimitBuyOrderNum ??= -1;
demodel.FullNumPinkage ??= 0;
demodel.FullMoneyPinkage ??= 0;
demodel.IsAreaBuy ??= 2;
if (demodel.IsAreaBuy == 1)
{
if (demodel.AreaList == null || !demodel.AreaList.Any())
{
return ApiResult.ParamIsNull("请选择区域");
}
}
demodel.IntegralPresent ??= 0;
demodel.IntegralPresentType ??= 1;
demodel.PointsDeduction ??= 0;
demodel.PointsDeductionType ??= 1;
demodel.IsMultipleDeduction ??= 2;
demodel.Status = 0;
demodel.CreateDate = DateTime.Now;
demodel.UpdateDate = DateTime.Now;
#endregion
demodel.SeparateDistribution ??= 2;
demodel.SeparateDistributionType ??= 1;
if (demodel.SeparateDistribution == 1)
{
//获取所有分销商等级
if (DGradeList == null)
{
DGradeList = guideCarModule.GetDistributorGradeList(new Model.Extend.User.RB_Distributor_Grade_Extend() { Enabled = 1, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
DGradeList.Add(new Model.Extend.User.RB_Distributor_Grade_Extend()
{
Grade = 0,
Name = "默认等级",
Id = 0
});
}
if (demodel.SeparateDistributionType == 1)
{
if (demodel.DistributionCommissionList == null || !demodel.DistributionCommissionList.Any())
{
return ApiResult.ParamIsNull("请传递分销佣金列表");
}
//普通设置 直接根据等级验证数量
if (DGradeList.Count() != demodel.DistributionCommissionList.Count())
{
return ApiResult.ParamIsNull("分销佣金列表数量不正确");
}
foreach (var item in DGradeList)
{
var defaultModel = demodel.DistributionCommissionList.Where(x => x.DistributorGrade == item.Id).FirstOrDefault();
if (defaultModel == null)
{
return ApiResult.ParamIsNull("分销佣金" + item.Name + "不存在");
}
defaultModel.OneCommission ??= 0;
defaultModel.TwoCommission ??= 0;
defaultModel.ThreeCommission ??= 0;
defaultModel.SpecificationSort = "";
}
}
else
{
if (demodel.IsCustomSpecification != 1)
{
return ApiResult.ParamIsNull("无法开启详细设置");
}
}
}
demodel.SeparateDistributionMoneyType ??= 1;
demodel.EnjoyMember ??= 2;
demodel.SeparateSetMember ??= 2;
if (demodel.EnjoyMember == 1 && demodel.SeparateSetMember == 1)
{
//获取所有会员等级
if (MGradeList == null)
{
MGradeList = guideCarModule.GetMemberGradeList(new Model.Extend.User.RB_Member_Grade_Extend() { Enabled = 1, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
}
if (!MGradeList.Any())
{
return ApiResult.ParamIsNull("单独设置会员价需先添加会员等级");
}
if (demodel.IsCustomSpecification == 2)
{
if (demodel.MemberPriceList == null || !demodel.MemberPriceList.Any())
{
return ApiResult.ParamIsNull("请传递会员价格列表");
}
if (MGradeList.Count() != demodel.MemberPriceList.Count())
{
return ApiResult.ParamIsNull("会员价格列表数量不正确");
}
foreach (var item in MGradeList)
{
var defaultModel = demodel.MemberPriceList.Where(x => x.MemberGrade == item.Id).FirstOrDefault();
if (defaultModel == null)
{
return ApiResult.ParamIsNull("会员价格" + item.Name + "不存在");
}
defaultModel.MemberPrice ??= 0;
defaultModel.SpecificationSort = "";
}
}
}
demodel.IsQuickBuy ??= 2;
demodel.IsSellWell ??= 2;
demodel.GoodsType ??= Common.Enum.Goods.OrderTypeEnum.Mall;
demodel.GoodsStatus ??= 2;
demodel.IsProxy ??= 2;
demodel.ProxyType ??= 1;
demodel.ProxyRises ??= 0;
demodel.ProxyMoney ??= 0;
demodel.IsProcurement = 2;//新增时
demodel.PresentFXGrade ??= 0;//赠送粉象等级
demodel.PresentFXMonth ??= 0;
demodel.Advertising ??= "";//广告词
demodel.SubName ??= "";//副标题
demodel.IsLiveGoods ??= 2;//是否直播商品 1是 2否
demodel.SendArea ??= "";//发货地
bool flag = guideCarModule.SetProductGoodsInfo(demodel);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 删除商品
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult DelGoodsInfo()
{
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull();
}
bool flag = guideCarModule.DelProcudtGoodsInfo(GoodsId, req.TenantId, req.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 上下架商品
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetGoodsStatusInfo()
{
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull();
}
bool flag = guideCarModule.SetGoodsStatusInfo(GoodsId, req.TenantId, req.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion #endregion
......
...@@ -2056,6 +2056,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -2056,6 +2056,7 @@ namespace Mall.WebApi.Controllers.MallBase
demodel.SubName ??= "";//副标题 demodel.SubName ??= "";//副标题
demodel.IsLiveGoods ??= 2;//是否直播商品 1是 2否 demodel.IsLiveGoods ??= 2;//是否直播商品 1是 2否
demodel.SendArea ??= "";//发货地 demodel.SendArea ??= "";//发货地
demodel.GoodsClassify = 0;
if (demodel.IsProxy == 1 && demodel.CostPrice > 0) if (demodel.IsProxy == 1 && demodel.CostPrice > 0)
{ {
decimal ProxyMoney = 0; decimal ProxyMoney = 0;
......
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