Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="accountID">账户id</param>
        /// <param name="provinceArray">省市区数组["北京","北京","朝阳"]</param>
        /// <param name="addressDetail">详细地址</param>
        /// <param name="orderLocationPhone">收件联系方式</param>
        /// <param name="orderLocationPersonName">收件人姓名</param>
        /// <returns></returns>
        public string SetAddress(string accountID, string provinceArray, string addressDetail, string orderLocationPhone, string orderLocationPersonName)
        {
            BaseResponseModel <AccountModel> responseModel = new BaseResponseModel <AccountModel>();

            if (string.IsNullOrEmpty(accountID) || string.IsNullOrEmpty(provinceArray) || string.IsNullOrEmpty(addressDetail))
            {
                responseModel.StatusCode = (int)ActionParams.code_error_null;
                return(JsonConvert.SerializeObject(responseModel));
            }
            responseModel.StatusCode = (int)ActionParams.code_ok;

            try
            {
                string[] pca     = JsonConvert.DeserializeObject <string[]>(provinceArray);
                var      address = new OrderLocation()
                {
                    ProvinceCityArea = pca, AddressDetail = addressDetail, OrderLocationPersonName = orderLocationPersonName, OrderLocationPhone = orderLocationPhone
                };
                var filter = Builders <AccountModel> .Filter.Eq(x => x.AccountID, new ObjectId(accountID));

                var update = Builders <AccountModel> .Update.Set(x => x.OrderLocation, address);

                new MongoDBTool().GetMongoCollection <AccountModel>().UpdateOne(filter, update);
            }
            catch (Exception)
            {
                responseModel.StatusCode = (int)ActionParams.code_error;
                throw;
            }
            return(JsonConvert.SerializeObject(responseModel));
        }
Example #2
0
        public static OrderLocationModel ToHydratedModel(this OrderLocation anOrderLocationEntity)
        {
            var result = anOrderLocationEntity.ToModel();

            result.Container    = anOrderLocationEntity.Container.ToModel();
            result.ShopLocation = anOrderLocationEntity.Location.ToModel();

            return(result);
        }
Example #3
0
 public static OrderLocationModel ToModel(this OrderLocation anOrderLocationEntity)
 {
     return(new OrderLocationModel()
     {
         OrderId = anOrderLocationEntity.OrderId,
         OrderLine = anOrderLocationEntity.OrderLine,
         LocationId = anOrderLocationEntity.LocationId,
         ContainerId = anOrderLocationEntity.ContainerId
     });
 }
        /// <summary>
        /// 保存或者修改订单地址
        /// </summary>
        /// <param name="accountID">账户ID</param>
        /// <param name="orderLocation">订单地址对象</param>
        internal void SaveOrderLocation(string accountID, OrderLocation orderLocation)
        {
            UpdateDefinition <AccountModel> update = null;
            FilterDefinition <AccountModel> filter = Builders <AccountModel> .Filter.Eq(x => x.AccountID, new ObjectId(accountID));

            var account = collection.Find(filter).FirstOrDefault();

            ///数据库空收件地址列表处理
            if (account.OrderLocations == null)
            {
                collection.UpdateOne(x => x.AccountID.Equals(new ObjectId(accountID)), Builders <AccountModel> .Update.Set(x => x.OrderLocations, new List <OrderLocation>()));
            }
            ///清空默认收件地址
            if (orderLocation.IsDefault)
            {
                foreach (var item in account.OrderLocations)
                {
                    filter = Builders <AccountModel> .Filter.Eq(x => x.AccountID, new ObjectId(accountID))
                             & Builders <AccountModel> .Filter
                             .Eq("OrderLocations.OrderLocationID", item.OrderLocationID);

                    update = Builders <AccountModel> .Update.Set("OrderLocations.$.IsDefault", false);

                    collection.UpdateOne(filter, update);
                }
            }
            ///增加收件地址
            if (orderLocation.OrderLocationID.Equals(ObjectId.Empty))
            {
                orderLocation.OrderLocationID = ObjectId.GenerateNewId();
                update = Builders <AccountModel> .Update.Push(x => x.OrderLocations, orderLocation);

                filter = Builders <AccountModel> .Filter.Eq(x => x.AccountID, new ObjectId(accountID));
            }
            ///修改收件地址
            else
            {
                filter = Builders <AccountModel> .Filter.Eq(x => x.AccountID, new ObjectId(accountID))
                         & Builders <AccountModel> .Filter
                         .Eq("OrderLocations.OrderLocationID", orderLocation.OrderLocationID);

                update = Builders <AccountModel> .Update.Set("OrderLocations.$", orderLocation);
            }
            ///统一提交
            collection.UpdateOne(filter, update);
        }
Example #5
0
        public List <OrderLocation> CalculatePosition(List <Order> orders)
        {
            List <OrderLocation> OLL = new List <OrderLocation>();

            foreach (Order order in orders)
            {
                foreach (OrderHasTickets OHT in order.OrderHasTickets)
                {
                    OrderLocation OL = new OrderLocation();

                    int aantaldagen = 0;

                    if (OHT.Ticket.TimeSlot.StartTime.DayOfWeek == DayOfWeek.Thursday)
                    {
                        aantaldagen = 0;
                    }
                    else if (OHT.Ticket.TimeSlot.StartTime.DayOfWeek == DayOfWeek.Friday)
                    {
                        aantaldagen = 1;
                    }
                    else if (OHT.Ticket.TimeSlot.StartTime.DayOfWeek == DayOfWeek.Saturday)
                    {
                        aantaldagen = 2;
                    }
                    else if (OHT.Ticket.TimeSlot.StartTime.DayOfWeek == DayOfWeek.Sunday)
                    {
                        aantaldagen = 3;
                    }

                    OL.bottom = (64.2 - 20 * aantaldagen);
                    OL.left   = (2.2 + 7.35 * (OHT.Ticket.TimeSlot.StartTime.Hour - 10) + OHT.Ticket.TimeSlot.StartTime.Minute * 0.12375);
                    OL.width  = (7.35 * (OHT.Ticket.TimeSlot.EndTime.Hour - OHT.Ticket.TimeSlot.StartTime.Hour) + (0.12375 * (OHT.Ticket.TimeSlot.EndTime.Minute - OHT.Ticket.TimeSlot.StartTime.Minute)));
                    OL.id     = OHT.Ticket_TimeSlot_Activity_Id;

                    OLL.Add(OL);
                }
            }

            return(OLL);
        }
Example #6
0
 public void SetLocation(OrderLocation orderLocation)
 {
     _orderLocation = orderLocation;
 }