Commit 69f5a72e authored by liudong1993's avatar liudong1993

商品采购

parent b70a9f50
......@@ -407,5 +407,9 @@ namespace Mall.Model.Entity.Product
/// 是否是采购商品 1是 2否
/// </summary>
public int? IsProcurement { get; set; }
/// <summary>
/// 采购状态 1正常 2代理下架
/// </summary>
public int? ProcurementStatus { get; set; }
}
}
......@@ -3350,21 +3350,33 @@ namespace Mall.Module.Product
/// <returns></returns>
public bool SetProductGoodsInfo(RB_Goods_Extend demodel)
{
//bool IsSyncProxy = false;
var goodsModel = new RB_Goods();
if (demodel.Id > 0) {
var goodsModel = goodsRepository.GetEntity(demodel.Id);
goodsModel = goodsRepository.GetEntity(demodel.Id);
if (goodsModel == null)
{
return false;
}
if (goodsModel.IsProcurement == 1)
{
{
//是采购的商品
if (demodel.CostPrice != goodsModel.CostPrice)
{
return false;
}
//验证 规格
}
if (demodel.IsCustomSpecification != goodsModel.IsCustomSpecification)
{
return false;
}
if (goodsModel.IsCustomSpecification == 1) {
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (splist.Count() != demodel.SpecificationPriceList.Count() || splist.Count() != demodel.SpecificationPriceList.Where(x => splist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count()) {
return false;
}
}
}
}
var trans = goodsRepository.DbTransaction;
......@@ -3420,6 +3432,44 @@ namespace Mall.Module.Product
{ nameof(RB_Goods.ProxyRises),demodel.ProxyRises},
{ nameof(RB_Goods.ProxyMoney),demodel.ProxyMoney},
};
if (goodsModel.IsProcurement == 1) {
//采购商品可修改
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.Sort),demodel.Sort},
{ nameof(RB_Goods.SellingPrice),demodel.SellingPrice},
{ nameof(RB_Goods.OriginalPrice),demodel.OriginalPrice},
{ nameof(RB_Goods.Unit),demodel.Unit},
{ nameof(RB_Goods.SalesNum),demodel.SalesNum},
{ 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}
};
}
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
......@@ -3466,134 +3516,188 @@ namespace Mall.Module.Product
#region 修改规格
if (demodel.IsCustomSpecification == 1)
{
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (slist.Count() != demodel.SpecificationList.Count() || slist.Count() != demodel.SpecificationList.Where(x => x.Id > 0).Count())
if (goodsModel.IsProcurement != 1)
{
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 });
//删除后新增
goods_SpecificationRepository.DeleteBatch(slist, trans);
goods_SpecificationValueRepository.DeleteBatch(svlist, trans);
goods_SpecificationPriceRepository.DeleteBatch(splist, trans);
foreach (var item in demodel.SpecificationList)
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (slist.Count() != demodel.SpecificationList.Count() || slist.Count() != demodel.SpecificationList.Where(x => x.Id > 0).Count())
{
int sid = goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{
CreateDate = demodel.CreateDate,
EnabledImage = item.EnabledImage,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Name = item.Name,
Sort = item.Sort,
Status = 0,
TenantId = demodel.TenantId
}, trans);
if (sid > 0)
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 });
//删除后新增
goods_SpecificationRepository.DeleteBatch(slist, trans);
goods_SpecificationValueRepository.DeleteBatch(svlist, trans);
goods_SpecificationPriceRepository.DeleteBatch(splist, trans);
foreach (var item in demodel.SpecificationList)
{
foreach (var qitem in item.SpecificationValueList)
int sid = goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{
CreateDate = demodel.CreateDate,
EnabledImage = item.EnabledImage,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Name = item.Name,
Sort = item.Sort,
Status = 0,
TenantId = demodel.TenantId
}, trans);
if (sid > 0)
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
foreach (var qitem in item.SpecificationValueList)
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = sid
}, trans);
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = sid
}, trans);
}
}
}
}
foreach (var item in demodel.SpecificationPriceList)
{
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
foreach (var item in demodel.SpecificationPriceList)
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
GoodsNumbers = item.GoodsNumbers,
GoodsWeight = item.GoodsWeight,
InventoryNum = item.InventoryNum,
MallBaseId = demodel.MallBaseId,
SellingPrice = item.SellingPrice,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
}, trans);
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
GoodsNumbers = item.GoodsNumbers,
GoodsWeight = item.GoodsWeight,
InventoryNum = item.InventoryNum,
MallBaseId = demodel.MallBaseId,
SellingPrice = item.SellingPrice,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
}, trans);
}
}
}
else
{
//更新
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)
else
{
var supmodel = demodel.SpecificationList.Where(x => x.Id == item.Id).FirstOrDefault();
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
//更新
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)
{
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},
{ nameof(RB_Goods_Specification.Name),supmodel.Name},
{ nameof(RB_Goods_Specification.Sort),supmodel.Sort}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_Specification.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag1 = goods_SpecificationRepository.Update(keyValues1, wheres1, trans);
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())
bool flag1 = goods_SpecificationRepository.Update(keyValues1, wheres1, trans);
if (flag1)
{
goods_SpecificationValueRepository.DeleteBatch(sv2list, trans);
foreach (var qitem in supmodel.SpecificationValueList)
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())
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
goods_SpecificationValueRepository.DeleteBatch(sv2list, trans);
foreach (var qitem in supmodel.SpecificationValueList)
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = item.Id
}, trans);
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = item.Id
}, trans);
}
}
}
else
{
foreach (var qitem in sv2list)
else
{
var supModel1 = supmodel.SpecificationValueList.Where(x => x.Id == qitem.Id).FirstOrDefault();
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
foreach (var qitem in sv2list)
{
var supModel1 = supmodel.SpecificationValueList.Where(x => x.Id == qitem.Id).FirstOrDefault();
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_Goods_SpecificationValue.Image),supModel1.Image},
{ nameof(RB_Goods_SpecificationValue.Name),supModel1.Name},
{ nameof(RB_Goods_SpecificationValue.Sort),supModel1.Sort}
};
List<WhereHelper> wheres2 = new List<WhereHelper>() {
List<WhereHelper> wheres2 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_Specification.Id),
FiledValue=qitem.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_SpecificationValueRepository.Update(keyValues2, wheres2, trans);
goods_SpecificationValueRepository.Update(keyValues2, wheres2, trans);
}
}
}
}
//价格新增/更新
if (splist.Count() != demodel.SpecificationPriceList.Count() || splist.Count() != demodel.SpecificationPriceList.Where(x => splist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count())
{
goods_SpecificationPriceRepository.DeleteBatch(splist, trans);
foreach (var item in demodel.SpecificationPriceList)
{
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
GoodsNumbers = item.GoodsNumbers,
GoodsWeight = item.GoodsWeight,
InventoryNum = item.InventoryNum,
MallBaseId = demodel.MallBaseId,
SellingPrice = item.SellingPrice,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
}, trans);
}
}
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)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_SpecificationPrice.SellingPrice),pupmodel.SellingPrice},
{ nameof(RB_Goods_SpecificationPrice.InventoryNum),pupmodel.InventoryNum},
{ nameof(RB_Goods_SpecificationPrice.GoodsWeight),pupmodel.GoodsWeight},
{ nameof(RB_Goods_SpecificationPrice.GoodsNumbers),pupmodel.GoodsNumbers}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_SpecificationPrice.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_SpecificationPriceRepository.Update(keyValues1, wheres1, trans);
}
}
}
}
}
else {
//只更新规格价格
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//价格新增/更新
if (splist.Count() != demodel.SpecificationPriceList.Count() || splist.Count() != demodel.SpecificationPriceList.Where(x => splist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count())
{
......@@ -3777,6 +3881,78 @@ namespace Mall.Module.Product
}
}
#endregion
#region 商品代理
//由代理 变成 非代理
if (goodsModel.IsProxy == 1 && demodel.IsProxy == 2)
{
//设置所有采购商品 下架 状态代理下架
var plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { GoodsId = demodel.Id, MallBaseId = goodsModel.MallBaseId, TenantId = goodsModel.TenantId });
string goodsIds = string.Join(",", plist.Select(x => x.ProxyGoodsId ?? 0));
var glist = goodsRepository.GetSingleListForGoodsId(new RB_Goods_Extend() { GoodsIds = goodsIds });
foreach (var item in glist)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods.GoodsStatus),2},
{ nameof(RB_Goods.ProcurementStatus),2},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goodsRepository.Update(keyValues1, wheres1);
}
}
else if (goodsModel.IsProxy == 2 && demodel.IsProxy == 1 && demodel.GoodsStatus == 1)
{
//启用代理 检测是否有已代理的 同步数据 并采购商品状态
var plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { GoodsId = demodel.Id, MallBaseId = goodsModel.MallBaseId, TenantId = goodsModel.TenantId });
string goodsIds = string.Join(",", plist.Select(x => x.ProxyGoodsId ?? 0));
var glist = goodsRepository.GetSingleListForGoodsId(new RB_Goods_Extend() { GoodsIds = goodsIds });
//同步数据
foreach (var item in glist)
{
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ 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.CostPrice),demodel.CostPrice},
{ nameof(RB_Goods.IsGoodsNegotiable),demodel.IsGoodsNegotiable},
{ nameof(RB_Goods.GoodsNumbers),demodel.GoodsNumbers},
{ nameof(RB_Goods.GoodsWeight),demodel.GoodsWeight},
{ nameof(RB_Goods.UpdateDate),demodel.UpdateDate}
};
List<WhereHelper> wheres2 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag2 = goodsRepository.Update(keyValues2, wheres2);
if (flag2) {
//检测规格更新
if (demodel.IsCustomSpecification == 1)
{
}
else {
//删除规格
}
}
}
}
else if (goodsModel.IsProxy == 1 && demodel.IsProxy == 1 && demodel.GoodsStatus == 1)
{
//修改所有采购商品 成本价格 规格
}
#endregion
}
}
else
......@@ -4514,10 +4690,11 @@ namespace Mall.Module.Product
/// 新增代理商品
/// </summary>
/// <param name="goodsId"></param>
/// <param name="categoryList"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public ApiResult SetProductGoodsProxy(int goodsId, int tenantId, int mallBaseId)
public ApiResult SetProductGoodsProxy(int goodsId, List<int> categoryList, int tenantId, int mallBaseId)
{
var plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { GoodsId = goodsId, ProxyMallBaseId = mallBaseId, ProxyTenantId = tenantId });
if (plist.Any()) {
......@@ -4597,10 +4774,24 @@ namespace Mall.Module.Product
ProxyType = 1,
ProxyRises = 0,
ProxyMoney = 0,
IsProcurement = 1
IsProcurement = 1,
ProcurementStatus = 1
}, trans);
if (Id > 0)
{
//商品分类
foreach (var item in categoryList) {
goods_CategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item,
CreateDate = DateTime.Now,
GoodsId = Id,
Id = 0,
MallBaseId = mallBaseId,
Status = 0,
TenantId = tenantId
}, trans);
}
//复制规格
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = goodsId });
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = goodsId });
......@@ -4648,6 +4839,58 @@ namespace Mall.Module.Product
}
}
/// <summary>
/// 取消商品代理
/// </summary>
/// <param name="goodsId"></param>
/// <param name="type"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool CancelGoodsProxy(int goodsId, int type, int tenantId, int mallBaseId)
{
var plist = new List<RB_Goods_Proxy_Extend>();
if (type == 1)
{
plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { GoodsId = goodsId, ProxyMallBaseId = mallBaseId, ProxyTenantId = tenantId });
}
else {
plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { ProxyGoodsId = goodsId, ProxyMallBaseId = mallBaseId, ProxyTenantId = tenantId });
}
if (!plist.Any()) {
return false;
}
var pModel = plist.FirstOrDefault();
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_Proxy.Status),1},
{ nameof(RB_Goods_Proxy.Remark),DateTime.Now.ToString("yyyy-MM-dd")+ " 取消代理"}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_Proxy.Id),
FiledValue=pModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = goods_ProxyRepository.Update(keyValues, wheres);
if (flag) {
//删除商品
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods.Status),1},
{ nameof(RB_Goods.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=pModel.ProxyGoodsId,
OperatorEnum=OperatorEnum.Equal
}
};
goodsRepository.Update(keyValues1, wheres1);
}
return flag;
}
#endregion
#region 商品导入
......
......@@ -178,6 +178,59 @@ 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> GetSingleListForGoodsId(RB_Goods_Extend dmodel)
{
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0";
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.Id from RB_Goods g where {where}";
return Get<RB_Goods_Extend>(sql).ToList();
}
/// <summary>
/// 小程序获取商品列表
/// </summary>
......
......@@ -1093,6 +1093,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.IsQuickBuy,
x.IsProxy,
x.IsProcurement,
x.ProcurementStatus,
x.GoodsStatus,
x.TenantId,
x.MallBaseId,
......@@ -1996,6 +1997,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.InventoryNum,
SalesNum = (x.SalesNum ?? 0) + (x.GoodsBuyNum ?? 0),
x.IsProcurement,
x.ProcurementStatus,
x.ProcurementGoodsId,
x.GoodsStatus,
x.TenantId,
......@@ -2014,11 +2016,42 @@ namespace Mall.WebApi.Controllers.MallBase
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
string CategoryStr = parms.GetStringValue("CategoryStr");
if (GoodsId <= 0) {
return ApiResult.ParamIsNull("请传递商品id");
}
if (string.IsNullOrEmpty(CategoryStr)) {
return ApiResult.ParamIsNull("请选择分类");
}
List<int> CategoryList = JsonConvert.DeserializeObject<List<int>>(CategoryStr);
return productModule.SetProductGoodsProxy(GoodsId, CategoryList, req.TenantId, req.MallBaseId);
}
/// <summary>
/// 取消商品代理
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult CancelGoodsProxy() {
return productModule.SetProductGoodsProxy(GoodsId, req.TenantId, req.MallBaseId);
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
int Type = parms.GetInt("Type", 1);//类型 1原商品id 2代理商品id
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull("请传递商品id");
}
bool flag = productModule.CancelGoodsProxy(GoodsId, Type, req.TenantId, req.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
#endregion
......
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