Exemplo n.º 1
0
 public bool AddSNOrderItemExt(List <Deploy.SNOrderItemDTO> snOrderItem)
 {
     if (snOrderItem == null)
     {
         return(true);
     }
     if (snOrderItem.Count == 0)
     {
         return(true);
     }
     snOrderItem.ForEach(item =>
     {
         SNOrderItem.ObjectSet().AddObject(new SNOrderItem()
         {
             Id                = item.Id,
             OrderId           = item.OrderId,
             OrderItemId       = item.OrderItemId,
             OrderCode         = item.OrderCode,
             CustomOrderId     = item.CustomOrderId,
             CustomOrderItemId = item.CustomOrderItemId,
             CustomSkuId       = item.CustomSkuId,
             ExpressStatus     = item.ExpressStatus,
             Status            = item.Status,
             DeliveryType      = item.DeliveryType,
             SubTime           = item.SubTime,
             ModifiedOn        = item.ModifiedOn,
             EntityState       = EntityState.Added
         });
     });
     return(ContextFactory.CurrentThreadContext.SaveChanges() > 0);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 取消预占库存订单接口
 /// </summary>
 public static bool suning_govbus_rejectorder_delete(Guid OrderId)
 {
     try
     {
         var relation = SNOrderItem.ObjectSet().Where(w => w.OrderId == OrderId).FirstOrDefault();
         if (relation == null)
         {
             return(false);
         }
         var request = new snsdk.suning_api_sdk.BizRequest.CustomGovbusRequest.RejectOrderDeleteRequest();
         request.orderId = relation.CustomOrderId;
         var response = SuningClient.Execute(request);
         if (response.respError == null)
         {
             return(response.unCampSuccess == "Y");
         }
         else
         {
             string Message = response.respError.error_msg + "===" + response.respError.error_msg;
             LogHelper.Error(string.Format("苏宁接口[suning.govbus.confirmorder.add]:{0}", Message));
             return(false);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error("苏宁接口[suning.govbus.confirmorder.add]Exception:" + ex.Message);
         return(false);
     }
 }
Exemplo n.º 3
0
        //#region 部分退货

        ///// <summary>
        ///// 部分商品退货
        ///// </summary>
        ///// <param name="reqDto">实体数据</param>
        ///// <returns></returns>
        //public Deploy.CustomDTO.ResultDTO SnReturnPartOrderExt(Deploy.CustomDTO.AfterSales.SNReturnPartOrderDTO reqDto, SNFactoryDeliveryEnum ty)
        //{

        //    Deploy.CustomDTO.ResultDTO retDto = new Deploy.CustomDTO.ResultDTO() { ResultCode = 0, isSuccess = false, Message = "退货申请失败" };
        //    //根据苏宁接口处理自己业务
        //    //switch (ty)
        //    //{
        //    //    case SNFactoryDeliveryEnum.FactoryDelivery:
        //    //        break;
        //    //    case SNFactoryDeliveryEnum.NonFactoryDelivery:
        //    //        break;
        //    //    default:
        //    //        break;
        //    //}

        //    ////调用苏宁接口
        //    //retDto = TPS.SuningSV.ReturnPartOrder(reqDto);

        //    return retDto;
        //}
        ///// <summary>
        ///// 部分退货---厂送
        ///// </summary>
        ///// <param name="reqDto"></param>
        ///// <returns></returns>
        //private Deploy.CustomDTO.ResultDTO ReturnPartFactoryDelivery(Deploy.CustomDTO.AfterSales.SNReturnPartOrderDTO reqDto)
        //{
        //    return null;
        //}
        //#endregion
        ///// <summary>
        ///// 整单退货接口申请
        ///// </summary>
        ///// <param name="reqDto"></param>
        ///// <returns></returns>
        //public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SnApplyRejectedExt(Deploy.CustomDTO.AfterSales.SNApplyRejectedDTO reqDto, SNFactoryDeliveryEnum ty)
        //{

        //    //根据苏宁接口处理自己业务
        //    //switch (ty)
        //    //{
        //    //    case SNFactoryDeliveryEnum.FactoryDelivery:
        //    //        break;
        //    //    case SNFactoryDeliveryEnum.NonFactoryDelivery:
        //    //        break;
        //    //    default:
        //    //        break;
        //    //}

        //    //调用苏宁接口
        //    //Deploy.CustomDTO.AfterSales.SNApplyRejectedReturnDTO dto = Jinher.AMP.BTP.TPS.SuningSV.ApplyRejected(reqDto);
        //    //根据苏宁接口处理自己业务
        //    return null;
        //}

        /// <summary>
        /// 查询苏宁订单详情
        /// </summary>
        /// <returns></returns>
        public List <Deploy.SNOrderItemDTO> GetSNOrderItemListExt(Deploy.SNOrderItemDTO snOrderItem)
        {
            List <Jinher.AMP.BTP.Deploy.SNOrderItemDTO> SNOrderItemlist = new List <Jinher.AMP.BTP.Deploy.SNOrderItemDTO>();

            try
            {
                if (!snOrderItem.OrderId.Equals(Guid.Empty) && snOrderItem.OrderItemId.Equals(Guid.Empty))
                {
                    var Query = SNOrderItem.ObjectSet().Where(w => w.OrderId == snOrderItem.OrderId).ToList();
                    ExecuteQuery(SNOrderItemlist, Query);
                }
                else if (snOrderItem.OrderId.Equals(Guid.Empty) && !snOrderItem.OrderItemId.Equals(Guid.Empty))
                {
                    var Query = SNOrderItem.ObjectSet().Where(w => w.OrderItemId == snOrderItem.OrderItemId).ToList();
                    ExecuteQuery(SNOrderItemlist, Query);
                }
                else if (!snOrderItem.OrderId.Equals(Guid.Empty) && !snOrderItem.OrderItemId.Equals(Guid.Empty))
                {
                    var Query = SNOrderItem.ObjectSet()
                                .Where(w => w.OrderItemId == snOrderItem.OrderItemId && w.OrderId == snOrderItem.OrderId)
                                .ToList();
                    ExecuteQuery(SNOrderItemlist, Query);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("SNAfterSaleBP.GetSNOrderItemListExt【苏宁-售后】查询苏宁订单详情", ex);
            }
            return(SNOrderItemlist);
        }
Exemplo n.º 4
0
        public bool UpdSNOrderItemExt(Deploy.SNOrderItemDTO snOrderItem)
        {
            var EntityQuery = SNOrderItem.ObjectSet();

            if (snOrderItem.OrderId != null)
            {
                EntityQuery.Where(w => w.OrderId == snOrderItem.OrderId);
            }
            if (snOrderItem.OrderItemId != null)
            {
                EntityQuery.Where(w => w.OrderItemId == snOrderItem.OrderItemId);
            }
            if (snOrderItem.OrderCode != null)
            {
                EntityQuery.Where(w => w.OrderCode == snOrderItem.OrderCode);
            }


            if (snOrderItem.CustomOrderId != null)
            {
                EntityQuery.Where(w => w.CustomOrderId == snOrderItem.CustomOrderId);
            }
            if (snOrderItem.CustomOrderItemId != null)
            {
                EntityQuery.Where(w => w.CustomOrderItemId == snOrderItem.CustomOrderItemId);
            }
            if (snOrderItem.CustomSkuId != null)
            {
                EntityQuery.Where(w => w.CustomSkuId == snOrderItem.CustomSkuId);
            }
            var EntityModels = EntityQuery.ToList();

            if (EntityModels == null)
            {
                return(true);
            }
            EntityModels.ForEach(item =>
            {
                item.Status      = snOrderItem.Status;
                item.ModifiedOn  = DateTime.Now;
                item.EntityState = EntityState.Modified;
                SNOrderItem.ObjectSet().Attach(item);
            });
            return(ContextFactory.CurrentThreadContext.SaveChanges() > 0);
        }
Exemplo n.º 5
0
 public bool ChangeOrderStatusForJobExt()
 {
     try
     {
         //更改订单状态
         var DataList = SuningSV.suning_govbus_message_get("11");
         DataList.ForEach(Item =>
         {
             var EntityList = SNOrderItem.ObjectSet()
                              .Where(w => w.CustomOrderId == Item.orderNo)
                              .ToList();
             if (EntityList != null)
             {
                 EntityList.ForEach(ItemModel =>
                 {
                     ItemModel.Status      = Convert.ToInt32(Item.status);
                     ItemModel.EntityState = EntityState.Modified;
                     SNOrderItem.ObjectSet().Attach(ItemModel);
                     //根据ID从消息池删除数据
                     if (ContextFactory.CurrentThreadContext.SaveChanges() >= 0)
                     {
                         SuningSV.suning_govbus_message_delete(Item.id);
                     }
                 });
             }
         });
         //检查确认预占失败的订单
         SNOrderItem.ObjectSet().Where(w => w.Status < 3).ToList()
         .ForEach(Item =>
         {
             SuningSV.suning_govbus_confirmorder_add(Item.OrderId, false);
         });
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.Error(string.Format("Job-SuningChangeOrderStatus:{0}", ex.Message));
         return(false);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 获取苏宁物流信息
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="orderItemId"></param>
        /// <returns></returns>
        public List <Deploy.SNExpressTraceDTO> GetExpressTraceExt(string orderId, string orderItemId)
        {
            ContextSession           contextSession = ContextFactory.CurrentThreadContext;
            List <SNExpressTraceDTO> SNExpressList  = new List <SNExpressTraceDTO>();
            var OrderItemGuid = Guid.Parse(orderItemId);
            var EntityQuery   = SNOrderItem.ObjectSet().Where(w => w.OrderItemId == OrderItemGuid).FirstOrDefault();

            LogHelper.Info(string.Format("苏宁物流3"));
            if (EntityQuery != null)
            {
                SuningSV.suning_govbus_orderlogistnew_get(new SNQueryParamsDto
                {
                    OrderId      = EntityQuery.CustomOrderId,
                    OrderItemIds = new List <SNQueryItemParamsDto>
                    {
                        new SNQueryItemParamsDto
                        {
                            SkuId       = EntityQuery.CustomSkuId,
                            OrderItemId = EntityQuery.CustomOrderItemId
                        }
                    }
                })
                .ForEach(ItemPackage =>
                {
                    ItemPackage.OrderLogistics.ForEach(LogisticsItem =>
                    {
                        SNExpressTraceDTO SNExpress = new SNExpressTraceDTO();
                        SNExpress.Id           = Guid.NewGuid();
                        SNExpress.OrderId      = ItemPackage.OrderId;
                        SNExpress.PackageId    = ItemPackage.PackageId;
                        SNExpress.OperateState = LogisticsItem.OperateState;
                        SNExpress.OperateTime  = string.IsNullOrWhiteSpace(LogisticsItem.OperateTime) ? DateTime.Now : DateTime.ParseExact(LogisticsItem.OperateTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture);
                        SNExpressList.Add(SNExpress);
                    });
                });
            }
            LogHelper.Info(string.Format("苏宁物流4"));
            return(SNExpressList.Count > 0 ? SNExpressList : null);
        }
Exemplo n.º 7
0
        public bool ChangeLogistStatusForJobExt()
        {
            ContextSession contextSession = ContextFactory.CurrentThreadContext;

            SuningSV.suning_govbus_message_get("12")
            .ForEach(Item =>
            {
                try
                {
                    var EntityQuery = SNOrderItem.ObjectSet()
                                      .Where(w => w.CustomOrderId == Item.orderNo)
                                      .Where(w => w.CustomOrderItemId == Item.orderItemNo)
                                      .FirstOrDefault();
                    if (EntityQuery != null)
                    {
                        EntityQuery.ExpressStatus = Convert.ToInt32(Item.status);
                        //根据订单获得物流信息
                        SuningSV.suning_govbus_orderlogistnew_get(new SNQueryParamsDto
                        {
                            OrderId      = EntityQuery.CustomOrderId,
                            OrderItemIds = new List <SNQueryItemParamsDto>
                            {
                                new SNQueryItemParamsDto
                                {
                                    SkuId       = EntityQuery.CustomSkuId,
                                    OrderItemId = EntityQuery.CustomOrderItemId
                                }
                            }
                        })
                        .ForEach(ItemPackage =>
                        {
                            ItemPackage.OrderItemIds.ForEach(OrderItem =>
                            {
                                var EntityModel = SNPackageTrace.ObjectSet()
                                                  .Where(w => w.OrderId == ItemPackage.OrderId)
                                                  .Where(w => w.OrderItemId == OrderItem.OrderItemId)
                                                  .Where(w => w.SkuId == OrderItem.SkuId)
                                                  .Where(w => w.PackageId == ItemPackage.PackageId)
                                                  .FirstOrDefault();
                                if (EntityModel == null)
                                {
                                    contextSession.SaveObject(new SNPackageTrace
                                    {
                                        Id = Guid.NewGuid(),
                                        CommodityOrderId = EntityQuery.OrderId,
                                        OrderId          = ItemPackage.OrderId,
                                        OrderItemId      = OrderItem.OrderItemId,
                                        SkuId            = OrderItem.SkuId,
                                        PackageId        = ItemPackage.PackageId,
                                        ReceiveTime      = string.IsNullOrWhiteSpace(ItemPackage.ReceiveTime) ? DateTime.Now : DateTime.ParseExact(ItemPackage.ReceiveTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture),
                                        ShippingTime     = string.IsNullOrWhiteSpace(ItemPackage.ShippingTime) ? DateTime.Now : DateTime.ParseExact(ItemPackage.ShippingTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture),
                                        EntityState      = EntityState.Added
                                    });
                                }
                                else
                                {
                                    EntityModel.ReceiveTime  = string.IsNullOrWhiteSpace(ItemPackage.ReceiveTime) ? DateTime.Now : DateTime.ParseExact(ItemPackage.ReceiveTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture);
                                    EntityModel.ShippingTime = string.IsNullOrWhiteSpace(ItemPackage.ShippingTime) ? DateTime.Now : DateTime.ParseExact(ItemPackage.ShippingTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture);
                                    EntityModel.EntityState  = EntityState.Modified;
                                    contextSession.SaveObject(EntityModel);
                                }
                            });
                            ItemPackage.OrderLogistics.ForEach(LogisticsItem =>
                            {
                                if (SNExpressTrace.ObjectSet().Where(w => w.OrderId == ItemPackage.OrderId && w.PackageId == ItemPackage.PackageId).FirstOrDefault() == null)
                                {
                                    contextSession.SaveObject(new SNExpressTrace
                                    {
                                        Id           = Guid.NewGuid(),
                                        OrderId      = ItemPackage.OrderId,
                                        PackageId    = ItemPackage.PackageId,
                                        OperateState = LogisticsItem.OperateState,
                                        OperateTime  = string.IsNullOrWhiteSpace(LogisticsItem.OperateTime) ? DateTime.Now : DateTime.ParseExact(LogisticsItem.OperateTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture),
                                        EntityState  = EntityState.Added
                                    });
                                }
                            });
                        });
                        //根据ID从消息池删除数据
                        if (contextSession.SaveChanges() >= 0)
                        {
                            //根据订单ID改订单状态
                            SuningSV.suning_govbus_rejection_changestatus(Item.status, EntityQuery);
                            SuningSV.suning_govbus_message_delete(Item.id);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(string.Format("Job-SuningChangeLogistStatus:{0}", ex));
                }
            });
            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contextSession"></param>
        /// <param name="order"></param>
        /// <param name="orderItem"></param>
        /// <param name="refund"></param>
        /// <param name="refundDTO"></param>
        /// <returns></returns>
        public static ResultDTO SNSubmitRefund(ContextSession contextSession, CommodityOrder order, OrderItem orderItem, OrderRefundAfterSales refund, SubmitOrderRefundDTO refundDTO)
        {
            //if (address == null)
            //{
            //    return new ResultDTO { isSuccess = false, Message = "取件地址不能为空。" };
            //}
            var snOrderItem = SNOrderItem.ObjectSet()
                              .Where(_ => _.OrderItemId == refundDTO.OrderItemId).FirstOrDefault();

            if (snOrderItem == null)
            {
                return(new ResultDTO {
                    isSuccess = false, ResultCode = 1, Message = "该订单不是苏宁订单。"
                });
            }
            SNReturnPartOrderDTO retDto = new SNReturnPartOrderDTO
            {
                OrderId  = snOrderItem.CustomOrderId,
                SkusList = new List <SNReturnPartOrderAddSkusDTO>()
                {
                    new SNReturnPartOrderAddSkusDTO()
                    {
                        SkuId = snOrderItem.CustomSkuId, Num = orderItem.Number.ToString()
                    }
                }
            };

            ResultDTO result = new ResultDTO {
                isSuccess = false, ResultCode = 1, Message = "退货失败"
            };
            SNFactoryDeliveryEnum fac = GetOrderFactoryDeliveryType(orderItem.CommodityOrderId, snOrderItem.CustomSkuId);

            if (fac == SNFactoryDeliveryEnum.NonFactoryDelivery)
            {
                result = SuningSV.ReturnPartOrder(retDto);;
                if (result.isSuccess)
                {
                    // 保存到 SNOrderRefundAfterSales
                    SNOrderRefundAfterSales snOrderRefundAfterSales = new SNOrderRefundAfterSales
                    {
                        Id         = Guid.NewGuid(),
                        SubTime    = DateTime.Now,
                        ModifiedOn = DateTime.Now,
                        AppId      = order.AppId,
                        OrderRefundAfterSalesId = refund.Id,
                        OrderId       = orderItem.CommodityOrderId,
                        OrderItemId   = orderItem.Id,
                        CustomOrderId = snOrderItem.CustomOrderId,
                        CommodityId   = orderItem.CommodityId,
                        CommodityNum  = orderItem.Number,
                        CustomSkuId   = snOrderItem.CustomSkuId,
                        Cancel        = 1,
                        //取件方式(必填 1 上门取件-非厂送-自营    2快递寄回-厂送 )
                        PickwareType = fac.GetHashCode(),

                        CustomerContactName = refundDTO.Address.customerContactName,
                        CustomerTel         = refundDTO.Address.customerTel,
                        PickwareAddress     = refundDTO.Address.ProviceCityStr + refundDTO.Address.pickwareAddress,
                        //暂时没用
                        AfsServiceId       = "",
                        AfsServiceStep     = 10,
                        AfsServiceStepName = "申请阶段",

                        EntityState = EntityState.Added
                    };

                    contextSession.SaveObject(snOrderRefundAfterSales);

                    UpdateApplyOrderStatus(contextSession, 3, orderItem.Id);
                }
                else
                {
                    UpdateApplyOrderStatus(contextSession, 4, orderItem.Id);
                    var log = new Deploy.JdlogsDTO
                    {
                        Id                 = Guid.NewGuid(),
                        SubTime            = DateTime.Now,
                        ThirdECommerceType = ThirdECommerceTypeEnum.SuNingYiGou.GetHashCode(),
                        Content            = "【苏宁售后】----【" + order.Code + "】中的" + orderItem.Name + "商品【" + snOrderItem.CustomSkuId + "】,提交售后申请失败,失败原因:【" + result.ResultCode + ":" + result.Message + "】"
                    };
                    JdlogsFacade facade = new JdlogsFacade();
                    facade.SaveJdlogs(log);
                }
            }
            else
            {
                // 保存到 SNOrderRefundAfterSales
                SNOrderRefundAfterSales snOrderRefundAfterSales = new SNOrderRefundAfterSales
                {
                    Id         = Guid.NewGuid(),
                    SubTime    = DateTime.Now,
                    ModifiedOn = DateTime.Now,
                    AppId      = order.AppId,
                    OrderRefundAfterSalesId = refund.Id,
                    OrderId       = orderItem.CommodityOrderId,
                    OrderItemId   = orderItem.Id,
                    CustomOrderId = snOrderItem.CustomOrderId,
                    CommodityId   = orderItem.CommodityId,
                    CommodityNum  = orderItem.Number,
                    CustomSkuId   = snOrderItem.CustomSkuId,
                    Cancel        = 1,
                    //取件方式(必填 1 上门取件-非厂送-自营    2快递寄回-厂送 )
                    PickwareType = fac.GetHashCode(),

                    CustomerContactName = refundDTO.Address.customerContactName,
                    CustomerTel         = refundDTO.Address.customerTel,
                    PickwareAddress     = refundDTO.Address.ProviceCityStr + refundDTO.Address.pickwareAddress,
                    //暂时没用
                    AfsServiceId       = "",
                    AfsServiceStep     = 10,
                    AfsServiceStepName = "申请阶段",

                    EntityState = EntityState.Added
                };

                contextSession.SaveObject(snOrderRefundAfterSales);

                UpdateApplyOrderStatus(contextSession, 3, orderItem.Id);
                result = new ResultDTO {
                    isSuccess = true, ResultCode = 0, Message = "退款申请成功"
                };
            }

            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取用户最新的所有订单的物流信息
        /// 查询前三条数据
        /// </summary>
        /// <param name="AppId"></param>
        /// <param name="Userid"></param>
        /// <returns></returns>
        public ResultDTO <ListResult <ComOrderExpressNew> > GetUserAllNewOrderExpressExt(Guid AppId, Guid Userid)
        {
            ListResult <ComOrderExpressNew> expressNews = new ListResult <ComOrderExpressNew>();

            expressNews.List = new List <ComOrderExpressNew>();
            ResultDTO <ListResult <ComOrderExpressNew> > result = new ResultDTO <ListResult <ComOrderExpressNew> >()
            {
                isSuccess  = false,
                ResultCode = 1,
                Data       = expressNews
            };
            string  json = string.Empty;
            JObject obj  = null;

            try
            {
                LogHelper.Info("【三条---京东】京东物流[开始调用]AppId=" + AppId + "  Userid=" + Userid + "");
                //获取已发货的订单信息
                //var comOrders = CommodityOrder.ObjectSet().Where(p => p.State == 2 && p.UserId == Userid && p.EsAppId == AppId).OrderByDescending(p => p.ModifiedOn).ToList();
                var comOrders = CommodityOrder.ObjectSet().Where(p => p.State != 0 && p.UserId == Userid && p.EsAppId == AppId).OrderByDescending(p => p.ModifiedOn).Take(3).ToList();
                LogHelper.Info("【三条---京东】京东物流comOrders-->[" + comOrders.Count() + "]");
                if (comOrders != null)
                {
                    List <ExpressTrace> expressList = null;
                    ComOrderExpressNew  expressNew  = null;
                    foreach (var order in comOrders.ToList())
                    {
                        expressList = new List <ExpressTrace>();
                        expressNew  = new ComOrderExpressNew();
                        var OrderItemInfo = OrderItem.ObjectSet().Where(p => p.CommodityOrderId == order.Id).FirstOrDefault();
                        expressNew.CommodityOrderId = order.Id;      //订单id
                        expressNew.Pic = OrderItemInfo.PicturesPath; //首条订单图片
                        //京东信息
                        var commodityOrderId = order.Id.ToString();
                        if (ThirdECommerceHelper.IsJingDongDaKeHu(order.AppId))
                        {
                            //var jdOrderitem = JdOrderItem.ObjectSet().FirstOrDefault(p => p.CommodityOrderId.Contains(commodityOrderId));
                            var query = JdOrderItem.ObjectSet().Where(p => p.CommodityOrderId.Contains(commodityOrderId));

                            //去重后的父单集合
                            var jdOrderList = query.Select(p => new { p.JdOrderId }).GroupBy(p => p.JdOrderId).ToList();

                            if (jdOrderList.Any())
                            {
                                jdOrderList.ForEach(p =>
                                {
                                    var jdwuliu = JdHelper.orderTrack(p.Key);

                                    LogHelper.Info("【三条---京东】京东物流====返回-->[" + jdwuliu + "]");
                                    if (jdwuliu != null)
                                    {
                                        JArray objson = JArray.Parse(jdwuliu);
                                        foreach (var item in objson)
                                        {
                                            ExpressTrace Express  = new ExpressTrace();
                                            Express.AcceptTime    = DateTime.Parse(item["msgTime"].ToString());
                                            Express.AcceptStation = item["content"].ToString().Trim();
                                            expressList.Add(Express);
                                        }
                                        AddExpressNewAll(expressNews, expressList, expressNew, "京东");
                                    }
                                });
                            }
                        }
                        else if (ThirdECommerceHelper.IsWangYiYanXuan(order.AppId))//网易严选或第三方电商
                        {
                            var orderItem = OrderItem.ObjectSet().FirstOrDefault(p => p.CommodityOrderId == order.Id);
                            var express   = ThirdECommerceHelper.GetOrderItemExpressTrace(order.AppId, orderItem.Id);
                            LogHelper.Info("【三条---严选】网易严选物流-->[" + JsonHelper.JsonSerializer(express) + "]");
                            if (express != null)
                            {
                                if (express.ExpressTraceList != null && express.ExpressTraceList.Count > 0)
                                {
                                    express.ExpressTraceList.ForEach(p =>
                                    {
                                        ExpressTrace Express  = new ExpressTrace();
                                        Express.AcceptTime    = p.Time == null ? DateTime.Now : DateTime.Parse(p.Time);
                                        Express.AcceptStation = p.Desc;
                                        expressList.Add(Express);
                                    });

                                    string name      = "严选";
                                    var    yxExpress = YXExpressTrace.ObjectSet().Where(p => p.OrderId == order.Id).FirstOrDefault();
                                    if (yxExpress != null)
                                    {
                                        name = yxExpress.ExpressCompany;
                                    }
                                    AddExpressNewAll(expressNews, expressList, expressNew, name);
                                }
                            }
                        }
                        else if (ThirdECommerceHelper.IsSuNingYiGou(order.AppId))//苏宁店铺
                        {
                            var snOrderitem = SNOrderItem.ObjectSet().FirstOrDefault(p => p.OrderId == order.Id);

                            SNExpressTraceFacade snExpress = new SNExpressTraceFacade();
                            var SuningWuliu = snExpress.GetExpressTrace(order.Id.ToString(), snOrderitem.OrderItemId.ToString());
                            LogHelper.Info("【三条---苏宁】苏宁物流[" + order.Id.ToString() + "," + snOrderitem.OrderItemId.ToString() + "]===返回-->[" + JsonHelper.JsonSerializer(SuningWuliu) + "]");
                            if (SuningWuliu != null)
                            {
                                SuningWuliu.ForEach(p =>
                                {
                                    ExpressTrace Express  = new ExpressTrace();
                                    Express.AcceptTime    = p.OperateTime == null ? DateTime.Now : p.OperateTime.Value;
                                    Express.AcceptStation = p.OperateState;
                                    expressList.Add(Express);
                                });
                                AddExpressNewAll(expressNews, expressList, expressNew, "苏宁");
                            }
                        }
                        else if (ThirdECommerceHelper.IsFangZheng(order.AppId))//方正店铺
                        {
                            var FangZhengWuliu = FangZhengSV.FangZheng_Logistics_InfoList(order.Id);
                            LogHelper.Info("【三条---方正】方正物流[" + commodityOrderId + "]===返回-->[" + JsonHelper.JsonSerializer(FangZhengWuliu) + "]");
                            if (FangZhengWuliu != null)
                            {
                                FangZhengWuliu.ExpressTraceList.ForEach(p =>
                                {
                                    ExpressTrace Express  = new ExpressTrace();
                                    Express.AcceptTime    = DateTime.Parse(p.Time);
                                    Express.AcceptStation = p.Desc;
                                    expressList.Add(Express);
                                });
                                AddExpressNewAll(expressNews, expressList, expressNew, "方正");
                            }
                        }
                        else
                        {
                            if (order.ExpOrderNo != null)
                            {
                                json = Express100SV.GetExpressFromKD100(order.ExpOrderNo, order.ShipExpCo);
                                obj  = JObject.Parse(json);
                                LogHelper.Info(string.Format("【三条---快递100】快递100:订单Id:{0},物流信息:{1}", order.Id, obj));
                                if (obj["message"].ToString().ToLower().Equals("ok"))
                                {
                                    JToken arr = obj["data"];
                                    foreach (var item in arr)
                                    {
                                        ExpressTrace Express = new ExpressTrace();
                                        Express.AcceptTime    = Convert.ToDateTime(item["ftime"].ToString());
                                        Express.AcceptStation = item["context"].ToString().Trim();
                                        expressList.Add(Express);
                                    }
                                    LogHelper.Info(string.Format("【三条---快递100】arr[{0}]--->expressList[{1}]", arr.Count(), expressList.Count));



                                    //快递单当前签收状态,包括0在途中、1已揽收、2疑难、3已签收、4退签、5同城派送中、6退回、7转单等7个状态,其中4-7需要另外开通才有效
                                    int deliverystatus = Convert.ToInt32(obj["state"].ToString());
                                    LogHelper.Info("【三条---快递100】deliverystatus-->[" + deliverystatus + "]");
                                    if (deliverystatus == 0)
                                    {
                                        expressNew.shipmentsTime = expressList.Min(p => p.AcceptTime);
                                        expressNew.state         = "已发货";
                                        expressNew.Remarked      = "您的订单已发货,由" + order.ShipExpCo + "快递配送,请注意物流信息~";
                                        expressNews.List.Add(expressNew);
                                    }
                                    else if (deliverystatus == 5)
                                    {
                                        expressNew.shipmentsTime = expressList.OrderByDescending(p => p.AcceptTime).FirstOrDefault().AcceptTime;
                                        expressNew.state         = "派件中";
                                        expressNew.Remarked      = "您的订单已开始派送,请保持电话畅通,确认商品外包装完好后签收~";
                                        expressNews.List.Add(expressNew);
                                    }
                                    else if (deliverystatus == 3)
                                    {
                                        expressNew.shipmentsTime = expressList.OrderByDescending(p => p.AcceptTime).FirstOrDefault().AcceptTime;
                                        expressNew.state         = "已签收";
                                        expressNew.Remarked      = "您的订单已签收";
                                        expressNews.List.Add(expressNew);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                    expressNews.Count = expressNews.List == null ? 0 : expressNews.List.Count();
                    if (expressNews.List.Any())
                    {
                        ListResult <ComOrderExpressNew> express = new ListResult <ComOrderExpressNew>();
                        express.List = new List <ComOrderExpressNew>();
                        express.List = expressNews.List.Take(3).ToList();
                        //取前三条
                        result.Data       = express;
                        result.isSuccess  = true;
                        result.ResultCode = 0;
                    }
                    else
                    {
                        result.Data       = expressNews;
                        result.isSuccess  = false;
                        result.ResultCode = 1;
                    }
                    LogHelper.Info(string.Format("获取用户最新的所有订单物流信息返回数据:{0}", JsonHelper.JsonSerializer(result)));
                    return(result);
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("获取用户最新的所有订单物流信息信息异常,异常信息:{0}", ex));
                return(result);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取用户最新的订单物流信息
        /// 查询第一条数据
        /// </summary>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.Commodity.ComOrderExpressNew> GetUserNewOrderExpressExt(System.Guid AppId, System.Guid Userid)
        {
            LogHelper.Info("【一条物流】====AppId-->[" + AppId + "]--->UserId=[" + Userid + "]");
            ComOrderExpressNew             ExpressNews = new ComOrderExpressNew();
            ResultDTO <ComOrderExpressNew> result      = new ResultDTO <ComOrderExpressNew>()
            {
                ResultCode = 1,
                isSuccess  = false,
                Data       = ExpressNews
            };
            string  json = null;
            JObject obj  = null;

            try
            {
                //获取已发货的订单信息
                var ComOrder = CommodityOrder.ObjectSet().Where(p => p.State == 2 && p.UserId == Userid && p.EsAppId == AppId).OrderByDescending(p => p.ModifiedOn).FirstOrDefault();

                if (ComOrder != null)
                {
                    List <ExpressTrace> ExpressList = new List <ExpressTrace>();
                    var OrderItemInfo = OrderItem.ObjectSet().Where(p => p.CommodityOrderId == ComOrder.Id).FirstOrDefault();
                    ExpressNews.CommodityOrderId = ComOrder.Id;   //订单id
                    ExpressNews.Pic = OrderItemInfo.PicturesPath; //首条订单图片
                    //京东信息
                    var commodityOrderId = ComOrder.Id;

                    /*
                     * var jdOrderitem = JdOrderItem.ObjectSet().FirstOrDefault(p => p.CommodityOrderId.Contains(commodityOrderId));
                     * LogHelper.Debug(string.Format("物流信息(订单信息),订单id{0}:", ComOrder.Id));
                     * //急速数据信息
                     * if (!string.IsNullOrWhiteSpace(ComOrder.ExpOrderNo) && jdOrderitem == null)
                     * {
                     *  //根据快递编号获取急速数据信息
                     *  json = GetWuliuJson(ComOrder.ExpOrderNo);
                     *  obj = JObject.Parse(json);
                     *  LogHelper.Info(string.Format("极速物流信息:订单Id:{0},物流信息:{1}", ComOrder.Id, obj));
                     *  if (Convert.ToInt32(obj["status"]) != 0)
                     *  {
                     *      return result;
                     *  }
                     *  JArray arr = (JArray)JsonConvert.DeserializeObject(obj["result"]["list"].ToString());
                     *  foreach (var item in arr)
                     *  {
                     *      ExpressTrace Express = new ExpressTrace();
                     *      Express.AcceptTime = Convert.ToDateTime(item["time"].ToString());
                     *      Express.AcceptStation = item["status"].ToString().Trim();
                     *      ExpressList.Add(Express);
                     *  }
                     *
                     *  if (Convert.ToInt32(obj["result"]["deliverystatus"]) == 1)
                     *  {
                     *      ExpressNews.shipmentsTime = ExpressList.Min(p => p.AcceptTime);
                     *      ExpressNews.state = "已发货";
                     *      ExpressNews.Remarked = "您的订单已发货,由" + ComOrder.ShipExpCo + "快递配送,请注意物流信息~";
                     *      result.ResultCode = 0;
                     *      result.isSuccess = true;
                     *  }
                     *  else if (Convert.ToInt32(obj["result"]["deliverystatus"]) == 2)
                     *  {
                     *      ExpressNews.shipmentsTime = ExpressList.OrderByDescending(p => p.AcceptTime).FirstOrDefault().AcceptTime;
                     *      ExpressNews.state = "派件中";
                     *      ExpressNews.Remarked = "您的订单已开始派送,请保持电话畅通,确认商品外包装完好后签收~";
                     *      result.ResultCode = 0;
                     *      result.isSuccess = true;
                     *  }
                     *  else
                     *  {
                     *      result.ResultCode = 1;
                     *      result.isSuccess = false;
                     *  }
                     * }
                     * else
                     * {
                     *  if (jdOrderitem != null)
                     *  {
                     *      var jdwuliu = JdHelper.orderTrack(jdOrderitem.JdOrderId);
                     *      if (jdwuliu != null)
                     *      {
                     *          JArray objson = JArray.Parse(jdwuliu);
                     *          foreach (var item in objson)
                     *          {
                     *              ExpressTrace Express = new ExpressTrace();
                     *              Express.AcceptTime = DateTime.Parse(item["msgTime"].ToString());
                     *              Express.AcceptStation = item["content"].ToString().Trim();
                     *              ExpressList.Add(Express);
                     *          }
                     *          var NewExpress = ExpressList.OrderByDescending(p => p.AcceptTime).FirstOrDefault();
                     *          if (NewExpress.AcceptStation.Contains("正在配送") || NewExpress.AcceptStation.Contains("自提"))
                     *          {
                     *              ExpressNews.shipmentsTime = NewExpress.AcceptTime;
                     *              ExpressNews.state = "派件中";
                     *              ExpressNews.Remarked = "您的订单已开始派送,请保持电话畅通,确认商品外包装完好后签收~";
                     *              result.ResultCode = 0;
                     *              result.isSuccess = true;
                     *          }
                     *          else if (NewExpress.AcceptStation.Contains("已签收"))
                     *          {
                     *              result.ResultCode = 1;
                     *              result.isSuccess = false;
                     *          }
                     *          else if (NewExpress.AcceptStation.Contains("出库") || NewExpress != null)
                     *          {
                     *              ExpressNews.shipmentsTime = ExpressList.Min(p => p.AcceptTime);
                     *              ExpressNews.state = "已发货";
                     *              ExpressNews.Remarked = "您的订单已发货,由京东快递配送,请注意物流信息~";
                     *              result.ResultCode = 0;
                     *              result.isSuccess = true;
                     *          }
                     *      }
                     *  }
                     * }*/



                    if (ThirdECommerceHelper.IsJingDongDaKeHu(ComOrder.AppId))
                    {
                        string orderId = commodityOrderId.ToString().ToLower();
                        LogHelper.Info("IsJingDongDaKeHu1--->" + orderId);



                        var jdOrderitem = JdOrderItem.ObjectSet().Where(p => p.CommodityOrderId.ToLower() == orderId).FirstOrDefault();
                        LogHelper.Info("IsJingDongDaKeHu2--->" + orderId);
                        if (jdOrderitem != null)
                        {
                            LogHelper.Info("IsJingDongDaKeHu3--->" + orderId);
                            var jdwuliu = JdHelper.orderTrack(jdOrderitem.JdOrderId);

                            LogHelper.Info("【一条---京东】京东物流[" + JsonHelper.JsonSerializer(jdOrderitem) + "]====返回-->[" + jdwuliu + "]");
                            if (jdwuliu != null)
                            {
                                JArray objson = JArray.Parse(jdwuliu);
                                foreach (var item in objson)
                                {
                                    ExpressTrace Express = new ExpressTrace();
                                    Express.AcceptTime    = DateTime.Parse(item["msgTime"].ToString());
                                    Express.AcceptStation = item["content"].ToString().Trim();
                                    ExpressList.Add(Express);
                                }
                                AddExpressNew(ExpressList, ExpressNews, result);
                            }
                        }
                    }
                    else if (ThirdECommerceHelper.IsWangYiYanXuan(ComOrder.AppId))//网易严选或第三方电商
                    {
                        var yxOrder = YXOrder.ObjectSet().FirstOrDefault(p => p.OrderId == commodityOrderId);
                        if (yxOrder != null)
                        {
                            var express = ThirdECommerceHelper.GetOrderItemExpressTrace(AppId, yxOrder.Id);

                            LogHelper.Info("【一条---严选】网易严选物流[" + JsonHelper.JsonSerializer(yxOrder) + "]===返回-->[" + JsonHelper.JsonSerializer(express) + "]");
                            if (express != null)
                            {
                                if (express.ExpressTraceList != null && express.ExpressTraceList.Count > 0)
                                {
                                    express.ExpressTraceList.ForEach(p =>
                                    {
                                        ExpressTrace Express  = new ExpressTrace();
                                        Express.AcceptTime    = p.Time == null ? DateTime.Now : DateTime.Parse(p.Time);
                                        Express.AcceptStation = p.Desc;
                                        ExpressList.Add(Express);
                                    });
                                    AddExpressNew(ExpressList, ExpressNews, result);
                                }
                            }
                        }
                    }
                    else if (ThirdECommerceHelper.IsSuNingYiGou(ComOrder.AppId))//苏宁店铺
                    {
                        var snOrderitem = SNOrderItem.ObjectSet().FirstOrDefault(p => p.OrderId == commodityOrderId);
                        if (snOrderitem != null)
                        {
                            SNExpressTraceFacade snExpress = new SNExpressTraceFacade();
                            var SuningWuliu = snExpress.GetExpressTrace(commodityOrderId.ToString(), snOrderitem.Id.ToString());

                            LogHelper.Info("【一条---苏宁】苏宁物流[" + JsonHelper.JsonSerializer(snOrderitem) + "]===返回-->[" + JsonHelper.JsonSerializer(SuningWuliu) + "]");
                            if (SuningWuliu != null)
                            {
                                SuningWuliu.ForEach(p =>
                                {
                                    ExpressTrace Express  = new ExpressTrace();
                                    Express.AcceptTime    = p.OperateTime == null ? DateTime.Now : p.OperateTime.Value;
                                    Express.AcceptStation = p.OperateState;
                                    ExpressList.Add(Express);
                                });
                                AddExpressNew(ExpressList, ExpressNews, result);
                            }
                        }
                    }
                    else if (ThirdECommerceHelper.IsFangZheng(ComOrder.AppId))//方正店铺
                    {
                        var FangZhengWuliu = FangZhengSV.FangZheng_Logistics_InfoList(commodityOrderId);
                        LogHelper.Info("【一条---方正】方正物流[" + commodityOrderId + "]===返回-->[" + JsonHelper.JsonSerializer(FangZhengWuliu) + "]");
                        if (FangZhengWuliu != null)
                        {
                            FangZhengWuliu.ExpressTraceList.ForEach(p =>
                            {
                                ExpressTrace Express  = new ExpressTrace();
                                Express.AcceptTime    = DateTime.Parse(p.Time);
                                Express.AcceptStation = p.Desc;
                                ExpressList.Add(Express);
                            });
                            AddExpressNew(ExpressList, ExpressNews, result);
                        }
                    }
                    else
                    {
                        json = Express100SV.GetExpressFromKD100(ComOrder.ExpOrderNo, ComOrder.ShipExpCo);
                        obj  = JObject.Parse(json);
                        LogHelper.Info(string.Format("【一条---快递100】快递100:订单Id:{0},物流信息:{1}", commodityOrderId, obj));
                        if (obj["message"].ToString().ToLower().Equals("ok"))
                        {
                            JArray arr = (JArray)JsonConvert.DeserializeObject(obj["data"].ToString());
                            foreach (var item in arr)
                            {
                                ExpressTrace Express = new ExpressTrace();
                                Express.AcceptTime    = Convert.ToDateTime(item["ftime"].ToString());
                                Express.AcceptStation = item["context"].ToString().Trim();

                                ExpressList.Add(Express);
                            }
                            //快递单当前签收状态,包括0在途中、1已揽收、2疑难、3已签收、4退签、5同城派送中、6退回、7转单等7个状态,其中4-7需要另外开通才有效
                            int deliverystatus = Convert.ToInt32(obj["state"].ToString());
                            if (deliverystatus == 0)
                            {
                                ExpressNews.shipmentsTime = ExpressList.Min(p => p.AcceptTime);
                                ExpressNews.state         = "已发货";
                                ExpressNews.Remarked      = "您的订单已发货,由" + ComOrder.ShipExpCo + "快递配送,请注意物流信息~";
                                result.ResultCode         = 0;
                                result.isSuccess          = true;
                            }
                            else if (deliverystatus == 5)
                            {
                                ExpressNews.shipmentsTime = ExpressList.OrderByDescending(p => p.AcceptTime).FirstOrDefault().AcceptTime;
                                ExpressNews.state         = "派件中";
                                ExpressNews.Remarked      = "您的订单已开始派送,请保持电话畅通,确认商品外包装完好后签收~";
                                result.ResultCode         = 0;
                                result.isSuccess          = true;
                            }
                            else if (deliverystatus == 3)
                            {
                                ExpressNews.shipmentsTime = ExpressList.OrderByDescending(p => p.AcceptTime).FirstOrDefault().AcceptTime;
                                ExpressNews.state         = "已签收";
                                ExpressNews.Remarked      = "您的订单已签收";
                                result.ResultCode         = 0;
                                result.isSuccess          = true;
                            }
                        }
                    }



                    result.Data = ExpressNews;
                    LogHelper.Info("Express100--->result[" + JsonHelper.JsonSerializer(result) + "]");
                    return(result);
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("获取用户最新的订单物流信息信息异常,异常信息:{0}", ex));
                return(result);
            }
        }