master
zxxxf 8 months ago
parent 07934ee355
commit e9918abe62

@ -22,7 +22,7 @@ namespace EntrustSettle.Api.Controllers
/// </summary> /// </summary>
[HttpPost] [HttpPost]
[ApiUser(ApiCode = "EntrustSettle")] [ApiUser(ApiCode = "EntrustSettle")]
public async Task<MessageModel> OrderSubmit(OrderSubmitDto inputDto) public async Task<MessageModel<List<OrderSubmitResultDto>>> OrderSubmit(OrderSubmitDto inputDto)
{ {
var result = await App.GetService<OrderController>().Submit(inputDto); var result = await App.GetService<OrderController>().Submit(inputDto);
return result; return result;

@ -121,7 +121,7 @@ namespace EntrustSettle.Api.Controllers
/// </summary> /// </summary>
[HttpPost] [HttpPost]
//[UseTran] //[UseTran]
public async Task<MessageModel> Submit(OrderSubmitDto inputDto) public async Task<MessageModel<List<OrderSubmitResultDto>>> Submit(OrderSubmitDto inputDto)
{ {
var validator = new OrderSubmitDtoValidator(); var validator = new OrderSubmitDtoValidator();
validator.ValidateAndThrow(inputDto); validator.ValidateAndThrow(inputDto);
@ -150,9 +150,13 @@ namespace EntrustSettle.Api.Controllers
orderList.Add(order); orderList.Add(order);
} }
unitOfWorkManage.BeginTran(); unitOfWorkManage.BeginTran();
var orderHasIdList = await orderService.AsInsertable(orderList.ToArray()).ExecuteCommandAsync(); foreach (var item in orderList)
//var orderIdList = orderHasIdList {
//var orderIdList = await orderService.Add(orderList); var id = await orderService.AsInsertable(item).ExecuteReturnSnowflakeIdAsync();
item.Id = id;
}
var orderIdList = orderList.Select(x => x.Id).ToList();
// 附件关联信息保存 // 附件关联信息保存
if (inputDto.AnnexIdList?.Count > 0) if (inputDto.AnnexIdList?.Count > 0)
@ -191,9 +195,11 @@ namespace EntrustSettle.Api.Controllers
// 查询所有待处理订单列表 // 查询所有待处理订单列表
var pendingOrderList = await orderService.Query(x => x.IsSend == false && orderIdList.Contains(x.Id)); var pendingOrderList = await orderService.Query(x => x.IsSend == false && orderIdList.Contains(x.Id));
var result = orderList.Select(x => new OrderSubmitResultDto() { OrderId = x.Id, Mblno = x.Mblno }).ToList();
if (pendingOrderList.Count == 0) if (pendingOrderList.Count == 0)
{ {
return SuccessMsg(); return Success(result);
} }
string domainUrl = AppSettings.app(["Startup", "Domain"]); string domainUrl = AppSettings.app(["Startup", "Domain"]);
@ -270,7 +276,7 @@ namespace EntrustSettle.Api.Controllers
} }
} }
return SuccessMsg(); return Success(result);
} }
/// <summary> /// <summary>
/// 获取订单附件信息列表 /// 获取订单附件信息列表
@ -445,30 +451,43 @@ namespace EntrustSettle.Api.Controllers
// 将更新后的状态及费用推送到消息队列 // 将更新后的状态及费用推送到消息队列
if (AppSettings.app("RabbitMQ", "Enabled").ObjToBool()) if (AppSettings.app("RabbitMQ", "Enabled").ObjToBool())
{ {
_ = Task.Run(() => _ = Task.Run(async () =>
{ {
string msg = $"Id[{order.Id}],提单号:[{order.Mblno}],手动更新状态后推送队列"; string msg = $"Id[{order.Id}],提单号:[{order.Mblno}],手动更新状态后推送队列";
try try
{ {
StatusPushDto pushDto = new() StatusPushDto pushDto = new()
{ {
OrderId = order.Id,
Mblno = order.Mblno,
MessageType = 1, MessageType = 1,
MessageDesc = "状态更新推送", MessageDesc = "状态更新推送",
Remark = changeStatusDto.Remark, Remark = changeStatusDto.Remark,
Status = (int)changeStatusDto.Status, Status = (int)changeStatusDto.Status,
StatusDesc = changeStatusDto.Status.ToString() StatusDesc = changeStatusDto.Status.ToString()
}; };
if (changeStatusDto.FeeList != null && changeStatusDto.FeeList.Count > 0) var feeList = await orderFeeService.Query(x => x.OrderId == order.Id);
if (feeList.Count > 0)
{ {
pushDto.FeeList = changeStatusDto.FeeList.Select(x => new StatusPushDto.FeeDto() pushDto.FeeList = feeList.Select(x => new StatusPushDto.FeeDto()
{ {
FeeId = x.Id,
FeeName = x.Name, FeeName = x.Name,
FeeAmount = x.Amount FeeAmount = x.Amount
}).ToList(); }).ToList();
} }
//if (changeStatusDto.FeeList != null && changeStatusDto.FeeList.Count > 0)
//{
// pushDto.FeeList = changeStatusDto.FeeList.Select(x => new StatusPushDto.FeeDto()
// {
// //Id = x.
// FeeName = x.Name,
// FeeAmount = x.Amount
// }).ToList();
//}
var json = JsonConvert.SerializeObject(pushDto, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); var json = JsonConvert.SerializeObject(pushDto, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
queueService.Push(msg, json); queueService.Push(msg, order.CompanyId, json);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -603,6 +622,8 @@ namespace EntrustSettle.Api.Controllers
{ {
BillPushDto pushDto = new() BillPushDto pushDto = new()
{ {
OrderId = order.Id,
Mblno = order.Mblno,
AnnexIdList = bindDto.AnnexIdList, AnnexIdList = bindDto.AnnexIdList,
}; };
if (bindDto.OperType == FileTypeEnum.) if (bindDto.OperType == FileTypeEnum.)
@ -619,7 +640,7 @@ namespace EntrustSettle.Api.Controllers
} }
var json = JsonConvert.SerializeObject(pushDto, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); var json = JsonConvert.SerializeObject(pushDto, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
queueService.Push(msg, json); queueService.Push(msg, order.CompanyId, json);
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -8,6 +8,6 @@ namespace EntrustSettle.IServices
{ {
public interface IQueueService public interface IQueueService
{ {
void Push(string opType, string data); void Push(string opType, string companyId, string data);
} }
} }

@ -0,0 +1,14 @@
namespace EntrustSettle.Model.Dtos
{
public class OrderSubmitResultDto
{
/// <summary>
/// 订单Id
/// </summary>
public long OrderId { get; set; }
/// <summary>
/// 订单提单号
/// </summary>
public string Mblno { get; set; }
}
}

@ -16,5 +16,14 @@ namespace EntrustSettle.Model.Dtos
/// 消息类型说明 /// 消息类型说明
/// </summary> /// </summary>
public string MessageDesc { get; set; } public string MessageDesc { get; set; }
/// <summary>
/// 订单Id
/// </summary>
public long OrderId { get; set; }
/// <summary>
/// 提单号
/// </summary>
public string Mblno { get; set; }
} }
} }

@ -7,7 +7,6 @@ namespace EntrustSettle.Model.Dtos
/// </summary> /// </summary>
public class StatusPushDto : BasePushDto public class StatusPushDto : BasePushDto
{ {
/// <summary> /// <summary>
/// 状态编码 已下单=0 已接单=1 待缴费=2 已缴费=3 已完结=4 /// 状态编码 已下单=0 已接单=1 待缴费=2 已缴费=3 已完结=4
/// </summary> /// </summary>
@ -34,6 +33,10 @@ namespace EntrustSettle.Model.Dtos
public class FeeDto public class FeeDto
{ {
/// <summary>
/// 费用记录主键
/// </summary>
public long FeeId { get; set; }
/// <summary> /// <summary>
/// 费用名称 /// 费用名称
/// </summary> /// </summary>

@ -15,13 +15,13 @@ namespace EntrustSettle.Services
{ {
this.logger = logger; this.logger = logger;
} }
public void Push(string opType, string data) public void Push(string opType, string compId, string data)
{ {
var mqUrl = AppSettings.app("RabbitMQ", "ConnectionString"); var mqUrl = AppSettings.app("RabbitMQ", "ConnectionString");
try try
{ {
const string MqActionExchangeName = "amq.direct"; string exchangeName = "amq.direct";
const string MqActionQueueName = "feedback.output"; string queueName = "feedback.output." + compId;
ConnectionFactory factory = new ConnectionFactory(); ConnectionFactory factory = new ConnectionFactory();
factory.Uri = new Uri(mqUrl); factory.Uri = new Uri(mqUrl);
@ -29,20 +29,18 @@ namespace EntrustSettle.Services
using (IConnection conn = factory.CreateConnection()) using (IConnection conn = factory.CreateConnection())
using (IModel mqModel = conn.CreateModel()) using (IModel mqModel = conn.CreateModel())
{ {
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct, true); mqModel.ExchangeDeclare(exchangeName, ExchangeType.Direct, true);
//var queueName = $"{MqActionQueueName}.{model.TenantId}";
var queueName = $"{MqActionQueueName}";
mqModel.QueueDeclare(queueName, false, false, false, null); mqModel.QueueDeclare(queueName, false, false, false, null);
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null); mqModel.QueueBind(queueName, exchangeName, queueName, null);
IBasicProperties props = mqModel.CreateBasicProperties(); IBasicProperties props = mqModel.CreateBasicProperties();
props.DeliveryMode = 2; props.DeliveryMode = 2;
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(data)); byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(data));
mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); mqModel.BasicPublish(exchangeName, queueName, props, messageBodyBytes);
conn.Close(); conn.Close();

@ -104,13 +104,15 @@ namespace EntrustSettle.Tasks
// 将更新后的状态及费用推送到消息队列 // 将更新后的状态及费用推送到消息队列
if (AppSettings.app("RabbitMQ", "Enabled").ObjToBool()) if (AppSettings.app("RabbitMQ", "Enabled").ObjToBool())
{ {
_ = Task.Run(async () => _ = Task.Run(() =>
{ {
string msg = $"Id[{order.Id}],提单号:[{order.Mblno}],自动更新状态后推送队列"; string msg = $"Id[{order.Id}],提单号:[{order.Mblno}],自动更新状态后推送队列";
try try
{ {
StatusPushDto pushDto = new() StatusPushDto pushDto = new()
{ {
OrderId = order.Id,
Mblno = order.Mblno,
MessageType = 1, MessageType = 1,
MessageDesc = "状态更新推送", MessageDesc = "状态更新推送",
Remark = "", Remark = "",
@ -125,18 +127,19 @@ namespace EntrustSettle.Tasks
_ => "未知状态", _ => "未知状态",
} }
}; };
var feeList = await orderFeeService.Query(x => x.OrderId == order.Id); //var feeList = await orderFeeService.Query(x => x.OrderId == order.Id);
if (feeList.Count > 0) //if (feeList.Count > 0)
{ //{
pushDto.FeeList = feeList.Select(x => new StatusPushDto.FeeDto() // pushDto.FeeList = feeList.Select(x => new StatusPushDto.FeeDto()
{ // {
FeeName = x.Name, // Id = x.Id,
FeeAmount = x.Amount // FeeName = x.Name,
}).ToList(); // FeeAmount = x.Amount
} // }).ToList();
//}
var json = JsonConvert.SerializeObject(pushDto, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); var json = JsonConvert.SerializeObject(pushDto, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
queueService.Push(msg, json); queueService.Push(msg, order.CompanyId, json);
} }
catch (Exception ex) catch (Exception ex)
{ {

Loading…
Cancel
Save