public ActionResult Index(string categoryid, string search, int sort = 0, int index = 1, int row = 5) { var data = new Models.ProductListModels.json_model(); try { if (AuthIsOpen) { var dic = new SortedDictionary <string, string>(); dic.Add("timestamp", Request["timestamp"]); VerifyAuthorize(dic); } var model = new List <Models.ProductListModels.result_model>(); var list = new Provider.ProductBasisProvider().GetList(categoryid, search, sort, index, row); var pic = ""; foreach (var item in list) { pic = new ERP.Common.FileHelper().GetWebFileUrl(item.PictureURL, Common.FileConfig.FileType.ProductPhoto.ToString()); model.Add(new Models.ProductListModels.result_model { pictureurl = pic, salecount = item.SaleCount, productid = item.Id, productname = item.ProductName, promoprice = item.PromoPrice, realprice = item.RealPrice, review = item.Review }); } data.response = (int)Extensions.ErrorInfo.OK; data.message = "成功"; data.result = model; } catch (Exception ex) { data.response = (int)Extensions.ErrorInfo.ServerError; data.message = "服务器内部错误"; Common.LogHelper.WriteLog(typeof(ProductCategoryController), ex); } return(Json(data)); }
public ActionResult ProdDetaile(string productid) { var response = 0; var message = ""; var result = ""; try { if (AuthIsOpen) { var dic = new SortedDictionary <string, string>(); dic.Add("timestamp", Request["timestamp"]); dic.Add("productid", productid); VerifyAuthorize(dic); } var info = new Provider.ProductBasisProvider().GetInfo(Common.ToolHelper.ConvertToLong(productid)); if (info != null) { response = (int)Extensions.ErrorInfo.OK; message = "成功"; result = info.ProductDetail; } else { response = 0; message = "请求失败"; } } catch (Exception ex) { response = (int)Extensions.ErrorInfo.ServerError; message = "服务器内部错误"; Common.LogHelper.WriteLog(typeof(ProductCategoryController), ex); } return(Json(new { response = response, message = message, result = result })); }
public ActionResult Index(string productid) { var data = new Models.ProductInfoModels.json_model(); try { if (string.IsNullOrEmpty(productid)) { return(Json(new { response = Extensions.ErrorInfo.ParameterError, message = "参数错误" })); } if (AuthIsOpen) { var dic = new SortedDictionary <string, string>(); dic.Add("timestamp", Request["timestamp"]); dic.Add("productid", productid); VerifyAuthorize(dic); } var product = new Models.ProductInfoModels.product_model(); //商品信息 var skuModel = new List <Models.ProductInfoModels.sku_model>(); //sku var propertity = new List <Models.ProductInfoModels.property>(); //商品属性 var proveder = new Provider.ProductBasisProvider(); var prod = proveder.GetProduct(Common.ToolHelper.ConvertToLong(productid)); var shop = new Cache.BIZ_ShopBasisCache().Get(Common.FormsTicket.SystemCode).Where(c => c.Id == prod.ShopId).FirstOrDefault(); if (prod.IsMoveProp == (int)Common.EnumModel.EIsMoveProp.OneProp) { product = new Models.ProductInfoModels.product_model { productid = prod.Id, salecount = prod.SaleCount, productname = prod.ProductName, promoprice = prod.PromoPrice, realprice = prod.RealPrice, review = prod.Review, ismoveprop = prod.IsMoveProp, stock = prod.Stock, shopid = prod.ShopId, shopname = shop.ShopName }; } else { product = new Models.ProductInfoModels.product_model { productid = prod.Id, salecount = prod.SaleCount, productname = prod.ProductName, promoprice = prod.PromoPrice, realprice = prod.RealPrice, review = prod.Review, ismoveprop = prod.IsMoveProp, stock = prod.Stock, shopid = prod.ShopId, shopname = shop.ShopName }; #region sku信息 var sku = new Provider.ProductSKUProvider().GetSKUByProd(Common.ToolHelper.ConvertToLong(productid)); var spic = ""; foreach (var item in sku) { spic = new ERP.Common.FileHelper().GetWebFileUrl(item.PictureURL, Common.FileConfig.FileType.ProductPhoto.ToString()); skuModel.Add(new Models.ProductInfoModels.sku_model { salecount = item.SaleCount, skuid = item.Id, stock = item.Stock, promoprice = item.PromoPrice, realprice = item.RealPrice, skustring = item.SKUString.Trim('-').Replace("-", ","), pictureurl = spic }); } #endregion #region 商品属性 var propValue = new List <Models.ProductInfoModels.property_value>(); var prop = new HashSet <int>(); //属性集合 var value = new HashSet <int>(); //属性值集合 var ps = prod.PropString.Split('|'); foreach (var item in ps[0].Split(',')) { prop.Add(Common.ToolHelper.ConvertToInt(item)); } foreach (var item in ps[1].Split(',')) { value.Add(Common.ToolHelper.ConvertToInt(item)); } var props = new Provider.ProductPropertyProvider().GetListByIds(prop); var values = new Provider.ProductPropertyProvider().GetValueByIds(prop); foreach (var item in props) { propValue = new List <Models.ProductInfoModels.property_value>(); foreach (var v in values.Where(c => c.PropertyId == item.Id)) { propValue.Add(new Models.ProductInfoModels.property_value { id = v.Id, name = v.Name }); } propertity.Add(new Models.ProductInfoModels.property { id = item.Id, name = item.PropName, values = propValue }); } #endregion } var picModel = new List <Models.ProductInfoModels.pic_model>(); #region 商品图片 var pics = proveder.GetPic(Common.ToolHelper.ConvertToLong(productid)); var pic = ""; foreach (var item in pics) { pic = new ERP.Common.FileHelper().GetWebFileUrl(item.PictureURL, Common.FileConfig.FileType.ProductPhoto.ToString()); picModel.Add(new Models.ProductInfoModels.pic_model { pictureurl = pic }); } #endregion var model = new Models.ProductInfoModels.result_model() { picture = picModel, sku = skuModel, product = product, property = propertity }; data.response = (int)Extensions.ErrorInfo.OK; data.message = "成功"; data.result = model; } catch (Exception ex) { data.response = (int)Extensions.ErrorInfo.ServerError; data.message = "服务器内部错误"; Common.LogHelper.WriteLog(typeof(ProductCategoryController), ex); } return(Json(data)); }
public ActionResult TempOrder(string token, string memberid, string productid, int quantity, string skuid = "") { var data = new Models.TempOrderModels.json_model(); try { if (string.IsNullOrEmpty(memberid) || string.IsNullOrEmpty(token) || string.IsNullOrEmpty(productid) || quantity == 0) { return(Json(new { response = Extensions.ErrorInfo.ParameterError, message = "参数错误" })); } var tc = new Cache.MemberTokenCache().Get(token); if (tc == null) { return(Json(new { response = Extensions.ErrorInfo.TokenError, message = "token验证失败请重新登录" })); } if (AuthIsOpen) { var dic = new SortedDictionary <string, string>(); dic.Add("timestamp", Request["timestamp"]); dic.Add("memberid", memberid); dic.Add("token", token); dic.Add("productid", productid); dic.Add("quantity", quantity.ToString()); VerifyAuthorize(dic); } #region 业务处理 var pro = new Provider.ProductBasisProvider().GetProduct(Common.ToolHelper.ConvertToLong(productid)); if (pro != null) { decimal price = 0;//有优惠需要计算优惠后的价格 string pic = ""; string skuName = ""; if (!string.IsNullOrEmpty(skuid)) { var sku = new Provider.ProductSKUProvider().GetSKU(Common.ToolHelper.ConvertToLong(skuid)); if (sku != null) { price = sku.PromoPrice; pic = sku.PictureURL; skuName = sku.SKUName; } } else { price = pro.PromoPrice; pic = pro.PictureURL; } var entity = new Entitys.Order_TempOrderBasis() { OrderId = Common.PrimaryKey.GetHashCodeID, ShopId = pro.ShopId, OrderPrice = price, MemberId = Common.ToolHelper.ConvertToLong(memberid), CreateTime = DateTime.Now, IsCart = 0 }; var detail = new List <Entitys.Order_TempOrderDetail>(); var info = new Entitys.Order_TempOrderDetail() { SKUId = Common.ToolHelper.ConvertToLong(skuid), SKUName = skuName, IsGift = 0, OrderId = entity.OrderId, PayPrice = price, PictureURL = pic, ProductId = Common.ToolHelper.ConvertToLong(productid), Quantity = quantity, ProductName = pro.ProductName, ProductPrice = pro.RealPrice, CartId = Common.Constant.LONG_DEFAULT, CreateTime = DateTime.Now }; detail.Add(info); var line = new Provider.TempOrderProvider().AddTempOrder(entity, detail); if (line > 0) { var dinfo = new List <Models.TempOrderModels.detail>(); foreach (var item in detail) { dinfo.Add(new Models.TempOrderModels.detail { skuid = item.SKUId, skuname = item.SKUName, isgift = item.IsGift, orderid = item.OrderId, payprice = item.PayPrice, pictureurl = new ERP.Common.FileHelper().GetWebFileUrl(item.PictureURL, Common.FileConfig.FileType.ProductPhoto.ToString()), productid = item.ProductId, productname = item.ProductName, productprice = item.ProductPrice, quantity = item.Quantity }); } var model = new Models.TempOrderModels.result_model() { orderid = entity.OrderId, shopid = entity.ShopId, list = dinfo, orderprice = entity.OrderPrice, }; data.response = (int)Extensions.ErrorInfo.OK; data.message = "成功"; data.result = model; } else { data.response = (int)Extensions.ErrorInfo.UpError; data.message = "失败"; } } else { data.response = (int)Extensions.ErrorInfo.ParameterError; data.message = "提交信息有误"; } #endregion } catch (Exception ex) { data.response = (int)Extensions.ErrorInfo.ServerError; data.message = "服务器内部错误"; Common.LogHelper.WriteLog(typeof(TempOrderController), ex); } return(Json(data)); }
public ActionResult TempCardOrder() { var param = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.TempOrderModels.param>(Request["param"]); //TODO:修改为json格式获取参数 var data = new Models.TempOrderModels.cart_json(); try { if (string.IsNullOrEmpty(param.memberid) || string.IsNullOrEmpty(param.token)) { return(Json(new { response = Extensions.ErrorInfo.ParameterError, message = "参数错误" })); } var tc = new Cache.MemberTokenCache().Get(param.token); if (tc == null) { return(Json(new { response = Extensions.ErrorInfo.TokenError, message = "token验证失败请重新登录" })); } if (AuthIsOpen) { var dic = new SortedDictionary <string, string>(); dic.Add("timestamp", param.timestamp); dic.Add("memberid", param.memberid); dic.Add("token", param.token); VerifyAuthorize(dic, param.timestamp, param.imei, param.sign); } var cartProvider = new Provider.ShoppingCartProvider(); var order = new List <Entitys.Order_TempOrderBasis>(); var detail = new List <Entitys.Order_TempOrderDetail>(); //选中购物车需要结算的商品 foreach (var item in param.shop) { var entity = new Entitys.Order_TempOrderBasis() { OrderId = Common.PrimaryKey.GetHashCodeID, ShopId = Common.ToolHelper.ConvertToLong(item.shopid), OrderPrice = 0, MemberId = Common.ToolHelper.ConvertToLong(param.memberid), CreateTime = DateTime.Now, IsCart = 1 }; decimal amount = 0; foreach (var pro in item.product) { var cart = cartProvider.GetCartProd(Common.ToolHelper.ConvertToLong(pro.cartid)); if (cart != null) { var pd = new Provider.ProductBasisProvider().GetProduct(cart.ProductId); decimal price = pd.PromoPrice;//有优惠需要计算优惠后的价格 string pic = pd.PictureURL; string skuName = ""; if (pd.IsMoveProp == (int)Common.EnumModel.EIsMoveProp.MoveProp) { var sku = new Provider.ProductSKUProvider().GetSKU(Common.ToolHelper.ConvertToLong(cart.SKUId)); if (sku != null) { price = sku.PromoPrice; pic = sku.PictureURL; skuName = sku.SKUName; } } var info = new Entitys.Order_TempOrderDetail() { CartId = cart.Id, SKUId = cart.SKUId, SKUName = skuName, IsGift = 0, OrderId = entity.OrderId, PayPrice = price, PictureURL = pic, ProductId = cart.ProductId, Quantity = pro.quantity, ProductName = pd.ProductName, ProductPrice = pd.RealPrice, CreateTime = DateTime.Now }; amount += info.PayPrice; detail.Add(info); } } entity.OrderPrice = amount; order.Add(entity); } #region 业务处理 var line = new Provider.TempOrderProvider().AddTempOrder(order, detail); if (line > 0) { var result = new List <Models.TempOrderModels.result_model>(); var prod = new List <Models.TempOrderModels.detail>(); foreach (var item in order) { prod = new List <Models.TempOrderModels.detail>(); foreach (var pro in detail.Where(c => c.OrderId == item.OrderId)) { prod.Add(new Models.TempOrderModels.detail { isgift = pro.IsGift, skuid = pro.SKUId, skuname = pro.SKUName, orderid = pro.OrderId, payprice = pro.PayPrice, pictureurl = pro.PictureURL, productid = pro.ProductId, productname = pro.ProductName, productprice = pro.ProductPrice, quantity = pro.Quantity }); } result.Add(new Models.TempOrderModels.result_model { orderid = item.OrderId, shopid = item.ShopId, orderprice = item.OrderPrice, list = prod }); } } else { data.response = (int)Extensions.ErrorInfo.UpError; data.message = "失败"; } #endregion } catch (Exception ex) { data.response = (int)Extensions.ErrorInfo.ServerError; data.message = "服务器内部错误"; Common.LogHelper.WriteLog(typeof(TempOrderController), ex); } return(Json(data)); }