master
zxxxf 8 months ago
parent 07934ee355
commit e9918abe62

@ -22,7 +22,7 @@ namespace EntrustSettle.Api.Controllers
/// </summary>
[HttpPost]
[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);
return result;

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

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

@ -15,13 +15,13 @@ namespace EntrustSettle.Services
{
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");
try
{
const string MqActionExchangeName = "amq.direct";
const string MqActionQueueName = "feedback.output";
string exchangeName = "amq.direct";
string queueName = "feedback.output." + compId;
ConnectionFactory factory = new ConnectionFactory();
factory.Uri = new Uri(mqUrl);
@ -29,20 +29,18 @@ namespace EntrustSettle.Services
using (IConnection conn = factory.CreateConnection())
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.QueueBind(queueName, MqActionExchangeName, queueName, null);
mqModel.QueueBind(queueName, exchangeName, queueName, null);
IBasicProperties props = mqModel.CreateBasicProperties();
props.DeliveryMode = 2;
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(data));
mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes);
mqModel.BasicPublish(exchangeName, queueName, props, messageBodyBytes);
conn.Close();

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

Loading…
Cancel
Save