Пример #1
0
        public JsonResult EditShopSales(ShopSaleModel Model)
        {
            JsonModel Jm = new JsonModel();

            if (ModelState.IsValid)
            {
                //促销BLL
                IShopSaleBLL SaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                T_ShopSale ShopSale = SaleBLL.GetEntity(a => a.Id == Model.Id);
                if (ShopSale != null)
                {
                    ShopSale.Title           = Model.Title;
                    ShopSale.Phone           = Model.Phone;
                    ShopSale.Content         = Model.Content;
                    ShopSale.GoodsCategoryId = Model.GoodsCategoryId.Value;
                    ShopSale.RemainingAmout  = Model.RemainingAmout;
                    ShopSale.Price           = Model.Price;
                    //保存修改
                    SaleBLL.Update(ShopSale);
                }
                else
                {
                    Jm.Msg = "该商品不存在";
                }
                //记录日志
                Jm.Content = Property.Common.PropertyUtils.ModelToJsonString(Model);
            }
            else
            {
                Jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(Jm, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult EditShopSales(int id)
        {
            //初始化模型
            ShopSaleModel model = new ShopSaleModel();
            //促销BLL
            IShopSaleBLL SaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

            var lst = SaleBLL.GetEntity(a => a.Id == id);

            if (lst != null)
            {
                model.Id                = lst.Id;
                model.Title             = lst.Title;
                model.Content           = lst.Content;
                model.Phone             = lst.Phone;
                model.RemainingAmout    = lst.RemainingAmout;
                model.Price             = lst.Price;
                model.GoodsCategoryId   = lst.GoodsCategoryId;
                model.GoodsCategoryList = GetGoodsCategoryList(lst.GoodsCategory.ShopId);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("SaleList"));
            }
        }
Пример #3
0
        public ActionResult AddShopSales()
        {
            ShopSaleModel model   = new ShopSaleModel();
            int           UserId  = GetSessionModel().UserID;
            IShopBLL      ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var Shop = ShopBll.GetEntity(s => s.ShopUserId == UserId);

            if (Shop != null)
            {
                //如果门店类型是绿色直供
                if (Shop.Type.Contains(ConstantParam.SHOP_TYPE_0.ToString()))
                {
                    ViewBag.IsHasPush = true;
                }
                else
                {
                    ViewBag.IsHasPush = false;
                }
                model.GoodsCategoryList = GetGoodsCategoryList(Shop.Id);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("SaleList"));
            }
        }
Пример #4
0
        public JsonResult AddShopSales(ShopSaleModel model)
        {
            JsonModel Jm = new JsonModel();

            if (ModelState.IsValid)
            {
                var currentShopId = GetCurrentShopId();
                //如果门店已创建
                if (currentShopId != null)
                {
                    T_ShopSale ShopSale = new T_ShopSale();
                    ShopSale.Title           = model.Title;
                    ShopSale.Phone           = model.Phone;
                    ShopSale.Content         = model.Content;
                    ShopSale.GoodsCategoryId = model.GoodsCategoryId.Value;
                    ShopSale.RemainingAmout  = model.RemainingAmout;
                    ShopSale.Price           = model.Price;
                    ShopSale.CreateTime      = DateTime.Now;
                    ShopSale.InSales         = 1;
                    //促销BLL
                    IShopSaleBLL SaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                    //保存
                    SaleBLL.Save(ShopSale);

                    //绿色直供推送
                    if (model.IsPush)
                    {
                        IShopBLL shopBLL = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                        string shopName = shopBLL.GetEntity(s => s.Id == currentShopId).ShopName;

                        //推送给业主客户端
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var registrationIds = userPushBLL.GetList(p => !string.IsNullOrEmpty(p.RegistrationId)).Select(p => p.RegistrationId).ToArray();

                        string alert = shopName + "的商品" + model.Title + "上架了";
                        bool   flag  = PropertyUtils.SendPush("商品上架", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);
                        if (!flag)
                        {
                            Jm.Msg = "推送发生异常";
                        }
                    }
                    //记录 Log
                    Jm.Content = Property.Common.PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    Jm.Msg = "门店还未创建";
                }
            }
            else
            {
                Jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(Jm, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        public ActionResult Upload(int id)
        {
            //门店BLL
            IShopSaleBLL SaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

            T_ShopSale    Model = SaleBLL.GetEntity(a => a.Id == id);
            ShopSaleModel List  = new ShopSaleModel();

            List.Id = Model.Id;
            if (Model.ImgPath != null && Model.ImgThumbnail != null)
            {
                List <string> pathstr  = Model.ImgPath.Split(new char[] { ';' }).ToList();
                List <string> ThumPath = Model.ImgThumbnail.Split(new char[] { ';' }).ToList();
                List.PathList     = pathstr;
                List.ThumPathList = ThumPath;
            }
            return(View(List));
        }
Пример #6
0
        public JsonResult Upload(ShopSaleModel Model)
        {
            JsonModel jm = new JsonModel();

            try
            {
                //促销BLL
                IShopSaleBLL SaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                T_ShopSale ShopSale = SaleBLL.GetEntity(a => a.Id == Model.Id);
                //图片路径
                string PathList = string.IsNullOrEmpty(ShopSale.ImgPath) ? "" : ShopSale.ImgPath + ";";
                //缩略图路径
                string ThumPathList    = string.IsNullOrEmpty(ShopSale.ImgThumbnail) ? "" : ShopSale.ImgThumbnail + ";";
                int    currentImgCount = PathList.Split(';').Count() - 1;
                if (Request.Files.Count + currentImgCount > 6)
                {
                    jm.Msg = "最多只能上传6张商品图片";
                    return(Json(jm, JsonRequestBehavior.AllowGet));
                }
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase file = Request.Files[i];

                    if (file != null)
                    {
                        var fileName = DateTime.Now.ToFileTime() + Path.GetExtension(file.FileName);
                        //判断图片路径是否存在
                        if (!System.IO.Directory.Exists(Server.MapPath(ConstantParam.SHOP_Sales)))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(ConstantParam.SHOP_Sales));
                        }
                        //判断缩略图路径是否存在
                        if (!System.IO.Directory.Exists(Server.MapPath(ConstantParam.SHOP_Sales_ThumIMG)))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(ConstantParam.SHOP_Sales_ThumIMG));
                        }
                        //保存图片
                        var path = Path.Combine(Server.MapPath(ConstantParam.SHOP_Sales), fileName);
                        file.SaveAs(path);
                        //生成缩略图
                        string thumpFile = DateTime.Now.ToFileTime() + ".jpg";

                        var thumpPath = Path.Combine(Server.MapPath(ConstantParam.SHOP_Sales_ThumIMG), thumpFile);
                        PropertyUtils.getThumImage(path, 18, 3, thumpPath);
                        PathList     += ConstantParam.SHOP_Sales + "/" + fileName + ";";
                        ThumPathList += ConstantParam.SHOP_Sales_ThumIMG + "/" + thumpFile + ";";
                    }
                }
                ShopSale.ImgPath      = PathList.Substring(0, PathList.Length - 1);
                ShopSale.ImgThumbnail = ThumPathList.Substring(0, ThumPathList.Length - 1);;

                //保存
                SaleBLL.Update(ShopSale);
                jm.Content = "商品:" + Model.Title + "上传图片";
            }
            catch (Exception e)
            {
                jm.Msg = e.Message;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }