Commit 616965b0 by 李承祥

修改实发绩效

parent 2a50eb79
...@@ -20,11 +20,14 @@ public class ComputeController : Controller ...@@ -20,11 +20,14 @@ public class ComputeController : Controller
{ {
private ComputeService _computeService; private ComputeService _computeService;
private AllotService _allotService; private AllotService _allotService;
private ClaimService _claim;
public ComputeController(AllotService allotService, public ComputeController(AllotService allotService,
ComputeService computeService) ComputeService computeService,
ClaimService claim)
{ {
_allotService = allotService; _allotService = allotService;
_computeService = computeService; _computeService = computeService;
_claim = claim;
} }
/// <summary> /// <summary>
...@@ -123,5 +126,22 @@ public ApiResponse AllCompute([FromBody]ComputerRequest request) ...@@ -123,5 +126,22 @@ public ApiResponse AllCompute([FromBody]ComputerRequest request)
var list = _computeService.AllCompute(request.AllotId); var list = _computeService.AllCompute(request.AllotId);
return new ApiResponse(ResponseType.OK, "ok", list); return new ApiResponse(ResponseType.OK, "ok", list);
} }
/// <summary>
/// 修改实发绩效
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("updatereal")]
[HttpPost]
public ApiResponse UpdateRealfee([CustomizeValidator(RuleSet = "UpdateReal"), FromBody] ComputerRequest request)
{
var user = _claim.At(request);
var compute = _computeService.GetComputeSingle(request.ComputeId);
if (null == compute)
throw new PerformanceException("当前数据记录不存在");
compute = _computeService.UpdateRealfee(request, user);
return new ApiResponse(ResponseType.OK, "修改成功", compute);
}
} }
} }
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class ChangeLog
{
public int uid { get; set; }
public string user { get; set; }
public DateTime date { get; set; }
public decimal? value { get; set; }
}
}
...@@ -8,6 +8,16 @@ namespace Performance.DtoModels ...@@ -8,6 +8,16 @@ namespace Performance.DtoModels
public class ComputerRequest : ApiRequest public class ComputerRequest : ApiRequest
{ {
/// <summary> /// <summary>
/// 绩效数据id
/// </summary>
public int ComputeId { get; set; }
/// <summary>
/// 实发绩效
/// </summary>
public decimal? RealGiveFee { get; set; }
/// <summary>
/// 绩效id /// 绩效id
/// </summary> /// </summary>
public int AllotId { get; set; } public int AllotId { get; set; }
...@@ -27,6 +37,12 @@ public ComputerRequestValidator() ...@@ -27,6 +37,12 @@ public ComputerRequestValidator()
{ {
RuleFor(x => x.Type).NotNull().NotEmpty(); RuleFor(x => x.Type).NotNull().NotEmpty();
}); });
RuleSet("UpdateReal", () =>
{
RuleFor(x => x.ComputeId).NotNull().GreaterThan(0);
RuleFor(x => x.RealGiveFee).NotNull();
});
} }
} }
} }
...@@ -150,5 +150,10 @@ public class res_compute ...@@ -150,5 +150,10 @@ public class res_compute
/// 实发绩效 /// 实发绩效
/// </summary> /// </summary>
public Nullable<decimal> RealGiveFee { get; set; } public Nullable<decimal> RealGiveFee { get; set; }
/// <summary>
/// 变更日志
/// </summary>
public string ChangeLog { get; set; }
} }
} }
...@@ -237,5 +237,37 @@ public List<ComputeResponse> AllCompute(int allotId) ...@@ -237,5 +237,37 @@ public List<ComputeResponse> AllCompute(int allotId)
} }
return list; return list;
} }
public res_compute GetComputeSingle(int computeid)
{
return _perforRescomputeRepository.GetEntity(t => t.ID == computeid);
}
/// <summary>
/// 修改实发绩效
/// </summary>
/// <param name="type"></param>
/// <param name="id"></param>
/// <param name="score"></param>
/// <returns></returns>
public res_compute UpdateRealfee(ComputerRequest request, UserIdentity user)
{
var compute = _perforRescomputeRepository.GetEntity(t => t.ID == request.ComputeId);
var log = JsonHelper.Deserialize<List<ChangeLog>>(compute.ChangeLog);
log = log ?? new List<ChangeLog>();
log.Add(new ChangeLog
{
uid = user.UserID,
user = user.RealName,
date = DateTime.Now,
value = compute.RealGiveFee
});
compute.RealGiveFee = request.RealGiveFee;
compute.ChangeLog = JsonHelper.Serialize(log);
if (!_perforRescomputeRepository.Update(compute))
throw new PerformanceException("修改失败");
return compute;
}
} }
} }
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