예제 #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="shopBll"></param>
 /// <param name="areaBll"></param>
 /// <param name="shopStatisticsBll"></param>
 /// <param name="platformBll"></param>
 public ShopController(IShopBLL shopBll, IAreaBLL areaBll, IShopStatisticsBLL shopStatisticsBll, IPlatformBLL platformBll)
 {
     this._shopBll           = shopBll;
     this._areaBll           = areaBll;
     this._shopStatisticsBll = shopStatisticsBll;
     this._platformBll       = platformBll;
 }
예제 #2
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"));
            }
        }
예제 #3
0
        public ActionResult UploadPic(ShopImgModel model)
        {
            JsonModel jm = new JsonModel();

            try
            {
                //门店BLL
                IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                var shopInfo = shopBll.GetEntity(index => index.Id == model.Id);

                //图片路径
                string PathList = shopInfo.ImgPath;
                //缩略图路径
                string ThumPathList = shopInfo.ImgThumbnail;
                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 (!Directory.Exists(Server.MapPath(ConstantParam.SHOP_IMG_DIR)))
                        {
                            Directory.CreateDirectory(Server.MapPath(ConstantParam.SHOP_IMG_DIR));
                        }
                        //判断缩略图路径是否存在
                        if (!Directory.Exists(Server.MapPath(ConstantParam.SHOP_THUM_IMG_DIR)))
                        {
                            Directory.CreateDirectory(Server.MapPath(ConstantParam.SHOP_THUM_IMG_DIR));
                        }
                        //保存图片
                        var path = Path.Combine(Server.MapPath(ConstantParam.SHOP_IMG_DIR), fileName);
                        file.SaveAs(path);
                        //生成缩略图
                        string thumpFile = DateTime.Now.ToFileTime() + ".jpg";

                        var thumpPath = Path.Combine(Server.MapPath(ConstantParam.SHOP_THUM_IMG_DIR), thumpFile);
                        PropertyUtils.getThumImage(path, 18, 3, thumpPath);
                        PathList     += ConstantParam.SHOP_IMG_DIR + fileName + ";";
                        ThumPathList += ConstantParam.SHOP_THUM_IMG_DIR + thumpFile + ";";
                    }
                }
                // 更新图片
                shopInfo.ImgPath      = PathList;
                shopInfo.ImgThumbnail = ThumPathList;
                shopInfo.UpdateTime   = DateTime.Now;
                // 保存到数据库
                shopBll.Update(shopInfo);

                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            catch (Exception e)
            {
                jm.Msg = e.Message;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult SetupPayType(ShopPayTypeSetupModel model)
        {
            JsonModel jm = new JsonModel();
            //根据商家ID,获取商家信息
            IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            T_Shop shop = shopBll.GetEntity(s => s.Id == model.shopId);

            // 新建用户角色关联表
            List <T_ShopPaymentManagement> payTypes = new List <T_ShopPaymentManagement>();

            if (model.ids != null)
            {
                foreach (var id in model.ids)
                {
                    T_ShopPaymentManagement item = new T_ShopPaymentManagement()
                    {
                        ShopId = model.shopId, PayTypeId = id
                    };
                    payTypes.Add(item);
                }
            }

            //修改商家支付类型集合
            if (shopBll.SetupPayTypes(shop, payTypes))
            {
                jm.Content = "商家 " + shop.ShopName + " 设置支付类型";
            }
            else
            {
                jm.Msg = "设置支付类型失败";
            }

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public ActionResult Index()
        {
            //获取登录用户的门店
            int      UserId  = GetSessionModel().UserID;
            IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

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

            if (Shop != null)
            {
                var placeNameList = Shop.ShopPlaces.Select(p => p.PropertyPlace.Name).ToList();
                var placeNames    = "";
                if (placeNameList != null && placeNameList.Count > 0)
                {
                    for (int i = 0; i < placeNameList.Count; i++)
                    {
                        placeNames += placeNameList[i] + ",";
                    }
                    placeNames = placeNames.Substring(0, placeNames.Length - 1);
                }
                ViewBag.PlaceNames = placeNames;
                return(View(Shop));
            }
            else
            {
                return(View());
            }
        }
예제 #6
0
        public ApiResultModel GetShopInfo([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层获取商家信息
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.ShopId);
                    //如果商家信息不为空
                    if (shop != null)
                    {
                        resultModel.result = new
                        {
                            ShopName          = shop.ShopName,
                            ShopContent       = string.Format("MobilePage/StoreIntroduce?ShopId={0}", shop.Id),
                            ShopMainSale      = shop.MainSale,
                            StartBusinessTime = shop.StartBusinessTime,
                            EndBusinessTime   = shop.EndBusinessTime,
                            ShopAddress       = shop.Address,
                            Phone             = shop.Phone,
                            ShopPicList       = shop.ImgPath
                        };
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.NO_APP;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
예제 #7
0
        public ActionResult EditShop(int id)
        {
            IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var shopInfo = ShopBll.GetEntity(index => index.Id == id);

            if (shopInfo != null)
            {
                ShopPlatformModel model = new ShopPlatformModel();
                model.Id                = shopInfo.Id;
                model.ShopName          = shopInfo.ShopName;
                model.MainSale          = shopInfo.MainSale;
                model.Tel               = shopInfo.Phone;
                model.ProvinceId        = shopInfo.ProvinceId;
                model.ProvinceList      = GetProvinceList();
                model.CityId            = shopInfo.CityId;
                model.CityList          = base.GetCityList(shopInfo.ProvinceId);
                model.CountyId          = shopInfo.CountyId;
                model.CountyList        = base.GetCountyList(shopInfo.CityId);
                model.Address           = shopInfo.Address;
                model.Content           = shopInfo.Content;
                model.StartBusinessTime = shopInfo.StartBusinessTime;
                model.EndBusinessTime   = shopInfo.EndBusinessTime;
                model.TimeList          = GetBusinessTimeList();
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
예제 #8
0
        public ActionResult OrderList(StoreOrderSearchModel model)
        {
            //获取登录用户的门店
            int      userId  = GetSessionModel().UserID;
            IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var shop = shopBll.GetEntity(u => u.ShopUserId == userId);

            //如果该门店存在
            if (shop != null)
            {
                //获取订单状态下拉列表
                model.OrderStatusList = GetOrderStatusList(shop.Type.Contains(ConstantParam.SHOP_TYPE_0.ToString()));

                //获取支付方式下拉列表
                model.PayWayList = GetPayWayList(shop.Type.Contains(ConstantParam.SHOP_TYPE_0.ToString()));

                //初始化默认查询模型
                DateTime today = DateTime.Today;
                if (model.StartDate == null)
                {
                    model.StartDate = today.AddDays(-today.Day + 1);
                }
                if (model.EndDate == null)
                {
                    model.EndDate = today;
                }

                //获取当前门店ID
                var shopId = GetCurrentShopId().Value;

                //根据订单日期查询
                DateTime endDate = model.EndDate.Value.AddDays(1);
                Expression <Func <T_Order, bool> > where = u => u.OrderDate >= model.StartDate.Value && u.OrderDate < endDate && u.ShopId == shopId &&
                                                           u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.IsStoreHided == ConstantParam.DEL_FLAG_DEFAULT;

                //根据订单状态查询
                if (model.OrderStatus != null)
                {
                    where = PredicateBuilder.And(where, u => u.OrderStatus == model.OrderStatus);
                }

                //根据支付方式查询
                if (model.PayWay != null)
                {
                    where = PredicateBuilder.And(where, u => u.PayWay == model.PayWay);
                }

                //根据查询条件调用BLL层 获取分页数据
                IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                var sortName = this.SettingSorting("Id", false);
                model.DataList = orderBll.GetPageList(where, sortName.SortName, sortName.IsAsc, model.PageIndex) as PagedList <T_Order>;
                return(View(model));
            }

            //否则返回首页
            return(RedirectToAction("Index", "ShopPlatform"));
        }
예제 #9
0
        public ActionResult EditShop(int id)
        {
            IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var shopInfo = ShopBll.GetEntity(index => index.Id == id);

            if (shopInfo != null)
            {
                ShopModel model = new ShopModel();
                model.Id                = shopInfo.Id;
                model.ShopUserName      = shopInfo.ShopUser.UserName;
                model.Types             = shopInfo.Type;
                model.TypeList          = GetTypeList();
                model.ShopName          = shopInfo.ShopName;
                model.MainSale          = shopInfo.MainSale;
                model.Tel               = shopInfo.Phone;
                model.Address           = shopInfo.Address;
                model.ProvinceId        = shopInfo.ProvinceId;
                model.ProvinceList      = GetProvinceList();
                model.CityId            = shopInfo.CityId;
                model.CityList          = base.GetCityList(shopInfo.ProvinceId);
                model.CountyId          = shopInfo.CountyId;
                model.CountyList        = base.GetCountyList(shopInfo.CityId);
                model.Content           = shopInfo.Content;
                model.StartBusinessTime = shopInfo.StartBusinessTime;
                model.EndBusinessTime   = shopInfo.EndBusinessTime;
                model.TimeList          = GetBusinessTimeList();
                //model.IsDelivery = shopInfo.IsDelivery == null ? false : (shopInfo.IsDelivery == 1 ? true : false);

                var placeList = shopInfo.ShopPlaces.Select(p => new
                {
                    PlaceId   = p.PropertyPlaceId,
                    PlaceName = p.PropertyPlace.Name
                }).ToList();

                model.PlaceIds   = "";
                model.placeNames = "";
                if (placeList != null && placeList.Count > 0)
                {
                    for (int i = 0; i < placeList.Count; i++)
                    {
                        model.PlaceIds   += placeList[i].PlaceId + ",";
                        model.placeNames += placeList[i].PlaceName + ",";
                    }
                    model.PlaceIds   = model.PlaceIds.Substring(0, model.PlaceIds.Length - 1);
                    model.placeNames = model.placeNames.Substring(0, model.placeNames.Length - 1);
                    model.PlaceList  = GetPlaceList(shopInfo.CityId, placeList.Select(p => p.PlaceId).ToList());
                }
                else
                {
                    model.PlaceList = GetPlaceList(shopInfo.CityId, null);
                }
                return(View(model));
            }
            else
            {
                return(RedirectToAction("ShopList"));
            }
        }
예제 #10
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="sysUserBll"></param>
 /// <param name="sysUserRoleBll"></param>
 /// <param name="areaBll"></param>
 /// <param name="shopBll"></param>
 /// <param name="sysUserLogBll"></param>
 public UserController(ISysUserBLL sysUserBll, ISysUserRoleBLL sysUserRoleBll, IAreaBLL areaBll, IShopBLL shopBll, ISysUserLogBLL sysUserLogBll)
 {
     this._sysUserBll     = sysUserBll;
     this._sysUserRoleBll = sysUserRoleBll;
     this._areaBll        = areaBll;
     this._shopBll        = shopBll;
     this._sysUserLogBll  = sysUserLogBll;
 }
예제 #11
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));
        }
예제 #12
0
        /// <summary>
        /// 二期商家结束HTML页面
        /// </summary>
        /// <param name="ShopId">门店ID</param>
        /// <returns></returns>
        public ActionResult StoreIntroduce(int ShopId)
        {
            //获取要查看详细的门店实体对象
            IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            T_Shop Shop = ShopBll.GetEntity(s => s.Id == ShopId);

            return(View(Shop));
        }
예제 #13
0
        public ApiResultModel SetShopInfo(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层获取商家信息
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.ShopId);

                    //设置主营内容
                    if (shop != null)
                    {
                        shop.ShopName = model.ShopName;
                        //shop.Content = model.ShopContent;
                        shop.MainSale          = model.MainSale;
                        shop.StartBusinessTime = model.StartBusinessTime;
                        shop.EndBusinessTime   = model.EndBusinessTime;
                        shop.Address           = model.Address;
                        shop.Phone             = model.Phone;
                        shop.UpdateTime        = DateTime.Now;
                        shopBll.Update(shop);
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
예제 #14
0
        public ActionResult AddShop(ShopModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                //初始化门店数据
                T_Shop newShop = new T_Shop()
                {
                    ShopName          = model.ShopName,
                    Phone             = model.Tel,
                    ProvinceId        = model.ProvinceId,
                    CityId            = model.CityId,
                    CountyId          = model.CountyId,
                    Address           = model.Address,
                    MainSale          = model.MainSale,
                    ShopUserId        = model.ShopUserId,
                    Content           = model.Content,
                    StartBusinessTime = model.StartBusinessTime,
                    EndBusinessTime   = model.EndBusinessTime,
                    UpdateTime        = DateTime.Now,
                    Type = model.Types
                };

                //如果服务小区不为空
                if (!string.IsNullOrEmpty(model.PlaceIds))
                {
                    foreach (var placeId in model.PlaceIds.Split(','))
                    {
                        newShop.ShopPlaces.Add(new R_ShopPlace()
                        {
                            PropertyPlaceId = Convert.ToInt32(placeId)
                        });
                    }
                }
                //默认支付方式:货到现金支付
                newShop.ShopPaymentManagements.Add(new T_ShopPaymentManagement()
                {
                    PayTypeId = 3
                });
                // 保存到数据库
                ShopBll.Save(newShop);
                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #15
0
        public ApiPageResultModel ShopList([FromUri] ShopSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    Expression <Func <T_Shop, bool> > where = u => u.Type.Contains(model.Type.ToString());
                    //如果是生活小卖店或五金店
                    if (model.Type == 2 || model.Type == 3)
                    {
                        var placeList = owner.UserPlaces.Select(m => m.PropertyPlaceId);
                        where = PredicateBuilder.And(where, u => u.ShopPlaces.Count(p => placeList.Contains(p.PropertyPlaceId)) > 0);
                    }
                    resultModel.Total  = shopBll.Count(where);
                    resultModel.result = shopBll.GetPageList(where, "Id", false, model.PageIndex).ToList().Select(s => new
                    {
                        Id       = s.Id,
                        ShopName = s.ShopName,
                        Content  = s.MainSale,
                        Phone    = string.IsNullOrEmpty(s.Phone) ? "" : s.Phone,
                        Img      = string.IsNullOrEmpty(s.ImgThumbnail) ? "" : s.ImgThumbnail.Split(';')[0]
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
예제 #16
0
        public ApiResultModel GetShopFreight([FromUri] ShopFreightSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取要查询的门店
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.Id);
                    if (shop != null)
                    {
                        var cost = shop.ShopShippingCosts.FirstOrDefault();
                        if (cost != null && cost.IsFree == 0 && (cost.OrderExpense == null || model.TotalPrice < cost.OrderExpense.Value))
                        {
                            resultModel.result = cost.Price.Value;
                        }
                        else
                        {
                            resultModel.result = 0;
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
예제 #17
0
        public ApiResultModel GetShopPayWay([FromUri] DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取要查询的门店
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.Id);
                    if (shop != null)
                    {
                        var PayWays = shop.ShopPaymentManagements.Select(p => p.PayTypeId).ToList();
                        if (PayWays.Count > 0)
                        {
                            resultModel.result = PayWays;
                        }
                        else
                        {
                            resultModel.result = new List <int>();
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
예제 #18
0
        public ApiResultModel ShopDetail2([FromUri] DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取要查看详细的门店实体对象
                    IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    T_Shop Shop = ShopBll.GetEntity(s => s.Id == model.Id);
                    if (Shop != null)
                    {
                        resultModel.result = new
                        {
                            ShopImg      = Shop.ImgPath,
                            ShopInfoPath = "MobilePage/StoreDetail2?ShopId=" + model.Id,
                        };
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.SHOP_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
예제 #19
0
 /// <summary>
 /// 初始化类公共属性
 /// </summary>
 private void Initialize()
 {
     _shopBll                 = CustomServiceLocator.GetInstance <IShopBLL>();
     _shopRetailRankBll       = CustomServiceLocator.GetInstance <IShopRetailRankBLL>();
     _shopRetailRankWinnerBll = CustomServiceLocator.GetInstance <IShopRetailRankLimitBLL>();
     _platformBll             = CustomServiceLocator.GetInstance <IPlatformBLL>();
     _appSettings             = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings;
     _config      = _appSettings.ShopRetailRankConfig;
     _now         = DateTime.Now;
     _startGrowth = _now.GetStartOfTheWeek();
     _endGrowth   = _now;
     _startKing   = _config.KingStartTime;
     _endKing     = _now;
 }
예제 #20
0
        /// <summary>
        /// 获取当前门店ID
        /// </summary>
        /// <returns></returns>
        public int?GetCurrentShopId()
        {
            //获取登录用户的门店
            int      UserId  = GetSessionModel().UserID;
            IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

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

            if (Shop != null)
            {
                return(Shop.Id);
            }
            return(null);
        }
예제 #21
0
        public ActionResult ShopList(ShopSearchModel model)
        {
            IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            Expression <Func <T_Shop, bool> > where = u => (string.IsNullOrEmpty(model.ShopName) ? true : u.ShopName.Contains(model.ShopName));
            if (model.Type != null)
            {
                where = PredicateBuilder.And <T_Shop>(where, u => u.Type.Contains(model.Type.Value.ToString()));
            }
            var sortModel = SettingSorting("Id", false);

            model.List     = ShopBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex) as PagedList <T_Shop>;
            model.TypeList = GetTypeList();
            return(View(model));
        }
예제 #22
0
        public ActionResult EditShop(ShopModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单验证成功
            if (ModelState.IsValid)
            {
                IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                T_Shop shop = ShopBll.GetEntity(m => m.Id == model.Id);
                if (shop != null)
                {
                    shop.ShopName          = model.ShopName;
                    shop.Phone             = model.Tel;
                    shop.ProvinceId        = model.ProvinceId;
                    shop.CityId            = model.CityId;
                    shop.CountyId          = model.CountyId;
                    shop.Address           = model.Address;
                    shop.MainSale          = model.MainSale;
                    shop.Content           = model.Content;
                    shop.StartBusinessTime = model.StartBusinessTime;
                    shop.EndBusinessTime   = model.EndBusinessTime;
                    //shop.IsDelivery = model.IsDelivery ? 1 : 0;
                    shop.Type       = model.Types;
                    shop.UpdateTime = DateTime.Now;

                    //修改保存到数据库
                    if (ShopBll.UpdateShop(shop, model.PlaceIds))
                    {
                        //日志记录
                        jm.Content = PropertyUtils.ModelToJsonString(model);
                    }
                    else
                    {
                        jm.Msg = "编辑失败";
                    }
                }
                else
                {
                    jm.Msg = "该门店不存在";
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #23
0
        public ActionResult SetupPayType(int id)
        {
            //根据商家ID,获取商家信息
            IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            T_Shop shop = shopBll.GetEntity(s => s.Id == id);

            //是否是绿色直供
            bool             isGreenSupplied = shop.Type.Contains(Property.Common.ConstantParam.SHOP_TYPE_0.ToString());
            ShopPayTypeModel paytypeModel    = new ShopPayTypeModel();

            //获取商家信息
            paytypeModel.Shop = shop;
            //获取支付类型  绿色直供包含5种
            var PayTypeList = new List <ShopPaymentType>();

            if (isGreenSupplied)
            {
                PayTypeList.Add(new ShopPaymentType()
                {
                    TypeId = 1, TypeName = "微信在线支付"
                });
                PayTypeList.Add(new ShopPaymentType()
                {
                    TypeId = 2, TypeName = "支付宝在线支付"
                });
            }

            PayTypeList.Add(new ShopPaymentType()
            {
                TypeId = 3, TypeName = "货到现金付款"
            });
            PayTypeList.Add(new ShopPaymentType()
            {
                TypeId = 4, TypeName = "货到微信付款"
            });
            PayTypeList.Add(new ShopPaymentType()
            {
                TypeId = 5, TypeName = "货到支付宝付款"
            });

            paytypeModel.PayTypeList = PayTypeList;
            //已经分配的支付类型
            paytypeModel.PayTypeIds = shop.ShopPaymentManagements.Select(s => s.PayTypeId).ToList();

            return(View(paytypeModel));
        }
예제 #24
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="shopRetailRankBll"></param>
 /// <param name="shopRetailRankLimitBll"></param>
 /// <param name="sysUserBll"></param>
 /// <param name="sysUserRoleBll"></param>
 /// <param name="sysUserLogBll"></param>
 /// <param name="areaBll"></param>
 /// <param name="goodsBll"></param>
 /// <param name="openDataBll"></param>
 /// <param name="shopBll"></param>
 /// <param name="baseSupplierBll"></param>
 /// <param name="retailCustomerBll"></param>
 public OpenController(IShopRetailRankBLL shopRetailRankBll, IShopRetailRankLimitBLL shopRetailRankLimitBll,
                       ISysUserBLL sysUserBll, ISysUserRoleBLL sysUserRoleBll, ISysUserLogBLL sysUserLogBll,
                       IOpenDataBLL openDataBll, IGoodsBLL goodsBll, IAreaBLL areaBll, IShopBLL shopBll,
                       IBaseSupplierBLL baseSupplierBll, IRetailCustomerBLL retailCustomerBll)
 {
     this._shopRetailRankBll      = shopRetailRankBll;
     this._shopRetailRankLimitBll = shopRetailRankLimitBll;
     this._sysUserBll             = sysUserBll;
     this._sysUserRoleBll         = sysUserRoleBll;
     this._sysUserLogBll          = sysUserLogBll;
     this._openDataBll            = openDataBll;
     this._goodsBll          = goodsBll;
     this._areaBll           = areaBll;
     this._shopBll           = shopBll;
     this._baseSupplierBll   = baseSupplierBll;
     this._retailCustomerBll = retailCustomerBll;
 }
예제 #25
0
        public ActionResult SetCoverImg(CoverImgUploadModel model)
        {
            JsonModel jm = new JsonModel();

            IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var shop = shopBll.GetEntity(index => index.Id == model.ShopId);

            try
            {
                //存入文件的路径
                string directory = Server.MapPath(ConstantParam.SHOP_IMG_DIR);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                //获取上传文件的扩展名
                string fileEx = Path.GetExtension(Path.GetFileName(model.CoverImgFile.FileName));
                //保存数据文件
                string fileName = DateTime.Now.ToFileTime().ToString() + fileEx;
                string savePath = Path.Combine(directory, fileName);
                model.CoverImgFile.SaveAs(savePath);
                shop.ImgPath = ConstantParam.SHOP_IMG_DIR + fileName;

                //判断缩略图路径是否存在
                if (!Directory.Exists(Server.MapPath(ConstantParam.SHOP_THUM_IMG_DIR)))
                {
                    Directory.CreateDirectory(Server.MapPath(ConstantParam.SHOP_THUM_IMG_DIR));
                }
                //生成缩略图
                string thumpFile = DateTime.Now.ToFileTime() + ".jpg";

                var thumpPath = Path.Combine(Server.MapPath(ConstantParam.SHOP_THUM_IMG_DIR), thumpFile);
                if (PropertyUtils.getThumImage(savePath, 18, 3, thumpPath))
                {
                    shop.ImgThumbnail = ConstantParam.SHOP_THUM_IMG_DIR + thumpFile;
                }
                shopBll.Update(shop);
            }
            catch
            {
                jm.Msg = "请求发生异常";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #26
0
        public ActionResult SetCoverImg(int id)
        {
            //门店BLL
            IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var shop = shopBll.GetEntity(index => index.Id == id);

            if (shop != null)
            {
                CoverImgUploadModel model = new CoverImgUploadModel();
                model.ShopId  = id;
                model.ImgPath = shop.ImgPath;
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
예제 #27
0
        public ActionResult UploadPic(int id)
        {
            //门店BLL
            IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var shopInfo = shopBll.GetEntity(index => index.Id == id);

            ShopImgModel shopImgModel = new ShopImgModel();

            shopImgModel.Id = id;
            if (shopInfo.ImgPath != null && shopInfo.ImgThumbnail != null)
            {
                List <string> imgPaths      = shopInfo.ImgPath.Split(new char[] { ';' }).ToList();
                List <string> thumbImgPaths = shopInfo.ImgThumbnail.Split(new char[] { ';' }).ToList();
                shopImgModel.ImgPathArray      = imgPaths;
                shopImgModel.ImgThumbPathArray = thumbImgPaths;
            }
            return(View(shopImgModel));
        }
예제 #28
0
        public JsonResult DelShopImg(int id, string href, string thum)
        {
            JsonModel Jm = new JsonModel();

            try
            {
                IShopBLL shopBLL = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                T_Shop Shop = shopBLL.GetEntity(a => a.Id == id);
                //删除缩略图路径
                int start = Shop.ImgThumbnail.IndexOf(href + ";");
                Shop.ImgThumbnail = Shop.ImgThumbnail.Remove(start, href.Length + 1);
                //获取缩略图片路径
                string path = Server.MapPath(href);
                //删除缩略图片
                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }
                //获取大图片路径
                int thumStart = Shop.ImgPath.IndexOf(thum + ";");
                Shop.ImgPath = Shop.ImgPath.Remove(thumStart, thum.Length + 1);
                string thumPath = Server.MapPath(thum);
                if (System.IO.File.Exists(thumPath))
                {
                    try
                    {
                        //删除原图片
                        System.IO.File.Delete(thumPath);
                    }
                    catch { }
                }
                shopBLL.Update(Shop);
                //记录log
                Jm.Content = "删除门店图片" + href;
            }
            catch
            {
                Jm.Msg = "删除出现异常";
            }
            return(Json(Jm));
        }
예제 #29
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="sysUserBll"></param>
 /// <param name="areaBll"></param>
 /// <param name="shopBll"></param>
 public GetUserDataLimitAction(ISysUserBLL sysUserBll, IAreaBLL areaBll, IShopBLL shopBll)
 {
     this._sysUserBll = sysUserBll;
     this._areaBll    = areaBll;
     this._shopBll    = shopBll;
 }
예제 #30
0
        public ApiResultModel AddGoods(GoodsInfoModel 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);

                    //商品分类实例化
                    T_ShopSale goods = new T_ShopSale()
                    {
                        Title           = model.Name,
                        Content         = model.Content,
                        CreateTime      = DateTime.Now,
                        GoodsCategoryId = model.GoodCategoryId,
                        Price           = model.Price,
                        RemainingAmout  = model.RemainingAmount,
                        InSales         = 1
                    };

                    //话题文件资源保存目录
                    string dir = HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales);

                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //图片上传
                    if (!string.IsNullOrEmpty(model.PicList))
                    {
                        var    fileName = DateTime.Now.ToFileTime().ToString() + ".zip";
                        string filepath = Path.Combine(dir, fileName);

                        using (FileStream fs = new FileStream(filepath, FileMode.Create))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fs))
                            {
                                byte[] datas = Convert.FromBase64String(model.PicList);
                                bw.Write(datas);
                                bw.Close();
                            }
                        }
                        //图片集路径保存
                        goods.ImgPath = PropertyUtils.UnZip(filepath, dir, ConstantParam.SHOP_Sales);

                        StringBuilder imgsSB = new StringBuilder();
                        //生成缩略图保存
                        foreach (var path in goods.ImgPath.Split(';'))
                        {
                            string thumpFile = DateTime.Now.ToFileTime() + ".jpg";
                            string thumpPath = Path.Combine(HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales_ThumIMG), thumpFile);
                            PropertyUtils.getThumImage(Path.Combine(HttpContext.Current.Server.MapPath(path)), 18, 3, thumpPath);
                            imgsSB.Append(ConstantParam.SHOP_Sales_ThumIMG + "/" + thumpFile + ";");
                        }

                        goods.ImgThumbnail = imgsSB.ToString();
                        goods.ImgThumbnail = goods.ImgThumbnail.Substring(0, goods.ImgThumbnail.Length - 1);
                    }

                    //保存商品
                    IShopSaleBLL goodsBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                    goodsBLL.Save(goods);

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

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

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

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

                        string alert = shopName + "的商品" + goods.Title + "上架了";
                        bool   flag  = PropertyUtils.SendPush("商品上架", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);
                        if (!flag)
                        {
                            resultModel.Msg = "推送发生异常";
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch (Exception ex)
            {
                PropertyUtils.WriteLogInfo("test");
                PropertyUtils.WriteLogError(ex);
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }