Commit ee99aa17 authored by 吴春's avatar 吴春

提交代码

parent e30d75e8
...@@ -7,6 +7,7 @@ using Mall.Model.Query; ...@@ -7,6 +7,7 @@ using Mall.Model.Query;
using Mall.Repository; using Mall.Repository;
using Mall.Repository.MarketingCenter; using Mall.Repository.MarketingCenter;
using MySqlX.XDevAPI.Relational; using MySqlX.XDevAPI.Relational;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Crypto.Tls; using Org.BouncyCastle.Crypto.Tls;
using System; using System;
...@@ -26,7 +27,7 @@ namespace Mall.Module.MarketingCenter ...@@ -26,7 +27,7 @@ namespace Mall.Module.MarketingCenter
/// 小程序模板仓储层对象 /// 小程序模板仓储层对象
/// </summary> /// </summary>
private readonly RB_Miniprogram_TemplateRepository miniprogram_TemplateRepository = new RB_Miniprogram_TemplateRepository(); private readonly RB_Miniprogram_TemplateRepository miniprogram_TemplateRepository = new RB_Miniprogram_TemplateRepository();
private readonly Repository.Miai.RB_MiAi_BaseInfoRepository miai_BaseInfoRepository = new Repository.Miai.RB_MiAi_BaseInfoRepository();
/// <summary> /// <summary>
/// 小程序模板分页列表 /// 小程序模板分页列表
/// </summary> /// </summary>
...@@ -47,7 +48,7 @@ namespace Mall.Module.MarketingCenter ...@@ -47,7 +48,7 @@ namespace Mall.Module.MarketingCenter
/// <param name="query">查询条件</param> /// <param name="query">查询条件</param>
/// <param name="IsAnalyzePlus">是否解析插件</param> /// <param name="IsAnalyzePlus">是否解析插件</param>
/// <returns></returns> /// <returns></returns>
public List<RB_Miniprogram_Template_Extend> GetMiniprogramTemplateListModule(RB_Miniprogram_Template_Extend query, bool IsAnalyzePlus = false) public List<RB_Miniprogram_Template_Extend> GetMiniprogramTemplateListModule(RB_Miniprogram_Template_Extend query, int TenantId = 0, int MallBaseId = 0, int UserId = 0, bool IsAnalyzePlus = false)
{ {
var list = miniprogram_TemplateRepository.GetMiniprogramTemplateListRepository(query); var list = miniprogram_TemplateRepository.GetMiniprogramTemplateListRepository(query);
if (IsAnalyzePlus) if (IsAnalyzePlus)
...@@ -61,7 +62,7 @@ namespace Mall.Module.MarketingCenter ...@@ -61,7 +62,7 @@ namespace Mall.Module.MarketingCenter
{ {
foreach (var subItem in item.ComponentDataList) foreach (var subItem in item.ComponentDataList)
{ {
AnalyzePlusModule(subItem); AnalyzePlusModule(subItem, TenantId,MallBaseId,UserId);
} }
} }
} }
...@@ -127,7 +128,7 @@ namespace Mall.Module.MarketingCenter ...@@ -127,7 +128,7 @@ namespace Mall.Module.MarketingCenter
/// 解析插件 /// 解析插件
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void AnalyzePlusModule(ComponentItem item) public void AnalyzePlusModule(ComponentItem item, int TenantId=0, int MallBaseId=0, int UserId = 0)
{ {
switch (item.Id) switch (item.Id)
{ {
...@@ -630,20 +631,317 @@ namespace Mall.Module.MarketingCenter ...@@ -630,20 +631,317 @@ namespace Mall.Module.MarketingCenter
var driveData = JsonHelper.DeserializeObject<MiAiUserItem>(item.data.ToString()); var driveData = JsonHelper.DeserializeObject<MiAiUserItem>(item.data.ToString());
if (driveData != null) if (driveData != null)
{ {
//miaiUserItem.goodsLength = driveData?.goodsLength ?? 0;
miaiUserItem.listStyle = driveData?.listStyle ?? 1; if (TenantId > 0 && MallBaseId > 0)
miaiUserItem.backgroundColor = driveData?.backgroundColor ?? ""; {
miaiUserItem.PaddingTop = driveData?.PaddingTop ?? "0"; miaiUserItem.listStyle = driveData?.listStyle ?? 1;
miaiUserItem.PaddingBottom = driveData?.PaddingBottom ?? "0"; miaiUserItem.backgroundColor = driveData?.backgroundColor ?? "";
miaiUserItem.PaddingLeft = driveData?.PaddingLeft ?? "0"; miaiUserItem.PaddingTop = driveData?.PaddingTop ?? "0";
miaiUserItem.PaddingRight = driveData?.PaddingRight ?? "0"; miaiUserItem.PaddingBottom = driveData?.PaddingBottom ?? "0";
miaiUserItem.SearchFilletPX = driveData?.SearchFilletPX ?? 0; miaiUserItem.PaddingLeft = driveData?.PaddingLeft ?? "0";
miaiUserItem.goodsLength = driveData.goodsLength; miaiUserItem.PaddingRight = driveData?.PaddingRight ?? "0";
miaiUserItem.sexType = driveData?.sexType ?? 0; miaiUserItem.SearchFilletPX = driveData?.SearchFilletPX ?? 0;
miaiUserItem.BrowseRate = miaiUserItem.addUserType == 2 ? (miaiUserItem.BrowseRate == 0 ? 1 : miaiUserItem.BrowseRate) : 0; miaiUserItem.goodsLength = driveData.goodsLength;
miaiUserItem.FollowRate = miaiUserItem.addUserType == 2 ? (miaiUserItem.FollowRate == 0 ? 1 : miaiUserItem.FollowRate) : 0; miaiUserItem.sexType = driveData?.sexType ?? 0;
miaiUserItem.list = new List<miaiUserDetail>(); miaiUserItem.BrowseRate = miaiUserItem.addUserType == 2 ? (miaiUserItem.BrowseRate == 0 ? 1 : miaiUserItem.BrowseRate) : 0;
miaiUserItem.list = driveData.list; miaiUserItem.FollowRate = miaiUserItem.addUserType == 2 ? (miaiUserItem.FollowRate == 0 ? 1 : miaiUserItem.FollowRate) : 0;
miaiUserItem.list = new List<miaiUserDetail>();
miaiUserItem.list = driveData.list;
int Sex = 0;
int Age = 0;
if (UserId > 0)//说明用户登录了的
{
//查看用户的
var baseInfo = miai_BaseInfoRepository.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 (miaiUserItem.sexType > 0)
{
Sex = miaiUserItem.sexType == 1 ? 2 : (miaiUserItem.sexType == 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 = miai_BaseInfoRepository.GetFirstBaseInfoList(new Model.Extend.Miai.RB_MiAi_BaseInfo_Extend
{
TenantId = TenantId,
MallBaseId = MallBaseId,
UserIds = Ids,
UserId = UserId
});
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(); //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.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 == 1)//匹配度暂无规则
{
var tempGoodsList = miai_BaseInfoRepository.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 tempGood in tempGoodsList)
{
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)
{
long rowCount = 0;
var tempGoodsList = miai_BaseInfoRepository.GetFirstBaseInfoPageList(1, miaiUserItem.goodsLength, out rowCount, new Model.Extend.Miai.RB_MiAi_BaseInfo_Extend
{
TenantId = TenantId,
MallBaseId = MallBaseId,
Sort = 2,
Sex = Sex,
UserId = UserId,
FollowRate = miaiUserItem.FollowRate == 0 ? 1 : miaiUserItem.FollowRate,
BrowseRate = miaiUserItem.BrowseRate == 0 ? 1 : miaiUserItem.BrowseRate,
});
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var tempGood in tempGoodsList)
{
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 == 3)
{
long rowCount = 0;
var tempGoodsList = miai_BaseInfoRepository.GetFirstBaseInfoPageList(1, miaiUserItem.goodsLength, out rowCount, new Model.Extend.Miai.RB_MiAi_BaseInfo_Extend
{
TenantId = TenantId,
MallBaseId = MallBaseId,
Sort = 3,
Sex = Sex,
UserId = UserId
});
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var tempGood in tempGoodsList)
{
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 {
miaiUserItem.listStyle = driveData?.listStyle ?? 1;
miaiUserItem.backgroundColor = driveData?.backgroundColor ?? "";
miaiUserItem.PaddingTop = driveData?.PaddingTop ?? "0";
miaiUserItem.PaddingBottom = driveData?.PaddingBottom ?? "0";
miaiUserItem.PaddingLeft = driveData?.PaddingLeft ?? "0";
miaiUserItem.PaddingRight = driveData?.PaddingRight ?? "0";
miaiUserItem.SearchFilletPX = driveData?.SearchFilletPX ?? 0;
miaiUserItem.goodsLength = driveData.goodsLength;
miaiUserItem.sexType = driveData?.sexType ?? 0;
miaiUserItem.BrowseRate = miaiUserItem.addUserType == 2 ? (miaiUserItem.BrowseRate == 0 ? 1 : miaiUserItem.BrowseRate) : 0;
miaiUserItem.FollowRate = miaiUserItem.addUserType == 2 ? (miaiUserItem.FollowRate == 0 ? 1 : miaiUserItem.FollowRate) : 0;
miaiUserItem.list = new List<miaiUserDetail>();
miaiUserItem.list = driveData.list;
}
} }
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -103,7 +103,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -103,7 +103,7 @@ namespace Mall.WebApi.Controllers.MallBase
int storeId = parms.GetInt("StoreId", 0); int storeId = parms.GetInt("StoreId", 0);
//用户id //用户id
int userId = RequestParm.UserId; int userId = RequestParm.UserId;
//首页数据 //首页数据
var homePage = new object(); var homePage = new object();
//底部导航 //底部导航
...@@ -180,7 +180,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -180,7 +180,7 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
foreach (var subItem in templateModel.ComponentDataList) foreach (var subItem in templateModel.ComponentDataList)
{ {
templateData.data.Add(MallHelper.PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId, RequestParm.SmallShopsId, isOpenSchool, storeId,userId)); templateData.data.Add(MallHelper.PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId, RequestParm.SmallShopsId, isOpenSchool, storeId, userId));
} }
} }
var tempObj = new var tempObj = new
...@@ -237,7 +237,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -237,7 +237,7 @@ namespace Mall.WebApi.Controllers.MallBase
MallBaseId = miniProgram.MallBaseId, MallBaseId = miniProgram.MallBaseId,
TenantId = miniProgram.TenantId, TenantId = miniProgram.TenantId,
QIds = templateIds QIds = templateIds
}, IsAnalyzePlus: true); }, (miniProgram.TenantId ?? 0), miniProgram.MallBaseId, userId, IsAnalyzePlus: true);
//解析模板 //解析模板
int index = 0; int index = 0;
foreach (var item in selfHomePage.DetailsList) foreach (var item in selfHomePage.DetailsList)
......
...@@ -153,7 +153,7 @@ namespace Mall.WebApi.Controllers ...@@ -153,7 +153,7 @@ namespace Mall.WebApi.Controllers
List<RB_Miniprogram_Template_Extend> tempList = new List<RB_Miniprogram_Template_Extend>(); List<RB_Miniprogram_Template_Extend> tempList = new List<RB_Miniprogram_Template_Extend>();
if (!string.IsNullOrEmpty(tempIds)) if (!string.IsNullOrEmpty(tempIds))
{ {
tempList = miniprogramTemplateModule.GetMiniprogramTemplateListModule(new RB_Miniprogram_Template_Extend() { QIds = tempIds }, IsAnalyzePlus: true); tempList = miniprogramTemplateModule.GetMiniprogramTemplateListModule(new RB_Miniprogram_Template_Extend() { QIds = tempIds }, TenantId, MallBaseId, UserId, IsAnalyzePlus: true);
} }
foreach (var item in navPageData.navs) foreach (var item in navPageData.navs)
{ {
...@@ -1392,10 +1392,10 @@ namespace Mall.WebApi.Controllers ...@@ -1392,10 +1392,10 @@ namespace Mall.WebApi.Controllers
Sex = Sex Sex = Sex
}, miAiUserItem.goodsLength); }, miAiUserItem.goodsLength);
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>(); List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var goodItem in miAiUserItem.list) foreach (var tempGood in tempGoodsList)
{ {
var lastItem = new miaiUserDetail(); var lastItem = new miaiUserDetail();
var tempGood = tempGoodsList?.Where(qitem => qitem.UserId == goodItem.id)?.FirstOrDefault(); // var tempGood = tempGoodsList?.Where(qitem => qitem.UserId == goodItem.id)?.FirstOrDefault();
if (tempGood != null && tempGood.Id > 0) if (tempGood != null && tempGood.Id > 0)
{ {
lastItem.id = tempGood.UserId; lastItem.id = tempGood.UserId;
...@@ -1455,10 +1455,10 @@ namespace Mall.WebApi.Controllers ...@@ -1455,10 +1455,10 @@ namespace Mall.WebApi.Controllers
BrowseRate = miAiUserItem.BrowseRate == 0 ? 1 : miAiUserItem.BrowseRate, BrowseRate = miAiUserItem.BrowseRate == 0 ? 1 : miAiUserItem.BrowseRate,
}); });
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>(); List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var goodItem in miAiUserItem.list) foreach (var tempGood in tempGoodsList)
{ {
var lastItem = new miaiUserDetail(); var lastItem = new miaiUserDetail();
var tempGood = tempGoodsList?.Where(qitem => qitem.UserId == goodItem.id)?.FirstOrDefault(); // var tempGood = tempGoodsList?.Where(qitem => qitem.UserId == goodItem.id)?.FirstOrDefault();
if (tempGood != null && tempGood.Id > 0) if (tempGood != null && tempGood.Id > 0)
{ {
lastItem.id = tempGood.UserId; lastItem.id = tempGood.UserId;
...@@ -1518,10 +1518,10 @@ namespace Mall.WebApi.Controllers ...@@ -1518,10 +1518,10 @@ namespace Mall.WebApi.Controllers
UserId = UserId UserId = UserId
}); });
List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>(); List<miaiUserDetail> newGoodsList = new List<miaiUserDetail>();
foreach (var goodItem in miAiUserItem.list) foreach (var tempGood in tempGoodsList)
{ {
var lastItem = new miaiUserDetail(); var lastItem = new miaiUserDetail();
var tempGood = tempGoodsList?.Where(qitem => qitem.UserId == goodItem.id)?.FirstOrDefault(); // var tempGood = tempGoodsList?.Where(qitem => qitem.UserId == goodItem.id)?.FirstOrDefault();
if (tempGood != null && tempGood.Id > 0) if (tempGood != null && tempGood.Id > 0)
{ {
lastItem.id = tempGood.UserId; lastItem.id = tempGood.UserId;
......
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