Commit 3769945d authored by liudong1993's avatar liudong1993
parents a317b618 86f39eed
using Mall.CacheManager.DataStatistic;
using Mall.Common.Plugin.Redis;
using Mall.Model.Extend.User;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.CacheManager.ByteDance
{
public class ByteDanceRedis
{
static RedisHelper redis = new RedisHelper(DataConstant.REDIS_DB2);
/// <summary>
/// 获取微信用的formID
/// </summary>
/// <param name="uid"></param>
/// <returns></returns>
public static List<ByteDanceCustomer> GetByteDanceList(int customerId, string FormId)
{
string cacheKey = CacheKey.UserModuleCacheKeyConfig.ByteDanceFormId + customerId + "_" + FormId;
List<ByteDanceCustomer> airInfo = new List<ByteDanceCustomer>();
try
{
var dic = redis.StringGet(cacheKey);
foreach (var item in dic)
{
var model = JsonConvert.DeserializeObject<List<ByteDanceCustomer>>(item.ToString());
airInfo.AddRange(model);
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "GetByteDanceList");
}
return airInfo;
}
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="airList"></param>
public static void SetDyteDanceInfo(List<ByteDanceCustomer> airList)
{
string cacheKey = CacheKey.UserModuleCacheKeyConfig.ByteDanceFormId + airList.FirstOrDefault().UserID + "_" + airList.FirstOrDefault().FormId;
TimeSpan ts = GetExpirTime(7 * 60 * 60 * 24 - 60 * 1);
redis.StringSet(cacheKey, JsonConvert.SerializeObject(airList), ts);
}
/// <summary>
/// 获取缓存时长
/// </summary>
/// <param name="JwtExpirTime"></param>
/// <returns></returns>
private static TimeSpan GetExpirTime(int JwtExpirTime)
{
DateTime dt = DateTime.Now;
DateTime dt2 = DateTime.Now;
TimeSpan ts = dt.AddSeconds(JwtExpirTime) - dt2;
return ts;
}
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="airList"></param>
public static void RemoveCacheKey(string CustomerID, string FormId, ByteDanceCustomer model)
{
string cacheKey = CacheKey.UserModuleCacheKeyConfig.ByteDanceFormId + CustomerID + "_" + FormId;
redis.ListRemove(cacheKey, model);
}
}
}
......@@ -31,5 +31,11 @@ namespace Mall.CacheKey
{
get { return "DATA_WeiXinToken"; }
}
public static string ByteDanceFormId
{
get { return "ByteDanceFormId_"; }
}
}
}
......@@ -318,5 +318,17 @@ namespace Mall.Common
return new ConfigurationBuilder().Add(new JsonConfigurationSource { Path = "appsettings.json" }).Build().GetSection("FirstPage").Value;
}
}
/// <summary>
/// 抖音发送消息模板
/// </summary>
public static string ByteDanceSendTemplate
{
get
{
return new ConfigurationBuilder().Add(new JsonConfigurationSource { Path = "appsettings.json" }).Build().GetSection("ByteDanceSendTemplate").Value;
}
}
}
}
\ No newline at end of file
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 员工基础设置表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Emp_Config
{
/// <summary>
/// 配置编号
/// </summary>
public int ConfigId
{
get;
set;
}
/// <summary>
/// 修改密码状态(0-不能修改,1-可以修改)
/// </summary>
public int? IsUpdatePwd
{
get;
set;
}
/// <summary>
/// 员工页面LOGO
/// </summary>
public string Logo
{
get;
set;
}
/// <summary>
/// 员工页面版权信息
/// </summary>
public string Copyright
{
get;
set;
}
/// <summary>
/// 员工页面版权链接
/// </summary>
public string CopyrightLink
{
get;
set;
}
/// <summary>
/// 商户号Id
/// </summary>
public int? TenantId
{
get;
set;
}
/// <summary>
/// 小程序Id
/// </summary>
public int? MallBaseId
{
get;
set;
}
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 员工基础设置表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Employee
{
/// <summary>
/// 员工编号
/// </summary>
public int EmpId
{
get;
set;
}
/// <summary>
/// 员工账号
/// </summary>
public string EmpAccount
{
get;
set;
}
/// <summary>
/// 员工密码
/// </summary>
public string EmpPwd
{
get;
set;
}
/// <summary>
/// 员工姓名
/// </summary>
public string EmpName
{
get;
set;
}
/// <summary>
/// 角色Id
/// </summary>
public string RoleAuth
{
get;
set;
}
/// <summary>
/// 商户号Id
/// </summary>
public int? TenantId
{
get;
set;
}
/// <summary>
/// 小程序Id
/// </summary>
public int? MallBaseId
{
get;
set;
}
/// <summary>
/// 状态(0-正常,1-删除)
/// </summary>
public int? Status
{
get;
set;
}
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 角色表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Role
{
/// <summary>
/// 角色编号
/// </summary>
public int RoleId
{
get;
set;
}
/// <summary>
/// 角色名称
/// </summary>
public string RoleName
{
get;
set;
}
/// <summary>
/// 备注/描述
/// </summary>
public string RoleIntro
{
get;
set;
}
/// <summary>
/// 角色权限
/// </summary>
public string RoleAuth
{
get;
set;
}
/// <summary>
/// 商户号Id
/// </summary>
public int? TenantId
{
get;
set;
}
/// <summary>
/// 小程序Id
/// </summary>
public int? MallBaseId
{
get;
set;
}
/// <summary>
/// 状态(0-正常,1-删除)
/// </summary>
public int? Status
{
get;
set;
}
}
}
using System;
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 员工基础设置表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Emp_Config_Extend : Model.Entity.User.RB_Emp_Config
{
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 员工基础设置表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Employee_Extend : Model.Entity.User.RB_Employee
{
}
}
\ No newline at end of file
......@@ -73,4 +73,31 @@ namespace Mall.Model.Extend.User
#endregion
}
/// <summary>
/// 抖音客户实体类
/// </summary>
public class ByteDanceCustomer
{
/// <summary>
/// form Id
/// </summary>
public string FormId { get; set; }
/// <summary>
/// form Id缓存时间
/// </summary>
public DateTime FormCreateDate { get; set; }
/// <summary>
/// 用户的标识
/// </summary>
public string Openid { get; set; }
/// <summary>
/// 客户编号
/// </summary>
public int UserID { get; set; }
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 角色表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Role_Extend : Model.Entity.User.RB_Role
{
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using Mall.Repository;
using Mall.Repository.User;
using System.Linq;
namespace Mall.Module.User
{
/// <summary>
/// 员工相关处理类
/// </summary>
public class EmployeeModule
{
/// <summary>
/// 角色管理仓储层对象
/// </summary>
private readonly RB_RoleRepository roleRepository = new RB_RoleRepository();
/// <summary>
/// 员工管理仓储层对象
/// </summary>
private readonly RB_EmployeeRepository employeeRepository = new RB_EmployeeRepository();
/// <summary>
/// 员工配置仓储层对象
/// </summary>
private readonly RB_Emp_ConfigRepository emp_ConfigRepository = new RB_Emp_ConfigRepository();
#region 角色管理
/// <summary>
/// 角色分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Role_Extend> GetRolePageListModule(int pageIndex, int pageSize, out long rowCount, RB_Role_Extend query)
{
return roleRepository.GetRolePageListRepository(pageIndex, pageSize, out rowCount, query);
}
/// <summary>
/// 获取角色列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Role_Extend> GetRoleListModule(RB_Role_Extend query)
{
return roleRepository.GetRoleListRepository(query);
}
/// <summary>
/// 新增修改角色
/// </summary>
/// <param name="extModel"></param>
/// <returns></returns>
public bool SetRoleModule(RB_Role_Extend extModel)
{
bool flag = false;
if (extModel.RoleId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Role_Extend.RoleName),extModel.RoleName.Trim()},
{ nameof(RB_Role_Extend.RoleIntro),extModel.RoleIntro},
{ nameof(RB_Role_Extend.RoleAuth),extModel.RoleAuth},
};
flag = roleRepository.Update(fileds, new WhereHelper(nameof(RB_Role_Extend.RoleId), extModel.RoleId));
}
else
{
var newId = roleRepository.Insert(extModel);
extModel.RoleId = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 获取角色实体
/// </summary>
/// <param name="RoleId"></param>
/// <returns></returns>
public RB_Role_Extend GetRoleModule(object RoleId)
{
return roleRepository.GetEntity<RB_Role_Extend>(RoleId);
}
/// <summary>
/// 删除角色
/// </summary>
/// <param name="RoleId"></param>
/// <returns></returns>
public bool RemoveRoleModule(object RoleId)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Role_Extend.Status),1},
};
flag = roleRepository.Update(fileds, new WhereHelper(nameof(RB_Role_Extend.RoleId), RoleId));
return flag;
}
#endregion
#region 员工管理
/// <summary>
/// 员工分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Employee_Extend> GetEmployeePageListModule(int pageIndex, int pageSize, out long rowCount, RB_Employee_Extend query)
{
return employeeRepository.GetEmployeePageListRepository(pageIndex, pageSize, out rowCount, query);
}
/// <summary>
/// 获取员工列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Employee_Extend> GetEmployeeListModule(RB_Employee_Extend query)
{
return employeeRepository.GetEmployeeListRepository(query);
}
/// <summary>
/// 新增修改员工
/// </summary>
/// <param name="extModel"></param>
/// <returns></returns>
public bool SetEmployeeModule(RB_Employee_Extend extModel)
{
bool flag = false;
if (extModel.EmpId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Employee_Extend.EmpAccount),extModel.EmpAccount.Trim()},
{ nameof(RB_Employee_Extend.EmpPwd),extModel.EmpPwd},
{ nameof(RB_Employee_Extend.EmpName),extModel.EmpName},
{ nameof(RB_Employee_Extend.RoleAuth),extModel.RoleAuth},
};
flag = employeeRepository.Update(fileds, new WhereHelper(nameof(RB_Employee_Extend.EmpId), extModel.EmpId));
}
else
{
var newId = employeeRepository.Insert(extModel);
extModel.EmpId = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 获取员工实体
/// </summary>
/// <param name="EmpId"></param>
/// <returns></returns>
public RB_Employee_Extend GetEmployeeModule(object EmpId)
{
return employeeRepository.GetEntity<RB_Employee_Extend>(EmpId);
}
/// <summary>
/// 删除员工
/// </summary>
/// <param name="EmpId"></param>
/// <returns></returns>
public bool RemoveEmployeeModule(object EmpId)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Employee_Extend.Status),1},
};
flag = roleRepository.Update(fileds, new WhereHelper(nameof(RB_Employee_Extend.EmpId), EmpId));
return flag;
}
#endregion
#region 员工配置
/// <summary>
/// 获取员工配置实体
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Emp_Config_Extend GetEmpConfigListModule(RB_Emp_Config_Extend query)
{
return emp_ConfigRepository.GetEmpConfigListRepository(query)?.FirstOrDefault();
}
/// <summary>
/// 新增修改员工配置
/// </summary>
/// <param name="extModel"></param>
/// <returns></returns>
public bool SetEmpConfigModule(RB_Emp_Config_Extend extModel)
{
bool flag = false;
if (extModel.ConfigId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Emp_Config_Extend.IsUpdatePwd),extModel.IsUpdatePwd},
{ nameof(RB_Emp_Config_Extend.Logo),extModel.Logo},
{ nameof(RB_Emp_Config_Extend.Copyright),extModel.Copyright},
{ nameof(RB_Emp_Config_Extend.CopyrightLink),extModel.CopyrightLink},
};
flag = emp_ConfigRepository.Update(fileds, new WhereHelper(nameof(RB_Emp_Config_Extend.ConfigId), extModel.ConfigId));
}
else
{
var newId = emp_ConfigRepository.Insert(extModel);
extModel.ConfigId = newId;
flag = newId > 0;
}
return flag;
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using System.Linq;
namespace Mall.Repository.User
{
/// <summary>
/// 员工基础配置仓储层
/// </summary>
public class RB_Emp_ConfigRepository : RepositoryBase<RB_Emp_Config>
{
/// <summary>
/// 获取员工配置列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Emp_Config_Extend> GetEmpConfigListRepository(RB_Emp_Config_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT * FROM RB_Emp_Config WHERE 1=1 AND Status=0 ");
if (query.TenantId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Emp_Config_Extend.TenantId), query.TenantId);
}
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Emp_Config_Extend.MallBaseId), query.MallBaseId);
}
if (query.ConfigId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Emp_Config_Extend.ConfigId), query.ConfigId);
}
return Get<RB_Emp_Config_Extend>(builder.ToString()).ToList();
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using System.Linq;
namespace Mall.Repository.User
{
/// <summary>
/// 员工表仓储层
/// </summary>
public class RB_EmployeeRepository : RepositoryBase<RB_Employee>
{
/// <summary>
/// 员工分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Employee_Extend> GetEmployeePageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Employee_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT * FROM RB_Employee WHERE 1=1 AND Status=0 ");
if (query.TenantId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Employee_Extend.TenantId), query.TenantId);
}
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Employee_Extend.MallBaseId), query.MallBaseId);
}
if (query.EmpId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Employee_Extend.EmpId), query.EmpId);
}
if (query.EmpName != null && !string.IsNullOrEmpty(query.EmpName.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Employee_Extend.EmpName), query.EmpName.Trim());
}
return GetPage<RB_Employee_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 获取员工列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Employee_Extend> GetEmployeeListRepository(RB_Employee_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT * FROM RB_Employee WHERE 1=1 AND Status=0 ");
if (query.TenantId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Employee_Extend.TenantId), query.TenantId);
}
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Employee_Extend.MallBaseId), query.MallBaseId);
}
if (query.EmpId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Employee_Extend.EmpId), query.EmpId);
}
if (query.EmpName != null && !string.IsNullOrEmpty(query.EmpName.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Employee_Extend.EmpName), query.EmpName.Trim());
}
return Get<RB_Employee_Extend>(builder.ToString()).ToList();
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using System.Linq;
namespace Mall.Repository.User
{
/// <summary>
/// 角色表仓储层
/// </summary>
public class RB_RoleRepository : RepositoryBase<RB_Role>
{
/// <summary>
/// 角色分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Role_Extend> GetRolePageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Role_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT * FROM RB_Role WHERE 1=1 AND Status=0 ");
if (query.TenantId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Role_Extend.TenantId), query.TenantId);
}
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Role_Extend.MallBaseId), query.MallBaseId);
}
if (query.RoleId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Role_Extend.RoleId), query.RoleId);
}
if (query.RoleName != null && !string.IsNullOrEmpty(query.RoleName.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Role_Extend.RoleName), query.RoleName.Trim());
}
return GetPage<RB_Role_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 获取角色列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Role_Extend> GetRoleListRepository(RB_Role_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT * FROM RB_Role WHERE 1=1 AND Status=0 ");
if (query.TenantId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Role_Extend.TenantId), query.TenantId);
}
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Role_Extend.MallBaseId), query.MallBaseId);
}
if (query.RoleId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Role_Extend.RoleId), query.RoleId);
}
if (query.RoleName != null && !string.IsNullOrEmpty(query.RoleName.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Role_Extend.RoleName), query.RoleName.Trim());
}
return Get<RB_Role_Extend>(builder.ToString()).ToList();
}
}
}
\ No newline at end of file
......@@ -36,6 +36,10 @@ namespace Mall.Repository.User
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Stores_Extend.Id), query.Id);
}
if (query.Name!=null && !string.IsNullOrEmpty(query.Name.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Stores_Extend.Name), query.Name.Trim());
}
builder.Append(" ORDER BY Id DESC ");
return GetPage<RB_Stores_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
......@@ -61,6 +65,10 @@ namespace Mall.Repository.User
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Stores_Extend.Id), query.Id);
}
if (query.Name != null && !string.IsNullOrEmpty(query.Name.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Stores_Extend.Name), query.Name.Trim());
}
builder.Append(" ORDER BY Id DESC ");
return Get<RB_Stores_Extend>(builder.ToString()).ToList();
}
......
......@@ -36,6 +36,10 @@ namespace Mall.Repository.User
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Video_Extend.Id), query.Id);
}
if (query.Title != null && !string.IsNullOrEmpty(query.Title.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Video_Extend.Title), query.Title.Trim());
}
builder.Append(" ORDER BY Id DESC ");
return GetPage<RB_Video_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
......@@ -61,6 +65,10 @@ namespace Mall.Repository.User
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Video_Extend.Id), query.Id);
}
if (query.Title != null && !string.IsNullOrEmpty(query.Title.Trim()))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Video_Extend.Title), query.Title.Trim());
}
builder.Append(" ORDER BY Id DESC ");
return Get<RB_Video_Extend>(builder.ToString()).ToList();
}
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using Mall.Module.User;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace Mall.WebApi.Controllers.ByteDance
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class ByteDanceController : BaseController
{
private readonly UserModule userModule = new UserModule();
/// <summary>
/// 保存客户formId
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public ApiResult SaveFormId()
{
var parms = RequestParm;
JObject parmsJob = JObject.Parse(RequestParm.msg.ToString());
int customerId = parmsJob.GetInt("customerId");
string formId = parmsJob.GetStringValue("formId");
// string openid = GetWx(code);
RB_Member_User customerInfo = new RB_Member_User();
//判断是否绑定了openid
customerInfo = userModule.GetMemberUserInfo(customerId);
if (customerInfo != null)
{
ByteDanceCustomer wechatExtend = new ByteDanceCustomer
{
FormCreateDate = System.DateTime.Now,
FormId = formId,
Openid = customerInfo.OpenId,
UserID = customerInfo.Id
};
List<ByteDanceCustomer> listCustomerWechat = new List<ByteDanceCustomer>
{
wechatExtend
};
CacheManager.ByteDance.ByteDanceRedis.SetDyteDanceInfo(listCustomerWechat);
}
return ApiResult.Success("");
}
/// <summary>
/// 向客户抖音小程序发送消息
/// </summary>
/// <param name="content"></param>
/// <param name="model"></param>
/// <param name="ID"></param>
/// <param name="guestModel"></param>
public void SendMsg(string content, ByteDanceCustomer model, int ID, RB_Member_User userModel)
{
//谁来接受微信消息通知
string tempOpenId = model.Openid;
//要使用的form_id
string formId = "";
var list = CacheManager.ByteDance.ByteDanceRedis.GetByteDanceList(model.UserID, formId);
if (list != null && list.Any())
{
formId = list.OrderBy(x => x.FormCreateDate).FirstOrDefault().FormId;
string WeChatSendTemplate = Common.Config.ByteDanceSendTemplate;
var tempData = new
{
keyword1 = new
{
value = "旅客意见调查表",
},
keyword2 = new
{
value = userModel.AliasName,
},
keyword3 = new
{
value = content,
},
};
//拼接字符串
var msgData = new
{
access_token = "",
touser = tempOpenId,//openId,推送给谁,给那个用户
template_id = WeChatSendTemplate,//模板消息ID,在微信小程序后台的模板消息里有.。这个是*****成功通知。的id
// topcolor = "#173177",
page = "",//点击消息卡片之后打开的小程序页面地址,空则无跳转。       
form_id = formId,//要从服务器数据库里取最近7天时间最长的一条没有使用的来,用完了要设置这个formId被用过了。
data = tempData
};
string postData = JsonHelper.Serialize(msgData);
string tempUrl = "https://developer.toutiao.com/api/apps/game/template/send";
string resulr = WebRequestPostOrGet(tempUrl, postData);
CacheManager.ByteDance.ByteDanceRedis.RemoveCacheKey(model.UserID.ToString(), formId, model);
}
}
/// <summary>
/// 发送消息
/// </summary>
/// <param name="sUrl"></param>
/// <param name="sParam"></param>
/// <returns></returns>
public static string WebRequestPostOrGet(string sUrl, string sParam)
{
byte[] bt = System.Text.Encoding.UTF8.GetBytes(sParam);
Uri uriurl = new Uri(sUrl);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uriurl);//HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url + (url.IndexOf("?") > -1 ? "" : "?") + param);
req.Method = "Post";
req.Timeout = 120 * 1000;
req.ContentType = "application/x-www-form-urlencoded;";
req.ContentLength = bt.Length;
using (Stream reqStream = req.GetRequestStream())//using 使用可以释放using段内的内存
{
reqStream.Write(bt, 0, bt.Length);
reqStream.Flush();
}
try
{
using (WebResponse res = req.GetResponse())
{
Stream resStream = res.GetResponseStream();
StreamReader resStreamReader = new StreamReader(resStream, System.Text.Encoding.UTF8);
string resLine;
System.Text.StringBuilder resStringBuilder = new System.Text.StringBuilder();
while ((resLine = resStreamReader.ReadLine()) != null)
{
resStringBuilder.Append(resLine + System.Environment.NewLine);
}
resStream.Close();
resStreamReader.Close();
return resStringBuilder.ToString();
}
}
catch (Exception ex)
{
return ex.Message;//url错误时候回报错
}
}
public ApiResult GetTest()
{
string info = ExecuteInCmd("ipconfig");
// ProcessCore.ExecuteOutCmd("-I http://www.baidu.com", @"C:\curl.exe");
return ApiResult.Success("", info);
}
/// <summary>
/// 执行外部命令
/// </summary>
/// <param name="argument">命令参数</param>
/// <param name="application">命令程序路径</param>
/// <returns>执行结果</returns>
public static string ExecuteOutCmd(string argument, string applocaltion)
{
using (var process = new System.Diagnostics.Process())
{
process.StartInfo.Arguments = argument;
process.StartInfo.FileName = applocaltion;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.StandardInput.AutoFlush = true;
process.StandardInput.WriteLine("exit");
//获取cmd窗口的输出信息
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
process.Close();
return output;
}
}
/// <summary>
/// 执行内部命令(cmd.exe 中的命令)
/// </summary>
/// <param name="cmdline">命令行</param>
/// <returns>执行结果</returns>
public static string ExecuteInCmd(string cmdline)
{
using (var process = new System.Diagnostics.Process())
{
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.StandardInput.AutoFlush = true;
process.StandardInput.WriteLine(cmdline + "&exit");
//获取cmd窗口的输出信息
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
process.Close();
return output;
}
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mall.Common.API;
using Mall.Model.Extend.User;
using Mall.Module.User;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Mall.Common.Plugin;
using Mall.Common.Enum.User;
using Mall.CacheManager.User;
using Newtonsoft.Json.Linq;
using Mall.Common;
using Mall.Model.Entity.User;
namespace Mall.WebApi.Controllers.User
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class EmployeeController : BaseController
{
/// <summary>
/// 员工相关处理类对象
/// </summary>
private readonly EmployeeModule module = new EmployeeModule();
#region 角色管理
/// <summary>
/// 角色分页列表
/// </summary>
/// <returns></returns>
public ApiResult GetRolePageList()
{
ResultPageModel pageModel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
var query = JsonConvert.DeserializeObject<RB_Role_Extend>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
var list = module.GetRolePageListModule(pageModel.pageIndex, pageModel.pageSize, out long rowsCount, query);
pageModel.count = Convert.ToInt32(rowsCount);
pageModel.pageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取角色列表
/// </summary>
/// <returns></returns>
public ApiResult GetRoleList()
{
var query = JsonConvert.DeserializeObject<RB_Role_Extend>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
var list = module.GetRoleListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 新增修改角色
/// </summary>
/// <returns></returns>
public ApiResult SetRole()
{
var extModel = JsonConvert.DeserializeObject<RB_Role_Extend>(RequestParm.msg.ToString());
extModel.Status = 0;
extModel.MallBaseId = RequestParm.MallBaseId;
extModel.TenantId = RequestParm.TenantId;
var flag = module.SetRoleModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取角色实体
/// </summary>
/// <returns></returns>
public ApiResult GetRole()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
var RoleId = parms.GetInt("RoleId", 0);
var extModel = module.GetRoleModule(RoleId);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 删除角色
/// </summary>
/// <returns></returns>
public ApiResult RemoveRole()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
var RoleId = parms.GetInt("RoleId", 0);
var flag = module.RemoveRoleModule(RoleId);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
#region 员工管理
/// <summary>
/// 员工分页列表
/// </summary>
/// <returns></returns>
public ApiResult GetEmployeePageList()
{
ResultPageModel pageModel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
var query = JsonConvert.DeserializeObject<RB_Employee_Extend>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
var list = module.GetEmployeePageListModule(pageModel.pageIndex, pageModel.pageSize, out long rowsCount, query);
pageModel.count = Convert.ToInt32(rowsCount);
pageModel.pageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取员工列表
/// </summary>
/// <returns></returns>
public ApiResult GetEmployeeList()
{
var query = JsonConvert.DeserializeObject<RB_Employee_Extend>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
var list = module.GetEmployeeListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 新增修改员工
/// </summary>
/// <returns></returns>
public ApiResult SetEmployee()
{
var extModel = JsonConvert.DeserializeObject<RB_Employee_Extend>(RequestParm.msg.ToString());
extModel.Status = 0;
extModel.MallBaseId = RequestParm.MallBaseId;
extModel.TenantId = RequestParm.TenantId;
var flag = module.SetEmployeeModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取员工实体
/// </summary>
/// <returns></returns>
public ApiResult GetEmployee()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
var EmpId = parms.GetInt("EmpId", 0);
var extModel = module.GetEmployeeModule(EmpId);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 删除员工
/// </summary>
/// <returns></returns>
public ApiResult RemoveEmployee()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
var EmpId = parms.GetInt("EmpId", 0);
var flag = module.RemoveEmployeeModule(EmpId);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
#region 员工管理
/// <summary>
/// 获取员工配置列表
/// </summary>
/// <returns></returns>
public ApiResult GetEmpConfigList()
{
var query = JsonConvert.DeserializeObject<RB_Emp_Config_Extend>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
var list = module.GetEmpConfigListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 新增修改员工配置
/// </summary>
/// <returns></returns>
public ApiResult SetEmpConfig()
{
var extModel = JsonConvert.DeserializeObject<RB_Emp_Config_Extend>(RequestParm.msg.ToString());
extModel.MallBaseId = RequestParm.MallBaseId;
extModel.TenantId = RequestParm.TenantId;
var flag = module.SetEmpConfigModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
}
}
\ No newline at end of file
......@@ -209,7 +209,7 @@ namespace Mall.WebApi.Controllers.User
/// 获取视频列表
/// </summary>
/// <returns></returns>
public ApiResult GetVideoListModule()
public ApiResult GetVideoList()
{
var query = JsonConvert.DeserializeObject<RB_Video_Extend>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId;
......
......@@ -4,6 +4,10 @@
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Controllers\ByteDance\ByteDanceController.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="web.config" />
</ItemGroup>
......@@ -25,5 +29,9 @@
<ProjectReference Include="..\Mall.ThirdCore\Mall.ThirdCore.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\ByteDance\" />
</ItemGroup>
</Project>
......@@ -24,6 +24,7 @@
"ProjectUrl": "D:/project/GitProject/tripfriend",
"DeveloperKitsPort": "63994",
"FirstPage": "pages/index/index.html",
"ByteDanceSendTemplate": "https://developer.toutiao.com/api/apps/game/template/send",
"RedisSetting": {
"RedisServer": "192.168.2.214",
"RedisPort": "6379",
......
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