添加项目文件。

This commit is contained in:
JianWeie
2021-12-20 21:27:32 +08:00
parent 747486f5cb
commit 82d825b7a5
3514 changed files with 887941 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.UI;
namespace CoreCms.Net.Services
{
/// <summary>
/// 用户表 接口实现
/// </summary>
public class CoreCmsUserWeChatInfoServices : BaseServices<CoreCmsUserWeChatInfo>, ICoreCmsUserWeChatInfoServices
{
private readonly ICoreCmsUserWeChatInfoRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsUserWeChatInfoServices(IUnitOfWork unitOfWork, ICoreCmsUserWeChatInfoRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
}
}

View File

@@ -0,0 +1,131 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.UI;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace CoreCms.Net.Services
{
/// <summary>
/// 微信订阅消息存储表 接口实现
/// </summary>
public class CoreCmsUserWeChatMsgSubscriptionServices : BaseServices<CoreCmsUserWeChatMsgSubscription>, ICoreCmsUserWeChatMsgSubscriptionServices
{
private readonly ICoreCmsUserWeChatMsgSubscriptionRepository _dal;
private readonly IServiceProvider _serviceProvider;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsUserWeChatMsgSubscriptionServices(IUnitOfWork unitOfWork, ICoreCmsUserWeChatMsgSubscriptionRepository dal, IServiceProvider serviceProvider)
{
this._dal = dal;
_serviceProvider = serviceProvider;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
/// <summary>
/// 获取模板信息
/// </summary>
/// <returns></returns>
public async Task<WebApiCallBack> tmpl(int userId)
{
var jm = new WebApiCallBack();
using var container = _serviceProvider.CreateScope();
var templateServices = container.ServiceProvider.GetService<ICoreCmsUserWeChatMsgTemplateServices>();
//支付通知|发货通知
var arr = new string[] { "pay", "ship", "cancel" };
var list = await templateServices.QueryListByClauseAsync(p => arr.Contains(p.templateTitle), p => p.id, OrderByType.Asc);
var arrTitle = list.Select(p => p.templateId).ToList();
jm.status = true;
jm.data = arrTitle;
jm.msg = "获取成功";
return jm;
}
/// <summary>
/// 设置订阅状态
/// </summary>
/// <returns></returns>
public async Task<WebApiCallBack> SetTip(int userId, string templateId, string status)
{
var jm = new WebApiCallBack();
using var container = _serviceProvider.CreateScope();
var templateServices = container.ServiceProvider.GetService<ICoreCmsUserWeChatMsgTemplateServices>();
var subscriptionServices = container.ServiceProvider.GetService<ICoreCmsUserWeChatMsgSubscriptionServices>();
var setting = await templateServices.QueryAsync();
var type = "";
if (setting.Any())
{
foreach (var item in setting)
{
if (item.templateId == templateId)
{
type = item.templateTitle;
break;
}
}
}
var count = await subscriptionServices.GetCountAsync(p => p.userId == userId && p.type == type);
if (status == "accept")
{
if (count < 1)
{
var sub = new CoreCmsUserWeChatMsgSubscription();
sub.userId = userId;
sub.templateId = templateId;
sub.type = type;
await subscriptionServices.InsertAsync(sub);
}
else
{
await subscriptionServices.UpdateAsync(
p => new CoreCmsUserWeChatMsgSubscription() { templateId = templateId },
p => p.userId == userId && p.type == type);
}
}
else
{
if (count > 0)
{
await subscriptionServices.DeleteAsync(p => p.userId == userId && p.type == type);
}
}
jm.status = true;
jm.msg = "设置订阅状态成功";
return jm;
}
}
}

View File

@@ -0,0 +1,128 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.UI;
using Microsoft.Extensions.DependencyInjection;
namespace CoreCms.Net.Services
{
/// <summary>
/// 用户订阅提醒状态 接口实现
/// </summary>
public class CoreCmsUserWeChatMsgSubscriptionSwitchServices : BaseServices<CoreCmsUserWeChatMsgSubscriptionSwitch>, ICoreCmsUserWeChatMsgSubscriptionSwitchServices
{
private readonly ICoreCmsUserWeChatMsgSubscriptionSwitchRepository _dal;
private readonly IServiceProvider _serviceProvider;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsUserWeChatMsgSubscriptionSwitchServices(IUnitOfWork unitOfWork, ICoreCmsUserWeChatMsgSubscriptionSwitchRepository dal, IServiceProvider serviceProvider)
{
this._dal = dal;
_serviceProvider = serviceProvider;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
/// <summary>
/// 获取用户是否订阅
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<WebApiCallBack> IsTip(int userId)
{
var jm = new WebApiCallBack { data = true, otherData = false };
using var container = _serviceProvider.CreateScope();
var templateServices = container.ServiceProvider.GetService<ICoreCmsUserWeChatMsgTemplateServices>();
var subscriptionServices = container.ServiceProvider.GetService<ICoreCmsUserWeChatMsgSubscriptionServices>();
var setting = await templateServices.QueryAsync();
var flag = false;
foreach (var item in setting)
{
if (!string.IsNullOrEmpty(item.templateId))
{
flag = true;
jm.otherData = true;
break;
}
}
if (flag)
{
var res = await _dal.QueryByClauseAsync(p => p.userId == userId);
if (res != null)
{
if (res.isSwitch) jm.data = false;
}
else
{
var count = await subscriptionServices.GetCountAsync(p => p.userId == userId);
if (count == setting.Count) jm.data = false;
}
}
else
{
jm.data = false;
}
jm.status = true;
jm.msg = "获取成功";
return jm;
}
/// <summary>
/// 获取用户是否关闭订阅
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<WebApiCallBack> CloseTip(int userId)
{
var jm = new WebApiCallBack();
var res = await _dal.QueryByClauseAsync(p => p.userId == userId);
if (res != null)
{
await _dal.UpdateAsync(
p => new CoreCmsUserWeChatMsgSubscriptionSwitch() { isSwitch = true },
p => p.userId == userId);
}
else
{
var st = new CoreCmsUserWeChatMsgSubscriptionSwitch();
st.isSwitch = true;
st.userId = userId;
await _dal.InsertAsync(st);
}
jm.status = true;
jm.msg = "关闭成功";
jm.otherData = true; //是否关闭订阅
return jm;
}
}
}

View File

@@ -0,0 +1,38 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.UI;
namespace CoreCms.Net.Services
{
/// <summary>
/// 微信小程序消息模板 接口实现
/// </summary>
public class CoreCmsUserWeChatMsgTemplateServices : BaseServices<CoreCmsUserWeChatMsgTemplate>, ICoreCmsUserWeChatMsgTemplateServices
{
private readonly ICoreCmsUserWeChatMsgTemplateRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsUserWeChatMsgTemplateServices(IUnitOfWork unitOfWork, ICoreCmsUserWeChatMsgTemplateRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
}
}

View File

@@ -0,0 +1,33 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/7/28 20:42:38
* Description: 暂无
***********************************************************************/
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
namespace CoreCms.Net.Services
{
/// <summary>
/// 微信授权交互 接口实现
/// </summary>
public class WeChatAccessTokenServices : BaseServices<WeChatAccessToken>, IWeChatAccessTokenServices
{
private readonly IWeChatAccessTokenRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public WeChatAccessTokenServices(IUnitOfWork unitOfWork, IWeChatAccessTokenRepository dal)
{
_dal = dal;
BaseDal = dal;
_unitOfWork = unitOfWork;
}
}
}