예제 #1
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));
        }
예제 #2
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);
        }