Esempio n. 1
0
        /// <summary>
        /// 添加商品到购物车
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="rq"></param>
        /// <returns></returns>
        public ResultDto <bool> AddShoppingCar(string uid, AddShoppingCarRQ rq)
        {
            var user = _userDomainService.GetUserByUID(uid);

            if (user == null)
            {
                return(Result <bool>(ResponseCode.sys_token_invalid, "获取用户信息错误"));
            }
            var isSave  = false;
            var product = _productDomainService.GetProductById(rq.ProductID);

            if (product == null)
            {
                return(Result <bool>(ResponseCode.sys_param_format_error, "商品不存在"));
            }
            var cardId = _ibll.wm_order_card.Where(q => q.UID == uid && q.DataStatus == (byte)DataStatus.Enable)
                         .Select(a => a.ID).First();

            if (cardId == 0)
            {
                cardId = _ibll.wm_order_card.AddReturnId(new wm_order_card
                {
                    UID        = uid,
                    Checked    = false,
                    CreateTime = DateTime.Now,
                    DataStatus = (byte)DataStatus.Enable,
                });
            }
            isSave = _ibll.wm_order_card_info.Add(new wm_order_card_info
            {
                Order_CardID = cardId,
                DataStatus   = (byte)DataStatus.Enable,
                ProductID    = product.ID,
                Product_Num  = rq.ProductNumber,
                CreateTime   = DateTime.Now,
            });
            return(Result(isSave));
        }
 public ProductResponse GetProductById(Guid id)
 {
     return(_productDomainService.GetProductById(id).MapToResponse());
 }