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)); }
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); }
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()); } }
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)); }
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")); } }
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")); } }
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")); }
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")); } }
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)); }
/// <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)); }
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); }
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); }
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); }
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); }
/// <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); }
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)); }
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)); }
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)); }
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)); }
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")); } }
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)); }
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); }
public ActionResult WeixinPayNotifyUrl() { Stream st = Request.InputStream; StreamReader sr = new StreamReader(st); string SRstring = sr.ReadToEnd(); XmlDocument doc = new XmlDocument(); doc.LoadXml(SRstring); sr.Close(); string return_code = doc.GetElementsByTagName("return_code")[0].InnerText; //如果返回成功 if (return_code == "SUCCESS") { string result_code = doc.GetElementsByTagName("result_code")[0].InnerText; if (result_code == "SUCCESS") { IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL"); string orderNo = doc.GetElementsByTagName("out_trade_no")[0].InnerText; var order = orderBll.GetEntity(o => o.PayTradeNo == orderNo); if (order != null && order.OrderStatus == ConstantParam.OrderStatus_NOPAY) { //获取商家账户信息 var wxAccount = order.Shop.ShopAccounts.Where(a => a.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat).FirstOrDefault(); if (wxAccount != null) { //获取商家账户信息 string WeixinPayKey = wxAccount.AccountKey; //组装签名字符串 StringBuilder signStr = new StringBuilder(); signStr.Append("appid=" + doc.GetElementsByTagName("appid")[0].InnerText + "&"); signStr.Append("bank_type=" + doc.GetElementsByTagName("bank_type")[0].InnerText + "&"); signStr.Append("cash_fee=" + doc.GetElementsByTagName("cash_fee")[0].InnerText + "&"); signStr.Append("fee_type=" + doc.GetElementsByTagName("fee_type")[0].InnerText + "&"); signStr.Append("is_subscribe=" + doc.GetElementsByTagName("is_subscribe")[0].InnerText + "&"); signStr.Append("mch_id=" + doc.GetElementsByTagName("mch_id")[0].InnerText + "&"); signStr.Append("nonce_str=" + doc.GetElementsByTagName("nonce_str")[0].InnerText + "&"); signStr.Append("openid=" + doc.GetElementsByTagName("openid")[0].InnerText + "&"); signStr.Append("out_trade_no=" + orderNo + "&"); signStr.Append("result_code=" + result_code + "&"); signStr.Append("return_code=" + return_code + "&"); signStr.Append("time_end=" + doc.GetElementsByTagName("time_end")[0].InnerText + "&"); signStr.Append("total_fee=" + doc.GetElementsByTagName("total_fee")[0].InnerText + "&"); signStr.Append("trade_type=" + doc.GetElementsByTagName("trade_type")[0].InnerText + "&"); signStr.Append("transaction_id=" + doc.GetElementsByTagName("transaction_id")[0].InnerText + "&"); signStr.Append("key=" + WeixinPayKey); string sign = PropertyUtils.GetMD5Str(signStr.ToString()).ToUpper(); //签名验证成功 if (doc.GetElementsByTagName("sign")[0].InnerText == sign) { //更新订单状态 order.OrderStatus = ConstantParam.OrderStatus_RECEIPT; order.PayWay = 1; order.PayDate = DateTime.Now; if (orderBll.Update(order)) { IShopBLL shopBLL = BLLFactory <IShopBLL> .GetBLL("ShopBLL"); var ShopUserId = shopBLL.GetEntity(s => s.Id == order.ShopId).ShopUserId; //推送给订单所属商家 IShopUserPushBLL userPushBLL = BLLFactory <IShopUserPushBLL> .GetBLL("ShopUserPushBLL"); var userPush = userPushBLL.GetEntity(p => p.UserId == ShopUserId); if (userPush != null) { string registrationId = userPush.RegistrationId; string alert = "订单号为" + order.OrderNo + "的订单已支付,点击查看详情"; //通知信息 PropertyUtils.SendPush("订单支付通知", alert, ConstantParam.MOBILE_TYPE_SHOP, registrationId); } } } } } return(Content("success")); } } return(Content("fail")); }
public JsonResult DeleteShop(int id) { JsonModel jm = new JsonModel(); IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL"); // 根据指定id值获取实体对象 var shopInfo = ShopBll.GetEntity(s => s.Id == id); if (shopInfo != null) { //删除门店 if (ShopBll.Delete(shopInfo)) { // 删除门店图片 if (!string.IsNullOrEmpty(shopInfo.ImgPath)) { //删除文件图片 string[] imgPaths = shopInfo.ImgPath.Split(';'); foreach (var imgPath in imgPaths) { if (!string.IsNullOrEmpty(imgPath)) { FileInfo f = new FileInfo(Server.MapPath(imgPath)); if (f.Exists) { f.Delete(); } } } } // 删除门店缩略图片 if (!string.IsNullOrEmpty(shopInfo.ImgThumbnail)) { //删除文件图片 string[] imgThumbnailPaths = shopInfo.ImgThumbnail.Split(';'); foreach (var imgPath in imgThumbnailPaths) { if (!string.IsNullOrEmpty(imgPath)) { FileInfo f = new FileInfo(Server.MapPath(imgPath)); if (f.Exists) { f.Delete(); } } } } jm.Content = "删除门店 " + shopInfo.ShopName; } else { jm.Msg = "删除失败"; } } else { jm.Msg = "该门店不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult AccountList() { //获取登录用户的门店 int userId = GetSessionModel().UserID; IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL"); var shop = shopBll.GetEntity(u => u.ShopUserId == userId); //如果该门店存在 if (shop != null) { ShopAccountModel model = new ShopAccountModel(); var shopId = GetCurrentShopId().Value; IShopAccountBLL shopAccountBll = BLLFactory <IShopAccountBLL> .GetBLL("ShopAccountBLL"); //微信账户 var shopAccount1 = shopAccountBll.GetEntity(u => u.ShopId == shopId && u.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //支付宝账户 var shopAccount2 = shopAccountBll.GetEntity(u => u.ShopId == shopId && u.AccountType == ConstantParam.PROPERTY_ACCOUNT_Alipay && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //微信不为空,支付宝为空 if (shopAccount1 != null && shopAccount2 == null) { model.WeChatNumber = shopAccount1.Number; model.WeChatMerchantNo = shopAccount1.MerchantNo; model.WeChatKey = shopAccount1.AccountKey; return(View(model)); } //支付宝不为空,微信为空 if (shopAccount2 != null && shopAccount1 == null) { model.AlipayNumber = shopAccount2.Number; model.AlipayMerchantNo = shopAccount2.MerchantNo; model.AlipayKey = shopAccount2.AccountKey; return(View(model)); } //微信,支付宝都不为空 if (shopAccount1 != null && shopAccount2 != null) { model.WeChatNumber = shopAccount1.Number; model.WeChatMerchantNo = shopAccount1.MerchantNo; model.WeChatKey = shopAccount1.AccountKey; model.AlipayNumber = shopAccount2.Number; model.AlipayMerchantNo = shopAccount2.MerchantNo; model.AlipayKey = shopAccount2.AccountKey; return(View(model)); } return(View()); } //否则返回首页 return(RedirectToAction("Index", "ShopPlatform")); }
public ApiResultModel GetShopPayType([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) { var payTypeIds = shop.ShopPaymentManagements.Select(s => s.PayTypeId); //是否是绿色直供 bool isGreenSupplied = shop.Type.Contains(Property.Common.ConstantParam.SHOP_TYPE_0.ToString()); //获取支付类型 绿色直供包含5种 var PayTypeList = new List <ShopPaymentType>(); if (isGreenSupplied) { PayTypeList.Add(new ShopPaymentType() { TypeId = 1, TypeName = "微信在线支付", TypeFlag = 1 }); PayTypeList.Add(new ShopPaymentType() { TypeId = 2, TypeName = "支付宝在线支付", TypeFlag = 2 }); } PayTypeList.Add(new ShopPaymentType() { TypeId = 3, TypeName = "货到现金付款", TypeFlag = 3 }); PayTypeList.Add(new ShopPaymentType() { TypeId = 4, TypeName = "货到微信付款", TypeFlag = 1 }); PayTypeList.Add(new ShopPaymentType() { TypeId = 5, TypeName = "货到支付宝付款", TypeFlag = 2 }); var List = PayTypeList.Select(t => new { TypeId = t.TypeId, TypeName = t.TypeName, TypeFlag = t.TypeFlag, IsCheck = payTypeIds.Contains(t.TypeId) }); resultModel.result = List; } else { resultModel.Msg = APIMessage.NO_APP; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel SetShopPayType(Property.UI.Models.Mobile.ShopPayTypeModel 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) { // 新建用户角色关联表 List <T_ShopPaymentManagement> payTypes = new List <T_ShopPaymentManagement>(); if (!string.IsNullOrEmpty(model.PayTypeIds)) { foreach (var id in model.PayTypeIds.Split(';')) { T_ShopPaymentManagement item = new T_ShopPaymentManagement() { ShopId = model.ShopId, PayTypeId = int.Parse(id) }; payTypes.Add(item); } shopBll.SetupPayTypes(shop, payTypes); } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel UploadShopImage(ShopImageModel model) { //string filePath = System.AppDomain.CurrentDomain.BaseDirectory + "YST.txt"; //StreamWriter sw = new StreamWriter(filePath, true); //sw.Write("测试开始。。。"); //sw.Close(); 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) { //设定头像路径及文件名 string dir = HttpContext.Current.Server.MapPath(ConstantParam.SHOP_IMG_DIR); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //设置商家封面 if (!string.IsNullOrEmpty(model.ShopImage)) { 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.ShopImage); bw.Write(datas); bw.Close(); } } //封面路径保存 shop.ImgPath = PropertyUtils.UnZip(filepath, dir, ConstantParam.SHOP_IMG_DIR); StringBuilder imgsSB = new StringBuilder(); //生成缩略图保存 foreach (var path in shop.ImgPath.Split(';')) { string thumpFile = DateTime.Now.ToFileTime() + ".jpg"; string thumpPath = Path.Combine(HttpContext.Current.Server.MapPath(ConstantParam.SHOP_THUM_IMG_DIR), thumpFile); PropertyUtils.getThumImage(Path.Combine(HttpContext.Current.Server.MapPath(path)), 18, 3, thumpPath); imgsSB.Append(ConstantParam.SHOP_THUM_IMG_DIR + thumpFile + ";"); } shop.ImgThumbnail = imgsSB.ToString(); shop.ImgThumbnail = shop.ImgThumbnail.Substring(0, shop.ImgThumbnail.Length - 1); } shopBll.Update(shop); } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }