コード例 #1
0
ファイル: Operation.cs プロジェクト: jk464479460/target
        public void UpdateCartGoInfo(Tb_CartGo cartGo, string oldId)
        {
            var cmd = new DataCommand("mySql", "UpdateCartGoInfo");

            cmd.SetParameters("@userId", cartGo.UserId);
            cmd.SetParameters("@Oldid", oldId);
            cmd.ExeSqlCmd();
        }
コード例 #2
0
ファイル: GoodsHanlder.cs プロジェクト: jk464479460/target
        public ResultAddToCart AddToCart(QueryAddCart query)
        {
            var result = new ResultAddToCart {
                Exception = new MyException()
            };

            try
            {
                var valiResult = ValidateAddCart(query.Code, query.Count);
                if (!valiResult.Equals("1"))
                {
                    result.Exception.Success = false;
                    result.Exception.Exmsg   = valiResult;
                    return(result);
                }
                query.Uid = query.Uid.Substring(1, query.Uid.Length - 2);
                var realSession = string.Empty;
                if (!ValidateClient(query.Uid, ref realSession))
                {
                    result.Exception.Success = false;
                    result.Exception.Exmsg   = "02";
                    return(result);
                }
                var whereStr = $" and good.Code={query.Code}";
                var res      = _goodsHandler.GetGoodsInfoByName(whereStr);

                {
                    var cartGo = new Tb_CartGo {
                        UserId = realSession, StockCode = query.Code, BuyCnt = query.Count, CurPrice = decimal.Parse(res[0].Price), CreateTime = DateTime.Now
                    };
                    var sessionArr = GetSession(realSession);
                    cartGo.TempUser = 1;
                    cartGo.UserId   = realSession;//realSession.Split('_')[0];
                    if (sessionArr.Length == 3)
                    {
                        cartGo.TempUser = 0;
                        cartGo.UserId   = sessionArr.GetValue(2).ToString();
                    }
                    _goodsHandler.AddStockToCart(cartGo);
                    result.Exception.Success = true;
                }
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                result.Exception.Exmsg   = $"{ex.Message}";
                AppLogger.Error($"{ex.StackTrace} {query.Uid} {query.Code} {query.Count}");
            }
            return(result);
        }
コード例 #3
0
ファイル: Operation.cs プロジェクト: jk464479460/target
        public void AddStockToCart(Tb_CartGo cartGo)
        {
            var cmd    = new DataCommand();
            var findIt = cmd.Search <Tb_CartGo>(x => x.StockCode.Equals(cartGo.StockCode) && x.UserId.Equals(cartGo.UserId) && x.IsPay != 1);

            if (findIt != null)
            {
                findIt.BuyCnt  += cartGo.BuyCnt;
                findIt.CurPrice = cartGo.CurPrice;
                DataCommand.Update(findIt);
                return;
            }
            cmd = new DataCommand("mySql", "InsertGoodsCartGo");
            cmd.SetParameters("@UserId", cartGo.UserId);
            cmd.SetParameters("@StockCode", cartGo.StockCode);
            cmd.SetParameters("@BuyCnt", $"{cartGo.BuyCnt}");
            cmd.SetParameters("@CurPrice", $"{cartGo.CurPrice}");
            cmd.SetParameters("@TempUser", $"{cartGo.TempUser}");
            cmd.SetParameters("@CreateTime", cartGo.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
            cmd.ExeSqlCmd();
        }