feat: 收益互换开平仓及收益结算接入OA移动审批
#EQD-6425 国联民生-衍生品系统移动审批(提交OA流程) - 审批节点支持配置“关联OA移动审批” - 创建OA流程并记录请求、requestId、状态及异常备注 - 支持OA轮询同步审批通过、退回和归档状态 - 本地通过、拒绝、撤回时同步强制归档未结束OA流程 - 增加审批列表OA备注展示及本地Mock联调接口 - 新增OA审批记录表和数据库升级脚本 - OA移动审批使用独立查询地址及isnextflow配置,不影响交易确认书OA
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System.Text.Json;
|
||||
using YLErp.Helpers;
|
||||
using YLErp.Model;
|
||||
using YLErp.Modules.TradeModule;
|
||||
|
||||
namespace YLErp.Web.WebAPI.Controllers
|
||||
{
|
||||
/// <summary>国联民生衍生品移动审批轮询入口,由 PowerJob 等外部调度器调用。</summary>
|
||||
[ApiController]
|
||||
public class TradeApprovalOAJobController : ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
[Route("api/job/tradeApproval/syncOAStatus")]
|
||||
public JsonResult SyncOAStatus([FromQuery] string requestId = null)
|
||||
{
|
||||
var configKey = AppManager.GetConfiguration()["JobConfig:ApiKey"];
|
||||
if (!string.IsNullOrEmpty(configKey) && Request.Headers["X-Job-Api-Key"].FirstOrDefault() != configKey)
|
||||
return new JsonResult(new { code = 401, msg = "Invalid API Key" });
|
||||
|
||||
var user = new OptUserInfo(0, "系统移动审批同步", OptUserFrom.System);
|
||||
var messages = new TradeApprovalOAService(user).SyncPendingStatuses(requestId);
|
||||
return new JsonResult(new { code = 0, data = new { total = messages.Count, details = messages } }, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.Json;
|
||||
using YLErp.Helpers;
|
||||
|
||||
namespace YLErp.Web.WebAPI.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 仅供本地开发验证收益互换移动审批调用链的 OA 模拟接口。
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/mock/tradeApprovalOa")]
|
||||
public class TradeApprovalOaMockController : ControllerBase
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, MockOaFlow> Flows = new();
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
};
|
||||
|
||||
[HttpPost("createOaFlow")]
|
||||
public IActionResult CreateOaFlow([FromBody] JsonElement payload)
|
||||
{
|
||||
if (!IsEnabled()) return NotFound();
|
||||
|
||||
var requestId = "mock-" + Guid.NewGuid().ToString("N");
|
||||
Flows[requestId] = new MockOaFlow { RequestId = requestId };
|
||||
return Json(new { code = 0, data = new { msg = string.Empty, requestid = requestId }, status = "SUCCESS" });
|
||||
}
|
||||
|
||||
[HttpGet("getRequestData")]
|
||||
public IActionResult GetRequestData([FromQuery] string requestId)
|
||||
{
|
||||
if (!IsEnabled()) return NotFound();
|
||||
|
||||
if (!Flows.TryGetValue(requestId ?? string.Empty, out var flow))
|
||||
return Json(new { code = 0, data = Array.Empty<object>(), status = "SUCCESS" });
|
||||
|
||||
return Json(new
|
||||
{
|
||||
code = 0,
|
||||
data = new[] { new { requestId = flow.RequestId, flowStatusType = flow.FlowStatusType, status = flow.Status } },
|
||||
status = "SUCCESS"
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost("forceEndOaFlow")]
|
||||
public IActionResult ForceEndOaFlow([FromQuery] string requestId)
|
||||
{
|
||||
if (!IsEnabled()) return NotFound();
|
||||
|
||||
if (requestId != null && Flows.TryGetValue(requestId, out var flow))
|
||||
{
|
||||
flow.FlowStatusType = "3";
|
||||
flow.Status = "归档";
|
||||
flow.IsEnded = true;
|
||||
}
|
||||
|
||||
return Json(new { code = 0, data = new { resultcode = "0" }, status = "SUCCESS" });
|
||||
}
|
||||
|
||||
[HttpPost("setStatus")]
|
||||
public IActionResult SetStatus([FromQuery] string requestId, [FromQuery] string flowStatusType, [FromQuery] string status = null)
|
||||
{
|
||||
if (!IsEnabled()) return NotFound();
|
||||
if (flowStatusType != "0" && flowStatusType != "1" && flowStatusType != "2" && flowStatusType != "3")
|
||||
return BadRequest(new { code = 1, msg = "flowStatusType 只能为 0、1 或 2" });
|
||||
if (!Flows.TryGetValue(requestId ?? string.Empty, out var flow))
|
||||
return NotFound(new { code = 1, msg = "未找到 requestId" });
|
||||
if (flow.IsEnded)
|
||||
return BadRequest(new { code = 1, msg = "OA 流程已归档" });
|
||||
|
||||
flow.FlowStatusType = flowStatusType;
|
||||
if (!string.IsNullOrWhiteSpace(status))
|
||||
flow.Status = status;
|
||||
return Json(new { code = 0, data = new { requestId, flowStatusType, status = flow.Status }, status = "SUCCESS" });
|
||||
}
|
||||
|
||||
[HttpGet("flows")]
|
||||
public IActionResult GetFlows()
|
||||
{
|
||||
if (!IsEnabled()) return NotFound();
|
||||
|
||||
return Json(new
|
||||
{
|
||||
code = 0,
|
||||
data = Flows.Values.Select(x => new { requestId = x.RequestId, flowStatusType = x.FlowStatusType, status = x.Status, isEnded = x.IsEnded }),
|
||||
status = "SUCCESS"
|
||||
});
|
||||
}
|
||||
|
||||
private static bool IsEnabled()
|
||||
{
|
||||
return bool.TryParse(AppManager.GetConfiguration()["TradeApprovalOaMock:Enabled"], out var enabled) && enabled;
|
||||
}
|
||||
|
||||
private JsonResult Json(object value)
|
||||
{
|
||||
return new JsonResult(value, JsonOptions);
|
||||
}
|
||||
|
||||
private sealed class MockOaFlow
|
||||
{
|
||||
public string RequestId { get; set; }
|
||||
public string FlowStatusType { get; set; } = "0";
|
||||
public string Status { get; set; } = "创建";
|
||||
public bool IsEnded { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user