示例#1
0
        /// <summary>
        /// 选择提货日期
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        protected override GetPickingDateRD ProcessRequest(APIRequest <GetPickingDateRP> pRequest)
        {
            var deliveryid = string.IsNullOrWhiteSpace(pRequest.Parameters.DeliveryId)
                ? "2"
                : pRequest.Parameters.DeliveryId;

            //基础数据初始化
            GetPickingDateRD           getPickingDateRD           = new GetPickingDateRD();
            CustomerTakeDeliveryBLL    customerTakeDeliveryBll    = new CustomerTakeDeliveryBLL(CurrentUserInfo);
            CustomerTakeDeliveryEntity customerTakeDeliveryEntity =
                customerTakeDeliveryBll.QueryByEntity(
                    new CustomerTakeDeliveryEntity()
            {
                DeliveryId = deliveryid, CustomerId = CurrentUserInfo.ClientID
            },
                    null).FirstOrDefault();
            SysTimeQuantumBLL    sysTimeQuantumBll    = new SysTimeQuantumBLL(CurrentUserInfo);
            SysTimeQuantumEntity sysTimeQuantumEntity =
                sysTimeQuantumBll.QueryByEntity(
                    new SysTimeQuantumEntity()
            {
                DeliveryId = deliveryid, CustomerID = CurrentUserInfo.ClientID
            },
                    new OrderBy[] { new OrderBy()
                                    {
                                        FieldName = "Quantum", Direction = OrderByDirections.Desc
                                    } })
                .FirstOrDefault();

            if (deliveryid == "2")
            {
                int?stockUpPeriod = customerTakeDeliveryEntity.StockUpPeriod == null
                    ? 0
                    : customerTakeDeliveryEntity.StockUpPeriod;
                int?maxDelivery = customerTakeDeliveryEntity.MaxDelivery == null
                    ? 0
                    : customerTakeDeliveryEntity.MaxDelivery;

                if (sysTimeQuantumEntity == null)
                {
                    getPickingDateRD.BeginDate =
                        DateTime.Now.AddHours(Convert.ToDouble(stockUpPeriod)).ToString("yyyy-MM-dd");
                    getPickingDateRD.IsDisplay = 1; //显示日期
                }
                else
                {
                    string[] timeTemp  = sysTimeQuantumEntity.Quantum.Split('-');
                    string   beginTime = DateTime.Now.AddHours(Convert.ToDouble(stockUpPeriod)).ToString("HH:mm");
                    getPickingDateRD.IsDisplay = 2; //都显示
                    //如果在备货完的结束日期没有时间段可以选择,则后一天为允许选择的开始时间
                    if (beginTime.CompareTo(timeTemp[0]) < 0)
                    {
                        getPickingDateRD.BeginDate =
                            DateTime.Now.AddHours(Convert.ToDouble(stockUpPeriod)).ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        getPickingDateRD.BeginDate =
                            DateTime.Now.AddHours(Convert.ToDouble(stockUpPeriod)).AddDays(1).ToString("yyyy-MM-dd");
                    }
                }

                if (maxDelivery == 0 && sysTimeQuantumEntity == null)
                {
                    getPickingDateRD.IsDisplay = 0; //都不显示
                }

                int?addMaxDelivery = maxDelivery == 0 ? 0 : customerTakeDeliveryEntity.MaxDelivery - 1;
                getPickingDateRD.EndDate =
                    Convert.ToDateTime(getPickingDateRD.BeginDate)
                    .AddDays(Convert.ToDouble(addMaxDelivery))
                    .ToString("yyyy-MM-dd");

                return(getPickingDateRD);
            }
            else if (deliveryid == "4")
            {
                var stockUpPeriod = customerTakeDeliveryEntity.StockUpPeriod == null
                    ? 0
                    : customerTakeDeliveryEntity.StockUpPeriod;                                              //需要提前多少天预约
                var deliveryServiceConfigDay = ConfigurationManager.AppSettings["DeliveryServiceConfigDay"]; //服时间为最近的7天

                DateTime today = DateTime.Now;

                DateTime beginDateTime =
                    today.AddHours(Convert.ToDouble(stockUpPeriod));

                DateTime endDate =
                    beginDateTime.AddHours(Convert.ToDouble(stockUpPeriod));

                getPickingDateRD.BeginDate = beginDateTime.ToString("yyyy-MM-dd");
                getPickingDateRD.EndDate   = endDate.ToString("yyyy-MM-dd");
                getPickingDateRD.IsDisplay = 2; //都显示
                return(getPickingDateRD);
            }
            else
            {
                return(getPickingDateRD);
            }
        }
        /// <summary>
        /// 提货时间段
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        protected override GetPickingQuantumRD ProcessRequest(APIRequest <GetPickingQuantumRP> pRequest)
        {
            GetPickingQuantumRP getPickingQuantunRP = pRequest.Parameters;
            GetPickingQuantumRD getPickingQuantunRD = new GetPickingQuantumRD();

            CustomerTakeDeliveryBLL    customerTakeDeliveryBll    = new CustomerTakeDeliveryBLL(CurrentUserInfo);
            CustomerTakeDeliveryEntity customerTakeDeliveryEntity =
                customerTakeDeliveryBll.QueryByEntity(
                    new CustomerTakeDeliveryEntity()
            {
                DeliveryId = getPickingQuantunRP.DeliveryId,
                CustomerId = CurrentUserInfo.ClientID
            }, null).FirstOrDefault();
            SysTimeQuantumBLL sysTimeQuantumBll = new SysTimeQuantumBLL(CurrentUserInfo);

            SysTimeQuantumEntity[] sysTimeQuantumEntity =
                sysTimeQuantumBll.QueryByEntity(
                    new SysTimeQuantumEntity()
            {
                DeliveryId = getPickingQuantunRP.DeliveryId,
                CustomerID = CurrentUserInfo.ClientID
            },
                    new OrderBy[] { new OrderBy()
                                    {
                                        FieldName = "Quantum", Direction = OrderByDirections.Asc
                                    } });
            if (getPickingQuantunRP.DeliveryId == "2")
            {
                string beginDate   = DateTime.Now.Date.ToString("yyyy-MM-dd");
                string pickingDate = "";
                getPickingQuantunRD.QuantumList = new List <QuantumInfo>();

                if (sysTimeQuantumEntity.Length == 0)
                {
                    return(getPickingQuantunRD);
                }
                if (!string.IsNullOrEmpty(getPickingQuantunRP.BeginDate))
                {
                    beginDate = Convert.ToDateTime(getPickingQuantunRP.BeginDate).ToString("yyyy-MM-dd");
                }
                if (!string.IsNullOrEmpty(getPickingQuantunRP.PickingDate))
                {
                    pickingDate = Convert.ToDateTime(getPickingQuantunRP.PickingDate).ToString("yyyy-MM-dd");
                }
                else
                {
                    return(getPickingQuantunRD);
                }

                List <QuantumInfo> list = new List <QuantumInfo>();
                //判断选择的是否为开始日期
                if (beginDate.Equals(pickingDate))
                {
                    string date =
                        DateTime.Now.AddHours(Convert.ToDouble(customerTakeDeliveryEntity.StockUpPeriod))
                        .ToString("yyyy-MM-dd");
                    //如果允许选择的开始日期是备货结束的日期的后一天,则时间段全部可以选择
                    if (date.CompareTo(beginDate) < 0)
                    {
                        for (int i = 0; i < sysTimeQuantumEntity.Length; i++)
                        {
                            QuantumInfo quantumInfo = new QuantumInfo()
                            {
                                Quantum = sysTimeQuantumEntity[i].Quantum
                            };
                            list.Add(quantumInfo);
                        }
                    }
                    else
                    {
                        string beginTime =
                            DateTime.Now.AddHours(Convert.ToDouble(customerTakeDeliveryEntity.StockUpPeriod))
                            .ToString("HH:mm");
                        for (int i = 0; i < sysTimeQuantumEntity.Length; i++)
                        {
                            string time = sysTimeQuantumEntity[i].Quantum.Split('-')[0];
                            if (time.CompareTo(beginTime) >= 1)
                            {
                                QuantumInfo quantumInfo = new QuantumInfo()
                                {
                                    Quantum = sysTimeQuantumEntity[i].Quantum
                                };
                                list.Add(quantumInfo);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < sysTimeQuantumEntity.Length; i++)
                    {
                        QuantumInfo quantumInfo = new QuantumInfo()
                        {
                            Quantum = sysTimeQuantumEntity[i].Quantum
                        };
                        list.Add(quantumInfo);
                    }
                }
                getPickingQuantunRD.QuantumList = list;

                return(getPickingQuantunRD);
            }
            else if (getPickingQuantunRP.DeliveryId == "4")
            {
                string beginDate   = DateTime.Now.Date.ToString("yyyy-MM-dd");
                string pickingDate = "";
                getPickingQuantunRD.QuantumList = new List <QuantumInfo>();

                if (sysTimeQuantumEntity.Length == 0)
                {
                    return(getPickingQuantunRD);
                }
                if (!string.IsNullOrEmpty(getPickingQuantunRP.BeginDate))
                {
                    beginDate = Convert.ToDateTime(getPickingQuantunRP.BeginDate).ToString("yyyy-MM-dd");
                }
                if (!string.IsNullOrEmpty(getPickingQuantunRP.PickingDate))
                {
                    pickingDate = Convert.ToDateTime(getPickingQuantunRP.PickingDate).ToString("yyyy-MM-dd");
                }
                else
                {
                    return(getPickingQuantunRD);
                }

                List <QuantumInfo> list = new List <QuantumInfo>();
                for (int i = 0; i < sysTimeQuantumEntity.Length; i++)
                {
                    QuantumInfo quantumInfo = new QuantumInfo()
                    {
                        Quantum = sysTimeQuantumEntity[i].Quantum
                    };
                    list.Add(quantumInfo);
                }

                getPickingQuantunRD.QuantumList = list;

                return(getPickingQuantunRD);
            }
            else
            {
                return(getPickingQuantunRD);
            }
        }
        /// <summary>
        /// 保存配送信息
        /// </summary>
        private string SaveDelivery(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <DeliveryInfoRp> >();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            if (string.IsNullOrWhiteSpace(rp.Parameters.DeliveryId) ||
                (rp.Parameters.DeliveryId != "1" && rp.Parameters.DeliveryId != "2" && rp.Parameters.DeliveryId != "4"))
            {
                throw new APIException("请求参数中缺少DeliveryId或值为空.")
                      {
                          ErrorCode = 121
                      };
            }

            if (loggingSessionInfo == null)
            {
                throw new APIException("请重新登录")
                      {
                          ErrorCode = 122
                      };
            }

            if (rp.Parameters.DeliveryId == "1")
            //保存送货到家信息
            {
                CustomerDeliveryStrategyBLL deliveryStrategyBLL = new CustomerDeliveryStrategyBLL(loggingSessionInfo);
                CustomerBasicSettingBLL     basicSettingBLL     = new CustomerBasicSettingBLL(loggingSessionInfo);

                //if (rp.Parameters.AmountEnd<=0)
                //{
                //    throw new APIException("请求参数中AmountEnd值为空,或者不正确") { ErrorCode = 123 };
                //}
                //if (rp.Parameters.DeliveryAmount<=0)
                //{
                //    throw new APIException("请求参数中DeliveryAmount值为空,或者不正确") { ErrorCode = 124 };
                //}
                if (rp.Parameters.Status != 0 && rp.Parameters.Status != 1)
                {
                    throw new APIException("请求参数中Status值为空,或者不正确")
                          {
                              ErrorCode = 125
                          };
                }
                if (string.IsNullOrWhiteSpace(rp.Parameters.Description))
                {
                    throw new APIException("请求参数中Description值为空,或者不正确")
                          {
                              ErrorCode = 126
                          };
                }

                //要保存的送货到家信息
                CustomerDeliveryStrategyEntity DeliveryStrategyEntity = new CustomerDeliveryStrategyEntity()
                {
                    CustomerId     = loggingSessionInfo.ClientID,
                    AmountBegin    = 0m,
                    AmountEnd      = rp.Parameters.AmountEnd,
                    DeliveryAmount = rp.Parameters.DeliveryAmount,
                    Status         = rp.Parameters.Status,
                    DeliveryId     = "1"
                };

                if (!string.IsNullOrWhiteSpace(rp.Parameters.DeliveryStrategyId))
                {
                    DeliveryStrategyEntity.Id = new Guid(rp.Parameters.DeliveryStrategyId);
                }

                //要保存的基数设置(描述)信息
                CustomerBasicSettingEntity BasicSettingEntity = new CustomerBasicSettingEntity()
                {
                    CustomerID   = loggingSessionInfo.ClientID,
                    SettingCode  = "DeliveryStrategy",
                    SettingValue = rp.Parameters.Description
                };

                if (!string.IsNullOrWhiteSpace(rp.Parameters.SettingId))
                {
                    BasicSettingEntity.SettingID = new Guid(rp.Parameters.SettingId);
                }

                deliveryStrategyBLL.SaveDeliveryStrategyAndBasicSetting(DeliveryStrategyEntity, BasicSettingEntity, loggingSessionInfo, rp.Parameters.DeliveryId);
            }

            if (rp.Parameters.DeliveryId == "2" || rp.Parameters.DeliveryId == "4")
            //保存到店提货信息
            {
                //if (rp.Parameters.StockUpPeriod<=0)
                //{
                //    throw new APIException("请求参数中StockUpPeriod值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.BeginWorkTime==null)
                //{
                //     throw new APIException("请求参数中BeginWorkTime值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.EndWorkTime==null)
                //{
                //    throw new APIException("请求参数中EndWorkTime值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.MaxDelivery <= 0)
                //{
                //    throw new APIException("请求参数中MaxDelivery值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.Status!=1&&rp.Parameters.Status!=0)
                //{
                //    throw new APIException("请求参数中Status值为空,或者不正确") { ErrorCode = 127 };
                //}

                CustomerTakeDeliveryEntity takeDeliveryEntity = new CustomerTakeDeliveryEntity()
                {
                    CustomerId    = loggingSessionInfo.ClientID,
                    StockUpPeriod = rp.Parameters.StockUpPeriod,
                    BeginWorkTime = rp.Parameters.BeginWorkTime,
                    EndWorkTime   = rp.Parameters.EndWorkTime,
                    MaxDelivery   = rp.Parameters.MaxDelivery,
                    Status        = rp.Parameters.Status,
                    DeliveryId    = rp.Parameters.DeliveryId
                };

                #region 配送时间段

                SysTimeQuantumBLL      sysTimeQuantumBll         = new SysTimeQuantumBLL(loggingSessionInfo);
                SysTimeQuantumEntity[] sysTimeQuantumEntityArray = sysTimeQuantumBll.QueryByEntity(new SysTimeQuantumEntity()
                {
                    CustomerID = loggingSessionInfo.ClientID
                }, null);

                if (rp.Parameters.QuantumList.Count != 0)
                {
                    for (int i = 0; i < sysTimeQuantumEntityArray.Length; i++)
                    {
                        if (i < rp.Parameters.QuantumList.Count)
                        {
                            sysTimeQuantumEntityArray[i].Quantum = rp.Parameters.QuantumList[i].Quantum;
                            sysTimeQuantumBll.Update(sysTimeQuantumEntityArray[i]);
                        }
                        else
                        {
                            sysTimeQuantumBll.Delete(sysTimeQuantumEntityArray[i]);
                        }
                    }
                    if (sysTimeQuantumEntityArray.Length < rp.Parameters.QuantumList.Count)
                    {
                        for (int i = sysTimeQuantumEntityArray.Length; i < rp.Parameters.QuantumList.Count; i++)
                        {
                            SysTimeQuantumEntity sysTimeQuantumEntity = new SysTimeQuantumEntity()
                            {
                                QuantumID  = Guid.NewGuid().ToString(),
                                Quantum    = rp.Parameters.QuantumList[i].Quantum,
                                Type       = 10,
                                CustomerID = loggingSessionInfo.ClientID,
                                DeliveryId = rp.Parameters.DeliveryId
                            };
                            sysTimeQuantumBll.Create(sysTimeQuantumEntity);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < sysTimeQuantumEntityArray.Length; i++)
                    {
                        sysTimeQuantumBll.Delete(sysTimeQuantumEntityArray[i]);
                    }
                }
                #endregion

                if (!string.IsNullOrWhiteSpace(rp.Parameters.TakeDeliveryId))
                {
                    takeDeliveryEntity.Id = new Guid(rp.Parameters.TakeDeliveryId);
                }

                //查询提货配置信息
                CustomerTakeDeliveryBLL takeDeliveryBLL = new CustomerTakeDeliveryBLL(loggingSessionInfo);
                takeDeliveryBLL.SaveCustomerTakeDelivery(takeDeliveryEntity, loggingSessionInfo, rp.Parameters.DeliveryId);
            }

            var rsp = new SuccessResponse <IAPIResponseData>(new EmptyResponseData());
            return(rsp.ToJSON());
        }
        protected override GetOrderDeliveryDateTimeRangeRD ProcessRequest(
            APIRequest <GetOrderDeliveryDateTimeRangeRP> pRequest)
        {
            var rd = new GetOrderDeliveryDateTimeRangeRD();

            var deliveryid = string.IsNullOrWhiteSpace(pRequest.Parameters.DeliveryId)
                ? "2"
                : pRequest.Parameters.DeliveryId;

            //基础数据初始化
            GetPickingDateRD getPickingDateRD   = new GetPickingDateRD();
            var getOrderDeliveryDateTimeRangeRD = new GetOrderDeliveryDateTimeRangeRD();
            CustomerTakeDeliveryBLL    customerTakeDeliveryBll    = new CustomerTakeDeliveryBLL(CurrentUserInfo);
            CustomerTakeDeliveryEntity customerTakeDeliveryEntity =
                customerTakeDeliveryBll.QueryByEntity(
                    new CustomerTakeDeliveryEntity()
            {
                DeliveryId = deliveryid, CustomerId = CurrentUserInfo.ClientID
            },
                    null).FirstOrDefault();
            SysTimeQuantumBLL sysTimeQuantumBll = new SysTimeQuantumBLL(CurrentUserInfo);
            var sysTimeQuantumEntityList        =
                sysTimeQuantumBll.QueryByEntity(
                    new SysTimeQuantumEntity()
            {
                DeliveryId = deliveryid, CustomerID = CurrentUserInfo.ClientID
            },
                    new OrderBy[] { new OrderBy()
                                    {
                                        FieldName = "Quantum", Direction = OrderByDirections.Asc
                                    } });

            var beginDateTime = DateTime.MinValue;
            var endDateTime   = DateTime.MinValue;

            var now = DateTime.Now;


            List <DateTimeInfo> dateTimeInfos = new List <DateTimeInfo>();

            int?stockUpPeriod = customerTakeDeliveryEntity.StockUpPeriod == null
                ? 0
                : customerTakeDeliveryEntity.StockUpPeriod;
            int?maxDelivery = customerTakeDeliveryEntity.MaxDelivery == null
                ? 0
                : customerTakeDeliveryEntity.MaxDelivery;

            if (deliveryid == "2")
            {
                if (sysTimeQuantumEntityList.Length == 0)
                {
                    beginDateTime = now.AddHours(Convert.ToDouble(stockUpPeriod));
                }
                else
                {
                    string[] timeTemp  = sysTimeQuantumEntityList[0].Quantum.Split('-');
                    string   beginTime = now.AddHours(Convert.ToDouble(stockUpPeriod)).ToString("HH:mm");
                    //如果在备货完的结束日期没有时间段可以选择,则后一天为允许选择的开始时间
                    if (beginTime.CompareTo(timeTemp[0]) < 0)
                    {
                        beginDateTime =
                            now.AddHours(Convert.ToDouble(stockUpPeriod));
                    }
                    else
                    {
                        beginDateTime =
                            now.AddHours(Convert.ToDouble(stockUpPeriod)).AddDays(1);
                    }
                }

                int?addMaxDelivery = maxDelivery == 0 ? 0 : customerTakeDeliveryEntity.MaxDelivery - 1;
                endDateTime = beginDateTime.AddDays(Convert.ToDouble(addMaxDelivery));
            }
            else if (deliveryid == "4")
            {
                if (sysTimeQuantumEntityList.Length == 0)
                {
                    beginDateTime = now.AddDays(Convert.ToDouble(stockUpPeriod));
                }
                else
                {
                    string[] timeTemp  = sysTimeQuantumEntityList[0].Quantum.Split('-');
                    string   beginTime = now.ToString("HH:mm");
                    //如果在备货完的结束日期没有时间段可以选择,则后一天为允许选择的开始时间
                    if (beginTime.CompareTo(timeTemp[1]) > 0)
                    {
                        beginDateTime =
                            now.AddDays(Convert.ToDouble(stockUpPeriod));
                    }
                    else
                    {
                        beginDateTime =
                            now.AddDays(Convert.ToDouble(stockUpPeriod)).AddDays(1);
                    }
                }

                var deliveryServiceConfigDay = "7";//ConfigurationManager.AppSettings["DeliveryServiceConfigDay"]; //服时间为最近的7天

                endDateTime = beginDateTime
                              .AddDays(int.Parse(deliveryServiceConfigDay));
            }

            for (var i = beginDateTime; i <= endDateTime; i = i.AddDays(1))
            {
                List <string> timeRange = new List <string>();

                foreach (var entity in sysTimeQuantumEntityList)
                {
                    string[] timeTemp  = entity.Quantum.Split('-');
                    string   beginTime = string.Empty;
                    if (deliveryid == "2")
                    {
                        beginTime = now.AddHours(Convert.ToDouble(stockUpPeriod)).ToString("HH:mm");
                    }
                    else if (deliveryid == "4")
                    {
                        beginTime = now.AddDays(Convert.ToDouble(stockUpPeriod)).ToString("HH:mm");
                    }

                    if (i == beginDateTime)
                    {
                        //if (beginTime.CompareTo(timeTemp[0]) < 0)
                        //{
                        timeRange.Add(entity.Quantum);
                        //}
                    }
                    else
                    {
                        timeRange.Add(entity.Quantum);
                    }

                    //如果在备货完的结束日期没有时间段可以选择,则后一天为允许选择的开始时间
                    //if (beginTime.CompareTo(timeTemp[0]) < 0)
                    //}
                }



                var dateTimeInfo = new DateTimeInfo
                {
                    dataRange = i.ToString("yyyy-MM-dd"),
                    timeRange = timeRange.ToArray()
                };
                dateTimeInfos.Add(dateTimeInfo);
            }

            rd.DateRange = dateTimeInfos.ToArray();


            return(rd);
        }
        /// <summary>
        /// 获取配送信息
        /// </summary>
        private string GetDeliveryDetail(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <DeliveryInfoRp> >();

            if (string.IsNullOrWhiteSpace(rp.Parameters.DeliveryId))
            {
                throw new APIException("请求参数中缺少DeliveryId或值为空.")
                      {
                          ErrorCode = 121
                      };
            }

            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            //配送信息
            DeliveryInfo DeliveryInfo = new DeliveryInfo();

            //TO DO 查询配送方式信息
            if (rp.Parameters.DeliveryId == "1")
            //送货到家信息
            {
                //查询商户配送策略表
                CustomerDeliveryStrategyBLL deliveryStrategyBLL = new CustomerDeliveryStrategyBLL(loggingSessionInfo);
                var deliveryStrategy = deliveryStrategyBLL.QueryByEntity(
                    new CustomerDeliveryStrategyEntity
                {
                    CustomerId = loggingSessionInfo.ClientID,
                    DeliveryId = rp.Parameters.DeliveryId
                },
                    null
                    ).FirstOrDefault();

                //查询商户基数设置
                CustomerBasicSettingBLL basicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);
                var basicSetting = basicSettingBLL.QueryByEntity(
                    new CustomerBasicSettingEntity
                {
                    SettingCode = "DeliveryStrategy",
                    CustomerID  = loggingSessionInfo.ClientID
                },
                    null
                    ).FirstOrDefault();

                //组织配送信息

                if (deliveryStrategy != null)
                {
                    DeliveryInfo.DeliveryStrategyId = deliveryStrategy.Id.ToString();  //配送策略id
                    DeliveryInfo.Status             = deliveryStrategy.Status;         //是否启用  1启用 0停用
                    DeliveryInfo.DeliveryAmount     = deliveryStrategy.DeliveryAmount; //默认配送费用
                    DeliveryInfo.AmountEnd          = deliveryStrategy.AmountEnd;      //免配送费最低订单金额
                }
                else
                {
                    DeliveryInfo.Status = 0;
                }

                if (basicSetting != null)
                {
                    DeliveryInfo.SettingId   = basicSetting.SettingID.ToString(); //商户基础设置
                    DeliveryInfo.Description = basicSetting.SettingValue;         //描述
                }
            }
            else if (rp.Parameters.DeliveryId == "2" || rp.Parameters.DeliveryId == "4")
            //到点提货信息
            {
                //查询提货配置信息
                CustomerTakeDeliveryBLL takeDeliveryBLL = new CustomerTakeDeliveryBLL(loggingSessionInfo);
                var takeDelivery = takeDeliveryBLL.QueryByEntity(
                    new CustomerTakeDeliveryEntity()
                {
                    DeliveryId = rp.Parameters.DeliveryId,
                    CustomerId = loggingSessionInfo.ClientID
                }, null
                    ).FirstOrDefault();


                DeliveryInfo.DeliveryAmount = 0;
                DeliveryInfo.AmountEnd      = 0;

                if (takeDelivery != null)
                {
                    DeliveryInfo.TakeDeliveryId = takeDelivery.Id.ToString();
                    DeliveryInfo.StockUpPeriod  = takeDelivery.StockUpPeriod;
                    DeliveryInfo.BeginWorkTime  = takeDelivery.BeginWorkTime;
                    DeliveryInfo.EndWorkTime    = takeDelivery.EndWorkTime;
                    DeliveryInfo.MaxDelivery    = takeDelivery.MaxDelivery;
                    DeliveryInfo.Status         = takeDelivery.Status;
                }
                else
                {
                    DeliveryInfo.Status = 0;
                }
                SysTimeQuantumBLL      sysTimeQuantumBll         = new SysTimeQuantumBLL(loggingSessionInfo);
                SysTimeQuantumEntity[] sysTimeQuantumEntityArray =
                    sysTimeQuantumBll.QueryByEntity(
                        new SysTimeQuantumEntity()
                {
                    DeliveryId = rp.Parameters.DeliveryId,
                    CustomerID = loggingSessionInfo.ClientID
                },
                        new OrderBy[] { new OrderBy()
                                        {
                                            FieldName = "Quantum", Direction = OrderByDirections.Asc
                                        } });
                DeliveryInfo.QuantumList = new List <QuantumInfo>();

                if (sysTimeQuantumEntityArray.Length != 0)
                {
                    for (int i = 0; i < sysTimeQuantumEntityArray.Length; i++)
                    {
                        QuantumInfo quantum = new QuantumInfo();
                        quantum.Quantum = sysTimeQuantumEntityArray[i].Quantum;
                        DeliveryInfo.QuantumList.Add(quantum);
                    }
                }
            }
            else
            {
                throw new APIException("DeliveryId不存在.")
                      {
                          ErrorCode = 121
                      };
            }

            var rd = new DeliveryInfoRD
            {
                DeliveryInfo = DeliveryInfo
            };

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }