Exemple #1
0
 /// <summary>
 /// 购物车商品条目数
 /// </summary>
 /// <param name="entId">企业</param>
 /// <param name="userId">用户</param>
 /// <param name="ywyId">业务员</param>
 /// <returns></returns>
 public ActionResult NumberOfItems(string entId, string userId, string ywyId = "")
 {
     try
     {
         if (string.IsNullOrEmpty(userId))
         {
             return(Json(new { success = false, message = "用户未登录,请先登录" }));
         }
         ///获取用户信息
         UserInfoDal     dal  = new UserInfoDal();
         List <UserInfo> user = dal.GetUserInfo(userId, entId);
         if (user.Count <= 0)
         {
             return(Json(new { success = false, message = "用户未登录,请重新登录" }));
         }
         ///获取购物车信息
         CartDal cdal = new CartDal();
         int     num  = cdal.GetCartCount(entId, userId, ywyId);
         return(Json(new { success = true, message = "购物车商品条目数获取成功", num }));
     }
     catch (Exception ex)
     {
         LogQueue.Write(LogType.Error, "Cart/NumberOfItems", ex.Message.ToString());
         return(Json(new { success = false, message = ex.Message.ToString() }));
     }
 }
Exemple #2
0
        /// <summary>
        /// 商品添加购物车
        /// </summary>
        /// <param name="entId">企业id</param>
        /// <param name="userId">用户id</param>
        /// <param name="article_Id">商品id</param>
        /// <param name="quantity">数量</param>
        /// <param name="cartType">购物车类型</param>
        /// <param name="fabh">促销方案编号</param>
        /// <param name="bs">'XQ'商品详情/''购物车</param>
        /// <returns></returns>
        public JsonResult CartAdd(string entId, string userId, string article_Id, decimal quantity, string cartType, string fabh, string bs = "", string ywyId = "")
        {
            try
            {
                ///获取用户信息
                UserInfoDal     userInfo = new UserInfoDal();
                List <UserInfo> user     = userInfo.GetUserInfo(userId ?? "", entId);

                if (string.IsNullOrEmpty(userId))
                {
                    return(Json(new { success = false, message = "用户未登录,请先登录" }));
                }
                else if (quantity <= 0)
                {
                    return(Json(new { success = false, message = "购买数量不能小于0" }));
                }
                else if (user[0].Status == 1)
                {
                    return(Json(new { success = false, message = "该账号未通过审核,无法购买商品" }));
                }
                ////客户经营范围拦截
                CartDal dal  = new CartDal();
                bool    flag = dal.CartAdd(entId, userId, article_Id, quantity, cartType, fabh, bs, ywyId);
                if (flag)
                {
                    ///获取购物车条目数
                    int num = dal.GetCartCount(entId, userId, ywyId);
                    return(Json(new { success = true, num = num, message = "加入购物车成功" }));
                }
                else
                {
                    return(Json(new { success = true, message = "加入失败" }));
                }
            }
            catch (Exception ex)
            {
                LogQueue.Write(LogType.Error, "Cart/CartAdd", ex.Message.ToString());
                return(Json(new { success = false, message = ex.Message.ToString() }));
            }
        }