委托结算状态接收接口+公司税号

master
zhangxiaofeng 7 months ago
parent 6fd9b2118a
commit 8bc00d6fab

@ -67,7 +67,7 @@ namespace EntrustSettle.Controllers
/// 返回一个错误提示,但不包含数据 /// 返回一个错误提示,但不包含数据
/// </summary> /// </summary>
[NonAction] [NonAction]
protected MessageModel FailedMsg(int code, string msg = "失败") protected MessageModel FailedMsg(string msg = "失败", int code = 500)
{ {
return new MessageModel() return new MessageModel()
{ {

@ -1,9 +1,12 @@
using EntrustSettle.Common; using EntrustSettle.Common;
using EntrustSettle.Controllers; using EntrustSettle.Controllers;
using EntrustSettle.IServices;
using EntrustSettle.Model; using EntrustSettle.Model;
using EntrustSettle.Model.Dtos; using EntrustSettle.Model.Dtos;
using EntrustSettle.Model.Models;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace EntrustSettle.Api.Controllers namespace EntrustSettle.Api.Controllers
{ {
@ -13,8 +16,22 @@ namespace EntrustSettle.Api.Controllers
[AllowAnonymous] [AllowAnonymous]
public class OpenController : BaseApiController public class OpenController : BaseApiController
{ {
public OpenController() private readonly IOrderService orderService;
private readonly ILogger<OpenController> logger;
private readonly IOrderHistoryService orderHistoryService;
private readonly IQueueService queueService;
private readonly IOrderFeeService orderFeeService;
public OpenController(IOrderService orderService,
ILogger<OpenController> logger,
IOrderHistoryService orderHistoryService,
IQueueService queueService,
IOrderFeeService orderFeeService)
{ {
this.orderService = orderService;
this.logger = logger;
this.orderHistoryService = orderHistoryService;
this.queueService = queueService;
this.orderFeeService = orderFeeService;
} }
/// <summary> /// <summary>
@ -64,5 +81,96 @@ namespace EntrustSettle.Api.Controllers
var result = await App.GetService<AnnexController>().DownloadFile(annexId); var result = await App.GetService<AnnexController>().DownloadFile(annexId);
return result; return result;
} }
/// <summary>
/// 海运达状态回推接口
/// </summary>
[HttpPost]
[ApiUser(ApiCode = "PushOrderStatus")]
public async Task<MessageModel> PushOrderStatus([FromBody] HydQueryResultDto item)
{
var orderList = await orderService.Query(x => x.Bsno == item.id);
if (orderList == null || orderList.Count == 0)
{
string msg = $"订单Id[{item.id}]接收到回推后未查询到本地订单";
logger.LogInformation(msg);
return FailedMsg(msg);
}
if (orderList.Count > 1)
{
string msg = $"订单Id[{item.id}]接收到回推后根据Id查询到多个本地订单{string.Join(',', orderList.Select(x => x.Mblno))}";
logger.LogInformation(msg);
return FailedMsg(msg);
}
var order = orderList[0];
if (order.Status == item.status)
{
string msg = $"订单Id[{item.id}],提单号[{order.Mblno}]状态不变";
logger.LogInformation(msg);
return SuccessMsg(msg);
}
order.Status = item.status;
var updateSuccess = await orderService.Update(order, x => new { x.Status });
logger.LogInformation($"订单Id[{item.id}],提单号[{order.Mblno}]状态更新{(updateSuccess ? "" : "")}status:{item.status}");
// 记录订单状态变更历史
await orderHistoryService.Add(new OrderHistory()
{
Pid = order.Id,
Status = item.status,
StatusTime = DateTime.Now,
CreateBy = "系统",
Remark = "(状态接收)"
});
// 将更新后的状态及费用推送到消息队列
if (AppSettings.app("RabbitMQ", "Enabled").ObjToBool())
{
_ = Task.Run(async () =>
{
string msg = $"Id[{order.Id}],提单号[{order.Mblno}],自动更新状态后推送队列";
try
{
StatusPushDto pushDto = new()
{
OrderId = order.Id,
Mblno = order.Mblno,
MessageType = 1,
MessageDesc = "状态更新推送",
Remark = "",
Status = item.status,
StatusDesc = item.status switch
{
0 => "已下单",
1 => "已接单",
2 => "待缴费",
3 => "已缴费",
4 => "已完结",
_ => "未知状态",
}
};
var feeList = await orderFeeService.Query(x => x.OrderId == order.Id);
if (feeList.Count > 0)
{
pushDto.FeeList = feeList.Select(x => new StatusPushDto.FeeDto()
{
FeeId = x.Id,
FeeName = x.Name,
FeeAmount = x.Amount
}).ToList();
}
var json = JsonConvert.SerializeObject(pushDto, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
queueService.Push(msg, order.CompanyId, json);
}
catch (Exception ex)
{
logger.LogError(ex, $"订单Id[{item.id}],提单号[{order.Mblno}]接收到状态然后推送时发生未知异常:{msg}");
}
});
}
return SuccessMsg($"订单Id[{item.id}],提单号[{order.Mblno}]状态更新成功");
}
} }
} }

@ -11,9 +11,11 @@ using EntrustSettle.Model.Models;
using EntrustSettle.Model.Models.DJY; using EntrustSettle.Model.Models.DJY;
using EntrustSettle.Model.Validator; using EntrustSettle.Model.Validator;
using EntrustSettle.Repository.UnitOfWorks; using EntrustSettle.Repository.UnitOfWorks;
using EntrustSettle.Services;
using FluentValidation; using FluentValidation;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Net.NetworkInformation;
namespace EntrustSettle.Api.Controllers namespace EntrustSettle.Api.Controllers
{ {
@ -137,6 +139,10 @@ namespace EntrustSettle.Api.Controllers
inputDto.MblnoList = inputDto.MblnoList.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).ToArray(); inputDto.MblnoList = inputDto.MblnoList.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).ToArray();
StringHelper.TrimStringProperties(inputDto); StringHelper.TrimStringProperties(inputDto);
// 查询税号
var custBalanceService = App.GetService<IBaseServices<CompanyNew>>();
var taxCode = await custBalanceService.Db.Queryable<CompanyNew>().Where(x => x.CompId == inputDto.CompanyId).Select(x => x.TaxCode).FirstAsync();
var orderList = new List<Order>(); var orderList = new List<Order>();
foreach (var item in inputDto.MblnoList) foreach (var item in inputDto.MblnoList)
{ {
@ -145,6 +151,7 @@ namespace EntrustSettle.Api.Controllers
Mblno = item, Mblno = item,
CompanyId = inputDto.CompanyId, CompanyId = inputDto.CompanyId,
CompanyName = inputDto.CompanyName, CompanyName = inputDto.CompanyName,
TaxCode = taxCode,
ServiceType = inputDto.ServiceType, ServiceType = inputDto.ServiceType,
ProjectType = inputDto.ProjectType, ProjectType = inputDto.ProjectType,
IsSend = false, IsSend = false,
@ -252,9 +259,11 @@ namespace EntrustSettle.Api.Controllers
registerFlag = 1, registerFlag = 1,
registerUser = new HydSubmitDto.RegisterUser() registerUser = new HydSubmitDto.RegisterUser()
{ {
phone = orderItem.ContactTel, phone = orderItem.ContactTel?.Trim(),
userName = orderItem.ContactName, userName = orderItem.ContactName?.Trim(),
enterpriseName = orderItem.CompanyName enterpriseName = orderItem.CompanyName?.Trim(),
sex = 1,
dutyNo = orderItem.TaxCode?.Trim() ?? ""
} }
}; };
// 开始提交 // 开始提交

@ -6,7 +6,7 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"applicationUrl": "http://localhost:6002" "applicationUrl": "http://*:6002"
} }
}, },
"$schema": "http://json.schemastore.org/launchsettings.json" "$schema": "http://json.schemastore.org/launchsettings.json"

@ -47,7 +47,8 @@
"Middleware": { "Middleware": {
"RequestResponseLog": { "RequestResponseLog": {
"Enabled": true, "Enabled": true,
"IgnoreApis": "/api/Annex/Upload,/api/Annex/DownloadFile,/api/Annex/Download", "IgnoreRequestApis": "/api/Annex/Upload,/api/Open/AnnexUpload",
"IgnoreResponseApis": "/api/Annex/DownloadFile,/api/Annex/Download,/api/Open/AnnexDownload",
"LogToFile": { "LogToFile": {
"Enabled": true "Enabled": true
}, },
@ -56,14 +57,14 @@
} }
}, },
"RecordAccessLogs": { "RecordAccessLogs": {
"Enabled": false, "Enabled": true,
"LogToFile": { "LogToFile": {
"Enabled": false "Enabled": true
}, },
"LogToDB": { "LogToDB": {
"Enabled": false "Enabled": false
}, },
"IgnoreApis": "/api/Annex/Upload,/api/Annex/DownloadFile,/api/Annex/Download" "IgnoreApis": "/api/Annex/Upload,/api/Open/AnnexUpload,/api/Annex/DownloadFile,/api/Annex/Download,/api/Open/AnnexDownload"
}, },
"SignalR": { "SignalR": {
"Enabled": false "Enabled": false
@ -235,10 +236,11 @@
}, },
"RabbitMQ": { "RabbitMQ": {
"Enabled": true, "Enabled": true,
"Connection": "60.209.125.238:40101/audit_booking", "ConnectionString": "amqp://entrust_settle_user:djy^2024@60.209.125.238:40101/entrust_settle"
"UserName": "audit_booking_user", //"Connection": "60.209.125.238:40101/audit_booking",
"Password": "djy^2024", //"UserName": "audit_booking_user",
"RetryCount": 3 //"Password": "djy^2024",
//"RetryCount": 3
}, },
"Kafka": { "Kafka": {
"Enabled": false, "Enabled": false,

@ -48,7 +48,7 @@
"RequestResponseLog": { "RequestResponseLog": {
"Enabled": true, "Enabled": true,
"IgnoreRequestApis": "/api/Annex/Upload,/api/Open/AnnexUpload", "IgnoreRequestApis": "/api/Annex/Upload,/api/Open/AnnexUpload",
"IgnoreResponseApis": "/api/Annex/DownloadFile,/api/Open/AnnexDownload", "IgnoreResponseApis": "/api/Annex/DownloadFile,/api/Annex/Download,/api/Open/AnnexDownload",
"LogToFile": { "LogToFile": {
"Enabled": true "Enabled": true
}, },
@ -64,7 +64,7 @@
"LogToDB": { "LogToDB": {
"Enabled": false "Enabled": false
}, },
"IgnoreApis": "/api/Annex/Upload,/api/Open/AnnexUpload,/api/Annex/DownloadFile,/api/Open/AnnexDownload" "IgnoreApis": "/api/Annex/Upload,/api/Open/AnnexUpload,/api/Annex/DownloadFile,/api/Annex/Download,/api/Open/AnnexDownload"
}, },
"SignalR": { "SignalR": {
"Enabled": false "Enabled": false
@ -127,7 +127,7 @@
"Enabled": true "Enabled": true
}, },
"SeedDBEnabled": false, // "SeedDBEnabled": false, //
"RoutePrefix": "", // "RoutePrefix": "" //
}, },
// DBType0=MySql,1=SqlServer,2=Sqlite,3=Oracle,4=PostgreSQL,5=Dm,6=Kdbndp // DBType0=MySql,1=SqlServer,2=Sqlite,3=Oracle,4=PostgreSQL,5=Dm,6=Kdbndp
// //
@ -230,7 +230,7 @@
"Enabled": false "Enabled": false
}, },
"Redis": { "Redis": {
"Enabled": false, "Enabled": true,
"ConnectionString": "127.0.0.1:6379,defaultDatabase=3", "ConnectionString": "127.0.0.1:6379,defaultDatabase=3",
"InstanceName": "" //Key "InstanceName": "" //Key
}, },

@ -52,7 +52,7 @@ namespace EntrustSettle.Extensions.Middlewares
// return; // return;
//} //}
// 过滤,只有接口 // 分别过滤请求和响应要记录日志的接口
var ignoreRequestApis = AppSettings.app("Middleware", "RequestResponseLog", "IgnoreRequestApis").Split(',').ToList(); var ignoreRequestApis = AppSettings.app("Middleware", "RequestResponseLog", "IgnoreRequestApis").Split(',').ToList();
var ignoreResponseApis = AppSettings.app("Middleware", "RequestResponseLog", "IgnoreResponseApis").Split(',').ToList(); var ignoreResponseApis = AppSettings.app("Middleware", "RequestResponseLog", "IgnoreResponseApis").Split(',').ToList();
@ -96,25 +96,21 @@ namespace EntrustSettle.Extensions.Middlewares
// 去除 Html // 去除 Html
//var reg = "<[^>]+>"; //var reg = "<[^>]+>";
//var isHtml = Regex.IsMatch(responseBody, reg);
//if (!string.IsNullOrEmpty(responseBody)) var logContent = new string[]
{ {
//var isHtml = Regex.IsMatch(responseBody, reg);
var logContent = new string[]
{
$"● 响应", $"● 响应",
$"[Path]:{context.Request.Path}", $"[Path]:{context.Request.Path}",
$"[StatusCode]:{context.Response.StatusCode}", $"[StatusCode]:{context.Response.StatusCode}",
$"[Body]:{(isIgnore? "" : responseBody )}", $"[Body]:{(isIgnore? "" : responseBody )}",
}; };
Parallel.For(0, 1, e => Parallel.For(0, 1, e =>
{ {
LogLock.OutLogAOP("RequestResponseLog", LogLock.OutLogAOP("RequestResponseLog",
context.TraceIdentifier, context.TraceIdentifier,
logContent); logContent);
}); });
}
} }
} }
} }

@ -17,9 +17,10 @@ namespace EntrustSettle.Model.Dtos
{ {
public string phone { get; set; } public string phone { get; set; }
public string userName { get; set; } public string userName { get; set; }
public string sex { get; set; } public int sex { get; set; }
public string idNumber { get; set; } public string idNumber { get; set; }
public string enterpriseName { get; set; } public string enterpriseName { get; set; }
public string dutyNo { get; set; }
} }
} }
} }

@ -0,0 +1,13 @@
using SqlSugar;
namespace EntrustSettle.Model.Models.DJY
{
[Tenant(DBConst.PingTai)]
[SugarTable("company_new")]
public class CompanyNew
{
//[SugarColumn(IsPrimaryKey = true)]
public string CompId { get; set; }
public string TaxCode { get; set; }
}
}

@ -26,6 +26,10 @@ namespace EntrustSettle.Model.Models
/// </summary> /// </summary>
public string CompanyName { get; set; } public string CompanyName { get; set; }
/// <summary> /// <summary>
/// 公司税号
/// </summary>
public string TaxCode { get; set; }
/// <summary>
/// 联系人Id /// 联系人Id
/// </summary> /// </summary>
public string ContactId { get; set; } public string ContactId { get; set; }

@ -111,9 +111,11 @@ namespace EntrustSettle.Tasks
registerFlag = 1, registerFlag = 1,
registerUser = new HydSubmitDto.RegisterUser() registerUser = new HydSubmitDto.RegisterUser()
{ {
phone = orderItem.ContactTel, phone = orderItem.ContactTel?.Trim(),
userName = orderItem.ContactName, userName = orderItem.ContactName?.Trim(),
enterpriseName = orderItem.CompanyName enterpriseName = orderItem.CompanyName?.Trim(),
sex = 1,
dutyNo = orderItem.TaxCode?.Trim() ?? ""
} }
}; };
// 开始提交 // 开始提交

Loading…
Cancel
Save