Commit e741890c authored by 吴春's avatar 吴春
parents dd6db51b b8e5b6b5
...@@ -18,5 +18,13 @@ namespace Mall.Model.Extend.User ...@@ -18,5 +18,13 @@ namespace Mall.Model.Extend.User
/// 微店ids /// 微店ids
/// </summary> /// </summary>
public string SmallShopsIds{ get; set; } public string SmallShopsIds{ get; set; }
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
/// <summary>
/// 商品名称
/// </summary>
public string GoodsName { get; set; }
} }
} }
...@@ -1089,7 +1089,6 @@ namespace Mall.Module.Product ...@@ -1089,7 +1089,6 @@ namespace Mall.Module.Product
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(model.CarouselImage); List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(model.CarouselImage);
//封面图 //封面图
model.CoverImage = CarouselIdList[0]; model.CoverImage = CarouselIdList[0];
//轮播图
} }
} }
//小程序名称 //小程序名称
...@@ -1765,7 +1764,7 @@ namespace Mall.Module.Product ...@@ -1765,7 +1764,7 @@ namespace Mall.Module.Product
var fxmodel = distributor_FXGradeRepository.GetEntity(model.PresentFXGrade); var fxmodel = distributor_FXGradeRepository.GetEntity(model.PresentFXGrade);
if (fxmodel != null) if (fxmodel != null)
{ {
PresentFXGradeMsg = "购买后赠送" + fxmodel.GradeName + "会员"; PresentFXGradeMsg = "购买后赠送" + fxmodel.GradeName + " ";
if (model.PresentFXMonth > 0) if (model.PresentFXMonth > 0)
{ {
PresentFXGradeMsg += (model.PresentFXMonth ?? 0) + "个月"; PresentFXGradeMsg += (model.PresentFXMonth ?? 0) + "个月";
......
...@@ -45,6 +45,26 @@ namespace Mall.Module.User ...@@ -45,6 +45,26 @@ namespace Mall.Module.User
/// 微店价格 /// 微店价格
/// </summary> /// </summary>
private readonly RB_SmallShops_PriceRepository smallShops_PriceRepository = new RB_SmallShops_PriceRepository(); private readonly RB_SmallShops_PriceRepository smallShops_PriceRepository = new RB_SmallShops_PriceRepository();
/// <summary>
/// 微店基础
/// </summary>
private readonly RB_MicroShop_BasicsRepository microShop_BasicsRepository = new RB_MicroShop_BasicsRepository();
/// <summary>
/// 商品表
/// </summary>
private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository();
/// <summary>
/// 规格价格
/// </summary>
private readonly RB_Goods_SpecificationPriceRepository goods_SpecificationPriceRepository = new RB_Goods_SpecificationPriceRepository();
/// <summary>
/// 规格
/// </summary>
private readonly RB_Goods_SpecificationRepository goods_SpecificationRepository = new RB_Goods_SpecificationRepository();
/// <summary>
/// 规格值
/// </summary>
private readonly RB_Goods_SpecificationValueRepository goods_SpecificationValueRepository = new RB_Goods_SpecificationValueRepository();
#region 微店管理 #region 微店管理
...@@ -74,6 +94,7 @@ namespace Mall.Module.User ...@@ -74,6 +94,7 @@ namespace Mall.Module.User
{ {
return smallShops_InfoRepository.GetSmallShopsDropDownList(pageIndex, pageSize, out count, demodel); return smallShops_InfoRepository.GetSmallShopsDropDownList(pageIndex, pageSize, out count, demodel);
} }
/// <summary> /// <summary>
/// 获取微店信息 /// 获取微店信息
/// </summary> /// </summary>
...@@ -85,6 +106,19 @@ namespace Mall.Module.User ...@@ -85,6 +106,19 @@ namespace Mall.Module.User
model.NickName = member_UserRepository.GetEntity(model?.UserId ?? 0)?.Name ?? ""; model.NickName = member_UserRepository.GetEntity(model?.UserId ?? 0)?.Name ?? "";
return model; return model;
} }
/// <summary>
/// 根据用户id 获取微店信息
/// </summary>
/// <param name="UserId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public RB_SmallShops_Info_Extend GetSmallShopsInfo_V2(int UserId,int tenantId, int mallBaseId)
{
var model = smallShops_InfoRepository.GetListForSingle(new RB_SmallShops_Info_Extend() { UserId = UserId, TenantId = tenantId, MallBaseId = mallBaseId }).FirstOrDefault();
return model;
}
/// <summary> /// <summary>
/// 微店审核 /// 微店审核
/// </summary> /// </summary>
...@@ -154,6 +188,394 @@ namespace Mall.Module.User ...@@ -154,6 +188,394 @@ namespace Mall.Module.User
return smallShops_InfoRepository.Update(keyValues, wheres); return smallShops_InfoRepository.Update(keyValues, wheres);
} }
/// <summary>
/// 微店基础表
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public Model.Entity.BaseSetUp.RB_MicroShop_Basics GetSmallShopsBaseInfo(int tenantId, int mallBaseId)
{
return microShop_BasicsRepository.GetMicroShopBasicsList(new Model.Entity.BaseSetUp.RB_MicroShop_Basics() { TenantId = tenantId, MallBaseId = mallBaseId }).FirstOrDefault();
}
#endregion
#region 微店小程序
/// <summary>
/// 设置全局价格
/// </summary>
/// <param name="upPrice"></param>
/// <param name="priceType"></param>
/// <param name="model"></param>
/// <returns></returns>
public bool SetSmallShopsGlobalPrice(decimal upPrice, int priceType, RB_SmallShops_Info_Extend model)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_SmallShops_Info_Extend.UpPrice),upPrice},
{ nameof(RB_SmallShops_Info_Extend.PriceType),priceType},
{ nameof(RB_SmallShops_Info_Extend.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_SmallShops_Info_Extend.Id),
FiledValue=model.Id,
OperatorEnum=OperatorEnum.Equal
}
};
return smallShops_InfoRepository.Update(keyValues, wheres);
}
/// <summary>
/// 获取微店商品价格设置列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public object GetSmallShopsGoodsPricePageList(int pageIndex, int pageSize, out long count, RB_SmallShops_Price_Extend demodel)
{
var goodsList = smallShops_PriceRepository.GetSmallShopsGoodsPricePageList(pageIndex, pageSize, out count, demodel);
List<object> RList = new List<object>();
if (goodsList.Any()) {
//查询出所有商品id
string goodsIds = string.Join(",", goodsList.Select(x => x.GoodsId ?? 0).Distinct());
var glist = goodsRepository.GetSingleListForGoodsId(new RB_Goods_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in glist) {
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
}
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var sslist = smallShops_PriceRepository.GetList(new RB_SmallShops_Price_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in goodsList) {
var model = glist.Where(x => x.Id == item.GoodsId).FirstOrDefault();
if (model != null) {
model.SpecificationList = new List<RB_Goods_Specification_Extend>();
model.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
if (model.IsCustomSpecification == 1)
{
model.SpecificationList = slist.Where(x => x.GoodsId == model.Id).ToList();
if (model.SpecificationList.Any())
{
foreach (var qitem in model.SpecificationList)
{
qitem.SpecificationValueList = svlist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationId == qitem.Id).ToList();
}
}
model.SpecificationPriceList = splist.Where(x => x.GoodsId == item.GoodsId).ToList();
}
#region 组装价格
List<object> priceList = new List<object>();
if (model.IsCustomSpecification == 1)
{
if (model.SpecificationPriceList.Any() && model.SpecificationList.Any())
{
foreach (var qitem in model.SpecificationPriceList)
{
var ssarr = qitem.SpecificationSort.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
List<object> attr_list = 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();
attr_list.Add(new
{
attr_group_name = smodel.Name,
attr_group_id = smodel.Sort,
attr_id = svmodel.Id,
attr_name = svmodel.Name
});
}
//查找 设置的店铺价格
var ssmodel = sslist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == qitem.SpecificationSort).FirstOrDefault();
var ssPrice = qitem.SellingPrice ?? 0;
if (ssmodel != null) {
if (ssmodel.PriceType == 1) {
ssPrice += Math.Ceiling(ssPrice * (ssmodel.UpPrice ?? 0) / 100);
}
}
priceList.Add(new
{
GoodsId = model.Id,
SpecificationKey = qitem.SpecificationSort,
qitem.SellingPrice,
AttrList = attr_list,
SmallShopsPrice = ssPrice,
SmallShopsPriceId = ssmodel?.Id ?? 0,
UpPrice = ssmodel?.UpPrice ?? 0,
PriceType = ssmodel?.PriceType ?? 0,
});
}
}
RList.Add(new
{
GoodsId = model.Id,
model.Name,
model.CoverImage,
SpecificationList = priceList
});
}
else
{
//查找 设置的店铺价格
var ssmodel = sslist.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == "").FirstOrDefault();
var ssPrice = model.SellingPrice ?? 0;
if (ssmodel != null)
{
if (ssmodel.PriceType == 1)
{
ssPrice += Math.Ceiling(ssPrice * (ssmodel.UpPrice ?? 0) / 100);
}
}
priceList.Add(new
{
GoodsId = model.Id,
SpecificationKey = "",
model.SellingPrice,
AttrList = new List<object>(){ new
{
attr_group_name = "规格",
attr_group_id = 0,
attr_id = 0,
attr_name = model.DefaultSpecificationName
} },
SmallShopsPrice = ssPrice,
SmallShopsPriceId = ssmodel?.Id ?? 0,
UpPrice = ssmodel?.UpPrice ?? 0,
PriceType = ssmodel?.PriceType ?? 0,
});
RList.Add(new
{
GoodsId = model.Id,
model.Name,
model.CoverImage,
SpecificationList = priceList
});
}
#endregion
}
}
}
return RList;
}
/// <summary>
/// 获取商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public object GetSmallShopsChooseGoodsPageList(int pageIndex, int pageSize, out long count, RB_SmallShops_Price_Extend demodel)
{
List<object> RList = new List<object>();
var glist = goodsRepository.GetPageList(pageIndex, pageSize, out count, new RB_Goods_Extend() { Id = demodel.GoodsId ?? 0, Name = demodel.GoodsName, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (glist.Any()) {
//查询出所有商品id
string goodsIds = string.Join(",", glist.Select(x => x.Id).Distinct());
foreach (var item in glist)
{
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
}
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var model in glist)
{
if (model != null)
{
model.SpecificationList = new List<RB_Goods_Specification_Extend>();
model.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
if (model.IsCustomSpecification == 1)
{
model.SpecificationList = slist.Where(x => x.GoodsId == model.Id).ToList();
if (model.SpecificationList.Any())
{
foreach (var qitem in model.SpecificationList)
{
qitem.SpecificationValueList = svlist.Where(x => x.GoodsId == model.Id && x.SpecificationId == qitem.Id).ToList();
}
}
model.SpecificationPriceList = splist.Where(x => x.GoodsId == model.Id).ToList();
}
#region 组装价格
List<object> priceList = new List<object>();
if (model.IsCustomSpecification == 1)
{
if (model.SpecificationPriceList.Any() && model.SpecificationList.Any())
{
foreach (var qitem in model.SpecificationPriceList)
{
var ssarr = qitem.SpecificationSort.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
List<object> attr_list = 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();
attr_list.Add(new
{
attr_group_name = smodel.Name,
attr_group_id = smodel.Sort,
attr_id = svmodel.Id,
attr_name = svmodel.Name
});
}
priceList.Add(new
{
GoodsId = model.Id,
SpecificationKey = qitem.SpecificationSort,
qitem.SellingPrice,
AttrList = attr_list,
});
}
}
RList.Add(new
{
GoodsId = model.Id,
model.Name,
model.CoverImage,
SpecificationList = priceList
});
}
else
{
priceList.Add(new
{
GoodsId = model.Id,
SpecificationKey = "",
model.SellingPrice,
AttrList = new List<object>(){ new
{
attr_group_name = "规格",
attr_group_id = 0,
attr_id = 0,
attr_name = model.DefaultSpecificationName
} }
});
RList.Add(new
{
GoodsId = model.Id,
model.Name,
model.CoverImage,
SpecificationList = priceList
});
}
#endregion
}
}
}
return RList;
}
/// <summary>
/// 保存微店商品价格
/// </summary>
/// <param name="goodsId"></param>
/// <param name="sSPList"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetSmallShopsGoodsPrice(int goodsId, List<RB_SmallShops_Price_Extend> sSPList, AppletUserInfo userInfo)
{
var model = smallShops_InfoRepository.GetListForSingle(new RB_SmallShops_Info_Extend() { UserId = userInfo.UserId, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId }).FirstOrDefault();
if (model == null || model.AuditStatus != DistributorAuditStatusEnum.Audited)
{
return false;
}
var splist = smallShops_PriceRepository.GetList(new RB_SmallShops_Price_Extend() { SmallShopsId = model.Id, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId });
if (splist.Any())
{
//修改
var insertList = sSPList.Where(x => !splist.Select(y => y.SpecificationKey).Contains(x.SpecificationKey)).ToList();
var updateList = splist.Where(x => sSPList.Select(y => y.SpecificationKey).Contains(x.SpecificationKey)).ToList();
var deleteList = splist.Where(x => !sSPList.Select(y => y.SpecificationKey).Contains(x.SpecificationKey)).ToList();
foreach (var item in insertList) {
if (item.UpPrice > 0)
{
item.SmallShopsId = model.Id;
item.GoodsId = goodsId;
item.UpPrice ??= 0;
item.PriceType ??= 0;
item.Status = 0;
item.TenantId = userInfo.TenantId;
item.MallBaseId = userInfo.MallBaseId;
item.CreateDate = DateTime.Now;
item.UpdateDate = DateTime.Now;
smallShops_PriceRepository.Insert(item);
}
}
foreach (var item in updateList) {
var sspmodel = sSPList.Where(x => x.SpecificationKey == item.SpecificationKey).FirstOrDefault();
if (sspmodel.UpPrice > 0)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_SmallShops_Price.UpPrice),sspmodel.UpPrice},
{ nameof(RB_SmallShops_Price.PriceType),sspmodel.PriceType},
{ nameof(RB_SmallShops_Price.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_SmallShops_Price.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
smallShops_PriceRepository.Update(keyValues, wheres);
}
else {
smallShops_PriceRepository.Delete(item);
}
}
foreach (var item in deleteList) {
smallShops_PriceRepository.Delete(item);
}
}
else {
foreach (var item in sSPList) {
if (item.UpPrice > 0)
{
item.SmallShopsId = model.Id;
item.GoodsId = goodsId;
item.UpPrice ??= 0;
item.PriceType ??= 0;
item.Status = 0;
item.TenantId = userInfo.TenantId;
item.MallBaseId = userInfo.MallBaseId;
item.CreateDate = DateTime.Now;
item.UpdateDate = DateTime.Now;
smallShops_PriceRepository.Insert(item);
}
}
}
return true;
}
#endregion #endregion
} }
} }
...@@ -36,11 +36,51 @@ namespace Mall.Repository.User ...@@ -36,11 +36,51 @@ namespace Mall.Repository.User
if (!string.IsNullOrEmpty(dmodel.SmallShopsIds)) { if (!string.IsNullOrEmpty(dmodel.SmallShopsIds)) {
where += $@" and di.{nameof(RB_SmallShops_Price_Extend.SmallShopsId)} in({dmodel.SmallShopsIds})"; where += $@" and di.{nameof(RB_SmallShops_Price_Extend.SmallShopsId)} in({dmodel.SmallShopsIds})";
} }
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and di.{nameof(RB_SmallShops_Price_Extend.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"select di.* from RB_SmallShops_Price_Extend di string sql = $@"select di.* from RB_SmallShops_Price_Extend di
where {where} order by di.Id desc"; where {where} order by di.Id desc";
return Get<RB_SmallShops_Price_Extend>(sql).ToList(); return Get<RB_SmallShops_Price_Extend>(sql).ToList();
} }
/// <summary>
/// 获取微店商品价格列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_SmallShops_Price_Extend> GetSmallShopsGoodsPricePageList(int pageIndex, int pageSize, out long count, RB_SmallShops_Price_Extend demodel)
{
string where = $@" 1=1 and sp.Status=0";
if (demodel.TenantId > 0)
{
where += $@" and sp.{nameof(RB_SmallShops_Price_Extend.TenantId)}={demodel.TenantId}";
}
if (demodel.MallBaseId > 0)
{
where += $@" and sp.{nameof(RB_SmallShops_Price_Extend.MallBaseId)}={demodel.MallBaseId}";
}
if (demodel.GoodsId > 0)
{
where += $@" and sp.{nameof(RB_SmallShops_Price_Extend.GoodsId)}={demodel.GoodsId}";
}
if (!string.IsNullOrEmpty(demodel.GoodsName))
{
where += $@" and g.{nameof(Model.Entity.Product.RB_Goods.Name)} like '%{demodel.GoodsName}%'";
}
string sql = $@"
SELECT sp.GoodsId FROM rb_smallshops_price sp
INNER JOIN rb_goods g on sp.GoodsId=g.Id
{where}
GROUP BY sp.GoodsId ORDER BY sp.CreateDate DESC
";
return GetPage<RB_SmallShops_Price_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
} }
} }
...@@ -1348,6 +1348,8 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1348,6 +1348,8 @@ namespace Mall.WebApi.Controllers.MallBase
new ExcelColumn(value:(item.IsSellWell??0).ToString()){ }, new ExcelColumn(value:(item.IsSellWell??0).ToString()){ },
new ExcelColumn(value:(item.IsGoodsNegotiable??0).ToString()){ }, new ExcelColumn(value:(item.IsGoodsNegotiable??0).ToString()){ },
} }
,
ColumnHight = 30
}; };
slist.Add(datarow); slist.Add(datarow);
} }
......
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