Commit 1533f968 authored by 吴春's avatar 吴春

提交代码

parent a61a6db9
......@@ -15,6 +15,8 @@ namespace Mall.Model.Extend.Miai
public string Name { get; set; }
public int Age { get; set; }
/// <summary>
/// 头像
/// </summary>
......
......@@ -1034,9 +1034,25 @@ namespace Mall.Module.Miai
{
return miai_BaseInfoRepository.GetFirstBaseInfoList( where);
}
/// <summary>
/// 首页插件匹配分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<RB_MiAi_BaseInfo_Extend> GetMatchingBaseInfoList(RB_MiAi_BaseInfo_Extend where, int Top)
{
return miai_BaseInfoRepository.GetMatchingBaseInfoList(where, Top);
}
#endregion
#region 我的粉丝/我的关注
#region 我的粉丝/我的关注
/// <summary>
/// 新增/修改我关注的会员配置
/// </summary>
......
......@@ -104,7 +104,7 @@ namespace Mall.Repository.Miai
public List<RB_MiAi_BaseInfo_Extend> GetFirstBaseInfoPageList(int pageIndex, int pageSize, out long rowsCount, RB_MiAi_BaseInfo_Extend where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT a.*,b.`Name`,b.Photo from RB_MiAi_BaseInfo as a
sb.Append($@"SELECT a.*,b.`Name`,b.Photo ,(YEAR (curdate())- YEAR ( a.Birthday )- 1+ (DATE_FORMAT( a.Birthday, '%m%d' )<=(DATE_FORMAT( curdate(), '%m%d' )))) Age from RB_MiAi_BaseInfo as a
LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklist!=1 ");
if (where != null)
{
......@@ -122,9 +122,12 @@ LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklis
}
if (where.UserId > 0)
{
sb.AppendFormat(" and a.UserId={0}", where.UserId);
sb.AppendFormat(" and a.UserId !={0}", where.UserId);
}
if (where.Sex > 0)
{
sb.AppendFormat(" and a.Sex !={0}", where.Sex);
}
if (!string.IsNullOrWhiteSpace(where.UserIds))
{
sb.AppendFormat(" and a.UserId in({0})", where.UserIds);
......@@ -132,14 +135,14 @@ LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklis
if (where.Sort == 1)
{
// sb.AppendFormat(" order by ");
// sb.AppendFormat(" order by ");
}
else if (where.Sort == 2)
{
sb.AppendFormat($@" ORDER BY (((a.FollowNum* {where.FollowRate})+(a.BrowseNum*{where.BrowseRate}))) desc");
}
else if (where.Sort ==3)
else if (where.Sort == 3)
{
sb.AppendFormat(" ORDER BY b.CreateDate desc ");
}
......@@ -149,6 +152,12 @@ LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklis
/// <summary>
/// 分页列表
/// </summary>
......@@ -160,7 +169,7 @@ LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklis
public List<RB_MiAi_BaseInfo_Extend> GetFirstBaseInfoList(RB_MiAi_BaseInfo_Extend where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT a.*,b.`Name`,b.Photo from RB_MiAi_BaseInfo as a
sb.Append($@"SELECT a.*,b.`Name`,b.Photo ,(YEAR (curdate())- YEAR ( a.Birthday )- 1+ (DATE_FORMAT( a.Birthday, '%m%d' )<=(DATE_FORMAT( curdate(), '%m%d' )))) Age from RB_MiAi_BaseInfo as a
LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklist!=1 ");
if (where != null)
{
......@@ -178,7 +187,11 @@ LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklis
}
if (where.UserId > 0)
{
sb.AppendFormat(" and a.UserId={0}", where.UserId);
sb.AppendFormat(" and a.UserId !={0}", where.UserId);
}
if (where.Sex > 0)
{
sb.AppendFormat(" and a.Sex !={0}", where.Sex);
}
if (!string.IsNullOrWhiteSpace(where.UserIds))
......@@ -200,7 +213,69 @@ LEFT JOIN rb_member_user as b on a.UserId=b.Id where a.Status=0 and b.Blacklis
sb.AppendFormat(" ORDER BY b.CreateDate desc ");
}
}
return Get<RB_MiAi_BaseInfo_Extend>( sb.ToString()).ToList();
return Get<RB_MiAi_BaseInfo_Extend>(sb.ToString()).ToList();
}
/// <summary>
/// 首页插件匹配分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<RB_MiAi_BaseInfo_Extend> GetMatchingBaseInfoList(RB_MiAi_BaseInfo_Extend where,int Top)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT
a. *,b.`Name`,b.Photo ,(YEAR (curdate())- YEAR ( a.Birthday )- 1+ (DATE_FORMAT( a.Birthday, '%m%d' )<=(DATE_FORMAT( curdate(), '%m%d' )))) Age
FROM
`RB_MiAi_BaseInfo` AS a
JOIN (
SELECT
ROUND(
RAND() * (
(SELECT MAX(id) FROM `RB_MiAi_BaseInfo`) - (SELECT MIN(id) FROM `RB_MiAi_BaseInfo`)
) + (SELECT MIN(id) FROM `RB_MiAi_BaseInfo`)
) AS id
) AS t2
LEFT JOIN rb_member_user as b on a.UserId=b.Id
WHERE
a.id >= t2.id and a.Status=0 and b.Blacklist!=1
ORDER BY
a.id
LIMIT {Top} ");
if (where != null)
{
if (where.TenantId > 0)
{
sb.AppendFormat(" and a.TenantId={0}", where.TenantId);
}
if (where.MallBaseId > 0)
{
sb.AppendFormat(" and a.MallBaseId={0}", where.MallBaseId);
}
if (where.Id > 0)
{
sb.AppendFormat(" and a.Id={0}", where.Id);
}
if (where.UserId > 0)
{
sb.AppendFormat(" and a.UserId!={0}", where.UserId);
}
if (where.Sex > 0)
{
sb.AppendFormat(" and a.Sex!={0}", where.Sex);
}
if (!string.IsNullOrWhiteSpace(where.UserIds))
{
sb.AppendFormat(" and a.UserId in({0})", where.UserIds);
}
}
return Get<RB_MiAi_BaseInfo_Extend>(sb.ToString()).ToList();
}
}
}
......@@ -101,6 +101,10 @@ namespace Mall.WebApi.Controllers.MallBase
//店铺id
int storeId = parms.GetInt("StoreId", 0);
//用户id
int userId = RequestParm.UserId;
//用户性别
int sex = parms.GetInt("Sex", 0);
//首页数据
var homePage = new object();
//底部导航
......@@ -177,7 +181,7 @@ namespace Mall.WebApi.Controllers.MallBase
{
foreach (var subItem in templateModel.ComponentDataList)
{
templateData.data.Add(MallHelper.PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId, RequestParm.SmallShopsId, isOpenSchool, storeId));
templateData.data.Add(MallHelper.PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId, RequestParm.SmallShopsId, isOpenSchool, sex, storeId,userId));
}
}
var tempObj = new
......@@ -250,7 +254,7 @@ namespace Mall.WebApi.Controllers.MallBase
{
foreach (var subItem in templateModel.ComponentDataList)
{
templateData.data.Add(MallHelper.PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId, RequestParm.SmallShopsId, isOpenSchool, storeId));
templateData.data.Add(MallHelper.PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId, RequestParm.SmallShopsId, isOpenSchool, storeId, userId));
}
}
var tempObj = new
......
......@@ -88,6 +88,7 @@ namespace Mall.WebApi.Controllers
/// </summary>
private static ReserveModule reserveModule = new ReserveModule();
/// <summary>
/// 模板处理类
/// </summary>
......@@ -105,7 +106,7 @@ namespace Mall.WebApi.Controllers
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public static object PlusDataToObject(ComponentItem subItem, int TenantId, int MallBaseId, int SmallShopsId, int IsOpenSchool, int StoreId)
public static object PlusDataToObject(ComponentItem subItem, int TenantId, int MallBaseId, int SmallShopsId, int IsOpenSchool, int StoreId, int SexInfo, int UserId = 0)
{
var obj = new object();
switch (subItem.Id)
......@@ -1288,17 +1289,48 @@ namespace Mall.WebApi.Controllers
if (miAiUserItem != null)
{
int Sex = 0;
int Age = 0;
if (UserId > 0)//说明用户登录了的
{
//查看用户的
var baseInfo = miaiModule.GetBaseInfoList(new Model.Extend.Miai.RB_MiAi_BaseInfo_Extend { TenantId = TenantId, MallBaseId = MallBaseId, UserId = UserId }).FirstOrDefault();
if (baseInfo != null)
{
Sex = baseInfo.Sex;
if (!string.IsNullOrWhiteSpace(baseInfo.Birthday))
{
try
{
Age = Convert.ToInt32(Common.Plugin.StringHelper.GetAge(baseInfo.Birthday));
}
catch (Exception)
{
Age = 0;
}
}
}
if (SexInfo > 0)
{
Sex = SexInfo == 1 ? 2 : (SexInfo == 2 ? 1 : 0);
}
}
//自定义商品
if (miAiUserItem.addUserType == 0)
{
if (miAiUserItem.list != null && miAiUserItem.list.Count > 0)
{
var Ids = "0," + string.Join(",", miAiUserItem.list.Select(qitem => qitem.id));
var tempGoodsList = miaiModule.GetFirstBaseInfoList( new Model.Extend.Miai.RB_MiAi_BaseInfo_Extend
var tempGoodsList = miaiModule.GetFirstBaseInfoList(new Model.Extend.Miai.RB_MiAi_BaseInfo_Extend
{
TenantId = TenantId,
MallBaseId = MallBaseId,
UserIds = Ids
UserIds = Ids,
Sex = Sex,
UserId = UserId
});
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var goodItem in miAiUserItem.list)
......@@ -1311,11 +1343,33 @@ namespace Mall.WebApi.Controllers
lastItem.name = tempGood.Name;
lastItem.Photo = tempGood.Photo;
lastItem.SexStr = tempGood.Sex == 1 ? "男" : "女";
lastItem.Age = Common.Plugin.StringHelper.GetAge(tempGood.Birthday);
lastItem.Age = tempGood.Age.ToString(); //Common.Plugin.StringHelper.GetAge(tempGood.Birthday);
lastItem.Marriage = (tempGood.Marriage.HasValue && tempGood.Marriage.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.Marriage) : "";
lastItem.Education = (tempGood.EducationType.HasValue && tempGood.EducationType.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.EducationType) : "";
if (UserId > 0 && Age > 0)
{
if (Age == tempGood.Age)
{
lastItem.MatchingRate = 90;
}
else if (Age > tempGood.Age)
{
lastItem.MatchingRate = ((Age - tempGood.Age) + 90) > 100 ? 100 : ((Age - tempGood.Age) + 90);
}
else if (Age < tempGood.Age)
{
lastItem.MatchingRate = (90 - (tempGood.Age - Age)) < 0 ? 0 : (90 - (tempGood.Age - Age));
}
else
{
lastItem.MatchingRate = 0;
}
}
else
{
lastItem.MatchingRate = 0;
}
lastItem.MatchingRate = 0;
lastItem.Score = 0;
lastItem.Album = tempGood.Album;
if (!string.IsNullOrWhiteSpace(lastItem.Album))
......@@ -1331,6 +1385,60 @@ namespace Mall.WebApi.Controllers
else if (miAiUserItem.addUserType == 1)//匹配度暂无规则
{
var tempGoodsList = miaiModule.GetMatchingBaseInfoList(new Model.Extend.Miai.RB_MiAi_BaseInfo_Extend
{
TenantId = TenantId,
MallBaseId = MallBaseId,
UserId = UserId,
Sex = Sex
}, miAiUserItem.goodsLength);
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var goodItem in miAiUserItem.list)
{
var lastItem = new miaiUserDetail();
var tempGood = tempGoodsList?.Where(qitem => qitem.UserId == goodItem.id)?.FirstOrDefault();
if (tempGood != null && tempGood.Id > 0)
{
lastItem.id = tempGood.UserId;
lastItem.name = tempGood.Name;
lastItem.Photo = tempGood.Photo;
lastItem.SexStr = tempGood.Sex == 1 ? "男" : "女";
lastItem.Age = tempGood.Age.ToString();
lastItem.Marriage = (tempGood.Marriage.HasValue && tempGood.Marriage.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.Marriage) : "";
lastItem.Education = (tempGood.EducationType.HasValue && tempGood.EducationType.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.EducationType) : "";
if (UserId > 0 && Age > 0)
{
if (Age == tempGood.Age)
{
lastItem.MatchingRate = 90;
}
else if (Age > tempGood.Age)
{
lastItem.MatchingRate = ((Age - tempGood.Age) + 90) > 100 ? 100 : ((Age - tempGood.Age) + 90);
}
else if (Age < tempGood.Age)
{
lastItem.MatchingRate = (90 - (tempGood.Age - Age)) < 0 ? 0 : (90 - (tempGood.Age - Age));
}
else
{
lastItem.MatchingRate = 0;
}
}
else
{
lastItem.MatchingRate = 0;
}
lastItem.Score = 0;
lastItem.Album = tempGood.Album;
if (!string.IsNullOrWhiteSpace(lastItem.Album))
{
lastItem.AlbumList = JsonConvert.DeserializeObject<List<string>>(lastItem.Album);
}
newGoodsList.Add(lastItem);
}
}
miAiUserItem.list = newGoodsList;
}
else if (miAiUserItem.addUserType == 2)
{
......@@ -1342,6 +1450,8 @@ namespace Mall.WebApi.Controllers
TenantId = TenantId,
MallBaseId = MallBaseId,
Sort = 2,
Sex = Sex,
UserId = UserId,
FollowRate = miAiUserItem.FollowRate == 0 ? 1 : miAiUserItem.FollowRate,
BrowseRate = miAiUserItem.BrowseRate == 0 ? 1 : miAiUserItem.BrowseRate,
});
......@@ -1356,11 +1466,33 @@ namespace Mall.WebApi.Controllers
lastItem.name = tempGood.Name;
lastItem.Photo = tempGood.Photo;
lastItem.SexStr = tempGood.Sex == 1 ? "男" : "女";
lastItem.Age = Common.Plugin.StringHelper.GetAge(tempGood.Birthday);
lastItem.Age = tempGood.Age.ToString();
lastItem.Marriage = (tempGood.Marriage.HasValue && tempGood.Marriage.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.Marriage) : "";
lastItem.Education = (tempGood.EducationType.HasValue && tempGood.EducationType.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.EducationType) : "";
lastItem.MatchingRate = 0;
if (UserId > 0 && Age > 0)
{
if (Age == tempGood.Age)
{
lastItem.MatchingRate = 90;
}
else if (Age > tempGood.Age)
{
lastItem.MatchingRate = ((Age - tempGood.Age) + 90) > 100 ? 100 : ((Age - tempGood.Age) + 90);
}
else if (Age < tempGood.Age)
{
lastItem.MatchingRate = (90 - (tempGood.Age - Age)) < 0 ? 0 : (90 - (tempGood.Age - Age));
}
else
{
lastItem.MatchingRate = 0;
}
}
else
{
lastItem.MatchingRate = 0;
}
lastItem.Score = 0;
lastItem.Album = tempGood.Album;
if (!string.IsNullOrWhiteSpace(lastItem.Album))
......@@ -1382,7 +1514,9 @@ namespace Mall.WebApi.Controllers
{
TenantId = TenantId,
MallBaseId = MallBaseId,
Sort = 3
Sort = 3,
Sex = Sex,
UserId = UserId
});
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var goodItem in miAiUserItem.list)
......@@ -1395,11 +1529,33 @@ namespace Mall.WebApi.Controllers
lastItem.name = tempGood.Name;
lastItem.Photo = tempGood.Photo;
lastItem.SexStr = tempGood.Sex == 1 ? "男" : "女";
lastItem.Age = Common.Plugin.StringHelper.GetAge(tempGood.Birthday);
lastItem.Age = tempGood.Age.ToString();
lastItem.Marriage = (tempGood.Marriage.HasValue && tempGood.Marriage.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.Marriage) : "";
lastItem.Education = (tempGood.EducationType.HasValue && tempGood.EducationType.Value > 0) ? Common.Plugin.EnumHelper.GetEnumName(tempGood.EducationType) : "";
lastItem.MatchingRate = 0;
if (UserId > 0 && Age > 0)
{
if (Age == tempGood.Age)
{
lastItem.MatchingRate = 90;
}
else if (Age > tempGood.Age)
{
lastItem.MatchingRate = ((Age - tempGood.Age) + 90) > 100 ? 100 : ((Age - tempGood.Age) + 90);
}
else if (Age < tempGood.Age)
{
lastItem.MatchingRate = (90 - (tempGood.Age - Age)) < 0 ? 0 : (90 - (tempGood.Age - Age));
}
else
{
lastItem.MatchingRate = 0;
}
}
else
{
lastItem.MatchingRate = 0;
}
lastItem.Score = 0;
lastItem.Album = tempGood.Album;
if (!string.IsNullOrWhiteSpace(lastItem.Album))
......@@ -2744,7 +2900,7 @@ namespace Mall.WebApi.Controllers
is_show_cart = mallBaseModel?.ListShopCar,
is_show_sales_num = mallBaseModel?.ListBuyCount,
is_show_goods_name = mallBaseModel?.ListName,
is_show_korea= miniProgram?.IsKorea??0,//是否是韩国馆(1-是)
is_show_korea = miniProgram?.IsKorea ?? 0,//是否是韩国馆(1-是)
is_underline_price = mallBaseModel?.DetailsLineationPrice,
is_express = mallBaseModel?.DeatilsExpress,
is_not_share_show = mallBaseModel?.OtherNoShare,
......
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