12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using XYY.gRpc.Order;
- using XYY.Model.Standard.MpsOrder;
- using XYY.TaskTrack.Standard;
- using Microsoft.Extensions.Logging;
- namespace XYY.WindowsService.ReshMQ.Works
- {
- public interface IMoreThanOneTicketGrpc : IBaseConsumer<OrderMpsOrderSubModel>
- {
- }
- public class MoreThanOneTicketGrpc : IMoreThanOneTicketGrpc
- {
- OrderGrpcChannel orderGrpcChannel;
- public MoreThanOneTicketGrpc(OrderGrpcChannel orderGrpcChannel, ILogger<MoreThanOneTicketGrpc> logger)
- {
- this.orderGrpcChannel = orderGrpcChannel;
- _logger = logger;
- }
- private readonly ILogger<MoreThanOneTicketGrpc> _logger;
- public async Task Consume(OrderMpsOrderSubModel message)
- {
- try
- {
- var client = new MoreThanOneTicketOrders.MoreThanOneTicketOrdersClient(orderGrpcChannel.Channel);
- var or = new MTOROrderRequest
- {
- ChannelId = message.Order.ChannelId,
- ChannelName = message.Order.ChannelName,
- City = message.Order.ReceiverCity,
- CountryCode = message.Order.ReceiverCountry,
- CustomerId = message.Order.CustomerId,
- CustomerOrderNo = message.Order.CustomerOrderNumber,
- ZipCode = message.Order.ReceiverZipCode,
- DraftOrderId = message.Order.DraftOrderId,
- MpsOrderId = message.Order.Id,
- Name = message.Order.ReceiverName,
- Phone = message.Order.ReceiverPhone ?? string.Empty,
- State = message.Order.ReceiverState ?? string.Empty,
- Stree = message.Order.ReceiverStreet1,
- Weight = message.Order.Weight,
- ReceiverCompany=message.Order.ReceiverCompanyName ?? string.Empty,
- ReceiverEmail=message.Order.ReceiverEmail ?? string.Empty,
- };
- or.Boxs.AddRange(message.Order.Boxs.Select(x => new MTOROrderRequestBox
- {
- BoxId = x.Id,
- BoxNumber = x.BoxNumber,
- Height =Convert.ToDouble(x.Height),
- Length = Convert.ToDouble(x.Length),
- Weight = Convert.ToDouble(x.Weight),
- Width = Convert.ToDouble(x.Width)
- }));
- var result = await client.CreateAsync(or);
- _logger.LogInformation(result.LabelPath);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- _logger.LogError("草稿订单转换失败${message} {request}", ex.Message, message);
- }
- }
- }
- }
|