Пример #1
0
        public ActionResult AddFS(string fsmodel)
        {
            try
            {
                FlashSaleModel model = (FlashSaleModel)JsonConvert.DeserializeObject(fsmodel, typeof(FlashSaleModel));

                if (Convert.ToDateTime(model.BeginDate) > Convert.ToDateTime(model.EndDate))
                {
                    return(Json(new Result {
                        msg = "开始时间不能大于结束时间!", success = false
                    }));
                }
                if (!_iFightGroupService.ProductCanJoinActive(model.ProductId))
                {
                    return(Json(new Result {
                        msg = "该商品已参与拼团或其他营销活动,请重新选择!", success = false
                    }));
                }
                model.ShopId = CurrentSellerManager.ShopId;
                _iLimitTimeBuyService.AddFlashSale(model);
                foreach (var d in model.Details)
                {
                    LimitOrderHelper.AddLimitStock(d.SkuId, d.Stock, DateTime.Parse(model.EndDate));
                }
                return(Json(new Result {
                    msg = "添加活动成功!", success = true
                }));
            }
            catch (Exception ex)
            {
                return(Json(new Result {
                    msg = ex.Message, success = false
                }));
            }
        }
Пример #2
0
 public ActionResult EditFS(string fsmodel)
 {
     try
     {
         FlashSaleModel model = (FlashSaleModel)JsonConvert.DeserializeObject(fsmodel, typeof(FlashSaleModel));
         if (Convert.ToDateTime(model.BeginDate) > Convert.ToDateTime(model.EndDate))
         {
             return(Json(new Result {
                 msg = "开始时间不能大于结束时间!", success = false
             }));
         }
         model.ShopId = CurrentSellerManager.ShopId;
         _iLimitTimeBuyService.UpdateFlashSale(model);
         foreach (var d in model.Details)
         {
             LimitOrderHelper.ModifyLimitStock(d.SkuId, d.Stock, DateTime.Parse(model.EndDate));
         }
         return(Json(new Result {
             msg = "添加活动成功!", success = true
         }));
     }
     catch (Exception ex)
     {
         return(Json(new Result {
             msg = ex.Message, success = false
         }));
     }
 }
Пример #3
0
        public void CheckAsync(string id)
        {
            AsyncManager.OutstandingOperations.Increment();
            int interval       = 3000;      //定义刷新间隔为200ms
            int maxWaitingTime = 15 * 1000; //定义最大等待时间为15s

            long[] orderIds;
            string message = "";

            Task.Factory.StartNew(() =>
            {
                int time = 0;
                while (true)
                {
                    time += interval;
                    System.Threading.Thread.Sleep(interval);
                    OrderState state = LimitOrderHelper.GetOrderState(id, out message, out orderIds);
                    if (state == OrderState.Processed)                    //已处理
                    {
                        AsyncManager.Parameters["state"]   = state.ToString();
                        AsyncManager.Parameters["message"] = message;
                        AsyncManager.Parameters["ids"]     = orderIds;
                        break;
                    }
                    else if (state == OrderState.Untreated)                    //未处理
                    {
                        if (time > maxWaitingTime)
                        {                        //大于最大等待时间
                            AsyncManager.Parameters["state"]   = state.ToString();
                            AsyncManager.Parameters["message"] = message;
                            AsyncManager.Parameters["ids"]     = null;
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else                    //出错
                    {
                        AsyncManager.Parameters["state"]   = state.ToString();
                        AsyncManager.Parameters["message"] = message;
                        AsyncManager.Parameters["ids"]     = null;
                        break;
                    }
                }
                AsyncManager.OutstandingOperations.Decrement();
            });
        }
Пример #4
0
        public JsonResult SubmitLimitOrder(CommonModel.OrderPostModel model)
        {
            model.CurrentUser  = CurrentUser;
            model.PlatformType = (int)PlatformType.PC;
            var result = OrderApplication.GetLimitOrder(model);

            if (LimitOrderHelper.IsRedisCache())
            {
                string            id = "";
                SubmitOrderResult r  = LimitOrderHelper.SubmitOrder(result, out id);
                if (r == SubmitOrderResult.SoldOut)
                {
                    throw new HimallException("已售空");
                }
                else if (r == SubmitOrderResult.NoSkuId)
                {
                    throw new InvalidPropertyException("创建订单的时候,SKU为空,或者数量为0");
                }
                else if (r == SubmitOrderResult.NoData)
                {
                    throw new InvalidPropertyException("参数错误");
                }
                else if (r == SubmitOrderResult.NoLimit)
                {
                    throw new InvalidPropertyException("没有限时购活动");
                }
                else if (string.IsNullOrEmpty(id))
                {
                    throw new InvalidPropertyException("参数错误");
                }
                else
                {
                    OrderApplication.UpdateDistributionUserLink(GetDistributionUserLinkId().ToArray(), UserId);
                    return(Json(new { success = true, Id = id }));
                }
            }
            else
            {
                var orderIds = OrderApplication.OrderSubmit(result);
                return(Json(new { success = true, orderIds = orderIds }));
            }
        }
Пример #5
0
        public JsonResult SubmitLimitOrder(OrderPostModel model, string payPwd)
        {
            model.CurrentUser  = base.CurrentUser;
            model.PlatformType = 1;
            OrderCreateModel limitOrder = OrderApplication.GetLimitOrder(model);

            if (LimitOrderHelper.IsRedisCache())
            {
                string id = "";
                switch (LimitOrderHelper.SubmitOrder(limitOrder, out id, payPwd))
                {
                case SubmitOrderResult.SoldOut:
                    throw new HimallException("已售空");

                case SubmitOrderResult.NoSkuId:
                    throw new InvalidPropertyException("创建预约单的时候,SKU为空,或者数量为0");

                case SubmitOrderResult.NoData:
                    throw new InvalidPropertyException("参数错误");

                case SubmitOrderResult.NoLimit:
                    throw new InvalidPropertyException("没有限时购活动");

                case SubmitOrderResult.ErrorPassword:
                    throw new InvalidPropertyException("支付密码错误");
                }
                if (string.IsNullOrEmpty(id))
                {
                    throw new InvalidPropertyException("参数错误");
                }
                OrderApplication.UpdateDistributionUserLink(base.GetDistributionUserLinkId().ToArray(), base.UserId);
                return(base.Json(new { success = true, Id = id }));
            }
            OrderReturnModel model3 = OrderApplication.OrderSubmit(limitOrder, payPwd);

            return(base.Json(new { success = model3.Success, orderIds = model3.OrderIds, realTotalIsZero = model3.OrderTotal == 0M }));
        }
Пример #6
0
        public JsonResult CloseOrder(long orderId)
        {
            var order = _iOrderService.GetOrder(orderId, CurrentUser.Id);

            if (order != null)
            {
                //if( order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery && order.PaymentType == OrderInfo.PaymentTypes.CashOnDelivery )
                //{
                //    _iOrderService.MemberApplyCloseOrder( orderId , CurrentUser.UserName );
                //}
                //else
                //{
                //    _iOrderService.MemberCloseOrder( orderId , CurrentUser.UserName );
                //    foreach( var item in order.OrderItemInfo )
                //    {
                //        _iProductService.UpdateStock( item.SkuId , item.Quantity );
                //    }
                //}
                _iOrderService.MemberCloseOrder(orderId, CurrentUser.UserName);
                foreach (var item in order.OrderItemInfo)
                {
                    LimitOrderHelper.ReleaseStock(item.SkuId, item.Quantity);
                }
            }
            else
            {
                return(Json(new Result()
                {
                    success = false, msg = "取消失败,该预约单已删除或者不属于当前用户!"
                }));
            }
            return(Json(new Result()
            {
                success = true, msg = "取消成功"
            }));
        }