Commit 470d4242 authored by 吴春's avatar 吴春

提交代码

parents 71bd60c5 8a6ce82a
......@@ -545,5 +545,9 @@ namespace Mall.Model.Entity.Product
/// 商品备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 课程分数
/// </summary>
public decimal? CourseScore { get; set; }
}
}
......@@ -434,7 +434,34 @@ namespace Mall.Model.Entity.User
}
public class MenuNavMoreModel {
public class MenuNavMoreModel {
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 菜单栏标题
/// </summary>
public string MenuNavTitle
{
get;
set;
}
/// <summary>
/// 标题样式 1标准
/// </summary>
public int TitleStyle { get; set; }
/// <summary>
/// 菜单栏样式(0-列表,1-九宫格)
/// </summary>
public int? MenuNavStyle
{
get;
set;
}
/// <summary>
/// 菜单列表
/// </summary>
public List<RB_MiniProgram_UserCenterMenu> MeunList { get; set; }
}
}
......@@ -100,8 +100,10 @@ namespace Mall.Model.Extend.User
/// 小程序用户中心【自定义】菜单列表
/// </summary>
public List<RB_MiniProgram_UserCenterMenu_Extend> SelfMenuList { get; set; }
/// <summary>
/// 菜单栏 多组
/// </summary>
public List<Entity.User.MenuNavMoreModel> NavMoreList { get; set; }
/// <summary>
/// 获取可跳转小程序
/// </summary>
......
......@@ -2,6 +2,7 @@
using Mall.Common.Plugin;
using Mall.Model.Entity.Education;
using Mall.Model.Entity.Product;
using Mall.Model.Entity.User;
using Mall.Model.Extend.Education;
using Mall.Model.Extend.Product;
using Mall.Model.Extend.User;
......@@ -87,6 +88,14 @@ namespace Mall.Module.Education
/// 会员等级
/// </summary>
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>
/// 会员信息
......@@ -1148,6 +1157,132 @@ namespace Mall.Module.Education
#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 教师管理
/// <summary>
///教师配置列表
......
......@@ -478,6 +478,22 @@ namespace Mall.Module.User
extModel.AccountMenuList = menuList?.Where(qitem => qitem.MenuType == 2)?.ToList();
extModel.SelfMenuList = menuList?.Where(qitem => qitem.MenuType == 4).OrderBy(qitem => qitem.PageSort)?.ToList();
}
if (!string.IsNullOrEmpty(extModel.MenuNavJson) && extModel.MenuNavJson != "[]")
{
extModel.NavMoreList = JsonConvert.DeserializeObject<List<MenuNavMoreModel>>(extModel.MenuNavJson);
}
else {
extModel.NavMoreList = new List<MenuNavMoreModel>() {
new MenuNavMoreModel(){
Sort=1,
MenuNavTitle="",
MenuNavStyle=0,
TitleStyle=1,
MeunList=new List<RB_MiniProgram_UserCenterMenu>()
}
};
}
}
if (isGetHomeData)
{
......@@ -722,6 +738,28 @@ namespace Mall.Module.User
bool flag = false;
if (extModel.MallBaseId > 0)
{
#region 组装菜单栏
if (extModel.NavMoreList != null && extModel.NavMoreList.Any())
{
extModel.MenuNavJson = JsonConvert.SerializeObject(extModel.NavMoreList.Select(x => new
{
x.Sort,
x.MenuNavTitle,
x.TitleStyle,
x.MenuNavStyle,
MeunList = x.MeunList.Select(z => new
{
z.PageSort,
z.MenuName,
z.MenuIcon,
z.MenuUrl
})
}));
}
else {
extModel.MenuNavJson = "[]";
}
#endregion
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_MiniProgram_Extend.DefaultBgImg),extModel.DefaultBgImg},
......@@ -736,6 +774,7 @@ namespace Mall.Module.User
{ nameof(RB_MiniProgram_Extend.IsShowMenuNav),extModel.IsShowMenuNav},
{ nameof(RB_MiniProgram_Extend.MenuNavTitle),extModel.MenuNavTitle},
{ nameof(RB_MiniProgram_Extend.MenuNavStyle),extModel.MenuNavStyle},
{ nameof(RB_MiniProgram_Extend.MenuNavJson),extModel.MenuNavJson},
};
if (extModel.FavoriteFootMenuList != null && extModel.FavoriteFootMenuList.Count > 0)
{
......
......@@ -517,9 +517,9 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <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();
if (dmodel.TenantId > 0)
......
......@@ -7,6 +7,12 @@ using Newtonsoft.Json;
using Mall.Model.Extend.Education;
using System;
using System.Linq;
using Mall.Model.Extend.Product;
using Mall.Module.Product;
using Mall.Model.Extend.User;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Mall.Common.Plugin;
namespace Mall.WebApi.Controllers.Education
{
......@@ -17,8 +23,182 @@ namespace Mall.WebApi.Controllers.Education
public class AppletSchoolController : ControllerBase
{
private readonly EducationModule educationModule = new EducationModule();
private readonly ProductModule productModule = new ProductModule();
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 资讯
/// <summary>
......
......@@ -535,6 +535,19 @@ namespace Mall.WebApi.Controllers.MallBase
@params = "",
}),
nar_menus = miniProgram?.NavMoreList?.Select(x => new {
x.Sort,
x.MenuNavTitle,
x.TitleStyle,
x.MenuNavStyle,
MeunList = x.MeunList.OrderBy(qitem => qitem.PageSort).Select(qitem => new {
icon_url = qitem.MenuIcon,
name = qitem.MenuName,
link_url = qitem.MenuUrl.Trim(),
open_type = "navigate",
@params = "",
})
}),
//订单菜单列表
order_bar = miniProgram?.OrderMenuList?.Select(qitem => new
{
......
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