Commit 01bbb2d0 authored by liudong1993's avatar liudong1993

个人中心调整

parent 06abd1b5
using Mall.Common.AOP;
using Mall.Common.Enum.MarketingCenter;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 用户足迹表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Member_Footmark
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 用户id
/// </summary>
public int? UserId
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 删除状态
/// </summary>
public int? Status { get; set; }
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
namespace Mall.Model.Extend.User
{
/// <summary>
/// 用户足迹表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Member_Footmark_Extend : RB_Member_Footmark
{
/// <summary>
/// 开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndTime { get; set; }
/// <summary>
/// 商品名称
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// 商品图片
/// </summary>
public string GoodsImgPath { get; set; }
/// <summary>
/// 商品价格
/// </summary>
public decimal Price { get; set; }
}
}
...@@ -15,6 +15,7 @@ using Microsoft.Extensions.Configuration.Json; ...@@ -15,6 +15,7 @@ using Microsoft.Extensions.Configuration.Json;
using Newtonsoft.Json; using Newtonsoft.Json;
using Mall.Repository.BaseSetUp; using Mall.Repository.BaseSetUp;
using Mall.Common.Enum.User; using Mall.Common.Enum.User;
using Mall.Common.API;
namespace Mall.Module.User namespace Mall.Module.User
{ {
...@@ -91,6 +92,10 @@ namespace Mall.Module.User ...@@ -91,6 +92,10 @@ namespace Mall.Module.User
/// 订单 /// 订单
/// </summary> /// </summary>
private readonly RB_Goods_OrderRepository goods_OrderRepository = new RB_Goods_OrderRepository(); private readonly RB_Goods_OrderRepository goods_OrderRepository = new RB_Goods_OrderRepository();
/// <summary>
/// 足迹
/// </summary>
private readonly RB_Member_FootmarkRepository member_FootmarkRepository = new RB_Member_FootmarkRepository();
/// <summary> /// <summary>
...@@ -1934,7 +1939,6 @@ namespace Mall.Module.User ...@@ -1934,7 +1939,6 @@ namespace Mall.Module.User
#endregion #endregion
#region 分销中心 #region 分销中心
...@@ -2404,6 +2408,184 @@ namespace Mall.Module.User ...@@ -2404,6 +2408,184 @@ namespace Mall.Module.User
#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_Member_Footmark_Extend> GetUserFootMarkPageList(int pageIndex, int pageSize, out long count, RB_Member_Footmark_Extend demodel)
{
var list = member_FootmarkRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any())
{
//查询商品信息
string goodsIds = string.Join(",", list.Select(x => x.GoodsId).Distinct());
var goodsList = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//查询图片
List<RB_Material_Info_Extend> Mlist = new List<RB_Material_Info_Extend>();
if (goodsList.Any())
{
List<int> imgIds = new List<int>();
foreach (var item in goodsList)
{
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage);
//封面图
imgIds.Add(CarouselIdList[0]);
}
}
if (imgIds.Any())
{
Mlist = material_InfoRepository.GetList(new RB_Material_Info_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, MaterialIds = string.Join(",", imgIds.Distinct()) });
}
}
foreach (var item in list)
{
var goodsModel = goodsList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
item.GoodsName = goodsModel?.Name ?? "";
item.Price = goodsModel?.SellingPrice ?? 0;
item.GoodsImgPath = "";
if (goodsModel != null)
{
if (!string.IsNullOrEmpty(goodsModel.CarouselImage) && goodsModel.CarouselImage != "[]")
{
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(goodsModel.CarouselImage);
//封面图
item.GoodsImgPath = Mlist.Where(x => x.Id == CarouselIdList[0]).FirstOrDefault()?.Path ?? "";
}
}
}
}
return list;
}
/// <summary>
/// 新增足迹
/// </summary>
/// <param name="goodsId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetUserFootMarkInfo(int goodsId, AppletUserInfo userInfo)
{
var model = member_FootmarkRepository.GetList(new RB_Member_Footmark_Extend() { GoodsId = goodsId, UserId = userInfo.UserId, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId }).FirstOrDefault();
if (model == null)
{
return member_FootmarkRepository.Insert(new RB_Member_Footmark()
{
Id = 0,
GoodsId = goodsId,
Status = 0,
UserId = userInfo.UserId,
CreateDate = DateTime.Now,
TenantId = userInfo.TenantId,
MallBaseId = userInfo.MallBaseId
}) > 0;
}
else {
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_Footmark.CreateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper{
FiledName=nameof(RB_Member_Footmark.Id),
FiledValue=model.Id,
OperatorEnum=OperatorEnum.Equal
}
};
return member_FootmarkRepository.Update(keyValues, wheres);
}
}
/// <summary>
/// 删除足迹
/// </summary>
/// <param name="footMarkId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool DelUserFootMarkInfo(int footMarkId, AppletUserInfo userInfo)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_Footmark.Status),1},
{ nameof(RB_Member_Footmark.CreateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper{
FiledName=nameof(RB_Member_Footmark.Id),
FiledValue=footMarkId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_Footmark.UserId),
FiledValue=userInfo.UserId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_Footmark.TenantId),
FiledValue=userInfo.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_Footmark.MallBaseId),
FiledValue=userInfo.MallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return member_FootmarkRepository.Update(keyValues, wheres);
}
#endregion
#region 个人中心
/// <summary>
/// 获取个人中心统计
/// </summary>
/// <param name="userId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public ApiResult GetAppletUserCenterStatistics(int userId, int tenantId, int mallBaseId)
{
var umodel = member_UserRepository.GetEntity(userId);
//获取我的收藏
int CollectionNum = member_CollectionRepository.GetMyCollectionNum(new RB_Member_Collection_Extend() { UserId = userId, TenantId = tenantId, MallBaseId = mallBaseId });
//获取我的足迹
int FootmarkNum = member_FootmarkRepository.GetMyFootmarkNum(userId, tenantId, mallBaseId);
//订单状态
List<RB_Goods_Order_Extend> olist = goods_OrderRepository.GetAppletGoodsOrderNumStatistics(userId, tenantId, mallBaseId);
//待评价
int WaitCommentNum = goods_OrderRepository.GetAppletGoodsOrderWaitCommentNum(userId, tenantId, mallBaseId);
//售后处理中
int AfterSaleNum = goods_OrderRepository.GetAppletGoodsOrderAfterSaleNum(userId, tenantId, mallBaseId);
return ApiResult.Success("",new {
CollectionNum,
FootmarkNum,
umodel.Integral,
umodel.CouponsNum,
umodel.CardVolumeNum,
MyOrder =new
{
NonPayment = olist.Where(x => x.OrderStatus == Common.Enum.Goods.OrderStatusEnum.NonPayment).FirstOrDefault()?.OrderNum ?? 0,
WaitSendGoods = olist.Where(x => x.OrderStatus == Common.Enum.Goods.OrderStatusEnum.WaitSendGoods).FirstOrDefault()?.OrderNum ?? 0,
WaitReceiving = olist.Where(x => x.OrderStatus == Common.Enum.Goods.OrderStatusEnum.WaitReceiving).FirstOrDefault()?.OrderNum ?? 0,
WaitCommentNum,
AfterSaleNum
}
});
}
#endregion
#region 数据统计-分销排行 #region 数据统计-分销排行
/// <summary> /// <summary>
/// 分页列表 /// 分页列表
......
...@@ -78,5 +78,36 @@ namespace Mall.Repository.User ...@@ -78,5 +78,36 @@ namespace Mall.Repository.User
string sql = $@"select * from RB_Member_Collection where {where} order by Id desc"; string sql = $@"select * from RB_Member_Collection where {where} order by Id desc";
return Get<RB_Member_Collection_Extend>(sql).ToList(); return Get<RB_Member_Collection_Extend>(sql).ToList();
} }
/// <summary>
/// 获取我的收藏数量
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public int GetMyCollectionNum(RB_Member_Collection_Extend dmodel)
{
string where = $" 1=1 and col.{nameof(RB_Member_Collection_Extend.Status)}=0";
where += $" and col.Type=1 and col.UserId={dmodel.UserId} and g.Status=0 and g.GoodsStatus=1";
if (dmodel.TenantId > 0)
{
where += $@" and col.{nameof(RB_Member_Collection_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and col.{nameof(RB_Member_Collection_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
string sql = $@"select count(0) from rb_member_collection col
inner join RB_Goods g on col.GoodsId=g.Id
where {where} order by col.Id desc";
var obj = ExecuteScalar(sql);
if (obj != null)
{
return Convert.ToInt32(obj);
}
else {
return 0;
}
}
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using System.Linq;
namespace Mall.Repository.User
{
/// <summary>
/// 会员足迹仓储层
/// </summary>
public class RB_Member_FootmarkRepository : RepositoryBase<RB_Member_Footmark>
{
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Member_Footmark_Extend> GetPageList(int pageIndex, int pageSize, out long rowCount, RB_Member_Footmark_Extend dmodel)
{
string where = $" 1=1 and g.Status=0 and g.GoodsStatus=1 and f.{nameof(RB_Member_Footmark.Status)}=0 ";
if (dmodel.TenantId > 0) {
where += $@" and f.{nameof(RB_Member_Footmark.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and f.{nameof(RB_Member_Footmark.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.UserId > 0) {
where += $@" and f.{nameof(RB_Member_Footmark.UserId)} ={dmodel.UserId}";
}
if (dmodel.GoodsId > 0) {
where += $@" and f.{nameof(RB_Member_Footmark.GoodsId)} ={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.StartTime)) {
where += $@" and f.{nameof(RB_Member_Footmark.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime)) {
where += $@" and f.{nameof(RB_Member_Footmark.CreateDate)} <='{dmodel.EndTime} 23:59:59'";
}
string sql = $@"select f.* from RB_Member_Footmark f
inner join rb_goods g on f.GoodsId = g.Id
where {where} order by f.CreateDate desc";
return GetPage<RB_Member_Footmark_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Member_Footmark_Extend> GetList(RB_Member_Footmark_Extend dmodel)
{
string where = $" 1=1 and {nameof(RB_Member_Footmark.Status)}=0 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Member_Footmark.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Member_Footmark.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.UserId > 0)
{
where += $@" and {nameof(RB_Member_Footmark.UserId)} ={dmodel.UserId}";
}
if (dmodel.GoodsId > 0)
{
where += $@" and {nameof(RB_Member_Footmark.GoodsId)} ={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and {nameof(RB_Member_Footmark.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and {nameof(RB_Member_Footmark.CreateDate)} <='{dmodel.EndTime} 23:59:59'";
}
string sql = $@"select * from RB_Member_Footmark where {where} order by CreateDate desc";
return Get<RB_Member_Footmark_Extend>(sql).ToList();
}
/// <summary>
/// 获取我的收藏
/// </summary>
/// <param name="UserId"></param>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <returns></returns>
public int GetMyFootmarkNum(int UserId, int TenantId, int MallBaseId)
{
string where = $" 1=1 and g.Status=0 and g.GoodsStatus=1 and f.{nameof(RB_Member_Footmark.Status)}=0 ";
if (TenantId > 0)
{
where += $@" and f.{nameof(RB_Member_Footmark.TenantId)}={TenantId}";
}
if (MallBaseId > 0)
{
where += $@" and f.{nameof(RB_Member_Footmark.MallBaseId)}={MallBaseId}";
}
if (UserId > 0)
{
where += $@" and f.{nameof(RB_Member_Footmark.UserId)} ={UserId}";
}
string sql = $@"select count(0) from RB_Member_Footmark f
inner join rb_goods g on f.GoodsId = g.Id
where {where} order by f.CreateDate desc";
var obj = ExecuteScalar(sql);
if (obj != null)
{
return Convert.ToInt32(obj);
}
else {
return 0;
}
}
}
}
...@@ -1753,6 +1753,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1753,6 +1753,7 @@ namespace Mall.WebApi.Controllers.MallBase
demodel.IsQuickBuy ??= 2; demodel.IsQuickBuy ??= 2;
demodel.IsSellWell ??= 2; demodel.IsSellWell ??= 2;
demodel.GoodsType ??= Common.Enum.Goods.OrderTypeEnum.Mall; demodel.GoodsType ??= Common.Enum.Goods.OrderTypeEnum.Mall;
demodel.GoodsStatus ??= 2;
bool flag = productModule.SetProductGoodsInfo(demodel); bool flag = productModule.SetProductGoodsInfo(demodel);
if (flag) if (flag)
......
...@@ -507,5 +507,103 @@ namespace Mall.WebApi.Controllers.User ...@@ -507,5 +507,103 @@ namespace Mall.WebApi.Controllers.User
//分销订单 提现明细 我的团队 //分销订单 提现明细 我的团队
#endregion #endregion
#region 我的足迹
/// <summary>
/// 获取我的足迹分页类别
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetUserFootMarkPageList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Member_Footmark_Extend demodel = JsonConvert.DeserializeObject<RB_Member_Footmark_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
var list = userModule.GetUserFootMarkPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.GoodsName,
x.GoodsImgPath,
x.Price,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd") : ""
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 新增足迹
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetUserFootMarkInfo() {
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
if (GoodsId <= 0) {
return ApiResult.ParamIsNull();
}
bool flag = userModule.SetUserFootMarkInfo(GoodsId, userInfo);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
/// <summary>
/// 删除足迹
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult DelUserFootMarkInfo() {
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parms = JObject.Parse(req.msg.ToString());
int FootMarkId = parms.GetInt("FootMarkId", 0);
if (FootMarkId <= 0)
{
return ApiResult.ParamIsNull();
}
bool flag = userModule.DelUserFootMarkInfo(FootMarkId, userInfo);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion
#region 个人中心
/// <summary>
/// 获取用户中心统计
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletUserCenterStatistics()
{
var userInfo = AppletUserInfo;
return userModule.GetAppletUserCenterStatistics(userInfo.UserId, userInfo.TenantId, userInfo.MallBaseId);
}
#endregion
} }
} }
\ No newline at end of file
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