Пример #1
0
 /// <summary>
 /// 获取配送方式
 /// </summary>
 /// <param name="deliveryId"></param>
 /// <returns></returns>
 public Base_Deliver GetDeliverInfo(int deliveryId)
 {
     using (var db = new HolycaEntities())
     {
         var queryTxt = from a in db.Base_Deliver
                        where a.intDeliverID == deliveryId
                        select a;
         return queryTxt.FirstOrDefault();
     }
 }
Пример #2
0
        /// <summary>
        /// 获取商品图片列表
        /// </summary>
        /// <param name="gid"></param>
        /// <returns></returns>
        public List<Pdt_Pic> GetGoodsPicList(int gid)
        {
            var holycaDb = new HolycaEntities();

            var queryTxt = from c in holycaDb.Pdt_Pic
                           where c.intProductID == gid && c.intIsEnable == 1
                           orderby c.vchPicType ascending
                           select c;

            return queryTxt.ToList();
        }
Пример #3
0
        /// <summary>
        /// 删除购物车中的商品信息
        /// </summary>
        /// <param name="shoppingCartId">购物车ID</param>
        /// <returns></returns>
        public bool DeleteShoppingCartByProductIdUserID(int shoppingCartId)
        {
            var holycaDb = new HolycaEntities();

            Sale_ShoppingCart queryTxt = holycaDb.Sale_ShoppingCart.Where(c => c.intShopCartID == shoppingCartId).FirstOrDefault();

            holycaDb.DeleteObject(queryTxt);

            holycaDb.SaveChanges();

            return true;
        }
Пример #4
0
 /// <summary>
 /// 获取全部地区数据
 /// </summary>
 /// <param name="regionType">地区类型</param>
 /// <returns></returns>
 public List<Base_Region> GetAllRegionList(int regionType)
 {
     using (var holycaDb = new HolycaEntities())
     {
         IQueryable<Base_Region> queryTxt = from a in holycaDb.Base_Region
                                            orderby a.intRegionID ascending
                                            select a;
         if (regionType > 0)
             queryTxt = queryTxt.Where(c => c.intRegionType == regionType);
         return queryTxt.ToList();
     }
 }
Пример #5
0
 /// <summary>
 /// 计算运费
 /// </summary>
 /// <param name="weight"></param>
 /// <param name="deliveId"></param>
 /// <param name="cityId"></param>
 /// <returns></returns>
 public decimal GetCarriage(long weight, int deliveId, int cityId)
 {
     using (var db = new HolycaEntities())
     {
         decimal result = 0;
         var objectParams = new System.Data.Objects.ObjectParameter("intcarriage", DbType.Int32);
         var carriage = db.Up_ShopCart_GetCarriage((int)weight, deliveId, cityId, objectParams);
         var upOutPutValue = MCvHelper.To<int>(objectParams.Value, 0);
         if (upOutPutValue > 0)
             result = upOutPutValue / 100;
         return result;
     }
 }
Пример #6
0
 /// <summary>
 /// 清除购物车数据
 /// </summary>
 /// <param name="userId"></param>
 public void ClearShoppingCart(int userId)
 {
     using (var db = new HolycaEntities())
     {
         var queryTxt = from a in db.Sale_ShoppingCart
                        where a.intUserID == userId
                        select a;
         var shoppingCartList = queryTxt.ToList();
         foreach (var saleShoppingCart in shoppingCartList)
         {
             db.Sale_ShoppingCart.DeleteObject(saleShoppingCart);
         }
         db.SaveChanges();
     }
 }
Пример #7
0
 /// <summary>
 /// 增加购物车商品信息
 /// </summary>
 /// <param name="shoppingCartEntity">购物车信息实体</param>
 /// <returns></returns>
 public bool AddShoppingCartProductInfo(ShoppingCartEntity shoppingCartEntity)
 {
     var holycaDb = new HolycaEntities();
     Sale_ShoppingCart sale_ShoppingCart = new Sale_ShoppingCart();
     MCvHelper.ObjectCopyTo(shoppingCartEntity, sale_ShoppingCart);
     try
     {
         holycaDb.Sale_ShoppingCart.AddObject(sale_ShoppingCart);
         holycaDb.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Пример #8
0
        /// <summary>
        /// 获取配送方式列
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="regionId"></param>
        /// <param name="payGroupId"></param>
        /// <returns></returns>
        public List<Base_Deliver> GetDeliverList(int channelId, int regionId, int payGroupId)
        {
            var holycaDb = new HolycaEntities();
            var queryTxt = from s in holycaDb.Base_Deliver
                           where (
                           from a in holycaDb.Base_Deliver_Pay
                           join b in holycaDb.Base_Deliver_Area on a.intDeliverID equals b.intDeliverID
                           join c in holycaDb.Base_Pay_Type on a.intPayID equals c.intPayID
                           where b.intIsEnable == 1 && b.intRegionID == regionId
                           && c.intIsEnable == 1 && c.intPayGroup == payGroupId
                           select a.intDeliverID).Contains(s.intDeliverID)
                           select s;
            var result = queryTxt.ToList();

            return result;
        }
Пример #9
0
 /// <summary>
 /// 获取购物车商品数量
 /// </summary>
 /// <param name="token"> </param>
 /// <param name="channelId"></param>
 /// <param name="uid"></param>
 /// <param name="user_id"> </param>
 /// <returns></returns>
 public int GetShoppingCartGoodsNum(string token, int channelId, string uid, int user_id)
 {
     using (var holycaDb = new HolycaEntities())
     {
         var queryTxt = from c in holycaDb.Sale_ShoppingCart
                        where c.intChannelID == channelId
                              && c.intIsDelete == 0
                        select c;
         if (user_id > 0)
             queryTxt = queryTxt.Where(w => w.intUserID == user_id);
         else if (!string.IsNullOrEmpty(token))
             queryTxt = queryTxt.Where(w => w.vchGuid == token);
         else return 0;
         try
         {
             var result = queryTxt.Sum(c => (int?)c.intBuyCount);
             return MCvHelper.To<int>(result, 0);
         }
         catch
         {
             return -1;
         }
     }
 }
Пример #10
0
 /// <summary>
 /// 设置购物车商品数量
 /// </summary>
 /// <param name="user_id"></param>
 /// <param name="guid"></param>
 /// <param name="shoppingCartId"></param>
 /// <param name="num"></param>
 /// <returns></returns>
 public bool SetShoppingCartGoodsNum(int user_id, string guid, int shoppingCartId, int num)
 {
     var result = false;
     if (num > 0)
     {
         using (var holycaDb = new HolycaEntities())
         {
             var shoppingCartEntity = holycaDb.Sale_ShoppingCart.First(s => s.intShopCartID == shoppingCartId);
             if (shoppingCartEntity != null)
             {
                 try
                 {
                     shoppingCartEntity.intBuyCount = num;
                     holycaDb.SaveChanges();
                     result = true;
                 }
                 catch (Exception)
                 {
                     holycaDb.Refresh(RefreshMode.ClientWins, shoppingCartEntity);
                     holycaDb.SaveChanges();
                     result = false;
                 }
             }
         }
     }
     return result;
 }
Пример #11
0
 /// <summary>
 /// 获取购物车总金额
 /// </summary>
 /// <param name="user_id"></param>
 /// <param name="guid"></param>
 /// <param name="channelId"> </param>
 /// <returns></returns>
 public decimal GetShoppingTotal(int user_id, string guid, int channelId)
 {
     decimal result = 0;
     using (var holycaDb = new HolycaEntities())
     {
         if (user_id > 0 || !string.IsNullOrEmpty(guid))
         {
             var queryTxt = from a in holycaDb.Sale_ShoppingCart where a.intChannelID == channelId && a.intIsDelete == 0 select a;
             if (user_id > 0)
                 queryTxt = queryTxt.Where(w => w.intUserID == user_id);
             else if (!string.IsNullOrEmpty(guid))
                 queryTxt = queryTxt.Where(w => w.vchGuid == guid);
             try
             {
                 result = MCvHelper.To<decimal>(queryTxt.Sum(s => (decimal?)(s.intBuyCount * s.numSalePrice)), 0);
             }
             catch
             {
                 result = -1;
             }
         }
     }
     return result;
 }
Пример #12
0
 /// <summary>
 /// 获取支付信息
 /// </summary>
 /// <param name="payId"></param>
 /// <returns></returns>
 public Base_Pay_Type GetPaymentInfo(int payId)
 {
     using (var db = new HolycaEntities())
     {
         var queryTxt = from a in db.Base_Pay_Type
                        where a.intPayID == payId && a.intIsEnable == 1
                        select a;
         return queryTxt.First();
     }
 }
Пример #13
0
 /// <summary>
 /// 获取地区数据
 /// </summary>
 /// <param name="parentId"></param>
 /// <returns></returns>
 public List<Base_Region> GetRegionList(int parentId)
 {
     if (parentId < 0)
         parentId = 0;
     var holycaDb = new HolycaEntities();
     var queryTxt = from a in holycaDb.Base_Region
                    where a.intFRegionID == parentId
                    orderby a.intRegionID ascending
                    select a;
     return queryTxt.ToList();
 }
Пример #14
0
        /// <summary>
        /// 获取支付方式
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="regionId"> </param>
        /// <returns>list</returns>
        public List<ItemPay> GetPaymentList(int channelId, int regionId)
        {
            var result = new List<ItemPay>();

            var holycaDb = new HolycaEntities();
            var queryTxt = from a in holycaDb.Base_Pay_Type
                           join b in holycaDb.Base_Deliver_Pay on a.intPayID equals b.intPayID
                           join c in holycaDb.Base_Deliver_Area on b.intDeliverID equals c.intDeliverID
                           where c.intRegionID == regionId
                           group a by a.intPayGroup into g
                           select g;

            var payList = queryTxt.ToList();

            payList.ForEach(item =>
                                {
                                    if (item.Key == 0)
                                        result.Add(new ItemPay { payid = 0, payname = "货到付款", paytype = 0, remark = "(送货上门后再付款,支持现金或POS机刷卡)" });
                                    else if (item.Key == 1)
                                    {
                                        if (channelId != (int)SystemType.MobileWebSite)
                                            result.Add(new ItemPay { payid = 1, payname = "在线支付", paytype = 1, remark = "(支持绝大数银行借记卡及部分银行信息卡)" });
                                    }
                                    else if (item.Key == 3)
                                    {
                                        if (channelId == (int)SystemType.MobileWebSite)
                                            result.Add(new ItemPay { payid = 3, payname = "支付宝(手机)支付", paytype = 3, remark = "(支持支付宝)" });
                                    }

                                });

            result.Sort((l1, l2) => l2.payid.CompareTo(l1.payid));

            return result;
        }
Пример #15
0
        /// <summary>
        /// 获取商品列表数据
        /// </summary>
        /// <param name="clusterId">群Id</param>
        /// <param name="channelId">渠道id</param>
        /// <param name="categoryId">分类id</param>
        /// <param name="brandId">品牌id</param>
        /// <param name="starAge">开始年龄</param>
        /// <param name="endAge">结束年龄</param>
        /// <param name="startPrice">开始价格</param>
        /// <param name="endPrice">结束价格</param>
        /// <param name="sortType">排序类型</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <param name="pageIndex">分页索引</param>
        /// <param name="pageTotal">数据总数</param>
        /// <returns></returns>
        public List<Vi_Web_Pdt_List> GetGoodsList(int clusterId, int channelId, int categoryId, int brandId,
            int starAge, int endAge, decimal startPrice, decimal endPrice,
            SortType? sortType, int pageSize, int pageIndex,
            out int pageTotal)
        {
            channelId = 102;
            var holycaDb = new HolycaEntities();
            if (sortType == null)
                sortType = SortType.SalesDesc;

            var queryTxt = from c in holycaDb.Vi_Web_Pdt_List
                           where c.intHerdID == clusterId && c.intChannelID == channelId
                           select c;

            #region 处理查询条件

            if (categoryId > 0)
                queryTxt = queryTxt.Where(p => p.intWebType == categoryId || p.intWebChildType == categoryId || p.intWebThirdType == categoryId);

            if (brandId > 0)
                queryTxt = queryTxt.Where(p => p.intBrandID == brandId);

            if (starAge > 0)
                queryTxt = queryTxt.Where(p => p.intStartAge <= starAge);

            if (endAge > 0)
                queryTxt = queryTxt.Where(p => p.intEndAge >= endAge);

            if (startPrice > 0)
                queryTxt = queryTxt.Where(p => p.numHerdPrice >= startPrice);

            if (endPrice > 0)
                queryTxt = queryTxt.Where(p => p.numHerdPrice <= endPrice);

            switch (sortType)
            {
                case SortType.EnableTimeAsc:
                    queryTxt = queryTxt.OrderBy(o => o.intIsNew);
                    break;
                case SortType.EnableTimeDesc:
                    queryTxt = queryTxt.OrderByDescending(o => o.intIsNew);
                    break;
                case SortType.PriceAsc:
                    queryTxt = queryTxt.OrderBy(o => o.numHerdPrice);
                    break;
                case SortType.PriceDesc:
                    queryTxt = queryTxt.OrderByDescending(o => o.numHerdPrice);
                    break;
                case SortType.SalesAsc:
                    queryTxt = queryTxt.OrderBy(o => o.intSalesVolume);
                    break;
                case SortType.SalesDesc:
                    queryTxt = queryTxt.OrderByDescending(o => o.intSalesVolume);
                    break;
            }

            #endregion

            pageTotal = queryTxt.Count();
            var list = queryTxt.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();

            return list;
        }
Пример #16
0
        /// <summary>
        /// 获取当前用户的购物车中的商品信息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="guid">用户全局变量</param>
        /// <param name="channelId">渠道ID</param>
        /// <returns></returns>
        public List<ShoppingCartEntity> GetShoppingCartProductInfosByUserIDGuidChannelID(int userId, string guid, int channelId)
        {
            var holycaDb = new HolycaEntities();
            List<ShoppingCartEntity> resultList = new List<ShoppingCartEntity>();
            ShoppingCartEntity shoppingCartEntity;
            List<Sale_ShoppingCart> retList = new List<Sale_ShoppingCart>();

            //用户登录了就用userId查询,用户未登录用Guid查
            if (userId > 0)
            {
                var queryTxt = from c in holycaDb.Sale_ShoppingCart
                               where c.intUserID == userId && c.intChannelID == channelId
                               select c;
                retList = queryTxt.ToList();
            }
            else
            {
                var queryTxt = from c in holycaDb.Sale_ShoppingCart
                               where c.vchGuid == guid && c.intChannelID == channelId
                               select c;

                retList = queryTxt.ToList();
            }
            if (retList != null && retList.Count > 0)
            {
                foreach (Sale_ShoppingCart ssc in retList)
                {
                    shoppingCartEntity = new ShoppingCartEntity();
                    MCvHelper.ObjectCopyTo(ssc, shoppingCartEntity);
                    resultList.Add(shoppingCartEntity);
                }
            }
            return resultList;
        }
Пример #17
0
 /// <summary>
 /// 获取支付列表
 /// </summary>
 /// <param name="sType"></param>
 /// <param name="paygroupId"></param>
 /// <returns></returns>
 public List<Base_Pay_Type> GetPayList(SystemType sType, int paygroupId)
 {
     using (var db = new HolycaEntities())
     {
         var queryTxt = from a in db.Base_Pay_Type
                        where a.intPayGroup == paygroupId && a.intIsEnable == 1
                        orderby a.intSortID descending
                        select a;
         return queryTxt.ToList();
     }
 }