Exemple #1
0
        public ActionResult Info(int sellerId, int productId)
        {
            string      msg;
            ProductInfo productInfo = null;
            BuyerInfo   user        = Session["User"] as BuyerInfo;

            if (user == null)
            {
                return(View(productInfo));
            }

            productInfo = ProductInfoBll.GetModel(sellerId, productId, out msg);


            var list = BuyerInfoBll.GetBuyerProductView(user.BuyerId, sellerId);


            BuyerProductView productInfo1 = list.FirstOrDefault(p => p.ProductId == productId);

            if (productInfo == null)
            {
                productInfo = new ProductInfo()
                {
                    ProductFullName = "商品信息有误"
                }
            }
            ;


            return(View(productInfo));
        }
Exemple #2
0
        /// <summary>
        /// 根据买家Id,商品类别,返回指定卖家上线商品信息列表
        /// BuyerProductView不是表记录,而是业务封装视图。
        /// gongjun@2016-12-05
        /// </summary>
        /// <param name="buyerId"></param>
        /// <param name="sellerId"></param>
        /// <returns></returns>
        public static List <BuyerProductView> GetBuyerProductView(int buyerId, int sellerId)
        {
            //xieguanheng 增加字段 SellerId 的返回  20161231
            var list = new List <BuyerProductView>();
            var sql  = "Select T1.[SellerId],T1.[ClassId], T1.ProductId,[ProductCode],[ProductFullName],[ProductShortName],ProductUnit"
                       + ",[Picture1],[Picture2],[Picture3],[Picture4],[Picture5],[Picture6]"
                       + ",T2.[Price1],T2.[MinOrder1],T2.[MaxOrder1],T2.IsNew,T2.IsPromotion,T3.[ProductQuantity]"
                       + " From [dbo].[ProductInfo] T1"
                       + " Left Join [SellerProductOnlineCustomerStrategy] T2"
                       + " On T1.[ProductId]= T2.[ProductId]"
                       + " Inner Join [BuyerShoppingCart] T3"
                       + " On T1.[ProductId]=T3.[ProductId]"
                       + string.Format("Where T1.[SellerId]= {0}  And T2.BuyerId = {1}"
                                       , sellerId, buyerId)
                       + " And [SaleStartDate]<GETDATE() And[SaleEndDate]>GETDATE()";
            var dt = BaseBll <object> .ExecuteDataTable(sql, GetConnectionString(sellerId));

            if (dt.Rows.Count == 0)
            {
                sql = "Select T1.[SellerId],T1.[ClassId], T1.ProductId,[ProductCode],[ProductFullName],[ProductShortName],ProductUnit"
                      + ",[Picture1],[Picture2],[Picture3],[Picture4],[Picture5],[Picture6]"
                      + ",T2.[Price1],T2.[MinOrder1],T2.[MaxOrder1],T2.IsNew,T2.IsPromotion,T3.[ProductQuantity]"
                      + " From [dbo].[ProductInfo] T1"
                      + " Left Join [SellerProductOnline] T2"
                      + " On T1.[ProductId]= T2.[ProductId]"
                      + " Inner Join [BuyerShoppingCart] T3"
                      + " On T1.[ProductId]=T3.[ProductId]"
                      + string.Format("Where T1.[SellerId]= {0} And T2.SaleState=1"
                                      , sellerId)
                      + " And [SaleStartDate]<GETDATE() And[SaleEndDate]>GETDATE()";
                dt = BaseBll <object> .ExecuteDataTable(sql, GetConnectionString(sellerId));
            }
            foreach (DataRow row in dt.Rows)
            {
                var view = new BuyerProductView();
                view.SellerId         = Convert.ToInt32(row["SellerId"]);
                view.ClassId          = Convert.ToInt32(row["ClassId"]);
                view.ProductId        = Convert.ToInt32(row["ProductId"]);
                view.ProductCode      = row["ProductCode"].ToString();
                view.ProductFullName  = row["ProductFullName"].ToString();
                view.ProductShortName = row["ProductShortName"].ToString();
                view.ProductUnit      = row["ProductUnit"].ToString();
                view.Picture1         = Convert.ToInt32(row["Picture1"]);
                view.Picture2         = Convert.ToInt32(row["Picture2"]);
                view.Picture3         = Convert.ToInt32(row["Picture3"]);
                view.Picture4         = Convert.ToInt32(row["Picture4"]);
                view.Picture5         = Convert.ToInt32(row["Picture5"]);
                view.Price1           = Convert.ToSingle(row["Price1"]);
                view.MinOrder1        = Convert.ToInt16(row["MinOrder1"]);
                view.MaxOrder1        = Convert.ToInt32(row["MaxOrder1"]);
                view.IsNew            = Convert.ToBoolean(row["IsNew"]);
                view.IsPromotion      = Convert.ToBoolean(row["IsPromotion"]);
                try
                {
                    view.ProductQuantity = Convert.ToInt32(row["ProductQuantity"]);
                }
                catch (Exception ex)
                {
                    view.ProductQuantity = 0;
                }
                list.Add(view);
            }
            return(list);
        }