Commit 856c1662 authored by liudong1993's avatar liudong1993

1 教育收据 + 2电商用户统计查询 增加应许重复提交属性

parent 8b4b6cf5
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Common.Enum.Education;
using VT.FW.DB;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 财务收据配置实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "EduConnection")]
public class RB_Receipt_Config
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 是否启用 1是 其他否
/// </summary>
public int Enable { get; set; }
/// <summary>
/// 使用的流程IDs 英文逗号分隔
/// </summary>
public string TempleteIds { get; set; }
/// <summary>
/// 章图片地址
/// </summary>
public string Images { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime UpdateTime { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Common.Enum.Education;
using VT.FW.DB;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 财务收据实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "EduConnection")]
public class RB_Receipt_Info
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 相关财务单据ID
/// </summary>
public int FinanceId { get; set; }
/// <summary>
/// 收据编号
/// </summary>
public string ReceiptNo { get; set; }
/// <summary>
/// 汇款人
/// </summary>
public string Remitter { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal Money { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 状态 1已认领 2未认领
/// </summary>
public int State { get; set; }
/// <summary>
/// 认领码 4位随机数
/// </summary>
public int ClaimCode { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 关联电商用户Id
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 电商用户名称
/// </summary>
public string UserName { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 财务收据配置扩展类
/// </summary>
[Serializable]
[DB(ConnectionName = "EduConnection")]
public class RB_Receipt_Config_ViewModel : Entity.Education.RB_Receipt_Config
{
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 财务收据扩展类
/// </summary>
[Serializable]
[DB(ConnectionName = "EduConnection")]
public class RB_Receipt_Info_ViewModel : Entity.Education.RB_Receipt_Info
{
/// <summary>
/// 章地址
/// </summary>
public string SealImages { get; set; }
/// <summary>
/// 经办人
/// </summary>
public string CreateByName { get; set; }
}
}
......@@ -145,6 +145,19 @@ namespace Mall.Module.Education
/// 校企仓储
/// </summary>
private readonly Rb_Education_SchoolRepository education_SchoolRepository = new Rb_Education_SchoolRepository();
/// <summary>
/// 收据配置
/// </summary>
private readonly RB_Receipt_ConfigRepository receipt_ConfigRepository = new RB_Receipt_ConfigRepository();
/// <summary>
/// 收据详情
/// </summary>
private readonly RB_Receipt_InfoRepository receipt_InfoRepository = new RB_Receipt_InfoRepository();
/// <summary>
/// 教育用户
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
#region 课程管理
......@@ -3516,5 +3529,80 @@ namespace Mall.Module.Education
return flag;
}
#endregion
#region 教育财务收据
/// <summary>
/// 获取收据分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Receipt_Info_ViewModel> GetMyEduReceiptInfoPageList(int pageIndex, int pageSize, out long count, RB_Receipt_Info_ViewModel demodel)
{
var list = receipt_InfoRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) {
string empIds = string.Join(",", list.Select(x => x.CreateBy).Distinct());
var empList = accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = 100000, QIds = empIds });
foreach (var item in list) {
item.CreateByName = empList.Where(x => x.Id == item.CreateBy).FirstOrDefault()?.EmployeeName ?? "";
}
}
return list;
}
/// <summary>
/// 获取收据详情
/// </summary>
/// <param name="financeId"></param>
/// <returns></returns>
public RB_Receipt_Info_ViewModel GetEduReceiptInfo(int financeId)
{
var receiptModel = receipt_InfoRepository.GetList(new RB_Receipt_Info_ViewModel() { Group_Id = 100000, FinanceId = financeId }).FirstOrDefault();
if (receiptModel != null) {
//查询盖章
var configModel = receipt_ConfigRepository.GetList(new RB_Receipt_Config_ViewModel() { Group_Id = 100000 }).FirstOrDefault();
if (configModel != null)
{
receiptModel.SealImages = configModel.Images;
}
receiptModel.CreateByName = accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = 100000, Id = receiptModel.CreateBy }).FirstOrDefault()?.EmployeeName ?? "";
}
return receiptModel;
}
/// <summary>
/// 客户收据认领
/// </summary>
/// <param name="receiptId"></param>
/// <param name="claimCode"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public string SetEduReceiptClaim(int receiptId, int claimCode, AppletUserInfo userInfo)
{
var remodel = receipt_InfoRepository.GetEntity(receiptId);
if (remodel == null || remodel.Status == 1) { return "收据不存在"; }
if (remodel.State == 1) { return "已认领,无法重复认领"; }
if (remodel.ClaimCode != claimCode) { return "认领码不正确"; }
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Receipt_Info_ViewModel.State), 1},
{ nameof(RB_Receipt_Info_ViewModel.UserId), userInfo.UserId},
{ nameof(RB_Receipt_Info_ViewModel.UserName), userInfo.Name},
{ nameof(RB_Receipt_Info_ViewModel.UpdateTime), DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName= nameof(RB_Receipt_Info_ViewModel.Id),
FiledValue = remodel.Id,
OperatorEnum= OperatorEnum.Equal
}
};
bool flag = receipt_InfoRepository.Update(keyValues, wheres);
return flag ? "" : "出错了,请联系管理员";
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
using VT.FW.DB.Dapper;
namespace Mall.Repository.Education
{
/// <summary>
/// 财务收据配置仓储层
/// </summary>
public class RB_Receipt_ConfigRepository : BaseRepository<RB_Receipt_Config>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Receipt_Config_ViewModel> GetList(RB_Receipt_Config_ViewModel demodel)
{
string where = $@" 1=1 ";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_Receipt_Config_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
string sql = $@"
SELECT * From RB_Receipt_Config r
WHERE {where}
ORDER BY r.Id DESC ";
return Get<RB_Receipt_Config_ViewModel>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
using VT.FW.DB.Dapper;
namespace Mall.Repository.Education
{
/// <summary>
/// 财务收据仓储层
/// </summary>
public class RB_Receipt_InfoRepository : BaseRepository<RB_Receipt_Info>
{
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Receipt_Info_ViewModel> GetPageList(int pageIndex, int pageSize, out long count, RB_Receipt_Info_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.Status =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.FinanceId > 0)
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.FinanceId)} ={demodel.FinanceId}";
}
if (demodel.UserId > 0)
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.UserId)} ={demodel.UserId}";
}
if (demodel.State > 0)
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.State)} ={demodel.State}";
}
if (!string.IsNullOrEmpty(demodel.ReceiptNo))
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.ReceiptNo)} ='{demodel.ReceiptNo}'";
}
if (!string.IsNullOrEmpty(demodel.Remitter))
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.Remitter)} like @Remitter";
parameters.Add("Remitter", "%" + demodel.Remitter + "%");
}
string sql = $@"
SELECT * From RB_Receipt_Info r
WHERE {where}
ORDER BY r.Id DESC ";
return GetPage<RB_Receipt_Info_ViewModel>(pageIndex, pageSize, out count, sql, parameters).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Receipt_Info_ViewModel> GetList(RB_Receipt_Info_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.Status =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.FinanceId > 0)
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.FinanceId)} ={demodel.FinanceId}";
}
if (demodel.State > 0)
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.State)} ={demodel.State}";
}
if (!string.IsNullOrEmpty(demodel.ReceiptNo))
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.ReceiptNo)} ='{demodel.ReceiptNo}'";
}
if (!string.IsNullOrEmpty(demodel.Remitter))
{
where += $@" and r.{nameof(RB_Receipt_Info_ViewModel.Remitter)} like @Remitter";
parameters.Add("Remitter", "%" + demodel.Remitter + "%");
}
string sql = $@"
SELECT * From RB_Receipt_Info r
WHERE {where}
ORDER BY r.Id DESC ";
return Get<RB_Receipt_Info_ViewModel>(sql, parameters).ToList();
}
/// <summary>
/// 获取收据最大的编码
/// </summary>
/// <param name="group_Id"></param>
/// <returns></returns>
public string GetMaxReceiptNo(int group_Id)
{
string sql = "SELECT MAX(ReceiptNo) FROM rb_receipt_info WHERE `Status` =0 and Group_Id =" + group_Id;
var obj = ExecuteScalar(sql);
return obj == null ? "" : obj.ToString();
}
}
}
......@@ -2823,5 +2823,98 @@ namespace Mall.WebApi.Controllers.Education
return ApiResult.Success(data: pageModel);
}
#endregion
#region 甲鹤财务收据
/// <summary>
/// 获取我的收据列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetMyEduReceiptInfoPageList()
{
var userInfo = base.AppletUserInfo;
ResultPageModel pmodel = JsonHelper.DeserializeObject<ResultPageModel>(base.RequestParm.msg.ToString());
RB_Receipt_Info_ViewModel demodel = JsonHelper.DeserializeObject<RB_Receipt_Info_ViewModel>(base.RequestParm.msg.ToString());
demodel.Group_Id = 100000;
demodel.UserId = userInfo.UserId;
var list = educationModule.GetMyEduReceiptInfoPageList(pmodel.pageIndex, pmodel.pageSize, out long count, demodel);
pmodel.count = Convert.ToInt32(count);
pmodel.pageData = list.Select(x => new
{
x.Id,
x.FinanceId,
x.ReceiptNo,
x.Remitter,
x.Money,
x.Remark,
x.State,
x.CreateBy,
x.CreateByName,
CreateTime = x.CreateTime.ToString("yyyy-MM-dd")
});
return ApiResult.Success("", pmodel);
}
/// <summary>
/// 获取财务收据详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetEduReceiptInfo() {
var userInfo = base.AppletUserInfo;
JObject parms = JObject.Parse(base.RequestParm.msg.ToString());
int FinanceId = parms.GetInt("FinanceId", 0);
if (FinanceId <= 0) { return ApiResult.ParamIsNull(); }
var model = educationModule.GetEduReceiptInfo(FinanceId);
if (model == null) { return ApiResult.Failed("收据不存在"); }
if (model.State == 1 && model.UserId != userInfo.UserId) { return ApiResult.Failed("该收据已被他人领取您无权查看"); }
return ApiResult.Success("", new
{
model?.Id,
model?.FinanceId,
model?.ReceiptNo,
model?.Remitter,
model?.Money,
model?.Remark,
model?.State,
model?.SealImages,
model?.UserId,
CreateTime = model?.CreateTime.ToString("yyyy-MM-dd"),
model?.CreateByName
});
}
/// <summary>
/// 收据认领
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetEduReceiptClaim() {
var userInfo = base.AppletUserInfo;
JObject parms = JObject.Parse(base.RequestParm.msg.ToString());
int ReceiptId = parms.GetInt("ReceiptId", 0);//收据ID
int ClaimCode = parms.GetInt("ClaimCode", 0);//认领码
if (ReceiptId <= 0) {
return ApiResult.ParamIsNull();
}
if (ClaimCode <= 0) {
return ApiResult.ParamIsNull();
}
string msg = educationModule.SetEduReceiptClaim(ReceiptId, ClaimCode, userInfo);
if (msg == "")
{
return ApiResult.Success();
}
else {
return ApiResult.Failed(msg);
}
}
#endregion
}
}
\ No newline at end of file
......@@ -1968,6 +1968,7 @@ namespace Mall.WebApi.Controllers.User
/// 首页数据统计
/// </summary>
/// <returns></returns>
[AllowRepeat]
public ApiResult MallIndexStatistics()
{
var query = JsonConvert.DeserializeObject<StatisticsQuery>(RequestParm.msg.ToString());
......@@ -2134,6 +2135,7 @@ namespace Mall.WebApi.Controllers.User
/// 用户数据统计
/// </summary>
/// <returns></returns>
[AllowRepeat]
public ApiResult MallDistributorStatistics()
{
var query = JsonConvert.DeserializeObject<StatisticsQuery>(RequestParm.msg.ToString());
......@@ -2148,6 +2150,7 @@ namespace Mall.WebApi.Controllers.User
/// 每日用户统计
/// </summary>
/// <returns></returns>
[AllowRepeat]
public ApiResult MallDistributorDayStatistics()
{
ResultPageModel pageModel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
......

using System;
namespace Mall.WebApi.Filter
{
/// <summary>
/// 允许重复提交表单属性
/// </summary>
public class AllowRepeatAttribute : Attribute
{
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ using Mall.CacheManager.User;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.Features;
using System.Reflection;
namespace Mall.WebApi.Filter
{
......@@ -128,32 +129,36 @@ namespace Mall.WebApi.Filter
#endregion
#region 验证表单重复提交
string controllerName = actionContext.ActionDescriptor.RouteValues["controller"].ToString().ToLower();
string actionName = actionContext.ActionDescriptor.RouteValues["action"].ToString().ToLower();
var action = actionContext.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;
string controllerName = action.RouteValues["controller"].ToString().ToLower();
string actionName = action.RouteValues["action"].ToString().ToLower();
if (!actionName.ToLower().Contains("get"))
{
string cachedKey = SecurityHelper.MD5(string.Format("cmd={0}&token={1}", controllerName + "/" + actionName, token));
try
var allowRepeat = action.MethodInfo.GetCustomAttribute(typeof(AllowRepeatAttribute));
if (allowRepeat == null)
{
if (UserReidsCache.Exists(cachedKey))//判断表单是否重复提交
string cachedKey = SecurityHelper.MD5(string.Format("cmd={0}&token={1}", controllerName + "/" + actionName, token));
try
{
actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
if (UserReidsCache.Exists(cachedKey))//判断表单是否重复提交
{
resultCode = (int)ResultCode.FormRepeatSubmit,
message = "表单重复提交,请稍后再试",
data = null
});
actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
{
resultCode = (int)ResultCode.FormRepeatSubmit,
message = "表单重复提交,请稍后再试",
data = null
});
}
else
{
//默认3秒钟之内不能重复提交
UserReidsCache.Set(cachedKey, 1, 3);
}
}
else
catch
{
//默认3秒钟之内不能重复提交
UserReidsCache.Set(cachedKey, 1, 3);
}
}
catch
{
}
}
#endregion
}
......
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