Commit a53ef10e authored by 黄奎's avatar 黄奎

新增服务

parent 70b11cf0
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Entity.AppletWeChat
{
/// <summary>
/// 直播海报配置实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Live_Config
{
/// <summary>
/// 主键Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 海报背景图
/// </summary>
public string LiveBgImg { get; set; }
/// <summary>
/// 二维码大小
/// </summary>
public int? LiveQrCodeSize { get; set; }
/// <summary>
/// 二维码上间距
/// </summary>
public int? LiveQrCodePaddingTop { get; set; }
/// <summary>
/// 二维码左间距
/// </summary>
public int? LiveQrCodePaddingLeft { get; set; }
/// <summary>
/// 二维码形状(0-圆形,1-方形)
/// </summary>
public int? LiveQrCodeType { get; set; }
/// <summary>
/// 商户Id
/// </summary>
public int? TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int? MallBaseId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateDate { get; set; }
}
}
......@@ -444,5 +444,15 @@ namespace Mall.Model.Entity.Product
/// 是否是直播商品 1是 2否
/// </summary>
public int? IsLiveGoods { get; set; }
/// <summary>
/// 自动上架时间
/// </summary>
public DateTime? ShelvesDate { get; set; }
/// <summary>
/// 自动下架时间
/// </summary>
public DateTime? DownDate { get; set; }
}
}
......@@ -162,5 +162,10 @@ namespace Mall.Model.Entity.User
/// 会员权益描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 粉象等级图标
/// </summary>
public string Icon { get; set; }
}
}
using Mall.Model.Entity.AppletWeChat;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Extend.AppletWeChat
{
/// <summary>
/// 直播海报配置扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Live_Config_Extend : RB_Live_Config
{
}
}
......@@ -4289,6 +4289,8 @@ namespace Mall.Module.Product
{ nameof(RB_Goods.SubName),demodel.SubName},
{ nameof(RB_Goods.MarketingLogo),demodel.MarketingLogo},
{ nameof(RB_Goods.IsLiveGoods),demodel.IsLiveGoods},
{ nameof(RB_Goods.ShelvesDate),demodel.ShelvesDate },
{ nameof(RB_Goods.DownDate),demodel.DownDate },
};
if (goodsModel.IsProcurement == 1)
{
......
......@@ -16,6 +16,7 @@ using Mall.Model.Query;
using VT.FW.DB;
using Mall.Model.Extend.AppletWeChat;
using Mall.Model.Entity.AppletWeChat;
using Mall.Repository.AppletWeChat;
namespace Mall.Module.User
{
......@@ -78,6 +79,11 @@ namespace Mall.Module.User
/// </summary>
private readonly MallStatisticsRepository mallStatisticsRepository = new MallStatisticsRepository();
/// <summary>
/// 直播配置仓储层
/// </summary>
private readonly RB_Live_ConfigRepository live_ConfigRepository = new RB_Live_ConfigRepository();
#region 轮播图管理
/// <summary>
......@@ -1782,7 +1788,7 @@ namespace Mall.Module.User
newLiveHouse.room_info.ForEach(x => x.TenantId = model.TenantId ?? 0);
newLiveHouse.room_info.ForEach(x => x.MallBaseId = model.MallBaseId);
newLiveHouse.room_info.ForEach(x => x.CreateDate = System.DateTime.Now);
AddLiveHouse(newLiveHouse.room_info, new Model.Entity.AppletWeChat.RB_Live_House { TenantId = model.TenantId ?? 0, MallBaseId = model.MallBaseId });
return true;
}
......@@ -1917,13 +1923,13 @@ namespace Mall.Module.User
string datetime = GetTime(item.start_time);
if (!string.IsNullOrWhiteSpace(datetime))
{
item.LiveTime =Convert.ToDateTime(datetime);
item.LiveTime = Convert.ToDateTime(datetime);
}
}
catch (Exception)
{
}
}
liveHouseRepository.InsertBatch(list);
......@@ -2132,5 +2138,46 @@ namespace Mall.Module.User
{
return mallStatisticsRepository.MallDistributorDayStatisticsRepository(query);
}
#region 直播配置
/// <summary>
/// 获取直播配置实体
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Live_Config_Extend GetLiveConfigModule(RB_Live_Config_Extend query)
{
return live_ConfigRepository.GetLiveConfigRepository(query);
}
/// <summary>
/// 新增修改直播配置
/// </summary>
/// <param name="extModel"></param>
/// <returns></returns>
public bool SetLiveConfigModule(RB_Live_Config_Extend extModel)
{
var flag = false;
var oldModel = GetLiveConfigModule(extModel);
if (oldModel!=null&&oldModel.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Live_Config_Extend.LiveBgImg),extModel.LiveBgImg},
{ nameof(RB_Live_Config_Extend.LiveQrCodeSize),extModel.LiveQrCodeSize},
{ nameof(RB_Live_Config_Extend.LiveQrCodePaddingTop),extModel.LiveQrCodePaddingTop},
{ nameof(RB_Live_Config_Extend.LiveQrCodePaddingLeft),extModel.LiveQrCodePaddingLeft},
{ nameof(RB_Live_Config_Extend.LiveQrCodeType),extModel.LiveQrCodeType},
};
flag = live_ConfigRepository.Update(fileds, new WhereHelper(nameof(RB_Live_Config_Extend.Id), extModel.Id));
}
else
{
flag = live_ConfigRepository.Insert(extModel) > 0;
}
return flag;
}
#endregion
}
}
......@@ -3294,9 +3294,11 @@ namespace Mall.Module.User
string GradeName = "默认等级";
int HpEnabled = 2;
int IsVip = 2;
string Icon = "";
if ((basicsModel?.IsEnableFXGrade ?? 0) == 1)
{
var gmodel = distributor_FXGradeRepository.GetEntity((model.FXGradeId ?? 0));
Icon = gmodel.Icon ?? "";
GradeName = gmodel?.GradeName ?? "默认等级";
if ((gmodel?.IsGuest ?? 0) == 3)
{
......@@ -3397,6 +3399,7 @@ namespace Mall.Module.User
UserName = umodel.Name,
umodel.Photo,
GradeName,
GradeIcon=Icon,
SuperiorId,
SuperiorName,
DistributorGradeEntrance = HpEnabled == 1 ? 2 : (basicsModel?.GradeEntrance ?? 2),
......@@ -3411,7 +3414,8 @@ namespace Mall.Module.User
IsEnableFXGrade = (basicsModel?.IsEnableFXGrade ?? 0),
IsVip,
VipExpiryDate = model.VipExpiryDate.HasValue ? model.VipExpiryDate.Value.ToString("yyyy-MM-dd") : "",
VipBuyCommission
VipBuyCommission,
}
};
}
......@@ -5162,6 +5166,7 @@ namespace Mall.Module.User
{ nameof(RB_Distributor_FXGrade.UpdateDate),demodel.UpdateDate},
{ nameof(RB_Distributor_FXGrade.DecimalType),demodel.DecimalType},
{ nameof(RB_Distributor_FXGrade.Description),demodel.Description},
{ nameof(RB_Distributor_FXGrade.Icon),demodel.Icon},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
......
using Mall.Model.Entity.AppletWeChat;
using Mall.Model.Extend.AppletWeChat;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Mall.Repository.AppletWeChat
{
/// <summary>
/// 直播海报配置仓储层
/// </summary>
public class RB_Live_ConfigRepository : BaseRepository<RB_Live_Config>
{
/// <summary>
/// 获取直播配置实体
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Live_Config_Extend GetLiveConfigRepository(RB_Live_Config_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT * FROM RB_Live_Config WHERE 1=1 ");
if (query != null)
{
if (query.MallBaseId > 0)
{
builder.AppendFormat(@" AND {0}={1} ", nameof(RB_Live_Config_Extend.MallBaseId), query.MallBaseId);
}
if (query.TenantId > 0)
{
builder.AppendFormat(@" AND {0}={1} ", nameof(RB_Live_Config_Extend.TenantId), query.TenantId);
}
if (query.Id > 0)
{
builder.AppendFormat(@" AND {0}={1} ", nameof(RB_Live_Config_Extend.Id), query.Id);
}
}
return Get<RB_Live_Config_Extend>(builder.ToString()).FirstOrDefault();
}
}
}
......@@ -114,6 +114,9 @@ namespace Mall.WebApi.Controllers.MallBase
//小程序
var mall = new object();
//直播海报配置
var liveConfig = new object();
//获取小程序信息
var miniProgram = new RB_MiniProgram_Extend();
if (MiniAppId != null && !string.IsNullOrEmpty(MiniAppId))
......@@ -387,6 +390,15 @@ namespace Mall.WebApi.Controllers.MallBase
hotspot = hotspotLogin,
hotspot_cancel = hotspotCancel
};
var liveConfigModel = programModule.GetLiveConfigModule(new Model.Extend.AppletWeChat.RB_Live_Config_Extend() { MallBaseId = miniProgram.MallBaseId, TenantId = miniProgram.TenantId });
liveConfig = new
{
liveConfigModel?.LiveQrCodeSize,
liveConfigModel?.LiveBgImg,
liveConfigModel?.LiveQrCodePaddingLeft,
liveConfigModel?.LiveQrCodePaddingTop,
liveConfigModel?.LiveQrCodeType,
};
var miniPageList = programPageModule.GetMiniprogram_Page_ListExtModule(new RB_MiniProgram_Page_Extend() { MallBaseId = RequestParm.MallBaseId });
var objResult = new
{
......@@ -398,6 +410,7 @@ namespace Mall.WebApi.Controllers.MallBase
share_setting_custom,
cat_style,
auth_page,//授权页面
liveConfig,
bar_title = miniPageList?.Select(qitem => new { name = qitem.PageName, value = qitem.PageUrl, new_name = qitem.SelfPageName }),//导航标题
};
return ApiResult.Success(data: objResult);
......
......@@ -1562,7 +1562,9 @@ namespace Mall.WebApi.Controllers.MallBase
model?.PresentFXMonth,
model?.Advertising,
model?.SubName,
model?.MarketingLogo
model?.MarketingLogo,
model?.ShelvesDate,
model?.DownDate,
});
}
......
......@@ -22,6 +22,7 @@ using Mall.Model.Entity.User;
using Mall.Module.Product;
using Microsoft.AspNetCore.Authorization;
using Mall.Model.Query;
using Mall.Model.Extend.AppletWeChat;
namespace Mall.WebApi.Controllers.User
{
......@@ -1785,5 +1786,35 @@ namespace Mall.WebApi.Controllers.User
return ApiResult.Success(data: basicData);
}
#endregion
#region 直播配置
/// <summary>
/// 获取直播配置实体
/// </summary>
/// <returns></returns>
public ApiResult GetLiveConfig()
{
var query = JsonConvert.DeserializeObject<RB_Live_Config_Extend>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
var extModel = programModule.GetLiveConfigModule(query);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 添加修改直播配置
/// </summary>
/// <returns></returns>
public ApiResult SetLiveConfig()
{
var extModel = JsonConvert.DeserializeObject<RB_Live_Config_Extend>(RequestParm.msg.ToString());
extModel.MallBaseId = RequestParm.MallBaseId;
extModel.TenantId = RequestParm.TenantId;
extModel.CreateDate = DateTime.Now;
var flag = programModule.SetLiveConfigModule(extModel);
return ApiResult.Success(data: extModel);
}
#endregion
}
}
\ No newline at end of file
......@@ -2739,6 +2739,7 @@ namespace Mall.WebApi.Controllers.User
x.DecimalType,
x.UpgradeId,
x.Description,
x.Icon,
UpdateDate = x.UpdateDate.HasValue ? x.UpdateDate.Value.ToString("yyyy-MM-dd") : ""
});
return ApiResult.Success("", pagelist);
......
using Mall.WindowsService.Model;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
......@@ -25,70 +24,4 @@ namespace Mall.WindowsService.Helper
}
}
}
/// <summary>
/// 配置文件帮助类
/// </summary>
public class ConfigHelper
{
/// <summary>
/// 获取任务配置文件
/// </summary>
/// <returns></returns>
public static IList<CommandModel> GetTaskConfig()
{
IList<CommandModel> list = new List<CommandModel>();
//加载接口配置文件
string settingPath = PathHelper.RootPath + @"\task.json";
using (StreamReader sr = new StreamReader(settingPath))
{
try
{
JsonSerializer serializer = new JsonSerializer();
serializer.Converters.Add(new JavaScriptDateTimeConverter());
serializer.NullValueHandling = NullValueHandling.Ignore;
//构建Json.net的读取流
JsonReader reader = new JsonTextReader(sr);
//对读取出的Json.net的reader流进行反序列化,并装载到模型中
list = serializer.Deserialize<IList<CommandModel>>(reader);
}
catch (Exception ex)
{
LogHelper.Write("加载配置文件" + ex.Message.ToString());
}
}
return list;
}
/// <summary>
/// 加载DLL文件
/// </summary>
/// <returns></returns>
public static Dictionary<string, object> LoadAssembly()
{
Dictionary<string, object> assemblyDic = new Dictionary<string, object>();
string path = PathHelper.RootPath;
DirectoryInfo directoryInfo = new DirectoryInfo(path);
if (directoryInfo.Exists)
{
//搜索dll文件
FileInfo[] dllList = directoryInfo.GetFiles("*.dll");
if (!object.Equals(dllList, null) && dllList.Length > 0)
{
foreach (var item in dllList)
{
AssemblyName assemblyName = AssemblyName.GetAssemblyName(item.FullName);
Assembly ass = Assembly.Load(assemblyName);
foreach (var type in ass.ExportedTypes)
{
string fullName = type.FullName;
assemblyDic.Add(fullName, type);
}
}
}
}
return assemblyDic;
}
}
}
......@@ -13,6 +13,7 @@ namespace Mall.WindowsService.Helper
private static int inTimer1 = 0;
private static int inTimer2 = 0;
private static int inTimer3 = 0;
private static int inTimer4 = 0;
/// <summary>
/// 收入单子服务开始执行方法
......@@ -103,5 +104,22 @@ namespace Mall.WindowsService.Helper
Interlocked.Exchange(ref inTimer3, 0);
}
}
/// <summary>
/// 商品定时上架,下架
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void GoodsShelves(object sender, System.Timers.ElapsedEventArgs e)
{
if (Interlocked.Exchange(ref inTimer4, 1) == 0)
{
LogHelper.Write("GoodsShelves=====Start");
Module.GoodsShelvesModule.ShelvesGoodsModule();
Module.GoodsShelvesModule.DownGoodsModule();
LogHelper.Write("GoodsShelves=====End");
Interlocked.Exchange(ref inTimer4, 0);
}
}
}
}
......@@ -31,4 +31,8 @@
<ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.WindowsService.Model
{
/// <summary>
/// 任务命令实体类
/// </summary>
public class CommandModel
{
/// <summary>
/// 对应方法名称
/// </summary>
public string Method { get; set; }
/// <summary>
/// 执行方式(1-每天,2-间隔多少小时,3-间隔多少分钟)
/// </summary>
public int ActionType { get; set; }
/// <summary>
/// 执行时间(01:00)
/// </summary>
public string ActionTime { get; set; }
}
}
using Mall.Repository.Product;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Mall.Model.Entity.Product;
using VT.FW.DB;
namespace Mall.WindowsService.Module
{
/// <summary>
/// 商品自动上架下架
/// </summary>
public class GoodsShelvesModule
{
/// <summary>
/// 商品仓储层对象
/// </summary>
private static readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository();
/// <summary>
/// 商品自动上架时间
/// </summary>
/// <returns></returns>
public static bool ShelvesGoodsModule()
{
bool flag = false;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT Id,GoodsStatus,ShelvesDate,DownDate
FROM rb_goods
WHERE Status=0 AND '{0}'>=ShelvesDate AND '{0}'<=DownDate AND GoodsStatus<>1
", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var list = goodsRepository.Get<RB_Goods>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Goods.GoodsStatus),1 }
};
flag = goodsRepository.Update(fileds, new WhereHelper(nameof(RB_Goods.Id), item.Id));
}
}
return flag;
}
/// <summary>
/// 商品自动下架
/// </summary>
/// <returns></returns>
public static bool DownGoodsModule()
{
bool flag = false;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT Id,GoodsStatus,ShelvesDate,DownDate
FROM rb_goods
WHERE Status=0 AND DownDate<='{0}' AND GoodsStatus=1 ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var list = goodsRepository.Get<RB_Goods>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Goods.GoodsStatus),2 }
};
flag = goodsRepository.Update(fileds, new WhereHelper(nameof(RB_Goods.Id), item.Id));
}
}
return flag;
}
}
}
......@@ -15,6 +15,7 @@ namespace Mall.WindowsService
private System.Timers.Timer timer2; //订单取消计时器
private System.Timers.Timer timer3; //订单自动收货计时器
private System.Timers.Timer timer4; //七天自动取消下线计时器
private System.Timers.Timer timer5; //定时上架和下架
public WindowsService()
{
......@@ -65,6 +66,17 @@ namespace Mall.WindowsService
timer4.Enabled = true;
#endregion
timer5 = new System.Timers.Timer();
timer5 = new System.Timers.Timer
{
Interval = 1000 * (60 * 0.2) //60分钟调用一次
};
timer5.Elapsed += new System.Timers.ElapsedEventHandler(helper.GoodsShelves);
timer5.Enabled = true;
#region
#endregion
}
protected override void OnStop()
......@@ -75,6 +87,7 @@ namespace Mall.WindowsService
this.timer2.Enabled = false;
this.timer3.Enabled = false;
this.timer4.Enabled = false;
this.timer5.Enabled = false;
}
}
}
{
"ConnectionStrings": {
"DefaultConnection": "server=192.168.2.214;user id=reborn;password=Reborn@2018;database=reborn_mall;CharSet=utf8; Convert Zero Datetime=true; ",
"DefaultConnection": "server=192.168.2.214;user id=reborn;password=Reborn@2018;database=test_reborn_mall_3;CharSet=utf8; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
"FinanceConnection": "server=192.168.2.214;user id=reborn;password=Reborn@2018;database=reborn_finance;CharSet=utf8; Convert Zero Datetime=true; ",
"FinanceConnectionPName": "MySql.Data.MySqlClient"
......
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