Commit 8a6ce82a authored by liudong1993's avatar liudong1993

1

parent e2882f97
...@@ -545,5 +545,9 @@ namespace Mall.Model.Entity.Product ...@@ -545,5 +545,9 @@ namespace Mall.Model.Entity.Product
/// 商品备注 /// 商品备注
/// </summary> /// </summary>
public string Remark { get; set; } public string Remark { get; set; }
/// <summary>
/// 课程分数
/// </summary>
public decimal? CourseScore { get; set; }
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using Mall.Common.Plugin; using Mall.Common.Plugin;
using Mall.Model.Entity.Education; using Mall.Model.Entity.Education;
using Mall.Model.Entity.Product; using Mall.Model.Entity.Product;
using Mall.Model.Entity.User;
using Mall.Model.Extend.Education; using Mall.Model.Extend.Education;
using Mall.Model.Extend.Product; using Mall.Model.Extend.Product;
using Mall.Model.Extend.User; using Mall.Model.Extend.User;
...@@ -87,6 +88,14 @@ namespace Mall.Module.Education ...@@ -87,6 +88,14 @@ namespace Mall.Module.Education
/// 会员等级 /// 会员等级
/// </summary> /// </summary>
private readonly RB_Member_GradeRepository member_GradeRepository = new RB_Member_GradeRepository(); private readonly RB_Member_GradeRepository member_GradeRepository = new RB_Member_GradeRepository();
/// <summary>
/// 微店
/// </summary>
private RB_SmallShops_InfoRepository smallShops_InfoRepository = new RB_SmallShops_InfoRepository();
/// <summary>
/// 微店商品价格
/// </summary>
private RB_SmallShops_PriceRepository smallShops_PriceRepository = new RB_SmallShops_PriceRepository();
/// <summary> /// <summary>
/// 会员信息 /// 会员信息
...@@ -1142,6 +1151,132 @@ namespace Mall.Module.Education ...@@ -1142,6 +1151,132 @@ namespace Mall.Module.Education
#endregion #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> GetAppletCoursePageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{
var list = goodsRepository.GetAppletGoodsPageList(pageIndex, pageSize, out count, demodel, 2);
if (list.Any())
{
//会员价格
var MemberPriceList = new List<RB_Goods_MemberPrice_Extend>();
if (list.Where(x => x.EnjoyMember == 1 && x.SeparateSetMember == 1).Any())
{
string goodsIds = string.Join(",", list.Where(x => x.EnjoyMember == 1 && x.SeparateSetMember == 1).Select(x => x.Id));
MemberPriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
}
string goodsIds2 = string.Join(",", list.Select(x => x.Id));
List<RB_Goods_Order_Extend> orderlist = goods_OrderRepository.GetGoodsOrderNum(goodsIds: goodsIds2);
#region 微店价格
RB_SmallShops_Info smallModel = new RB_SmallShops_Info();
List<RB_SmallShops_Price_Extend> smallPList = new List<RB_SmallShops_Price_Extend>();
if (demodel.SmallShopsId > 0)
{
smallModel = smallShops_InfoRepository.GetEntity(demodel.SmallShopsId);
smallPList = smallShops_PriceRepository.GetList(new RB_SmallShops_Price_Extend() { SmallShopsId = demodel.SmallShopsId, GoodsIds = goodsIds2 });
}
#endregion
foreach (var item in list)
{
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
if (demodel.SmallShopsId > 0)
{
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.GoodsId == item.Id && x.UpPrice > 0).Any())
{
var sspModel = smallPList.Where(x => x.GoodsId == item.Id && x.SpecificationKey == "").FirstOrDefault();
if (sspModel != null)
{
//单商品设置的
if (sspModel.PriceType == 1)
{
item.SellingPrice = (item.SellingPrice ?? 0) + Math.Ceiling((item.SellingPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
}
else if (sspModel.PriceType == 2)
{
item.SellingPrice = (item.SellingPrice ?? 0) + (sspModel.UpPrice ?? 0);
}
}
else
{
if ((smallModel.UpPrice ?? 0) > 0)
{
if (smallModel.PriceType == 1)
{
item.SellingPrice = (item.SellingPrice ?? 0) + Math.Ceiling((item.SellingPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
item.SellingPrice = (item.SellingPrice ?? 0) + (smallModel.UpPrice ?? 0);
}
}
}
}
}
if (item.EnjoyMember == 1 && item.SeparateSetMember == 1)
{
item.MemberPriceList = MemberPriceList.Where(x => x.GoodsId == item.Id).ToList();
#region 微店处理会员价格
if (item.MemberPriceList.Any() && demodel.SmallShopsId > 0)
{
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.GoodsId == item.Id && x.UpPrice > 0).Any())
{
foreach (var mqitem in item.MemberPriceList)
{
var sspModel = smallPList.Where(x => x.SpecificationKey == mqitem.SpecificationSort).FirstOrDefault();
if (sspModel != null)
{
//单商品设置的
if (sspModel.PriceType == 1)
{
mqitem.MemberPrice = (mqitem.MemberPrice ?? 0) + Math.Ceiling((mqitem.MemberPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
}
else if (sspModel.PriceType == 2)
{
mqitem.MemberPrice = (mqitem.MemberPrice ?? 0) + (sspModel.UpPrice ?? 0);
}
}
else
{
if ((smallModel.UpPrice ?? 0) > 0)
{
if (smallModel.PriceType == 1)
{
mqitem.MemberPrice = (mqitem.MemberPrice ?? 0) + Math.Ceiling((mqitem.MemberPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
mqitem.MemberPrice = (mqitem.MemberPrice ?? 0) + (smallModel.UpPrice ?? 0);
}
}
}
}
}
}
#endregion
}
item.SalesNum += (orderlist.Where(x => x.GoodsId == item.Id).FirstOrDefault()?.OrderNum ?? 0);
}
}
return list;
}
#endregion
#region 教师管理 #region 教师管理
/// <summary> /// <summary>
///教师配置列表 ///教师配置列表
......
...@@ -517,9 +517,9 @@ WHERE {where} group by g.Id order by g.CreateDate desc"; ...@@ -517,9 +517,9 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// <param name="count"></param> /// <param name="count"></param>
/// <param name="dmodel"></param> /// <param name="dmodel"></param>
/// <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, int GoodsClassify = 0)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=0"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify={GoodsClassify}";
var parameters = new DynamicParameters(); var parameters = new DynamicParameters();
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
......
...@@ -2,6 +2,16 @@ ...@@ -2,6 +2,16 @@
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Mall.Module.Education; using Mall.Module.Education;
using Mall.Common.API;
using Newtonsoft.Json;
using Mall.Model.Extend.Product;
using Mall.Module.Product;
using Mall.Model.Extend.User;
using System.Collections.Generic;
using System.Linq;
using System;
using Newtonsoft.Json.Linq;
using Mall.Common.Plugin;
namespace Mall.WebApi.Controllers.Education namespace Mall.WebApi.Controllers.Education
{ {
...@@ -12,8 +22,182 @@ namespace Mall.WebApi.Controllers.Education ...@@ -12,8 +22,182 @@ namespace Mall.WebApi.Controllers.Education
public class AppletSchoolController : ControllerBase public class AppletSchoolController : ControllerBase
{ {
private readonly EducationModule educationModule = new EducationModule(); private readonly EducationModule educationModule = new EducationModule();
private readonly ProductModule productModule = new ProductModule();
private Module.User.UserModule UserModule = new Module.User.UserModule(); private Module.User.UserModule UserModule = new Module.User.UserModule();
#region 课程
/// <summary>
/// 小程序课程分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletCoursePageList(object requestMsg)
{
var parms = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (parms.MallBaseId <= 0)
{
return ApiResult.ParamIsNull();
}
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(parms.msg.ToString());
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
demodel.GoodsStatus = 1;//只查询销售中的
demodel.SmallShopsId = parms.SmallShopsId;
int UserId = parms.UserId;
demodel.UserId = UserId;
RB_Member_User_Extend userModel = new RB_Member_User_Extend();
RB_Member_Grade_Extend memberGrade = new RB_Member_Grade_Extend();
if (UserId > 0)
{
userModel = productModule.GetMemberUserInfo(UserId);
if (userModel.MemberGrade > 0)
{
memberGrade = productModule.GetMemberGradeList(new RB_Member_Grade_Extend() { Id = userModel.MemberGrade ?? 0, Enabled = 1, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
}
if (demodel.SmallShopsId == 0)
{
demodel.SmallShopsId = userModel.SmallShopId;
}
}
var list = educationModule.GetAppletCoursePageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
List<object> RList = new List<object>();
if (list.Any())
{
foreach (var model in list)
{
#region 组装价格
List<object> priceList = new List<object>();
decimal price_member = model.SellingPrice ?? 0;//未设会员价格的话 就为销售价格
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1)
{
if (model.MemberPriceList.Any())
{
var mlist = model.MemberPriceList;
if (UserId > 0 && userModel.MemberGrade > 0)
{
var gmodel = mlist.Where(x => x.MemberGrade == userModel.MemberGrade).FirstOrDefault();
price_member = gmodel.MemberPrice ?? 0;
}
}
}
else
{
if (UserId > 0 && userModel.MemberGrade > 0)
{
price_member = Math.Round((model.SellingPrice ?? 0) * (memberGrade?.Discount ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
}
}
priceList.Add(new
{
id = 0,
goods_id = model.Id,
sign_id = "",
stock = model.InventoryNum,
price = model.SellingPrice ?? 0,
no = model.GoodsNumbers,
weight = model.GoodsWeight,
pic_url = "",
is_delete = 0,
attr_list = new
{
attr_group_name = "规格",
attr_group_id = 0,
attr_id = 0,
attr_name = model.DefaultSpecificationName
},
price_member
});
#endregion
#region 会员价格
decimal memberprice = model.SellingPrice ?? 0;
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)
{
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 + "件",
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,
attr_list = x.SpecificationValueList.Select(z => new
{
attr_id = z.Sort,
attr_name = z.Name,
pic_url = z.ImagePath
})
}),
attr = priceList,
goods_stock = model.InventoryNum,
goods_num = model.InventoryNum,
marketingLogo = model.MarketingLogo,
video_type = model.VideoType,
erpgoodobj = model.ERPGoodObj
});
}
}
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = RList;
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取小程序商品详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsInfo(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
return ApiResult.ParamIsNull();
}
JObject prams = JObject.Parse(req.msg.ToString());
int GoodsId = prams.GetInt("GoodsId", 0);
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull();
}
int UserId = req.UserId;
var Robj = productModule.GetAppletGoodsInfo_V2(GoodsId, UserId, req.SmallShopsId, req.TenantId, req.MallBaseId);
return ApiResult.Success("", Robj);
}
#endregion
#region 资讯 #region 资讯
#endregion #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