Exemplo n.º 1
0
 public ActionResult CanReturnGoods(string trackNumber, int reasonType)
 {
     try
     {
         _fubService.CanAddMailReturnGoodsLogs(trackNumber, reasonType);
         var wayBill = _wayBillInfoRepository.GetWayBillInfoExtSilm(trackNumber);
         return(Json(new
         {
             Result = true,
             TrackNumber = trackNumber,
             ReasonType = reasonType,
             Weight = wayBill.Weight,
             Country = GetGetCountryListFromCache().FirstOrDefault(p => p.CountryCode == wayBill.CountryCode).ChineseName,
             ReturnBy = _workContext.User.UserUame,
         }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = false, Message = ex.Message }));
     }
 }
Exemplo n.º 2
0
        public CheckOnWayBillResponseResult CheckOnWayBillCS(InStorageFormModel filter)
        {
            var model = new CheckOnWayBillResponseResult();
            var error = new StringBuilder();

            if (string.IsNullOrWhiteSpace(filter.CustomerCode))
            {
                model.Result  = false;
                model.Message = "客户为空!";
            }
            else
            {
                var NumberStr = string.Empty;
                if (!string.IsNullOrWhiteSpace(filter.WayBillNumber))
                {
                    NumberStr = filter.WayBillNumber.Trim();
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(filter.TrackingNumber))
                    {
                        NumberStr = filter.TrackingNumber.Trim();
                    }
                }
                if (string.IsNullOrWhiteSpace(NumberStr))
                {
                    model.Result  = false;
                    model.Message = "单号为空!";
                }
                else
                {
                    var waybillinfo = _wayBillInfoRepository.GetWayBillInfoExtSilm(NumberStr);

                    if (waybillinfo != null)
                    {
                        if (WayBill.StatusToValue(WayBill.StatusEnum.Submitted) != waybillinfo.Status)
                        {
                            error.AppendLine(string.Format("运单:{0}状态为{1}!<br/>", NumberStr, WayBill.GetStatusDescription(waybillinfo.Status)));
                        }
                        if (error.Length == 0 && waybillinfo.GoodsTypeID != filter.GoodsTypeID)
                        {
                            error.AppendLine(string.Format("运单:{0}货物类型不是一致", NumberStr));
                        }
                        if (error.Length == 0 && !string.IsNullOrWhiteSpace(filter.TrackingNumber))
                        {
                            var w = _wayBillInfoRepository.GetWayBillByTrackingNumber(filter.TrackingNumber.Trim());
                            if (w != null && w.WayBillNumber != waybillinfo.WayBillNumber)
                            {
                                error.AppendLine(string.Format("跟踪号:{0}系统已经存在", filter.TrackingNumber));
                            }
                        }
                        if (error.Length == 0 && waybillinfo.IsHold)
                        {
                            error.AppendLine(string.Format("运单:{0}已经Hold!<br/>", NumberStr));
                        }
                        if (error.Length == 0 && waybillinfo.InShippingMethodID.HasValue &&
                            waybillinfo.InShippingMethodID.Value != filter.ShippingMethodId)
                        {
                            error.AppendLine(string.Format("入仓运输方式与运单运输方式:{0}不一致!<br/>",
                                                           waybillinfo.InShippingMethodName));
                            //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber,
                            //WayBill.AbnormalTypeEnum.InAbnormal,
                            //string.Format("运单号:{0}国家或运输方式异常", waybillinfo.WayBillNumber));
                        }
                        if (error.Length == 0 && waybillinfo.CustomerCode.ToUpper() != filter.CustomerCode.ToUpper())
                        {
                            error.AppendLine(string.Format("入仓客户与运单客户:{0}不一致!<br/>", waybillinfo.CustomerCode));
                            //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber,
                            //                                 WayBill.AbnormalTypeEnum.InAbnormal,
                            //                                 string.Format("入仓客户与运单客户:{0}不一致", waybillinfo.CustomerCode));
                        }
                        if (error.Length > 0)
                        {
                            model.Result  = false;
                            model.Message = error.ToString();
                        }
                        else
                        {
                            var chineseName = GetGetCountryListFromCache().Find(p => p.CountryCode == waybillinfo.CountryCode).ChineseName;


                            //var areaIdList =
                            //    _freightService.GetCountryArea(filter.ShippingMethodId, waybillinfo.CountryCode)
                            //                   .FirstOrDefault();


                            var listShippingMethodCountryModel = GetShippingMethodCountriesFromCache(filter.ShippingMethodId);
                            var areaIdList = listShippingMethodCountryModel.Find(p => p.CountryCode == waybillinfo.CountryCode);

                            if (areaIdList != null)
                            {
                                model.Result  = true;
                                model.Message = chineseName + "(" + areaIdList.AreaId + "区)";
                            }
                            else
                            {
                                //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber,
                                //                                 WayBill.AbnormalTypeEnum.InAbnormal,
                                //                                 string.Format("该运输方式无法送达该目的地国家{0} ", chineseName));
                                model.Result  = false;
                                model.Message = string.Format("该运输方式无法送达该目的地国家{0} ", chineseName);
                            }
                        }
                        model.TrackingNumber = waybillinfo.TrackingNumber;

                        //返回运单的重量weight
                        model.ErrorWayBillNumber = waybillinfo.Weight.HasValue ? waybillinfo.Weight.ToString() : "0";

                        model.ShippingInfo = new ShippingInfoModel();

                        _wayBillInfoRepository.Get(waybillinfo.WayBillNumber).ShippingInfo.CopyTo(model.ShippingInfo);
                    }
                    else
                    {
                        NoForecastAbnormal noForecastAbnormal = new NoForecastAbnormal()
                        {
                            CustomerCode     = filter.CustomerCode,
                            Number           = NumberStr,
                            ShippingMethodId = filter.ShippingMethodId,
                            Weight           = filter.Weight,
                            CreatedOn        = DateTime.Now,
                            CreatedBy        = filter.OperatorUserName,
                            LastUpdatedOn    = DateTime.Now,
                            LastUpdatedBy    = filter.OperatorUserName,
                        };
                        _orderService.UpdateNoForecastAbnormal(noForecastAbnormal);

                        model.Result  = false;
                        model.Message = string.Format("单号:{0}无预报,不能扫描入仓!", NumberStr);
                    }
                }
            }
            return(model);
        }