Browse Source

订单处理

FLH 1 tháng trước cách đây
mục cha
commit
354ec57c98
1 tập tin đã thay đổi với 28 bổ sung2 xóa
  1. 28 2
      3.Service/XYY.Service.Standard.ChannelApi/Shiphubx/Api.cs

+ 28 - 2
3.Service/XYY.Service.Standard.ChannelApi/Shiphubx/Api.cs

@@ -1,10 +1,13 @@
 using iTextSharp.text.pdf.parser;
+using NPOI.SS.Formula.PTG;
 using RestSharp;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using XYY.Core.Standard.ExtendMethods;
+using XYY.Data.Standard.Order;
+
 //using XYY.Common.Standard;
 using XYY.Model.Standard.Order;
 using XYY.Service.Standard.ChannelApi.Base;
@@ -15,6 +18,13 @@ namespace XYY.Service.Standard.ChannelApi.Sengi.Shiphubx
     {
         public string ServiceName => "Shiphubx";
 
+         public IOrderRepository _orderRepository { get; set; }
+
+        public Api(IOrderRepository orderRepository)
+        {
+            _orderRepository = orderRepository;
+        }
+
         public Task<List<BagDeclareErrosResult>> BagDeclare(BagDeclareRequest bagDeclareRequest)
         {
             throw new NotImplementedException();
@@ -69,6 +79,13 @@ namespace XYY.Service.Standard.ChannelApi.Sengi.Shiphubx
                 };
             }
             string refrno = order.SystemNo.Replace("XYYEX", "A");
+            //if (channel.Id == 916)
+            //{
+            //    if (order.IsOnline)
+            //        refrno = order.TransferNumber;
+            //    else
+            //       refrn
+            //}
             decimal avgweight = order.CustomerWeight / (decimal)goods.Sum(x => x.Quantity);
             decimal orderWeight = order.CustomerWeight;
             CreateOrderReq req = new CreateOrderReq
@@ -166,14 +183,23 @@ namespace XYY.Service.Standard.ChannelApi.Sengi.Shiphubx
                 var orderInfoResponse = client.Execute<LabelResult>(orderInfoRequest);
                 if (orderInfoResponse.IsSuccessful)
                 {
+                    await _orderRepository.AddChannelOrderInfoRecord(order.ChannelId, orderInfoResponse.Data.logistics_code, order.SystemNo);
                     string labelUrl = orderInfoResponse.Data.label_url;
+                    string serviceNumber = orderInfoResponse.Data.refer_no;
+                    if (channel.Id == 916)
+                    { 
+                        if (order.IsOnline)
+                            serviceNumber = order.TransferNumber;
+                        else
+                            serviceNumber = order.SystemNo;
+                    }
                     return new UploadResult
                     {
                         IsSuccess = true,
                         TrackingNumber = orderInfoResponse.Data.logistics_code,
                         DownloadUrl = labelUrl,
-                        ServiceOrderNumber = orderInfoResponse.Data.refer_no,
-                        ServiceOrderNumber3 = orderInfoResponse.Data.refer_no
+                        ServiceOrderNumber = serviceNumber,
+                        ServiceOrderNumber3 = serviceNumber
                     };
                 }
                 else