コード例 #1
0
        public ActionResult SetupShippingCost()
        {
            ShopShippingCostModel model = new ShopShippingCostModel();

            if (GetCurrentShopId().HasValue)
            {
                int shopId = GetCurrentShopId().Value;
                IShopShippingCostBLL shippingCostBLL = BLLFactory <IShopShippingCostBLL> .GetBLL("ShopShippingCostBLL");

                var shippingCost = shippingCostBLL.GetEntity(s => s.ShopId == shopId);

                if (shippingCost != null)
                {
                    model.OrderExpense = shippingCost.OrderExpense;
                    model.Price        = shippingCost.Price;
                    model.Id           = shippingCost.Id;
                    model.IsFree       = shippingCost.IsFree == 1 ? true : false;
                }

                model.ShopId = shopId;

                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
コード例 #2
0
        public JsonResult SetupShippingCost(ShopShippingCostModel model)
        {
            JsonModel Jm = new JsonModel();

            if (ModelState.IsValid)
            {
                IShopShippingCostBLL shippingCostBLL = BLLFactory <IShopShippingCostBLL> .GetBLL("ShopShippingCostBLL");

                //如果存在更新,否则添加新的
                if (model.Id.HasValue)
                {
                    var shippingCost = shippingCostBLL.GetEntity(s => s.Id == model.Id);

                    shippingCost.OrderExpense = model.OrderExpense;
                    shippingCost.Price        = model.Price;
                    shippingCost.IsFree       = model.IsFree ? 1 : 0;

                    shippingCostBLL.Update(shippingCost);
                }
                else
                {
                    T_ShopShippingCost shippingCost = new T_ShopShippingCost();

                    shippingCost.ShopId       = model.ShopId;
                    shippingCost.OrderExpense = model.OrderExpense;
                    shippingCost.Price        = model.Price;
                    shippingCost.IsFree       = model.IsFree ? 1 : 0;

                    shippingCostBLL.Save(shippingCost);
                }

                Jm.Content = Property.Common.PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                Jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }

            return(Json(Jm, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public ApiResultModel SetShopShippingCost(Property.UI.Models.Mobile.ShopShippingCostModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前用户
                IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    IShopShippingCostBLL shippingCostBLL = BLLFactory <IShopShippingCostBLL> .GetBLL("ShopShippingCostBLL");

                    //如果存在更新,否则添加新的
                    if (model.Id.HasValue)
                    {
                        var shippingCost = shippingCostBLL.GetEntity(s => s.Id == model.Id);

                        shippingCost.OrderExpense = model.OrderExpense;
                        shippingCost.Price        = model.Price;
                        shippingCost.IsFree       = model.IsFree;

                        shippingCostBLL.Update(shippingCost);
                    }
                    else
                    {
                        T_ShopShippingCost shippingCost = new T_ShopShippingCost();

                        shippingCost.ShopId       = model.ShopId;
                        shippingCost.OrderExpense = model.OrderExpense;
                        shippingCost.Price        = model.Price;
                        shippingCost.IsFree       = model.IsFree;

                        shippingCostBLL.Save(shippingCost);
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
コード例 #4
0
        public ApiResultModel GetShopShippingCost([FromUri] ShopInfoModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前用户
                IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //调用商家BLL层获取商家信息
                    IShopShippingCostBLL shippingCostBLL = BLLFactory <IShopShippingCostBLL> .GetBLL("ShopShippingCostBLL");

                    var shippingCost = shippingCostBLL.GetEntity(s => s.ShopId == model.ShopId);
                    //如果商家信息不为空
                    if (shippingCost != null)
                    {
                        resultModel.result = new
                        {
                            Id           = shippingCost.Id,
                            OrderExpense = shippingCost.OrderExpense.HasValue ? shippingCost.OrderExpense.ToString() : "",
                            Price        = shippingCost.Price,
                            IsFree       = shippingCost.IsFree
                        };
                    }
                    else
                    {
                        resultModel.result = new
                        {
                            Id           = "",
                            OrderExpense = "",
                            Price        = "",
                            IsFree       = ""
                        };
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }