/// <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="pEntity">实体实例</param> public void Create(SysTimeQuantumEntity pEntity) { _currentDAO.Create(pEntity); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(SysTimeQuantumEntity pEntity, IDbTransaction pTran) { _currentDAO.Update(pEntity, pTran); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <SysTimeQuantumEntity> PagedQueryByEntity(SysTimeQuantumEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex) { return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex)); }
/// <summary> /// 根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public SysTimeQuantumEntity[] QueryByEntity(SysTimeQuantumEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(SysTimeQuantumEntity pEntity) { _currentDAO.Delete(pEntity); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> public void Update(SysTimeQuantumEntity pEntity) { _currentDAO.Update(pEntity); }
/// <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()); }