Commit 4de0ff95 authored by liudong1993's avatar liudong1993
parents f3fb9ebe d5c3a3cd
...@@ -138,5 +138,7 @@ namespace Mall.Common.Data ...@@ -138,5 +138,7 @@ namespace Mall.Common.Data
/// 状态 /// 状态
/// </summary> /// </summary>
public int S { get; set; } public int S { get; set; }
public List<Node> Children { get; set; }
} }
} }
...@@ -13,6 +13,38 @@ namespace Mall.Common ...@@ -13,6 +13,38 @@ namespace Mall.Common
public class ConvertHelper public class ConvertHelper
{ {
/// <summary>
/// json字符串将属性值中的英文双引号变成中文双引号
/// </summary>
/// <param name="strJson">json字符串</param>
/// <returns></returns>
public static string JsonReplaceSign(string strJson)
{
char[] temp = strJson.ToCharArray();
int n = temp.Length;
for (int i = 0; i < n; i++)
{
if (temp[i] == ':' && temp[i + 1] == '"')
{
for (int j = i + 2; j < n; j++)
{
if (temp[j] == '"')
{
if (temp[j + 1] != ',' && temp[j + 1] != '}')
{
temp[j] = '”';
}
else if (temp[j + 1] == ',' || temp[j + 1] == '}')
{
break;
}
}
}
}
}
return new String(temp);
}
/// <summary> /// <summary>
/// 转换字符流成字符串 /// 转换字符流成字符串
/// </summary> /// </summary>
...@@ -45,7 +77,7 @@ namespace Mall.Common ...@@ -45,7 +77,7 @@ namespace Mall.Common
return data; return data;
} }
/// <summary> /// <summary>
/// 类型转换 /// 类型转换
/// </summary> /// </summary>
...@@ -103,7 +135,7 @@ namespace Mall.Common ...@@ -103,7 +135,7 @@ namespace Mall.Common
/// <param name="obj"></param> /// <param name="obj"></param>
/// <param name="defaultValue">默认值</param> /// <param name="defaultValue">默认值</param>
/// <returns></returns> /// <returns></returns>
public static int ToInt(object obj,int defaultValue=0) public static int ToInt(object obj, int defaultValue = 0)
{ {
int result = defaultValue; int result = defaultValue;
if (obj != null) if (obj != null)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net;
using System.Text; using System.Text;
namespace Mall.Common.Plugin namespace Mall.Common.Plugin
...@@ -11,6 +12,50 @@ namespace Mall.Common.Plugin ...@@ -11,6 +12,50 @@ namespace Mall.Common.Plugin
/// </summary> /// </summary>
public class FileHelper public class FileHelper
{ {
/// <summary>
/// 生成图片
/// </summary>
/// <param name="url"></param>
public static void CreateImage(string url)
{
string tempPath = GetFileUrl(url);
string path = Environment.CurrentDirectory + tempPath;//下载到的地址+文件名
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
//发送请求并获取相应回应数据
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
//直到request.GetResponse()程序才开始向目标网页发送Post请求
Stream responseStream = response.GetResponseStream();
string newFilePath = path.Substring(0, path.LastIndexOf("/"));
if (!System.IO.Directory.Exists(newFilePath))//如果不存在就创建file文件夹
{
System.IO.Directory.CreateDirectory(newFilePath);
}
//创建本地文件写入流
Stream stream = new FileStream(path, FileMode.Create);
byte[] bArr = new byte[1024];
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
while (size > 0)
{
stream.Write(bArr, 0, size);
size = responseStream.Read(bArr, 0, (int)bArr.Length);
}
stream.Close();
responseStream.Close();
}
/// <summary>
/// 获取Oss文件全路径
/// </summary>
/// <param name="path">文件相对路径</param>
/// <returns></returns>
public static string GetFileUrl(string path)
{
return path.Replace("http://auth-zjhejiang-com.oss-cn-hangzhou.aliyuncs.com", "")
.Replace("https://cdnimg.iotweixin.com", "").Replace("http://img.weibaoge.cn","").Replace("http://v4test.zjhejiang.com","")
.Replace("http://v4test1.oss-cn-hangzhou.aliyuncs.com","").Replace("https://viitto-1301420277.cos.ap-chengdu.myqcloud.com","");
}
/// <summary> /// <summary>
/// 网站文件夹虚拟目录 /// 网站文件夹虚拟目录
/// </summary> /// </summary>
...@@ -22,7 +67,7 @@ namespace Mall.Common.Plugin ...@@ -22,7 +67,7 @@ namespace Mall.Common.Plugin
/// <param name="filePath">文件夹路径</param> /// <param name="filePath">文件夹路径</param>
public static void DeleteFile(string filePath) public static void DeleteFile(string filePath)
{ {
string newPath = AppContext.BaseDirectory+ "\\" + filePath; string newPath = AppContext.BaseDirectory + "\\" + filePath;
DirectoryInfo theFolder = new DirectoryInfo(newPath); DirectoryInfo theFolder = new DirectoryInfo(newPath);
if (theFolder.Exists) if (theFolder.Exists)
{ {
...@@ -100,7 +145,7 @@ namespace Mall.Common.Plugin ...@@ -100,7 +145,7 @@ namespace Mall.Common.Plugin
{ {
string newTempFilePath = filePath.Substring(filePath.IndexOf("/")); ; string newTempFilePath = filePath.Substring(filePath.IndexOf("/")); ;
var strPath = AppContext.BaseDirectory + "\\" + VirtualDirectory + newTempFilePath; //System.Web.HttpContext.Current.Server.MapPath("~/" + VirtualDirectory + newTempFilePath); var strPath = AppContext.BaseDirectory + "\\" + VirtualDirectory + newTempFilePath; //System.Web.HttpContext.Current.Server.MapPath("~/" + VirtualDirectory + newTempFilePath);
string newfilePath = AppContext.BaseDirectory + "\\" + VirtualDirectory +newFilePath.Substring(0, strPath.LastIndexOf('\\') - 1); //System.Web.HttpContext.Current.Server.MapPath("~/" + VirtualDirectory) + newFilePath.Substring(0, strPath.LastIndexOf('\\') - 1); string newfilePath = AppContext.BaseDirectory + "\\" + VirtualDirectory + newFilePath.Substring(0, strPath.LastIndexOf('\\') - 1); //System.Web.HttpContext.Current.Server.MapPath("~/" + VirtualDirectory) + newFilePath.Substring(0, strPath.LastIndexOf('\\') - 1);
if (!Directory.Exists(newfilePath)) if (!Directory.Exists(newfilePath))
{ {
Directory.CreateDirectory(newfilePath); Directory.CreateDirectory(newfilePath);
......
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.MarketingCenter
{
/// <summary>
/// 充值自定义设置
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Recharge_Custom
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 余额名称
/// </summary>
public string BalanceName { get; set; }
/// <summary>
/// 充值金额
/// </summary>
public string RechareName { get; set; }
/// <summary>
/// 充值说明
/// </summary>
public string RechareExplain { get; set; }
/// <summary>
/// 按钮圆角
/// </summary>
public int BtnFillet { get; set; }
/// <summary>
/// 按钮文本
/// </summary>
public string BtnName { get; set; }
/// <summary>
/// 背景颜色
/// </summary>
public string BackgroundColor { get; set; }
/// <summary>
/// 文本颜色
/// </summary>
public string TextColor { get; set; }
}
}
...@@ -80,5 +80,7 @@ namespace Mall.Model.Extend.BaseSetUp ...@@ -80,5 +80,7 @@ namespace Mall.Model.Extend.BaseSetUp
/// 批量name查询 /// 批量name查询
/// </summary> /// </summary>
public string NameStr { get; set; } public string NameStr { get; set; }
public List<RB_Destination_Extend> Children { get; set; }
} }
} }
...@@ -33,5 +33,10 @@ namespace Mall.Model.Entity.MarketingCenter ...@@ -33,5 +33,10 @@ namespace Mall.Model.Entity.MarketingCenter
/// 创建人 /// 创建人
/// </summary> /// </summary>
public string CreateByName { get; set; } public string CreateByName { get; set; }
/// <summary>
/// 编号【逗号分割查询使用】
/// </summary>
public string QIds { get; set; }
} }
} }
\ No newline at end of file
...@@ -162,9 +162,9 @@ namespace Mall.Module.BaseSetUp ...@@ -162,9 +162,9 @@ namespace Mall.Module.BaseSetUp
/// 获取列表 /// 获取列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<Mall.Common.Data.Node> GetAllList() public List<RB_Destination_Extend> GetAllList()
{ {
return rb_DestinationRepository.GetAllList(); return rb_DestinationRepository.GetAllDestinationList();
} }
/// <summary> /// <summary>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Mall.Common\Mall.Common.csproj" />
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" /> <ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
<ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" /> <ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" />
</ItemGroup> </ItemGroup>
......
...@@ -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.Linq;
using Org.BouncyCastle.Crypto.Tls; using Org.BouncyCastle.Crypto.Tls;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -45,16 +46,16 @@ namespace Mall.Module.MarketingCenter ...@@ -45,16 +46,16 @@ 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, bool IsAnalyzePlus = false)
{ {
var list= miniprogram_TemplateRepository.GetMiniprogramTemplateListRepository(query); var list = miniprogram_TemplateRepository.GetMiniprogramTemplateListRepository(query);
if (IsAnalyzePlus) if (IsAnalyzePlus)
{ {
foreach (var item in list) foreach (var item in list)
{ {
if (item.TemplateData != null && !string.IsNullOrEmpty(item.TemplateData)) if (item.TemplateData != null && !string.IsNullOrEmpty(item.TemplateData))
{ {
item.ComponentDataList = JsonHelper.DeserializeObject<List<ComponentItem>>(item.TemplateData); item.ComponentDataList = JsonHelper.DeserializeObject<List<ComponentItem>>(Mall.Common.ConvertHelper.JsonReplaceSign(item.TemplateData));
if (item.ComponentDataList != null && item.ComponentDataList.Count > 0) if (item.ComponentDataList != null && item.ComponentDataList.Count > 0)
{ {
foreach (var subItem in item.ComponentDataList) foreach (var subItem in item.ComponentDataList)
...@@ -130,7 +131,7 @@ namespace Mall.Module.MarketingCenter ...@@ -130,7 +131,7 @@ namespace Mall.Module.MarketingCenter
switch (item.Id) switch (item.Id)
{ {
//背景组件 //背景组件
case "background":item.data = JsonHelper.DeserializeObject<backgroundItem>(item.data.ToString()); break; case "background": item.data = JsonHelper.DeserializeObject<backgroundItem>(item.data.ToString()); break;
//查找组件 //查找组件
case "search": item.data = JsonHelper.DeserializeObject<searchItem>(item.data.ToString()); break; case "search": item.data = JsonHelper.DeserializeObject<searchItem>(item.data.ToString()); break;
//导航组件 //导航组件
...@@ -145,18 +146,106 @@ namespace Mall.Module.MarketingCenter ...@@ -145,18 +146,106 @@ namespace Mall.Module.MarketingCenter
case "link": item.data = JsonHelper.DeserializeObject<linkItem>(item.data.ToString()); break; case "link": item.data = JsonHelper.DeserializeObject<linkItem>(item.data.ToString()); break;
//图片广告插件 //图片广告插件
case "rubik": case "rubik":
try JObject jObj = JObject.Parse(item.data.ToString());
Int32.TryParse(jObj["style"].ToString(), out int style);
Int32.TryParse(jObj["space"].ToString(), out int space);
Int32.TryParse(jObj["h"].ToString(), out int h_root);
Int32.TryParse(jObj["w"].ToString(), out int w_root);
var subData = new rubikItem()
{ {
item.data = JsonHelper.DeserializeObject<rubikItem>(item.data.ToString()); style = style,
space = space,
height = jObj["height"].ToString(),
w = w_root.ToString(),
h = h_root,
hotspot = new List<hotspotItem>(),
list = new List<rubikDetailItem>(),
};
if (!string.IsNullOrWhiteSpace(jObj["hotspot"].ToString()))
{
subData.hotspot = Common.Plugin.JsonHelper.DeserializeObject<List<hotspotItem>>(jObj["hotspot"].ToString());
} }
catch if (!string.IsNullOrWhiteSpace(jObj["list"].ToString()))
{ {
item.data = new rubikItem() JArray jArray = JArray.Parse(jObj["list"].ToString());
if (jArray != null && jArray.Count > 0)
{ {
hotspot = new List<hotspotItem>(), foreach (var subItem in jArray)
list = new List<rubikDetailItem>() { new rubikDetailItem() { link = new List<rubikLinkItem>() { new rubikLinkItem ()} } }, {
}; Int32.TryParse(subItem["w"].ToString(), out int w);
Int32.TryParse(subItem["h"].ToString(), out int h2);
Int32.TryParse(subItem["x"].ToString(), out int x);
Int32.TryParse(subItem["y"].ToString(), out int y);
int zIndex = 0;
if (subItem["zIndex"] != null && !string.IsNullOrWhiteSpace(subItem["zIndex"].ToString()))
{
Int32.TryParse(subItem["zIndex"].ToString(), out zIndex);
}
var links = new List<rubikLinkItem>();
if (subItem["link"] != null && !string.IsNullOrWhiteSpace(subItem["link"].ToString()))
{
try
{
var linkObj = JObject.Parse(subItem["link"].ToString());
links.Add(new rubikLinkItem()
{
PageName = linkObj["name"].ToString(),
PageUrl = linkObj["value"].ToString(),
new_link_url = linkObj["new_link_url"].ToString(),
IsParameter = 0,
ParameterValue = linkObj["name"].ToString(),
});
}
catch
{
}
try
{
var linkArray = JArray.Parse(subItem["link"].ToString());
if (linkArray != null && linkArray.Count > 0)
{
foreach (var linkItem in linkArray)
{
links.Add(new rubikLinkItem()
{
PageName = linkItem["name"].ToString(),
PageUrl = linkItem["value"].ToString(),
new_link_url = linkItem["new_link_url"].ToString(),
IsParameter = 0,
ParameterValue = linkItem["name"].ToString(),
});
}
}
}
catch
{
}
}
subData.list.Add(new rubikDetailItem()
{
w = w,
h = h2,
x = x,
y = y,
link = links,
width = subItem["width"].ToString(),
height = subItem["height"].ToString(),
left = subItem["left"].ToString(),
top = subItem["top"].ToString(),
pic_url = subItem["pic_url"].ToString(),
backgroundImage = subItem["backgroundImage"].ToString(),
backgroundRepeat = subItem["backgroundRepeat"].ToString(),
backgroundSize = subItem["backgroundSize"].ToString(),
backgroundPosition = subItem["backgroundPosition"].ToString(),
zIndex = zIndex
}); ;
}
}
} }
item.data = subData;
break; break;
//视频插件 //视频插件
case "video": item.data = JsonHelper.DeserializeObject<videoItem>(item.data.ToString()); break; case "video": item.data = JsonHelper.DeserializeObject<videoItem>(item.data.ToString()); break;
......
...@@ -18,6 +18,8 @@ namespace Mall.Module.MarketingCenter ...@@ -18,6 +18,8 @@ namespace Mall.Module.MarketingCenter
private RB_Member_BalanceRepository balanceRepository = new RB_Member_BalanceRepository(); private RB_Member_BalanceRepository balanceRepository = new RB_Member_BalanceRepository();
private RB_Recharge_SettingsRepository settingsRepository = new RB_Recharge_SettingsRepository(); private RB_Recharge_SettingsRepository settingsRepository = new RB_Recharge_SettingsRepository();
private RB_Recharge_CustomRepository customRepository = new RB_Recharge_CustomRepository();
#region 充值规则信息 #region 充值规则信息
/// <summary> /// <summary>
/// 充值信息列表 /// 充值信息列表
...@@ -156,5 +158,51 @@ namespace Mall.Module.MarketingCenter ...@@ -156,5 +158,51 @@ namespace Mall.Module.MarketingCenter
} }
#endregion #endregion
#region 自定义充值
/// <summary>
/// 自定义充值信息列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Recharge_Custom> GetRechargeCustomList(RB_Recharge_Custom query)
{
return customRepository.GetRechargeCustomList(query);
}
/// <summary>
/// 新增/修改自定义充值
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateRechargeCustom(RB_Recharge_Custom model)
{
if (model.ID == 0)
{
return customRepository.Insert(model) > 0;
}
else
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Recharge_Custom.BalanceName), model.BalanceName},
{nameof(RB_Recharge_Custom.RechareName), model.RechareName},
{nameof(RB_Recharge_Custom.RechareExplain), model.RechareExplain},
{nameof(RB_Recharge_Custom.BtnFillet), model.BtnFillet},
{nameof(RB_Recharge_Custom.BtnName), model.BtnName},
{nameof(RB_Recharge_Custom.BackgroundColor), model.BackgroundColor},
{nameof(RB_Recharge_Custom.TextColor), model.TextColor},
{nameof(RB_Recharge_Custom.UpdateDate), model.UpdateDate},
};
List<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper(){ FiledName=nameof(RB_Recharge_Custom.ID),FiledValue=model.ID ,OperatorEnum=OperatorEnum.Equal}
};
return customRepository.Update(fileds, whereHelpers);
}
}
#endregion
} }
} }
...@@ -234,6 +234,22 @@ SELECT * FROM {0} WHERE 1=1 AND ParentID<>2 {1} ...@@ -234,6 +234,22 @@ SELECT * FROM {0} WHERE 1=1 AND ParentID<>2 {1}
return queryList; return queryList;
} }
/// <summary>
/// 获取地区列表
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetAllDestinationList()
{
List<Common.Data.Node> queryList = new List<Common.Data.Node>();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT * FROM {0} WHERE 1=1 ", TableName);
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
List<RB_Destination_Extend> list = Get<RB_Destination_Extend>(sb.ToString()).ToList();
return list;
}
/// <summary> /// <summary>
/// 根据Ids获取地区名称 /// 根据Ids获取地区名称
/// </summary> /// </summary>
......
using Mall.Model.Entity.MarketingCenter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.MarketingCenter
{
/// <summary>
/// 自定义充值仓储层
/// </summary>
public class RB_Recharge_CustomRepository : RepositoryBase<RB_Recharge_Custom>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Recharge_Custom); } }
/// <summary>
/// 自定义充值信息列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Recharge_Custom> GetRechargeCustomList(RB_Recharge_Custom query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Recharge_Custom.Status)}=0 ");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_Recharge_Custom.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Recharge_Custom.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Recharge_Custom.MallBaseId)}={query.MallBaseId}");
}
}
return Get<RB_Recharge_Custom>(builder.ToString()).ToList();
}
}
}
...@@ -38,6 +38,10 @@ namespace Mall.Repository.MarketingCenter ...@@ -38,6 +38,10 @@ namespace Mall.Repository.MarketingCenter
{ {
builder.AppendFormat(" AND {0}={1}", nameof(RB_Template_Market_Extend.IsUse), query.IsUse); builder.AppendFormat(" AND {0}={1}", nameof(RB_Template_Market_Extend.IsUse), query.IsUse);
} }
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%'", nameof(RB_Template_Market_Extend.Name), query.Name.Trim());
}
} }
return GetPage<RB_Template_Market_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList(); return GetPage<RB_Template_Market_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
} }
...@@ -58,6 +62,14 @@ namespace Mall.Repository.MarketingCenter ...@@ -58,6 +62,14 @@ namespace Mall.Repository.MarketingCenter
{ {
builder.Append($" AND {nameof(RB_Template_Market_Extend.Name)} like '%{query.Name.Trim()}%'"); builder.Append($" AND {nameof(RB_Template_Market_Extend.Name)} like '%{query.Name.Trim()}%'");
} }
if (query.Id > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Template_Market_Extend.Id), query.Id);
}
if (!string.IsNullOrWhiteSpace(query.QIds))
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Template_Market_Extend.Id), query.QIds);
}
} }
return Get<RB_Template_Market_Extend>(builder.ToString()).ToList(); return Get<RB_Template_Market_Extend>(builder.ToString()).ToList();
} }
......
...@@ -637,6 +637,7 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id ...@@ -637,6 +637,7 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
string where = $" where 1=1 "; string where = $" where 1=1 ";
string payMemerNumWhere = ""; string payMemerNumWhere = "";
string orderTypeWhere = ""; string orderTypeWhere = "";
string sql = "";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and a.{nameof(RB_Goods_Order.TenantId)}={dmodel.TenantId}"; where += $@" and a.{nameof(RB_Goods_Order.TenantId)}={dmodel.TenantId}";
...@@ -666,8 +667,8 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id ...@@ -666,8 +667,8 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
{ {
if (dmodel.OrderStatus == 1) if (dmodel.OrderStatus == 1)
{ {
where += $@" and a.{nameof(RB_Goods_Order.OrderStatus)} in (1,2,4,3)"; where += $@" and a.{nameof(RB_Goods_Order.OrderStatus)} in (1,2,4,3,6)";
payMemerNumWhere += $@" and {nameof(RB_Goods_Order.OrderStatus)} in (1,2,4,3)"; payMemerNumWhere += $@" and {nameof(RB_Goods_Order.OrderStatus)} in (1,2,4,3,6)";
} }
else if (dmodel.OrderStatus == 2) else if (dmodel.OrderStatus == 2)
{ {
...@@ -681,7 +682,7 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id ...@@ -681,7 +682,7 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
} }
else if (dmodel.OrderStatus == 4)//后面做因为现在还没有售后表 else if (dmodel.OrderStatus == 4)//后面做因为现在还没有售后表
{ {
where += $@" and a.{nameof(RB_Goods_OrderAfterSale.ReOrderStatus)} in (1,2,4,3)";
} }
else if (dmodel.OrderStatus == 5)//后面做因为现在还没有售后表 else if (dmodel.OrderStatus == 5)//后面做因为现在还没有售后表
{ {
...@@ -699,11 +700,46 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id ...@@ -699,11 +700,46 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
payMemerNumWhere += $" AND DATE_FORMAT({nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )"; payMemerNumWhere += $" AND DATE_FORMAT({nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
} }
string sql = $@"SELECT t.CreateDate,SUM(t.GoodsNum)as GoodsNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as PayMoney, // string sql = $@"SELECT t.CreateDate,SUM(t.GoodsNum)as GoodsNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as PayMoney,
(SELECT COUNT(UserId) from rb_goods_order where DATE_FORMAT(CreateDate,'%Y-%m-%d' )=t.CreateDate {payMemerNumWhere} GROUP BY UserId) as PayMemerNum //(SELECT COUNT(distinct UserId) from rb_goods_order where DATE_FORMAT(CreateDate,'%Y-%m-%d' )=t.CreateDate {payMemerNumWhere} ) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId from rb_goods_order as a //from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId from rb_goods_order as a
LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId {where}) // LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId {where})
//as t GROUP BY t.CreateDate desc";
if (dmodel.OrderStatus == 0 || dmodel.OrderStatus == 1 || dmodel.OrderStatus == 2 || dmodel.OrderStatus == 3)
{
sql = $@"SELECT t.CreateDate,SUM(t.GoodsNum)as GoodsNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId,c.PayMemerNum from rb_goods_order as a
LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from rb_goods_order where 1=1 {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as t GROUP BY t.CreateDate desc";
}
else if (dmodel.OrderStatus == 4)
{
sql = $@"SELECT t.CreateDate,SUM(t.ReNumber)as GoodsNum ,COUNT(t.ReOrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.Refund as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from RB_Goods_OrderAfterSale where {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as t GROUP BY t.CreateDate desc"; as t GROUP BY t.CreateDate desc";
}
else if (dmodel.OrderStatus == 4)
{
sql = $@"SELECT t.CreateDate,SUM(t.ReNumber)as GoodsNum ,COUNT(t.ReOrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.Refund as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from RB_Goods_OrderAfterSale where {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as t GROUP BY t.CreateDate desc";
}
else if (dmodel.OrderStatus == 5)
{
sql = $@"SELECT t.CreateDate,SUM(t.ReNumber)as GoodsNum ,COUNT(t.ReOrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.RefundActual as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from RB_Goods_OrderAfterSale where {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as t GROUP BY t.CreateDate desc";
}
return GetPage<DataStatistics_Query>(pageIndex, pageSize, out count, sql).ToList(); return GetPage<DataStatistics_Query>(pageIndex, pageSize, out count, sql).ToList();
} }
......
...@@ -224,7 +224,7 @@ namespace Mall.Repository.User ...@@ -224,7 +224,7 @@ namespace Mall.Repository.User
string sql = @$" SELECT CreateDate,SUM(Income) as Income, SUM(Expend) as Expend from ( string sql = @$" SELECT CreateDate,SUM(Income) as Income, SUM(Expend) as Expend from (
select DATE_FORMAT(a.CreateDate, '%Y-%m-%d') as CreateDate, a.Integral as Income, 0 as Expend from {TableName} as a LEFT JOIN {MemberTableName} as b on a.UserId=b.Id where a.Type = 1 {builder.ToString()} select DATE_FORMAT(a.CreateDate, '%Y-%m-%d') as CreateDate, a.Integral as Income, 0 as Expend from {TableName} as a LEFT JOIN {MemberTableName} as b on a.UserId=b.Id where a.Type = 1 {builder.ToString()}
union all union all
select DATE_FORMAT(a.CreateDate, '%Y-%m-%d') as CreateDate, a.Integral as Income, 0 as Expend from {TableName} as a LEFT JOIN {MemberTableName} as b on a.UserId=b.Id where a.Type = 2 {builder.ToString()} select DATE_FORMAT(a.CreateDate, '%Y-%m-%d') as CreateDate, 0 as Income, a.Integral as Expend from {TableName} as a LEFT JOIN {MemberTableName} as b on a.UserId=b.Id where a.Type = 2 {builder.ToString()}
) as t GROUP BY CreateDate "; ) as t GROUP BY CreateDate ";
return GetPage<Integral_Query>(pageIndex, pageSize, out rowCount, sql).ToList(); return GetPage<Integral_Query>(pageIndex, pageSize, out rowCount, sql).ToList();
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.10.0" /> <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RabbitMQ.Client" Version="6.0.0" /> <PackageReference Include="RabbitMQ.Client" Version="6.0.0" />
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.10" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -10,14 +10,7 @@ namespace Mall.ThirdCore.Oss ...@@ -10,14 +10,7 @@ namespace Mall.ThirdCore.Oss
/// <returns></returns> /// <returns></returns>
public static IOssService Get() public static IOssService Get()
{ {
if (Config.FileService == "1") return TencentOss.Instance();
{
return AliOssService.Instance();
}
else
{
return OytourOssService.Instance();
}
} }
} }
} }
using COSXML;
using COSXML.Auth;
using COSXML.Model.Object;
using COSXML.Model.Bucket;
using COSXML.CosException;
using Newtonsoft.Json.Linq;
using System.IO;
using COSXML.Utils;
using System.Collections.Generic;
using System;
namespace Mall.ThirdCore.Oss
{
/// <summary>
/// 腾讯OSS服务
/// </summary>
public class TencentOss: IOssService
{
private string endpoint = "";
private string accessKeyId = "";
private string accessKeySecret = "";
private string bucketName = "";
/// <summary>
/// 构造函数
/// </summary>
/// <param name="endpoint"></param>
/// <param name="accessKeyId"></param>
/// <param name="accessKeySecret"></param>
/// <param name="bucketName"></param>
public TencentOss(string endpoint, string accessKeyId, string accessKeySecret, string bucketName)
{
this.endpoint = endpoint;
this.accessKeyId = accessKeyId;
this.accessKeySecret = accessKeySecret;
this.bucketName = bucketName;
}
/// <summary>
/// 创建实例
/// </summary>
/// <returns></returns>
public static TencentOss Instance()
{
string endpoint = "ap-chengdu";
string accessKeyId = "AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd";
string accessKeySecret = "PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob";
string bucketName = "viitto-1301420277";
return new TencentOss(endpoint, accessKeyId, accessKeySecret, bucketName);
}
/// <summary>
/// 上传文件
/// </summary>
/// <param name="fileName">文件名</param>
/// <param name="stream">文件流</param>
/// <returns></returns>
public OssResult UploadFile(string filePath, System.IO.Stream stream)
{
OssResult ossResult = new OssResult();
CosXmlConfig config = new CosXmlConfig.Builder()
.SetConnectionTimeoutMs(60000) //设置连接超时时间,单位毫秒,默认45000ms
.SetReadWriteTimeoutMs(40000) //设置读写超时时间,单位毫秒,默认45000ms
.IsHttps(true) //设置默认 HTTPS 请求
.SetAppid("1301420277") //设置腾讯云账户的账户标识 APPID
.SetRegion(this.endpoint) //设置一个默认的存储桶地域
.Build();
string secretId = this.accessKeyId; //云 API 密钥 SecretId
string secretKey =this.accessKeySecret; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
CosXml cosXml = new CosXmlServer(config, qCloudCredentialProvider);
try
{
string fileExtention = System.IO.Path.GetExtension(filePath);
string bucket = this.bucketName; //存储桶,格式:BucketName-APPID
string key = @"/SaleBefore/Goods/"+DateTime.Now.Ticks.ToString()+fileExtention; //对象在存储桶中的位置,即称对象键
PutObjectRequest request = new PutObjectRequest(bucket, key, filePath);
//设置签名有效时长
request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
//设置进度回调
request.SetCosProgressCallback(delegate (long completed, long total)
{
//Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total));
});
//执行请求
PutObjectResult result = cosXml.PutObject(request);
//对象的 eTag
ossResult.data = key;
ossResult.resultCode = 1;
ossResult.message = "上传成功";
}
catch (COSXML.CosException.CosClientException clientEx)
{
ossResult.resultCode = 0;
ossResult.message = clientEx.Message;
}
catch (COSXML.CosException.CosServerException serverEx)
{
ossResult.resultCode = 0;
ossResult.message = serverEx.Message;
}
return ossResult;
}
/// <summary>
/// 删除文件
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public OssResult DeleteFile(string fileName)
{
OssResult result = new OssResult();
return result;
}
/// <summary>
/// 批量删除文件
/// </summary>
/// <param name="fileNameList"></param>
/// <returns></returns>
public OssResult DeleteFile(List<string> fileNameList)
{
OssResult result=new OssResult ();
return result;
}
/// <summary>
/// 拷贝文件
/// </summary>
/// <param name="sourceFileName">源文件</param>
/// <param name="targetFileName">目标文件</param>
/// <returns></returns>
public OssResult FileCopy(string sourceFileName, string targetFileName)
{
OssResult result = new OssResult();
return result;
}
/// <summary>
/// 判断文件是否存在
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public bool FileIsExist(string fileName)
{
return false;
}
}
}
\ No newline at end of file
...@@ -8,6 +8,7 @@ using System.Linq; ...@@ -8,6 +8,7 @@ using System.Linq;
using Mall.WebApi.Filter; using Mall.WebApi.Filter;
using Mall.Common.API; using Mall.Common.API;
using Mall.Common.Plugin; using Mall.Common.Plugin;
using Mall.ThirdCore.Oss;
namespace Mall.WebApi.Controllers.File namespace Mall.WebApi.Controllers.File
{ {
...@@ -64,9 +65,6 @@ namespace Mall.WebApi.Controllers.File ...@@ -64,9 +65,6 @@ namespace Mall.WebApi.Controllers.File
} }
} }
/// <summary> /// <summary>
/// 上传文件到本地临时文件 /// 上传文件到本地临时文件
/// </summary> /// </summary>
...@@ -112,5 +110,50 @@ namespace Mall.WebApi.Controllers.File ...@@ -112,5 +110,50 @@ namespace Mall.WebApi.Controllers.File
} }
} }
/// <summary>
/// 文件上传
/// </summary>
/// <param name="request"></param>
/// <param name="files"></param>
/// <returns></returns>
public virtual ApiResult UploadTencent()
{
try
{
var files = Request.Form.Files;
if (files.Count == 0)
{
return new ApiResult { resultCode = (int)ResultCode.Fail, message = "未选择文件", data = "" };
}
string filename = files[0].FileName;
string fileExtention = System.IO.Path.GetExtension(files[0].FileName);
string path = Guid.NewGuid().ToString() + fileExtention;
string basepath = AppContext.BaseDirectory;
string path_server = basepath + "\\SaleBefore\\Goods\\" + path;
if (!Directory.Exists(basepath + "\\SaleBefore\\Goods\\"))
{
Directory.CreateDirectory(basepath + "\\SaleBefore\\Goods\\");
}
using (FileStream fstream = new FileStream(path_server, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
files[0].CopyTo(fstream);
}
IOssService ossService = OssService.Get();
OssResult result = ossService.UploadFile(path_server,null);
try
{
System.IO.File.Delete(path_server);
}
catch {
}
return ApiResult.Success("", Common.Config.GetFileUrl(result.data.ToString()));
}
catch (Exception ex)
{
LogHelper.Write(ex, "FileUpload");
return ApiResult.Failed();
}
}
} }
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Entity.MarketingCenter;
using Mall.Model.Extend.BaseSetUp;
using Mall.Model.Extend.MarketingCenter;
using Mall.Model.Extend.User;
using Mall.Module.BaseSetUp;
using Mall.Module.MarketingCenter;
using Mall.Module.Product;
using Mall.Module.User;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Mall.WebApi.Controllers
{
/// <summary>
/// 小程序首页帮助类
/// </summary>
public class MallHelper
{
/// <summary>
/// 产品处理类
/// </summary>
private static ProductModule productModule = new ProductModule();
/// <summary>
/// 导航图标处理类
/// </summary>
private static MiniProgramNaviconModule programNaviconModule = new MiniProgramNaviconModule();
/// <summary>
/// 内容管理
/// </summary>
private static ContentModule contentModule = new ContentModule();
/// <summary>
/// 商户小程序处理类
/// </summary>
private static Module.User.MiniProgramModule programModule = new Module.User.MiniProgramModule();
/// <summary>
/// 小程序基础配置
/// </summary>
private static MallBaseModule mallBaseModule = new MallBaseModule();
/// <summary>
/// 用户积分
/// </summary>
private static IntegralModule integralModule = new IntegralModule();
/// <summary>
/// 用户处理类
/// </summary>
private static UserModule userModule = new UserModule();
/// <summary>
/// 解析插件数据为对象
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public static object PlusDataToObject(ComponentItem subItem, int TenantId, int MallBaseId)
{
var obj = new object();
switch (subItem.Id)
{
//背景插件
case "background":
var backgroundData = subItem.data as backgroundItem;
obj = new
{
id = subItem.Id,
data = backgroundData
};
break;
//搜索插件
case "search":
var searchData = subItem.data as searchItem;
obj = new
{
id = subItem.Id,
data = searchData
};
break;
//导航组件
case "nav":
var navData = subItem.data as navItem;
obj = new
{
id = subItem.Id,
data = navData
};
break;
//轮播广告插件
case "banner":
var bannerData = subItem.data as bannerItem;
obj = new
{
id = subItem.Id,
data = bannerData
};
break;
//公告组件
case "notice":
var noticeData = subItem.data as noticeItem;
obj = new
{
id = subItem.Id,
data = noticeData
};
break;
//专题组件
case "topic":
var topicData = subItem.data as topicItem;
obj = new
{
id = subItem.Id,
data = topicData
};
break;
//标题组件
case "link":
var linkData = subItem.data as linkItem;
obj = new
{
id = subItem.Id,
data = linkData
};
break;
//图片广告插件
case "rubik":
var rubikData = subItem.data as rubikItem;
obj = new
{
id = subItem.Id,
data = rubikData
};
break;
//视频插件
case "video":
var videoData = subItem.data as videoItem;
obj = new
{
id = subItem.Id,
data = videoData
};
break;
//商品插件
case "goods":
var goodsData = subItem.data as goodsItem;
if (goodsData != null)
{
//显示商品分类
if (goodsData.showCat)
{
if (goodsData.catList != null && goodsData.catList.Count > 0)
{
foreach (var childItem in goodsData.catList)
{
//自定义商品
if (childItem.staticGoods)
{
if (childItem.goodsList != null && childItem.goodsList.Count > 0)
{
var Ids = "0," + string.Join(",", childItem.goodsList.Select(qitem => qitem.id));
var tempGoodsList = productModule.GetProductGoodsList(new Model.Extend.Product.RB_Goods_Extend()
{
TenantId = TenantId,
MallBaseId = MallBaseId,
GoodsIds = Ids
});
foreach (var lastItem in childItem.goodsList)
{
var tempGood = tempGoodsList?.Where(qitem => qitem.Id == lastItem.id)?.FirstOrDefault();
if (tempGood != null && tempGood.Id > 0)
{
lastItem.name = tempGood?.Name ?? lastItem.name;
lastItem.price = Math.Round((tempGood?.SellingPrice ?? lastItem.price), 2);
lastItem.picUrl = tempGood?.CoverImage != null ? Common.Config.GetFileUrl(tempGood.CoverImage) : Common.Config.GetFileUrl(lastItem.picUrl);
lastItem.OriginalPrice = Math.Round((tempGood?.OriginalPrice ?? 0), 2);
}
}
}
}
//自动添加商品
else
{
childItem.goodsList = new List<GoodsDetailsItem2>();
var catGoodsList = productModule.GetProductGoodsPageList(1, childItem.goodsNum, out long rowsCount, new Model.Extend.Product.RB_Goods_Extend()
{
TenantId = TenantId,
MallBaseId = MallBaseId,
CategoryIds = childItem.id.ToString()
});
if (catGoodsList != null && catGoodsList.Count > 0)
{
foreach (var gItem in catGoodsList)
{
childItem.goodsList.Add(new GoodsDetailsItem2()
{
id = gItem.Id,
price = Math.Round((gItem?.SellingPrice ?? 0), 2),
name = gItem.Name,
picUrl = Common.Config.GetFileUrl(gItem.CoverImage),
OriginalPrice = Math.Round((gItem?.OriginalPrice ?? 0), 2)
});
}
}
}
}
}
}
//不显示商品分类
else
{
//自动添加商品
if (goodsData.addGoodsType == 0)
{
goodsData.list = new List<GoodsDetailsItem2>();
var goodsList = productModule.GetProductGoodsPageList(1, goodsData.goodsLength, out long rowsCount, new Model.Extend.Product.RB_Goods_Extend()
{
TenantId = TenantId,
MallBaseId = MallBaseId
});
if (goodsList != null && goodsList.Count > 0)
{
foreach (var gItem in goodsList)
{
goodsData.list.Add(new GoodsDetailsItem2()
{
id = gItem.Id,
price = Math.Round((gItem?.SellingPrice ?? 0), 2),
name = gItem.Name,
picUrl = Common.Config.GetFileUrl(gItem.CoverImage),
OriginalPrice = Math.Round((gItem?.OriginalPrice ?? 0), 2)
});
}
}
}
//手动添加商品
else
{
if (goodsData.list != null && goodsData.list.Count > 0)
{
var Ids = "0," + string.Join(",", goodsData.list.Select(qitem => qitem.id));
var tempGoodsList = productModule.GetProductGoodsList(new Model.Extend.Product.RB_Goods_Extend()
{
TenantId = TenantId,
MallBaseId = MallBaseId,
GoodsIds = Ids
});
foreach (var childItem in goodsData.list)
{
var tempGood = tempGoodsList?.Where(qitem => qitem.Id == childItem.id)?.FirstOrDefault();
if (tempGood != null && tempGood.Id > 0)
{
childItem.name = tempGood?.Name ?? childItem.name;
childItem.price = Math.Round((tempGood?.SellingPrice ?? childItem.price), 2);
childItem.picUrl = tempGood?.CoverImage != null ? Common.Config.GetFileUrl(tempGood.CoverImage) : Common.Config.GetFileUrl(childItem.picUrl);
childItem.OriginalPrice = Math.Round((tempGood?.OriginalPrice ?? 0), 2);
}
}
}
}
}
}
obj = new
{
id = subItem.Id,
data = goodsData
};
break;
//门店插件
case "store":
var storeData = subItem.data as storeItem;
obj = new
{
id = subItem.Id,
data = storeData
};
break;
//版权插件
case "copyright":
var copyrightData = subItem.data as copyrightItem;
obj = new
{
id = subItem.Id,
data = copyrightData
};
break;
//签到插件
case "check-in":
var checkinData = subItem.data as checkinItem;
obj = new
{
id = subItem.Id,
data = checkinData
};
break;
//用户信息插件
case "user-info":
var userinfoData = subItem.data as userinfoItem;
obj = new
{
id = subItem.Id,
data = userinfoData
};
break;
//用户订单插件
case "user-order":
var userorderData = subItem.data as userorderItem;
obj = new
{
id = subItem.Id,
data = userorderData
};
break;
//地图插件
case "map":
var mapData = subItem.data as mapItem;
obj = new
{
id = subItem.Id,
data = mapData
};
break;
//微信公众号插件
case "mp-link":
var mplinkData = subItem.data as mplinkItem;
obj = new
{
id = subItem.Id,
data = mplinkData
};
break;
//图文插件
case "image-text":
var imagetextData = subItem.data as imagetextItem;
obj = new
{
id = subItem.Id,
data = imagetextData
};
break;
//优惠券插件
case "coupon":
var couponData = subItem.data as couponItem;
obj = new
{
id = subItem.Id,
data = couponData
};
break;
//倒计时插件
case "timer":
var timerData = subItem.data as timerItem;
obj = new
{
id = subItem.Id,
data = timerData
};
break;
//拼团插件
case "pintuan":
var pintuanData = subItem.data as pintuanItem;
obj = new
{
id = subItem.Id,
data = pintuanData
};
break;
//预约插件
case "booking":
var bookingData = subItem.data as bookingItem;
obj = new
{
id = subItem.Id,
data = bookingData
};
break;
//砍价插件
case "bargain":
var bargainData = subItem.data as bargainItem;
obj = new
{
id = subItem.Id,
data = bargainData
};
break;
//积分商城插件
case "integral-mall":
var integralmallData = subItem.data as integralmallItem;
obj = new
{
id = subItem.Id,
data = integralmallData
};
break;
//抽奖插件
case "lottery":
var lotteryData = subItem.data as lotteryItem;
obj = new
{
id = subItem.Id,
data = lotteryData
};
break;
//预售
case "advance":
var advanceData = subItem.data as advanceItem;
obj = new
{
id = subItem.Id,
data = advanceData
};
break;
//超级会员卡
case "vip-card":
var vipcardData = subItem.data as vipcardItem;
obj = new
{
id = subItem.Id,
data = vipcardData
};
break;
//直播组件
case "live":
var liveData = subItem.data as liveItem;
obj = new
{
id = subItem.Id,
data = liveData
};
break;
//空组件
case "empty":
var emptyData = subItem.data as emptyItem;
obj = new
{
id = subItem.Id,
data = emptyData
};
break;
//流量主广告
case "ad":
var adData = subItem.data as adItem;
obj = new
{
id = subItem.Id,
data = adData
};
break;
//弹窗广告
case "modal":
var modalData = subItem.data as modalItem;
obj = new
{
id = subItem.Id,
data = modalData
};
break;
//弹窗广告
case "quick-nav":
var quicknavData = subItem.data as quicknavItem;
obj = new
{
id = subItem.Id,
data = quicknavData
};
break;
}
return obj;
}
/// <summary>
/// 自定义首页布局
/// </summary>
/// <param name="miniProgram"></param>
/// <returns></returns>
public static object DefaultHomepage(RB_MiniProgram_Extend miniProgram)
{
var templateData = new
{
id = 0,
name = "",
data = new List<object>()
};
foreach (var subitem in miniProgram.HomeDataList)
{
switch (subitem.key)
{
//搜索框
case "search":
templateData.data.Add(new
{
id = subitem.key,
data = new searchItem()
{
color = "#FFFFFF",
background = "#f2f2f2", //背景颜色
radius = 4, //圆角
placeholder = "搜索", //提示文字
textColor = "#555555", //文字颜色
textPosition = "left" //文字位置
}
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
break;
//轮播图
case "banner":
var bannerList = programModule.GetMallNavListModule(new Model.Entity.User.RB_Mall_Nav_Extend() { TenantId = miniProgram.TenantId, MallBaseId = miniProgram.MallBaseId });
var detailsBannerList = new List<bannerDetailItem>();
if (bannerList != null && bannerList.Count > 0)
{
foreach (var bItem in bannerList)
{
detailsBannerList.Add(new bannerDetailItem()
{
url = bItem.NavLink,
picUrl = Common.Config.GetFileUrl(bItem.NavImg)
});
}
}
templateData.data.Add(new
{
id = subitem.key,
data = new bannerItem()
{
style = 1, //样式
fill = 1, //填充方式0-留白 1填充
height = 450, //默认高度
banners = detailsBannerList
}
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
break;
//导航图标
case "home_nav":
var navList = programNaviconModule.GetMiniProgramNaviconListModule(new RB_MiniProgram_Navicon_Extend()
{
MallBaseId = miniProgram.MallBaseId
});
List<navIconItem> navs = new List<navIconItem>();
if (navList != null && navList.Count > 0)
{
foreach (var nItem in navList)
{
navs.Add(new navIconItem()
{
icon = Common.Config.GetFileUrl(nItem.NavIconImg),
url = nItem.NavIconUrl,
key = "",
name = nItem.NavIconName,
openType = ""
});
}
}
templateData.data.Add(new
{
id = "nav",
data = new navItem()
{
color = "#353535",
rows = 1,//每页行数
columns = subitem.row_num, //每行个数
scroll = true, //左右滑动
showImg = false, //背景图片
backgroundColor = "#ffffff", //背景颜色
backgroundPicUrl = "", //背景链接
position = 5, //图片位置
mode = 1, //填充方式
backgroundHeight = 100, //背景图宽
backgroundWidth = 100, //背景图高
navs = navs, //导航图标
}
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
break;
//视频插件
case "video":
templateData.data.Add(new
{
id = subitem.key,
data = new videoItem()
{
pic_url = Common.Config.GetFileUrl(subitem.video_pic_url),
url = subitem.video_url,
}
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
break;
//公告
case "notice":
templateData.data.Add(new
{
id = subitem.key,
data = new noticeItem()
{
name = subitem.NoticeName, //公告名称
content = subitem.NoticeContent, //公告内容
icon = Common.Config.GetFileUrl(subitem.notice_url), //公告图标
textColor = subitem.notice_text_color, //文字颜色
background = subitem.notice_bg_color, //背景颜色
headerUrl = "", //头部图片
btnColor = "#ff4544", //按钮颜色
btnWidth = 500, //按钮宽度
btnHeight = 80, //按钮高度
btnRadius = 40, //按钮圆角
btnText = "我知道了", //按钮文本内容
btnTextColor = "#ffffff" //按钮文本颜色
}
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
break;
//专题
case "topic":
var topicSourceList = contentModule.GetTopicListModule(new Model.Entity.User.RB_Topic_Extend()
{
MallBaseId = miniProgram.MallBaseId,
TenantId = miniProgram.TenantId,
});
var topic_list = new List<topicDetailsItem>();
if (topicSourceList != null && topicSourceList.Count > 0)
{
foreach (var tItem in topicSourceList)
{
topic_list.Add(new topicDetailsItem()
{
cover_pic = Common.Config.GetFileUrl(tItem.CoverImg),
read_count = 0,
title = tItem.Title,
id = tItem.Id,
layout = 0
});
}
}
templateData.data.Add(new
{
id = subitem.key,
data = new topicItem()
{
style = "normal",
count = subitem.topic_num,
logo_1 = Common.Config.GetFileUrl(subitem.topic_url),
logo_2 = Common.Config.GetFileUrl(subitem.topic_url_2),
icon = Common.Config.GetFileUrl(subitem.label_url),
cat_show = false,
list = new List<topicTypeItem>(),
topic_list = topic_list
}
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
break;
//领劵中心
case "coupon":
break;
//商品分类
case "cat":
var cats = new catItem()
{
goodsNum = 6,
id = subitem.relation_id,
menuName = subitem.name,
name = subitem.name,
staticGoods = false,
goodsList = new List<GoodsDetailsItem2>()
};
if (subitem.relation_id == 0)
{
var goodsList = productModule.GetProductGoodsPageList(1, 6, out long rowsCount, new Model.Extend.Product.RB_Goods_Extend()
{
TenantId = Convert.ToInt32(miniProgram.TenantId),
MallBaseId = miniProgram.MallBaseId
});
if (goodsList != null && goodsList.Count > 0)
{
foreach (var gItem in goodsList)
{
cats.goodsList.Add(new GoodsDetailsItem2()
{
id = gItem.Id,
price = Math.Round(gItem?.SellingPrice ?? 0, 2),
name = gItem.Name,
picUrl = Common.Config.GetFileUrl(gItem.CoverImage),
OriginalPrice = Math.Round(gItem?.OriginalPrice ?? 0, 2)
});
}
}
}
else
{
var goodsList = productModule.GetProductGoodsPageList(1, 6, out long rowsCount, new Model.Extend.Product.RB_Goods_Extend()
{
TenantId = Convert.ToInt32(miniProgram.TenantId),
MallBaseId = miniProgram.MallBaseId,
CategoryIds = subitem.relation_id.ToString()
});
if (goodsList != null && goodsList.Count > 0)
{
foreach (var gItem in goodsList)
{
cats.goodsList.Add(new GoodsDetailsItem2()
{
id = gItem.Id,
price = Math.Round(gItem?.SellingPrice ?? 0, 2),
name = gItem.Name,
picUrl = Common.Config.GetFileUrl(gItem.CoverImage),
OriginalPrice = Math.Round(gItem?.OriginalPrice ?? 0, 2)
});
}
}
}
templateData.data.Add(new
{
id = "goods",
data = new goodsItem()
{
showCat = true,
catPosition = "top",
catStyle = 0,
addGoodsType = 0,
goodsLength = 6,
listStyle = 3,
goodsCoverProportion = "1-1",
fill = 1,
goodsStyle = 1,
textStyle = 1,
showGoodsName = true,
showGoodsPrice = true,
showBuyBtn = true,
buyBtn = "cart",
buyBtnStyle = 1,
buyBtnText = "购买",
buttonColor = "#ff4544",
showGoodsTag = false,
customizeGoodsTag = false,
goodsTagPicUrl = "",
showImg = false,
backgroundColor = "#fff",
backgroundPicUrl = "",
position = 5,
mode = 1,
backgroundHeight = 100,
backgroundWidth = 100,
list = new List<GoodsDetailsItem2>(),
catList = new List<catItem>() { cats }
}
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
break;
//图片魔方
case "block":
var blockSource = programModule.GetMallMagicListModule(new Model.Entity.User.RB_Mall_Magic_Extend()
{
MallBaseId = miniProgram.MallBaseId,
TenantId = Convert.ToInt32(miniProgram.TenantId),
Id = subitem.relation_id
}).FirstOrDefault();
if (blockSource != null && blockSource.Id > 0)
{
var rubikData = new rubikItem()
{
style = Convert.ToInt32(blockSource.Style),
space = 0,
list = new List<rubikDetailItem>(),
};
switch (rubikData.style)
{
//1张图
case 0:
rubikData.height = "360";
rubikData.w = "1";
rubikData.h = 1;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 1,
h = 1,
x = 0,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(100%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
//两张图
case 1:
rubikData.height = "360";
rubikData.w = "25";
rubikData.h = 12;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 10,
h = 12,
x = 0,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(40%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 15,
h = 12,
x = 10,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[1].Link
}
},
width = "calc(60%)",
height = "calc(100%)",
left = "calc(40%)",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[1].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
//三张图
case 2:
rubikData.height = "360";
rubikData.w = "25";
rubikData.h = 12;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 10,
h = 12,
x = 0,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(40%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 15,
h = 6,
x = 10,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[1].Link
}
},
width = "calc(60%)",
height = "calc(50%)",
left = "calc(40%)",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[1].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 15,
h = 6,
x = 10,
y = 6,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[2].Link
}
},
width = "calc(60%)",
height = "calc(50%)",
left = "calc(40%)",
top = "calc(50%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[2].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
//四张图
case 3:
rubikData.height = "360";
rubikData.w = "50";
rubikData.h = 24;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 20,
h = 24,
x = 0,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(40%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 30,
h = 12,
x = 20,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[1].Link
}
},
width = "calc(60%)",
height = "calc(50%)",
left = "calc(40%)",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[1].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 15,
h = 12,
x = 20,
y = 12,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[2].Link
}
},
width = "calc(30%)",
height = "calc(50%)",
left = "calc(40%)",
top = "calc(50%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[2].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 15,
h = 12,
x = 35,
y = 12,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[3].Link
}
},
width = "calc(30%)",
height = "calc(50%)",
left = "calc(70%)",
top = "calc(50%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[3].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
//两张平分图
case 4:
rubikData.height = "240";
rubikData.w = "50";
rubikData.h = 16;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 25,
h = 16,
x = 0,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(50%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 25,
h = 16,
x = 25,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[1].Link
}
},
width = "calc(50%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[1].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
//三张平分图
case 5:
rubikData.height = "240";
rubikData.w = "75";
rubikData.h = 24;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 25,
h = 24,
x = 0,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(33.33%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 25,
h = 24,
x = 25,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[1].Link
}
},
width = "calc(33.33%)",
height = "calc(100%)",
left = "calc(33.33%)",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[1].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 25,
h = 24,
x = 50,
y = 6,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[2].Link
}
},
width = "calc(33.34%)",
height = "calc(100%)",
left = "calc(66.66%)",
top = "calc(0%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[2].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
//四张平分
case 6:
rubikData.height = "186";
rubikData.w = "4";
rubikData.h = 1;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 1,
h = 1,
x = 0,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(25%)",
height = "calc(100%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 1,
h = 1,
x = 1,
y = 0,
link = new List<rubikLinkItem>() {
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[1].Link
}
},
width = "calc(25%)",
height = "calc(100%)",
left = "calc(25%)",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[1].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 1,
h = 1,
x = 2,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[2].Link
}
},
width = "calc(25%)",
height = "calc(100%)",
left = "calc(50%)",
top = "calc(0%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[2].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 1,
h = 1,
x = 3,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[3].Link
}
},
width = "calc(25%)",
height = "calc(100%)",
left = "calc(75%)",
top = "calc(0%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[3].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
//四张上下平分
case 7:
rubikData.height = "372";
rubikData.w = "250";
rubikData.h = 124;
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 125,
h = 62,
x = 0,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[0].Link
}
},
width = "calc(50%)",
height = "calc(50%)",
left = "0%",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[0].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 125,
h = 62,
x = 125,
y = 0,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[1].Link
}
},
width = "calc(50%)",
height = "calc(50%)",
left = "calc(50%)",
top = "0%",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[1].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 125,
h = 62,
x = 0,
y = 62,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[2].Link
}
},
width = "calc(50%)",
height = "calc(50%)",
left = "calc(0%)",
top = "calc(50%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[2].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
rubikData.list.Add(new rubikDetailItem()
{
backgroundColor = "",
numberX = 0,
numberY = 0,
w = 125,
h = 62,
x = 125,
y = 62,
link = new List<rubikLinkItem>()
{
new rubikLinkItem()
{
new_link_url = blockSource.MagicDataList[3].Link
}
},
width = "calc(50%)",
height = "calc(50%)",
left = "calc(50%)",
top = "calc(50%)",
pic_url = Common.Config.GetFileUrl(blockSource.MagicDataList[3].ImgUrl),
backgroundImage = "",
backgroundRepeat = "no-repeat",
backgroundSize = "cover",
backgroundPosition = "center"
});
break;
}
templateData.data.Add(new
{
id = "rubik",
data = rubikData
});
templateData.data.Add(new
{
id = "empty",
data = new emptyItem()
{
background = "#ffffff",
height = 10
}
});
}
break;
}
}
var tempObj = new
{
id = miniProgram.MallBaseId,
name = "自定义首页布局",
page_id = miniProgram.MallBaseId,
template_id = miniProgram.MallBaseId,
template = templateData
};
return tempObj;
}
/// <summary>
/// 基本设置
/// </summary>
/// <param name="miniProgram"></param>
/// <returns></returns>
public static object GetBasicSetting(RB_MiniProgram_Extend miniProgram)
{
#region 基本设置
//基础配置 Add By:W 2020年6月1号
var mallBaseModel = mallBaseModule.GetListRepository(new RB_MallBase_Extend { TenantId = miniProgram.TenantId ?? 0, MallBaseId = miniProgram.MallBaseId }).FirstOrDefault();
if (mallBaseModel == null)
{
mallBaseModel = new RB_MallBase_Extend();
}
//获取物流配置
var logisticsRules = mallBaseModule.GetLogisticsList(new RB_Logistics { TenantId = miniProgram.TenantId ?? 0, MallBaseId = miniProgram.MallBaseId }).FirstOrDefault();
if (logisticsRules == null)
{
logisticsRules = new RB_Logistics();
}
//用户积分
var integralModel = integralModule.GetIntegralSettingsList(new RB_Integral_Settings { TenantId = miniProgram.TenantId ?? 0, MallBaseId = miniProgram.MallBaseId }).FirstOrDefault();
if (integralModel == null)
{
integralModel = new RB_Integral_Settings();
}
List<string> payment_type = new List<string>();
if (!string.IsNullOrWhiteSpace(mallBaseModel.PayWay))
{
foreach (var item in mallBaseModel.PayWay.Split(","))
{
switch (item)
{
case "1":
payment_type.Add("online_pay");
break;
case "2":
payment_type.Add("huodao");
break;
case "3":
payment_type.Add("balance");
break;
default:
break;
}
}
}
List<string> send_type = new List<string>();
if (!string.IsNullOrWhiteSpace(mallBaseModel.DeliverWay))
{
foreach (var item in mallBaseModel.DeliverWay.Split(","))
{
switch (item)
{
case "1":
send_type.Add("express");
break;
case "2":
send_type.Add("offline");
break;
case "3":
send_type.Add("city");
break;
default:
break;
}
}
}
List<string> good_negotiable = new List<string>();
if (!string.IsNullOrWhiteSpace(mallBaseModel.ConsultWay))
{
foreach (var item in mallBaseModel.ConsultWay.Split(","))
{
switch (item)
{
case "1":
good_negotiable.Add("contact");
break;
case "2":
good_negotiable.Add("contact_tel");
break;
case "3":
good_negotiable.Add("contact_web");
break;
default:
break;
}
}
}
var setting = new
{
contact_tel = mallBaseModel?.ContactNumber,
over_time = mallBaseModel?.CancelTime,
delivery_time = mallBaseModel?.AutoReceiving,
after_sale_time = mallBaseModel?.AfterTime,
payment_type = payment_type.ToArray(),//支付方式
send_type = send_type.ToArray(),//发货方式
kdniao_mch_id = logisticsRules?.ExpressBirdID,//快递鸟配置
kdniao_api_key = logisticsRules?.ExpressBirdAPIKey,
member_integral = integralModel?.IntegralNum,
member_integral_rule = integralModel?.Explain,
good_negotiable = good_negotiable.ToArray(),//商品面议联系方式
mobile_verify = "",
is_small_app = mallBaseModel?.TurnMini,
small_app_id = mallBaseModel?.MinAppId,
small_app_url = mallBaseModel?.MinUrl,
small_app_pic = mallBaseModel?.TurnMiniIco,
is_customer_services = mallBaseModel?.OnlineService,
customer_services_pic = mallBaseModel?.OnlineServiceIco,
is_dial = mallBaseModel?.OneCall,
dial_pic = mallBaseModel?.OneCallIco,
is_web_service = mallBaseModel?.ServiceOutLink,
web_service_url = mallBaseModel?.OuterServiceLink,
web_service_pic = mallBaseModel?.ServiceOutLinkIco,
is_quick_navigation = mallBaseModel?.SuspendBtn,
quick_navigation_style = mallBaseModel?.SuspendStyle,
quick_navigation_opened_pic = mallBaseModel?.UnfoldIco,
quick_navigation_closed_pic = mallBaseModel?.PackUpIco,
is_show_stock = "",
is_use_stock = "",
sell_out_pic = "",
sell_out_other_pic = "",
is_common_user_member_price = mallBaseModel?.DetailsMemberPrice,
is_member_user_member_price = mallBaseModel?.DetailsVipMemberPrice,
is_share_price = mallBaseModel?.DetailsSharePrice,
is_purchase_frame = mallBaseModel?.BuySwitch,
purchase_num = mallBaseModel?.CarouselOrder,
is_comment = mallBaseModel?.DetailsComment,
is_sales = mallBaseModel?.DetailsBuyNum,
is_mobile_auth = mallBaseModel?.OtherIndexMoblie,
is_official_account = mallBaseModel?.OtherTencent,
is_manual_mobile_auth = mallBaseModel?.OtherManualMobile,
is_icon_members_grade = mallBaseModel?.OtherMemerLevel,
is_goods_video = mallBaseModel?.DetailsVideo,
is_quick_map = mallBaseModel?.ShortcutNavigation,
quick_map_pic = mallBaseModel?.ShortcutNavigationIco,
quick_map_address = mallBaseModel?.Address,
longitude = mallBaseModel?.LongAndLat.Split(",")[0],
latitude = mallBaseModel?.LongAndLat.Split(",")[1],
is_quick_home = mallBaseModel?.BackTopNavigation,
quick_home_pic = mallBaseModel?.BackTopNavigationIco,
logo = "",
share_title = mallBaseModel?.MinShareTitle,
share_pic = mallBaseModel?.MinShareIco,
is_add_app = mallBaseModel?.MinSwitch,
add_app_bg_color = mallBaseModel?.MinBackColor,
add_app_bg_transparency = mallBaseModel?.MinBackClarity,
add_app_bg_radius = mallBaseModel?.MinBackCircularBead,
add_app_text = mallBaseModel?.MinTips,
add_app_text_color = mallBaseModel?.MinTipsColor,
add_app_icon_color_type = mallBaseModel?.MinIcoColor,
is_close = "",
business_time_type = "",
business_time_custom_type = "",
business_time_type_day = "",
business_time_type_week = "",
auto_business = "",
auto_business_time = "",
is_icon_super_vip = "",
is_show_normal_vip = "",
is_show_super_vip = "",
is_required_position = mallBaseModel?.OtherMustAddress,
is_share_tip = mallBaseModel?.OtherApplyShare,
is_show_cart = mallBaseModel?.ListShopCar,
is_show_sales_num = mallBaseModel?.ListBuyCount,
is_show_goods_name = mallBaseModel?.ListName,
is_underline_price = mallBaseModel?.DetailsLineationPrice,
is_express = mallBaseModel?.DeatilsExpress,
is_not_share_show = mallBaseModel?.OtherNoShare,
is_show_cart_fly = mallBaseModel?.CarSuspendBtn,
is_show_score_top = mallBaseModel?.BackTopBtn,
express_select_type = logisticsRules?.LogisticsType,//待会儿处理
express_aliapy_code = logisticsRules?.AliyunAppCode,
is_quick_customize = mallBaseModel?.Custom,
quick_customize_pic = mallBaseModel?.TurnIco,
quick_customize_open_type = "",
quick_customize_params = "",
quick_customize_link_url = mallBaseModel?.TurnLink,
quick_customize_new_params = "",
theme_color = "",
latitude_longitude = mallBaseModel?.LongAndLat
};
#endregion
return setting;
}
/// <summary>
/// 分销基础信息
/// </summary>
/// <returns></returns>
public static object GetDistributorBasicsInfo(RB_MiniProgram_Extend miniProgram)
{
#region 分销基础信息
var distributorBasics = userModule.GetDistributorBasicsInfo((miniProgram.TenantId ?? 0).ToString(), miniProgram.MallBaseId);
if (!string.IsNullOrEmpty(distributorBasics.WithdrawWay))
{
distributorBasics.WithdrawWayList = JsonConvert.DeserializeObject<List<int>>(distributorBasics.WithdrawWay);
}
List<string> pay_type = new List<string>();
if (!string.IsNullOrWhiteSpace(distributorBasics.WithdrawWay))
{
foreach (var item in distributorBasics.WithdrawWayList)
{
switch (item)
{
case 1:
pay_type.Add("auto");
break;
case 2:
pay_type.Add("wechat");
break;
case 3:
pay_type.Add("alipay");
break;
case 4:
pay_type.Add("bank");
break;
case 5:
pay_type.Add("balance");
break;
default:
break;
}
}
}
var share_setting = new
{
level = distributorBasics?.DistributorTier,
is_rebate = distributorBasics?.InPurchasing,
price_type = distributorBasics?.DistributorCommissionType,
first = distributorBasics?.OneCommission,
second = distributorBasics?.TwoCommission,
third = distributorBasics?.ThreeCommission,
share_condition = "",
condition = distributorBasics?.ReferralsCondition ?? 0,
auto_share_val = "",
share_goods_status = "",
share_goods_warehouse_id = "",
pay_type = pay_type.ToArray(),
cash_max_day = distributorBasics?.DailyWithdrawalLimit,
min_money = distributorBasics?.MinimumWithdrawalLimit,
cash_service_charge = distributorBasics?.WithdrawFee,
agree = distributorBasics?.ApplicationProtocol,
content = distributorBasics?.UserNotes,
pic_url_apply = "",
pic_url_status = distributorBasics?.BackgroundImage,
pic_url_home_head = distributorBasics?.IndexImage,
become_condition = "",
cat_list = "",
is_show_share_level = "",
};
#endregion
return share_setting;
}
/// <summary>
/// 分销设置
/// </summary>
/// <param name="miniProgram"></param>
/// <returns></returns>
public static object GetDistributorCustomInfo(RB_MiniProgram_Extend miniProgram)
{
#region share_setting_custom
var distributorCustom = userModule.GetDistributorCustomInfo((miniProgram.TenantId ?? 0).ToString(), miniProgram.MallBaseId);
var share_setting_custom = new
{
menus = new
{
money = new
{
name = distributorCustom?.DistributionCommissionName,
icon = distributorCustom?.DistributionCommissionImage,
open_type = "",
url = "",
tel = ""
},
order = new
{
name = distributorCustom?.DistributionOrderName,
icon = distributorCustom?.DistributionOrderImage,
open_type = "",
url = "",
tel = ""
},
cash = new
{
name = distributorCustom?.WithdrawDetialsName,
icon = distributorCustom?.WithdrawDetialsImage,
open_type = "",
url = "",
tel = ""
},
team = new
{
name = distributorCustom?.MyTeamName,
icon = distributorCustom?.MyTeamImage,
open_type = "",
url = "",
tel = ""
},
qrcode = new
{
name = distributorCustom?.PromoteQRCodeName,
icon = distributorCustom?.PromoteQRCodeImage,
open_type = "",
url = "",
tel = ""
},
},
words = new
{
can_be_presented = new { name = distributorCustom?.CommissionForWithdrawalName, defaultStr = "可提现佣金" },
already_presented = new { name = distributorCustom?.CommissionWithdrawnName, defaultStr = "已提现佣金" },
parent_name = new { name = distributorCustom?.ReferrerName, defaultStr = "推荐人" },
pending_money = new { name = distributorCustom?.CommissionTobePaidName, defaultStr = "待打款佣金" },
cash = new { name = distributorCustom?.WithdrawDepositName, defaultStr = "提现" },
user_instructions = new { name = distributorCustom?.UserNotesName, defaultStr = "用户须知" },
apply_cash = new { name = distributorCustom?.IWantToWithdrawName, defaultStr = "我要提现" },
cash_type = new { name = distributorCustom?.WithdrawalWayName, defaultStr = "提现方式" },
cash_money = new { name = distributorCustom?.WithdrawalAmountName, defaultStr = "提现金额" },
order_money_un = new { name = distributorCustom?.OutstandingCommissionName, defaultStr = "未结算佣金" },
share_name = new { name = distributorCustom?.DistributorName, defaultStr = "分销商" },
one_share = new { name = distributorCustom?.OneDistributionName, defaultStr = "一级分销名称" },
second_share = new { name = distributorCustom?.TwoDistributionName, defaultStr = "二级分销名称" },
three_share = new { name = distributorCustom?.ThreeDistributionName, defaultStr = "三级分销名称" },
},
apply = new
{
share_apply = new { name = distributorCustom?.DistributionApplication, defaultStr = "分销申请" },
share_apply_pact = new { name = distributorCustom?.ApplicationAgreement, defaultStr = "分销申请协议" },
apply_btn_color = distributorCustom?.ButtonTextColor,
apply_btn_background = distributorCustom?.ButtonColor,
apply_btn_title = distributorCustom?.ButtonText,
apply_btn_round = distributorCustom?.ButtonFilletPX,
apply_head_pic = distributorCustom?.HeadImage,
apply_end_pic = distributorCustom?.BottomImage
},
};
#endregion
return share_setting_custom;
}
}
}
...@@ -3,7 +3,9 @@ using System.Collections.Generic; ...@@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Mall.Common.API; using Mall.Common.API;
using Mall.Common.Data;
using Mall.Common.Plugin; using Mall.Common.Plugin;
using Mall.Model.Extend.BaseSetUp;
using Mall.Module.BaseSetUp; using Mall.Module.BaseSetUp;
using Mall.WebApi.Filter; using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
...@@ -29,7 +31,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -29,7 +31,7 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary> /// </summary>
/// <param name="ParentID">父节点编号</param> /// <param name="ParentID">父节点编号</param>
/// <returns></returns> /// <returns></returns>
public ApiResult GetChildList() public ApiResult GetChildList()
{ {
JObject parm = JObject.Parse(RequestParm.msg.ToString()); JObject parm = JObject.Parse(RequestParm.msg.ToString());
int ID = parm.GetInt("Id"); int ID = parm.GetInt("Id");
...@@ -48,5 +50,42 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -48,5 +50,42 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed("未找到相关数据!"); return ApiResult.Failed("未找到相关数据!");
} }
} }
[HttpPost]
public ApiResult GetAllList()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
var list = destinationModule.GetAllList();
var result = GetData(list);
return ApiResult.Success("", result);
}
public static List<RB_Destination_Extend> GetData(List<RB_Destination_Extend> nodeList)
{
List<RB_Destination_Extend> nodes = nodeList.Where(x => x.ParentID == 2).ToList();
foreach (RB_Destination_Extend item in nodes)
{
item.Children = GetChildrens(nodeList, item);
}
return nodes;
}
//递归获取子节点
public static List<RB_Destination_Extend> GetChildrens(List<RB_Destination_Extend> nodeList, RB_Destination_Extend node)
{
List<RB_Destination_Extend> childrens = nodeList.Where(x => x.ParentID == node.ID).ToList();
foreach (RB_Destination_Extend item in childrens)
{
item.Children = GetChildrens(nodeList, item);
}
return childrens;
}
} }
} }
\ No newline at end of file
...@@ -274,6 +274,14 @@ namespace Mall.WebApi.Controllers.MarketingCenter ...@@ -274,6 +274,14 @@ namespace Mall.WebApi.Controllers.MarketingCenter
} }
} }
if (query.CouponType == CouponTypeEnum.Discount)
{
if (query.DiscountsPrice > 10)
{
return ApiResult.Failed("折扣率的值必须不大于10");
}
}
if (query.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Category || query.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Product) if (query.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Category || query.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Product)
{ {
......
...@@ -333,5 +333,69 @@ namespace Mall.WebApi.Controllers.MarketingCenter ...@@ -333,5 +333,69 @@ namespace Mall.WebApi.Controllers.MarketingCenter
} }
#endregion #endregion
#region 余额自定义设置
/// <summary>
/// 获取详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetRechargeCustomList()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Recharge_Custom>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
var oldLogisticsModel = rechargeModule.GetRechargeCustomList(query).FirstOrDefault();
if (oldLogisticsModel == null)
{
oldLogisticsModel = new RB_Recharge_Custom();
oldLogisticsModel.BalanceName = "余额";
oldLogisticsModel.RechareName = "充值金额";
oldLogisticsModel.RechareExplain = "充值说明";
oldLogisticsModel.BtnFillet = 40;
oldLogisticsModel.BtnName = "立即充值";
oldLogisticsModel.BackgroundColor = "#FF4544";
oldLogisticsModel.TextColor = "#FFFFFF";
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 保存充值方案
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult AddOrUpdateRechargeCustom()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Recharge_Custom>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
if (query == null)
{
return ApiResult.Failed("请传入自定义设置");
}
else
{
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
}
query.UpdateDate = System.DateTime.Now;
bool result = rechargeModule.AddOrUpdateRechargeCustom(query);
if (result)
{
return ApiResult.Success("自定义设置保存成功");
}
else
{
return ApiResult.Failed("自定义设置保存失败");
}
}
}
#endregion
} }
} }
\ No newline at end of file
...@@ -216,7 +216,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter ...@@ -216,7 +216,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter
#region 销售统计 #region 销售统计
/// <summary> /// <summary>
/// 充值方案列表 ///销售统计列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
......
...@@ -366,6 +366,172 @@ namespace Mall.WebApi.Controllers.MarketingCenter ...@@ -366,6 +366,172 @@ namespace Mall.WebApi.Controllers.MarketingCenter
var flag = templateMarketModule.LoadTemplateMarketIsUseModule(Id, extModel); var flag = templateMarketModule.LoadTemplateMarketIsUseModule(Id, extModel);
return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed(); return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
} }
/// <summary>
/// 重新设置图片
/// </summary>
/// <returns></returns>
public ApiResult SetTemplateImg()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Template_Market_Extend>(parms.msg.ToString());
var list = templateMarketModule.GetTemplateMarketListModule(query);
string message = "";
if (list != null && list.Count > 0)
{
foreach (var rootItem in list)
{
if (rootItem.Pics != null && !string.IsNullOrEmpty(rootItem.Pics))
{
try
{
Common.Plugin.FileHelper.CreateImage(rootItem.Pics);
rootItem.Pics = Common.Plugin.FileHelper.GetFileUrl(rootItem.Pics);
rootItem.Pics = Common.Config.GetFileUrl(rootItem.Pics);
}
catch (Exception ex)
{
message += ex.Message + " ";
}
}
List<ComponentItem> items = new List<ComponentItem>();
if (rootItem.TemplateData != null && !string.IsNullOrWhiteSpace(rootItem.TemplateData))
{
items = Common.Plugin.JsonHelper.DeserializeObject<List<ComponentItem>>(rootItem.TemplateData.Replace("\r\n", "").Replace(@"\", "").Trim());
}
if (items != null && items.Count > 0)
{
try
{
foreach (var item in items)
{
switch (item.Id)
{
//背景组件
case "background":
var backgroundData = Common.Plugin.JsonHelper.DeserializeObject<backgroundItem>(item.data.ToString());
if (!string.IsNullOrWhiteSpace(backgroundData.backgroundPicUrl))
{
Common.Plugin.FileHelper.CreateImage(backgroundData.backgroundPicUrl);
backgroundData.backgroundPicUrl = Common.Plugin.FileHelper.GetFileUrl(backgroundData.backgroundPicUrl);
backgroundData.backgroundPicUrl = Common.Config.GetFileUrl(backgroundData.backgroundPicUrl);
}
item.data = backgroundData;
break;
//查找组件
case "search":
break;
//导航组件
case "nav":
var navData = Common.Plugin.JsonHelper.DeserializeObject<navItem>(item.data.ToString());
if (navData.navs != null && navData.navs.Count > 0)
{
foreach (var subItem in navData.navs)
{
if (!string.IsNullOrWhiteSpace(subItem.icon))
{
Common.Plugin.FileHelper.CreateImage(subItem.icon);
subItem.icon = Common.Plugin.FileHelper.GetFileUrl(subItem.icon);
subItem.icon = Common.Config.GetFileUrl(subItem.icon);
}
}
}
item.data = navData;
break;
//轮播广告插件
case "banner":
var bannerData = Common.Plugin.JsonHelper.DeserializeObject<bannerItem>(item.data.ToString());
if (bannerData.banners != null && bannerData.banners.Count > 0)
{
foreach (var subItem in bannerData.banners)
{
if (!string.IsNullOrWhiteSpace(subItem.picUrl))
{
Common.Plugin.FileHelper.CreateImage(subItem.picUrl);
subItem.picUrl = Common.Plugin.FileHelper.GetFileUrl(subItem.picUrl);
subItem.picUrl = Common.Config.GetFileUrl(subItem.picUrl);
}
}
}
item.data = bannerData;
break;
//图片广告插件
case "rubik":
try
{
var rubikData = Common.Plugin.JsonHelper.DeserializeObject<rubikItem>(item.data.ToString());
if (rubikData.list != null && rubikData.list.Count > 0)
{
foreach (var subItem in rubikData.list)
{
if (!string.IsNullOrWhiteSpace(subItem.pic_url))
{
Common.Plugin.FileHelper.CreateImage(subItem.pic_url);
subItem.pic_url = Common.Plugin.FileHelper.GetFileUrl(subItem.pic_url);
subItem.pic_url = Common.Config.GetFileUrl(subItem.pic_url);
}
if (!string.IsNullOrWhiteSpace(subItem.backgroundImage))
{
var newUrl = subItem.backgroundImage.Replace("url('", "").Replace("')", "");
Common.Plugin.FileHelper.CreateImage(newUrl);
subItem.backgroundImage = Common.Plugin.FileHelper.GetFileUrl(newUrl);
subItem.backgroundImage = "url('" + Common.Config.GetFileUrl(subItem.backgroundImage) + "')";
}
}
}
item.data = rubikData;
}
catch
{
}
break;
//商品插件
case "goods":
var goodData = Common.Plugin.JsonHelper.DeserializeObject<goodsItem>(item.data.ToString());
if (!string.IsNullOrWhiteSpace(goodData.goodsTagPicUrl))
{
Common.Plugin.FileHelper.CreateImage(goodData.goodsTagPicUrl);
goodData.goodsTagPicUrl = Common.Plugin.FileHelper.GetFileUrl(goodData.goodsTagPicUrl);
goodData.goodsTagPicUrl = Common.Config.GetFileUrl(goodData.goodsTagPicUrl);
}
item.data = goodData;
break;
//公告组件
case "notice":
var noticeData = Common.Plugin.JsonHelper.DeserializeObject<noticeItem>(item.data.ToString());
if (!string.IsNullOrWhiteSpace(noticeData.icon))
{
Common.Plugin.FileHelper.CreateImage(noticeData.icon);
noticeData.icon = Common.Plugin.FileHelper.GetFileUrl(noticeData.icon);
noticeData.icon = Common.Config.GetFileUrl(noticeData.icon);
}
if (!string.IsNullOrWhiteSpace(noticeData.headerUrl))
{
Common.Plugin.FileHelper.CreateImage(noticeData.headerUrl);
noticeData.headerUrl = Common.Plugin.FileHelper.GetFileUrl(noticeData.headerUrl);
noticeData.headerUrl = Common.Config.GetFileUrl(noticeData.headerUrl);
}
item.data = noticeData;
break;
}
}
}
catch (Exception ex)
{
message += rootItem.Id + " " + ex.Message + " ";
}
}
rootItem.TemplateData = Common.Plugin.JsonHelper.Serialize(items);
templateMarketModule.SetTemplateMarketModule(rootItem);
}
}
return ApiResult.Success(message: message);
}
#endregion #endregion
} }
} }
\ No newline at end of file
...@@ -844,6 +844,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -844,6 +844,7 @@ namespace Mall.WebApi.Controllers.User
public ApiResult GetMenuList() public ApiResult GetMenuList()
{ {
List<object> resultList = new List<object>(); List<object> resultList = new List<object>();
var menuList = menuModule.GetMenuListModule(new RB_Menu_Extend() { });
var list = new List<RB_Menu_Extend>(); var list = new List<RB_Menu_Extend>();
if (RequestParm.EmpId > 0) if (RequestParm.EmpId > 0)
{ {
...@@ -851,11 +852,46 @@ namespace Mall.WebApi.Controllers.User ...@@ -851,11 +852,46 @@ namespace Mall.WebApi.Controllers.User
if (roleList != null && roleList.Count > 0) if (roleList != null && roleList.Count > 0)
{ {
list = menuModule.GetMenuListModule(new RB_Menu_Extend() { QMenuIds = roleList?.FirstOrDefault()?.RoleAuth }); list = menuModule.GetMenuListModule(new RB_Menu_Extend() { QMenuIds = roleList?.FirstOrDefault()?.RoleAuth });
var superList = new List<RB_Menu_Extend>();
foreach (var item in list)
{
if (item.MenuLevel == 3)
{
var secondMenuList = menuList.Where(qitem => qitem.MenuId == item.ParentId).ToList();
foreach (var secondItem in secondMenuList)
{
if (!(superList.Where(qitem => qitem.MenuId == secondItem.MenuId).Count() > 0))
{
superList.Add(secondItem);
}
var firstMenuList= menuList.Where(qitem => qitem.MenuId == secondItem.ParentId).ToList();
foreach (var firstItem in firstMenuList)
{
if (!(superList.Where(qitem => qitem.MenuId == firstItem.MenuId).Count() > 0))
{
superList.Add(firstItem);
}
}
}
}
if (item.MenuLevel == 2)
{
var firstMenuList = menuList.Where(qitem => qitem.MenuId == item.ParentId).ToList();
foreach (var firstItem in firstMenuList)
{
if (!(superList.Where(qitem => qitem.MenuId == firstItem.MenuId).Count() > 0))
{
superList.Add(firstItem);
}
}
}
}
list.AddRange(superList);
} }
} }
else else
{ {
list = menuModule.GetMenuListModule(new RB_Menu_Extend() { }); list = menuList;
} }
var rootList = list.Where(qitem => qitem.MenuLevel == 1).OrderBy(qitem => qitem.SortNum).ToList(); var rootList = list.Where(qitem => qitem.MenuLevel == 1).OrderBy(qitem => qitem.SortNum).ToList();
......
...@@ -25,5 +25,7 @@ ...@@ -25,5 +25,7 @@
<ProjectReference Include="..\Mall.ThirdCore\Mall.ThirdCore.csproj" /> <ProjectReference Include="..\Mall.ThirdCore\Mall.ThirdCore.csproj" />
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project> </Project>
...@@ -49,6 +49,7 @@ namespace Mall.WebApi ...@@ -49,6 +49,7 @@ namespace Mall.WebApi
"http://localhost:8082", "http://localhost:8082",
"http://127.0.0.1:50512", "http://127.0.0.1:50512",
"http://127.0.0.1:20224", "http://127.0.0.1:20224",
"http://127.0.0.1:28221",
"http://www.test.com:8080", "http://www.test.com:8080",
"http://www.test.com:8081", "http://www.test.com:8081",
"http://yx.oytour.com", "http://yx.oytour.com",
......
...@@ -8,6 +8,7 @@ using System.Text; ...@@ -8,6 +8,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Test.DBHelper; using Test.DBHelper;
using MySql.Data.MySqlClient;
namespace Test.Helper namespace Test.Helper
{ {
...@@ -21,8 +22,168 @@ namespace Test.Helper ...@@ -21,8 +22,168 @@ namespace Test.Helper
/// </summary> /// </summary>
public static void GetData() public static void GetData()
{ {
string cookie = "__login_route=%2Fadmin%2Fpassport%2Flogin; __login_role=admin; search={'keyword':'','status':' - 1','sort_prop':'','sort_type':'','cats'[],'date_start':null,'date_end':null}; HJ_SESSION_ID=kmmormovvm2u9qh5drkgsbj1ta; _csrf=7a980bb65eabe0ac3d77199092030044b17ae9779de00eaed628c8095ab2fe0ca%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22rsnZWVWkZkpfvVhLBXu8sGG3px0Dgcsx%22%3B%7D"; string cookie = "__login_route=%2Fadmin%2Fpassport%2Flogin; __login_role=admin; HJ_SESSION_ID=4t7hlqga7scesoid63ln4gbv3n; _csrf=7e088e7a563fba6d8b51b65eebea11468c0c2ea43c8e99199be24320e3e86c94a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22D9rE0_dOz8RHzW5y695GOQPTWJZgT8Sk%22%3B%7D";
GetGategoryImgList(cookie); GetPage(cookie);
}
public static void GetPage(string cookie)
{
var list = GetPageList(cookie);
if (list != null && list.Count > 0)
{
var index = 1;
foreach (var item in list)
{
Console.WriteLine(index + "/" + list.Count + item.title + "分类Start");
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" INSERT INTO RB_Miniprogram_Page_Templ(PageName,IsUse,IsShowNav,IsHome,TenantId,MallBaseId,CreateDate,CreateBy,Status)");
builder.AppendFormat(" VALUES('{0}',{1},{2},{3},1,1,'{4}',1,0);SELECT LAST_INSERT_ID()", item.title,item.is_disable,item.show_navs,item.is_home_page, DateTime.Now);
List<MySqlParameter> paramsList = new List<MySqlParameter>();
try
{
var res = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, builder.ToString(), paramsList.ToArray());
if (res != null && Convert.ToInt32(res) > 0)
{
string updateSql = string.Format("UPDATE RB_Miniprogram_Page_Templ SET Id={0} WHERE Id={1}", item.id, Convert.ToInt32(res));
var res1 = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, updateSql, null);
}
if (item.navs != null && item.navs.Count > 0)
{
foreach (var subItem in item.navs)
{
StringBuilder builder2 = new StringBuilder();
builder2.AppendFormat(" INSERT INTO rb_miniprogram_page_templ_details(PageTemplID,NavName,TemplateId,TemplateShowName)");
builder2.AppendFormat(" VALUES({0},'{1}',{2},'{3}');SELECT LAST_INSERT_ID()", item.id, subItem.template, subItem.template_id, string.Format("#{0}:{1}",subItem.template_id,subItem.template));
var res2 = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, builder2.ToString(), null);
}
}
}
catch (Exception ex)
{
Console.WriteLine(index + "/" + ex.Message);
}
index++;
Console.WriteLine(index + "/" + list.Count + item.title + "分类End");
}
}
}
/// <summary>
/// 获取页面数据
/// </summary>
/// <param name="cookie"></param>
/// <returns></returns>
public static List<PageData> GetPageList(string cookie)
{
List<PageData> list = new List<PageData>();
string ApiUrl = "https://wx.weibaoge.cn/web/index.php?r=plugin%2Fdiy%2Fmall%2Fpage%2Findex&page={0}";
string url1 = string.Format(ApiUrl, "1");
string jsonData = HttpGet(url1, cookie);
if (jsonData != null && !string.IsNullOrEmpty(jsonData))
{
JObject obj = JObject.Parse(jsonData);
JObject dataObj = JObject.Parse(obj["data"].ToString());
list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PageData>>(dataObj["list"].ToString());
}
if (list == null)
{
list = new List<PageData>();
}
Thread.Sleep(1000 * 5);
string url2 = string.Format(ApiUrl, "2");
string jsonData2 = HttpGet(url2, cookie);
if (jsonData2 != null && !string.IsNullOrEmpty(jsonData2))
{
JObject obj = JObject.Parse(jsonData2);
JObject dataObj = JObject.Parse(obj["data"].ToString());
var list2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PageData>>(dataObj["list"].ToString());
if (list2 != null && list2.Count > 0)
{
list.AddRange(list2);
}
}
return list;
}
/// <summary>
/// 获取模板
/// </summary>
public static void GetTemplate(string cookie)
{
var list = GetTemplateList(cookie);
if (list != null && list.Count > 0)
{
var index = 1;
foreach (var item in list)
{
Console.WriteLine(index + "/" + list.Count + item.name + "分类Start");
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" INSERT INTO rb_miniprogram_template(TenantId,MallBaseId,TemplateName,TemplateData,CreateDate,CreateBy,Status)");
builder.AppendFormat(" VALUES(1,1,'{0}',@data,'{1}',1,0);SELECT LAST_INSERT_ID()", item.name, DateTime.Now);
List<MySqlParameter> paramsList = new List<MySqlParameter>();
paramsList.Add(new MySqlParameter()
{
ParameterName= "@data",
Value= item.data.Replace(@"\", "")
});
try
{
var res = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, builder.ToString(), paramsList.ToArray());
if (res != null && Convert.ToInt32(res) > 0)
{
string updateSql = string.Format("UPDATE rb_miniprogram_template SET Id={0} WHERE Id={1}", item.id, Convert.ToInt32(res));
var res1 = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, updateSql, null);
}
}
catch (Exception ex)
{
Console.WriteLine(index + "/" + ex.Message);
}
index++;
Console.WriteLine(index + "/" + list.Count + item.name + "分类End");
}
}
}
/// <summary>
/// 获取模板列表
/// </summary>
/// <param name="cookie"></param>
/// <returns></returns>
public static List<TemplateData> GetTemplateList(string cookie)
{
List<TemplateData> list = new List<TemplateData>();
string ApiUrl = "https://wx.weibaoge.cn/web/index.php?r=plugin%2Fdiy%2Fmall%2Ftemplate%2Findex&page={0}";
string url1 = string.Format(ApiUrl, "1");
string jsonData = HttpGet(url1, cookie);
if (jsonData != null && !string.IsNullOrEmpty(jsonData))
{
JObject obj = JObject.Parse(jsonData);
JObject dataObj = JObject.Parse(obj["data"].ToString());
list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<TemplateData>>(dataObj["list"].ToString());
}
if (list == null)
{
list = new List<TemplateData>();
}
Thread.Sleep(1000 * 5);
string url2 = string.Format(ApiUrl, "2");
string jsonData2 = HttpGet(url2, cookie);
if (jsonData2 != null && !string.IsNullOrEmpty(jsonData2))
{
JObject obj = JObject.Parse(jsonData2);
JObject dataObj = JObject.Parse(obj["data"].ToString());
var list2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<TemplateData>>(dataObj["list"].ToString());
if (list2 != null && list2.Count > 0)
{
list.AddRange(list2);
}
}
return list;
} }
...@@ -45,7 +206,7 @@ namespace Test.Helper ...@@ -45,7 +206,7 @@ namespace Test.Helper
int parentId = 0; int parentId = 0;
try try
{ {
var res = MySqlHelper.ExecuteScalar(MySqlHelper.defaultConnection, System.Data.CommandType.Text, builder.ToString(), null); var res = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, builder.ToString(), null);
if (res != null && Convert.ToInt32(res) > 0) if (res != null && Convert.ToInt32(res) > 0)
{ {
Int32.TryParse(res.ToString(), out parentId); Int32.TryParse(res.ToString(), out parentId);
...@@ -73,7 +234,7 @@ namespace Test.Helper ...@@ -73,7 +234,7 @@ namespace Test.Helper
stringBuilder.AppendFormat(" VALUES('{0}',{1},{2},'{3}','{4}',0,0,1,1,'{5}','{6}',1,0)", subItem.name, subItem.type, parentId, path, "", DateTime.Now, DateTime.Now); stringBuilder.AppendFormat(" VALUES('{0}',{1},{2},'{3}','{4}',0,0,1,1,'{5}','{6}',1,0)", subItem.name, subItem.type, parentId, path, "", DateTime.Now, DateTime.Now);
try try
{ {
var newResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, stringBuilder.ToString(), null); var newResult = DBHelper.MySqlHelper.ExecuteNonQuery(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, stringBuilder.ToString(), null);
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -190,6 +351,8 @@ namespace Test.Helper ...@@ -190,6 +351,8 @@ namespace Test.Helper
{ {
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Headers.Add("cookie", cookie); myRequest.Headers.Add("cookie", cookie);
myRequest.Headers.Add("x-requested-with", "XMLHttpRequest");
//x-requested-with: XMLHttpRequest
myRequest.Method = "GET"; myRequest.Method = "GET";
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
......
...@@ -6,6 +6,95 @@ using System.Threading.Tasks; ...@@ -6,6 +6,95 @@ using System.Threading.Tasks;
namespace Test.Model namespace Test.Model
{ {
/// <summary>
/// 页面实体类
/// </summary>
public class PageData
{
/// <summary>
/// 页面编号
/// </summary>
public int id { get; set; }
/// <summary>
/// 页面标题
/// </summary>
public string title { get; set;}
/// <summary>
/// 是否显示导航
/// </summary>
public int show_navs { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public int is_disable { get; set; }
/// <summary>
/// 是否首页
/// </summary>
public int is_home_page { get; set; }
/// <summary>
/// 导航模板
/// </summary>
public List<navsData> navs { get; set; }
}
/// <summary>
/// 导航数据
/// </summary>
public class navsData
{
/// <summary>
/// 导航编号
/// </summary>
// public int navs { get; set; }
/// <summary>
/// 导航编号
/// </summary>
public int navs_id { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string template { get; set; }
/// <summary>
/// 模板编号
/// </summary>
public int template_id { get; set; }
}
/// <summary>
/// 模板实体类
/// </summary>
public class TemplateData
{
/// <summary>
/// 模板编号
/// </summary>
public int id { get; set; }
/// <summary>
/// 商城编号
/// </summary>
public int mall_id { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 模板数据
/// </summary>
public string data { get; set; }
}
/// <summary> /// <summary>
/// 分类实体 /// 分类实体
/// </summary> /// </summary>
......
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