Commit 14a15218 authored by 吴春's avatar 吴春

提交代码

parent 238cb0f7
......@@ -246,6 +246,17 @@ namespace Mall.Module.Product
}
string goodsIds2 = string.Join(",", list.Select(x => x.Id));
List<RB_Goods_Order_Extend> orderlist = goods_OrderRepository.GetGoodsOrderNum(goodsIds: goodsIds2);
//2020-08-06 Add by:W 查询商品分类获取分类包邮规则
string allGoodsIds = string.Join(",", list.Select(x => x.Id));
var goodsCategoryList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = allGoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
string categoryIds = string.Join(",", goodsCategoryList.Select(x => x.CategoryId).Distinct());
List<RB_FreeShipping_Extend> freeShippingList = new List<RB_FreeShipping_Extend>();
if (!string.IsNullOrWhiteSpace(categoryIds))
{
freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, CategoryIds = categoryIds });
}
//2020-08-06 Add by:W End
foreach (var item in list)
{
item.CoverImage = "";
......@@ -269,7 +280,35 @@ namespace Mall.Module.Product
}
item.SalesNum += (orderlist.Where(x => x.GoodsId == item.Id).FirstOrDefault()?.OrderNum ?? 0);
//2020-08-06 Add by:W 查询商品分类获取分类包邮规则
if (freeShippingList != null && freeShippingList.Any())
{
var nowcategory = goodsCategoryList.Where(x => x.GoodsId == item.Id).Select(x => x.CategoryId);
var fullNumPinkageModel = freeShippingList.Where(x => nowcategory.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
{
fullNumPinkageModel = freeShippingList.Where(x => nowcategory.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
{
fullNumPinkageModel = freeShippingList.Where(x => nowcategory.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
{
fullNumPinkageModel = freeShippingList.Where(x => nowcategory.Contains(x.CategoryId) && x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId == 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
}
item.FreeShippingModel = (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0) ? new RB_FreeShipping_Extend() : fullNumPinkageModel;
}
else
{
item.FreeShippingModel = new RB_FreeShipping_Extend();
}
//2020-08-06 Add by:W End
}
}
return list;
}
......@@ -1059,7 +1098,7 @@ namespace Mall.Module.Product
var freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = model.MallBaseId, TenantId = model.TenantId, CategoryIds = categoryIds });
if (freeShippingList != null && freeShippingList.Any())
{
var fullNumPinkageModel = freeShippingList.Where(x => x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x=>x.ID).FirstOrDefault();
var fullNumPinkageModel = freeShippingList.Where(x => x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullNumPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullNumPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
if (fullNumPinkageModel == null || fullNumPinkageModel.ID <= 0)
{
fullNumPinkageModel = freeShippingList.Where(x => x.IsFreeShipping == 1 && x.IsEnable == 1 && x.FullMoneyPinkage > 0 && x.CategoryId > 0).OrderBy(x => x.FullMoneyPinkage).ThenByDescending(x => x.ID).FirstOrDefault();
......
......@@ -75,7 +75,8 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProductCategoryTreeList(object requestMsg) {
public ApiResult GetProductCategoryTreeList(object requestMsg)
{
var parms = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (parms.MallBaseId <= 0)
{
......@@ -96,7 +97,8 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProductCategoryStyleInfo(object requestMsg) {
public ApiResult GetProductCategoryStyleInfo(object requestMsg)
{
var parms = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (parms.MallBaseId <= 0)
{
......@@ -123,7 +125,8 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsPageList(object requestMsg) {
public ApiResult GetAppletGoodsPageList(object requestMsg)
{
var parms = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (parms.MallBaseId <= 0)
{
......@@ -183,8 +186,10 @@ namespace Mall.WebApi.Controllers.MallBase
memberGrade = productModule.GetMemberGradeList(new RB_Member_Grade_Extend() { Id = userModel.MemberGrade ?? 0, Enabled = 1, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
}
}
if (list.Any()) {
foreach (var model in list) {
if (list.Any())
{
foreach (var model in list)
{
#region 组装价格
List<object> priceList = new List<object>();
if (model.IsCustomSpecification == 1)
......@@ -295,33 +300,37 @@ namespace Mall.WebApi.Controllers.MallBase
#region 会员价格
decimal memberprice = model.SellingPrice ?? 0;
if (UserId>0 && userModel.MemberGrade > 0 && model.EnjoyMember == 1 && model.SeparateSetMember == 1 && model.MemberPriceList.Any())
if (UserId > 0 && userModel.MemberGrade > 0 && model.EnjoyMember == 1 && model.SeparateSetMember == 1 && model.MemberPriceList.Any())
{
memberprice = model.MemberPriceList.Where(x => x.MemberGrade == userModel.MemberGrade).Min(x => x.MemberPrice ?? 0);
}
else if(UserId>0 && userModel.MemberGrade > 0)
else if (UserId > 0 && userModel.MemberGrade > 0)
{
memberprice = memberprice * (memberGrade?.Discount ?? 10) / 10;
}
#endregion
RList.Add(new {
id= model.Id,
sign= "",
name= model.Name,
cover_pic= model.CoverImage,
video_url= model.VideoAddress,
original_price= model.OriginalPrice,
unit= model.Unit,
page_url= "/pages/goods/goods?id="+ model.Id,
is_negotiable= model.IsGoodsNegotiable,
is_level= model.EnjoyMember,
level_price= memberprice,
price= (model.SellingPrice??0).ToString("#0.00"),
price_content= "¥"+ (model.SellingPrice ?? 0).ToString("#0.00"),
is_sales= model.GoodsStatus,
sales= "已售"+model.SalesNum + "件",
attr_groups= model.SpecificationList.Select(x => new
RList.Add(new
{
id = model.Id,
sign = "",
name = model.Name,
cover_pic = model.CoverImage,
video_url = model.VideoAddress,
original_price = model.OriginalPrice,
unit = model.Unit,
page_url = "/pages/goods/goods?id=" + model.Id,
is_negotiable = model.IsGoodsNegotiable,
is_level = model.EnjoyMember,
level_price = memberprice,
price = (model.SellingPrice ?? 0).ToString("#0.00"),
price_content = "¥" + (model.SellingPrice ?? 0).ToString("#0.00"),
is_sales = model.GoodsStatus,
sales = "已售" + model.SalesNum + "件",
freeShippingName = model.FreeShippingModel.Name,
freeShippingFullMoneyPinkage = model.FreeShippingModel.FullMoneyPinkage ?? 0,
freeShippingFullNumPinkage = model.FreeShippingModel.FullNumPinkage ?? 0,
attr_groups = model.SpecificationList.Select(x => new
{
attr_group_id = x.Sort,
attr_group_name = x.Name,
......@@ -332,9 +341,9 @@ namespace Mall.WebApi.Controllers.MallBase
pic_url = z.ImagePath
})
}),
attr= priceList,
goods_stock= model.InventoryNum,
goods_num= model.InventoryNum
attr = priceList,
goods_stock = model.InventoryNum,
goods_num = model.InventoryNum
});
}
}
......@@ -349,7 +358,8 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsInfo(object requestMsg) {
public ApiResult GetAppletGoodsInfo(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
......@@ -357,7 +367,8 @@ namespace Mall.WebApi.Controllers.MallBase
}
JObject prams = JObject.Parse(req.msg.ToString());
int GoodsId = prams.GetInt("GoodsId", 0);
if (GoodsId <= 0) {
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull();
}
int UserId = req.UserId;
......@@ -746,7 +757,8 @@ namespace Mall.WebApi.Controllers.MallBase
is_quick_shop = model.IsQuickBuy,
is_sell_well = model.IsSellWell,
is_negotiable = model.IsGoodsNegotiable,
cats = model.CategoryList.Select(x => new {
cats = model.CategoryList.Select(x => new
{
x.CategoryId,
x.CategoryName
})//分类
......@@ -901,7 +913,8 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.ParamIsNull();
}
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(parms.msg.ToString());
if (!demodel.RecommendType.HasValue && demodel.RecommendType <=0) {
if (!demodel.RecommendType.HasValue && demodel.RecommendType <= 0)
{
return ApiResult.ParamIsNull("请传递推荐类型");
}
......@@ -1134,7 +1147,8 @@ namespace Mall.WebApi.Controllers.MallBase
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletVipGradeInfo(object requestMsg) {
public ApiResult GetAppletVipGradeInfo(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
......@@ -1153,7 +1167,8 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetGoodsPoster() {
public ApiResult GetGoodsPoster()
{
string address = new HtmlToImgHelper().GetHtmlToImage();
return ApiResult.Success("", address);
}
......
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