Commit f41ee42c authored by 吴春's avatar 吴春

提交代码

parent 2ef5972d
......@@ -370,6 +370,11 @@ namespace Mall.Model.Extend.Product
/// 供应商名称
/// </summary>
public string SupplierName { get; set; }
/// <summary>
/// 是否同步商品0-全部,1-是,2-否
/// </summary>
public int Isynchro { get; set; }
}
/// <summary>
......
......@@ -5253,7 +5253,7 @@ namespace Mall.Module.Product
foreach (var demodel in list)
{
int Id = goodsRepository.Insert(demodel);
flag = Id > 0;
flag = Id > 0;
if (flag)
{
//插入分类
......@@ -5328,7 +5328,7 @@ namespace Mall.Module.Product
});
}
}
}
}
......@@ -5338,7 +5338,7 @@ namespace Mall.Module.Product
LogHelper.Write(ex, "SynchroGoods:" + Common.Plugin.JsonHelper.Serialize(list));
return false;
}
return flag;
}
......@@ -6320,6 +6320,110 @@ namespace Mall.Module.Product
#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> GetSynchroPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel, int IsGetSpec = 0)
{
var list = goodsRepository.GetSynchroPageList(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);
//规格列表
List<RB_Goods_Specification_Extend> SpecificationList = new List<RB_Goods_Specification_Extend>();
//规格值
List<RB_Goods_SpecificationValue_Extend> svlist = new List<RB_Goods_SpecificationValue_Extend>();
//规格值列表
List<RB_Goods_SpecificationPrice_Extend> SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
if (IsGetSpec == 1)
{
SpecificationList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
SpecificationPriceList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
}
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;
if (IsGetSpec == 1)
{
item.SpecificationList = SpecificationList?.Where(qitem => qitem.GoodsId == item.Id)?.ToList() ?? new List<RB_Goods_Specification_Extend>();
if (item.SpecificationList != null && item.SpecificationList.Count > 0)
{
foreach (var subItem in item.SpecificationList)
{
subItem.SpecificationValueList = svlist.Where(x => x.SpecificationId == subItem.Id).ToList();
}
}
var tempPriceList = SpecificationPriceList?.Where(qitem => qitem.GoodsId == item.Id)?.ToList() ?? new List<RB_Goods_SpecificationPrice_Extend>();
int SortNum = 1;
foreach (var childItem in tempPriceList)
{
if (!string.IsNullOrEmpty(childItem.SpecificationSort))
{
var ssarr = childItem.SpecificationSort.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = item.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 = item.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
});
}
childItem.AttrList = AttrList;
}
childItem.SortNum = SortNum;
SortNum++;
}
item.SpecificationPriceList = tempPriceList.OrderByDescending(x => x.SortNum).ToList();
}
}
}
return list;
}
/// <summary>
/// 获取后台商品分页列表
/// </summary>
......
......@@ -1600,5 +1600,179 @@ where {where} group by g.Id order by col.Id desc";
#endregion
#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> GetSynchroPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel, bool IsAllClassify = false)
{
DynamicParameters parameters = new DynamicParameters();
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 ";
string sourceWhere = "";
if (dmodel.GoodsClassify == 3)
{//查询非司导商品
where += $@" and g.GoodsClassify =3";
}
else if (dmodel.GoodsClassify == 1)
{//查询非司导商品
where += $@" and g.GoodsClassify <> 1";
}
else if (IsAllClassify == false)
{
where += $@" and g.GoodsClassify=0";
}
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.RetailStore > -1)
{
where += $@" and g.{nameof(RB_Goods_Extend.RetailStore)}={dmodel.RetailStore}";
}
if (!string.IsNullOrEmpty(dmodel.StoresIds))
{
where += $@" and FIND_IN_SET('{dmodel.StoresIds}',g.{nameof(RB_Goods_Extend.StoresIds)})";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (dmodel.Isynchro > 0)
{
if (dmodel.Isynchro == 1)
{
where += $@" and synchro.{nameof(RB_Goods_Extend.Isynchro)}>0";
}
else if (dmodel.Isynchro == 2)
{
where += $@" and synchro.{nameof(RB_Goods_Extend.Isynchro)}=0";
}
}
sourceWhere = $@"and TenantId={dmodel.SourceTenantId} and MallBaseId={dmodel.SourceMallBaseId}";
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 @Name ";
parameters.Add("Name", "%" + dmodel.Name.Trim() + "%");
}
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}";
}
if (dmodel.CreateBy > -1)
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateBy)}={dmodel.CreateBy}";
}
if (dmodel.MinProfitRate > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.MinProfitRate)} <{dmodel.MinProfitRate}";
}
if (dmodel.GoodsPageType.HasValue)
{
if (dmodel.GoodsPageType == Common.Enum.Goods.GoodsPageTypeEnum.Mall)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsPageType)} in(0,1)";
}
else if (dmodel.GoodsPageType == Common.Enum.Goods.GoodsPageTypeEnum.School)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsPageType)} in(0,2)";
}
}
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 IFNULL(synchro.Isynchro,0) as Isynchro,g.*,s.`Name` as SupplierName from RB_Goods g
inner join rb_goods_category c on g.Id=c.GoodsId
LEFT JOIN rb_supplier as s on g.SupplierId=s.ID
LEFT JOIN (SELECT SourceGoodsId,COUNT(*) as Isynchro from RB_Goods where SourceGoodsId>0 {sourceWhere} GROUP BY SourceGoodsId ) as
synchro on synchro.SourceGoodsId=g.Id
where {where} group by g.Id order by {orderBy}";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql, parameters).ToList();
}
#endregion
}
}
......@@ -3077,12 +3077,13 @@ namespace Mall.WebApi.Controllers.MallBase
StartTime = parameters.GetStringValue("StartTime"),
EndTime = parameters.GetStringValue("EndTime"),
OrderBy = parameters.GetInt("OrderBy"),
RetailStore = parameters.GetInt("RetailStore", -1),
Isynchro = parameters.GetInt("Isynchro", 0),
SupplierId = parameters.GetInt("SupplierId", 0),
};
//demodel.TenantId = parms.TenantId;
// demodel.MallBaseId = parms.MallBaseId;s
demodel.SourceMallBaseId = parms.TenantId;
demodel.SourceTenantId = parms.MallBaseId;
decimal MinProfitRate = 0;
if (demodel.TenantId == 1)
{
......@@ -3092,15 +3093,15 @@ namespace Mall.WebApi.Controllers.MallBase
{
demodel.MinProfitRate = MinProfitRate;
}
var list = productModule.GetProductGoodsPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
List<RB_Goods_Extend> goodsList = new List<RB_Goods_Extend>();
if (list != null && list.Any())
{
string GoodsIds = string.Join(",", list.Select(x => x.Id));//商品ids
//根据商品id获取商品信息
goodsList = productModule.GetGoodsList(new RB_Goods_Extend { SourceGoodsIdIds = GoodsIds, TenantId = parms.TenantId, MallBaseId = parms.MallBaseId });
var list = productModule.GetSynchroPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
//List<RB_Goods_Extend> goodsList = new List<RB_Goods_Extend>();
//if (list != null && list.Any())
//{
// string GoodsIds = string.Join(",", list.Select(x => x.Id));//商品ids
// //根据商品id获取商品信息
// goodsList = productModule.GetGoodsList(new RB_Goods_Extend { SourceGoodsIdIds = GoodsIds, TenantId = parms.TenantId, MallBaseId = parms.MallBaseId });
}
//}
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
......@@ -3132,7 +3133,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.SourceGoodsId,
x.RetailStore,
x.SupplierName,
Isynchro = (goodsList != null && goodsList.Any()) ? goodsList.Where(x => x.SourceGoodsId == x.Id).Count() : 0
Isynchro = x.Isynchro
});
return ApiResult.Success("", pagelist);
}
......@@ -3148,7 +3149,7 @@ namespace Mall.WebApi.Controllers.MallBase
string GoodsIds = parms.GetStringValue("GoodsIds");//商品ids
//根据商品id获取商品信息
var goodsList = productModule.GetGoodsList(new RB_Goods_Extend { GoodsIds = GoodsIds });
if (goodsList.Any(x => x.SourceGoodsId > 0))
if (goodsList.Any(x => x.SourceGoodsId > 0 && x.TenantId == RequestParm.TenantId && x.MallBaseId == RequestParm.MallBaseId))
{
return ApiResult.Failed("分享平台的商品不能多次分享添加");
}
......
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