/// <summary>
        /// get specified order by order code.
        /// </summary>
        /// <param name="orderCode">order id</param>
        /// <returns></returns>
        public async Task <(bool Succeed, OrderItemResult Order, string ErrorMessage)> GetOrder(int userId,
                                                                                                string orderCode)
        {
            var order = await Dapper.QueryFirstOrDefaultAsync <OrderItemResult>(
                "select OrderCode,OrderStatus,PayStatus,CreatedOn,Result from `Order` where OrderCode=@orderCode and UserId=@userId",
                new { orderCode, userId });

            if (order == null)
            {
                return(false, null, "order not exists");
            }
            var lstDetail = await Dapper.QueryAsync <NewOrderDetail>(
                "select OrderCode,GoodsId,Count,Price from OrderDetail where OrderCode=@orderCode", new { orderCode });

            var lstGoodsId = lstDetail.Select(i => i.GoodsId).ToList();
            var lstGoods   = await GoodsService.GoodsInfos(lstGoodsId);

            order.GoodsInfos = new List <GoodsInfoObj>();
            lstDetail.ForEach(j =>
            {
                var srcGoods = lstGoods.FirstOrDefault(k => k.Id == j.GoodsId);
                order.GoodsInfos.Add(new GoodsInfoObj
                {
                    Count   = j.Count,
                    GoodsId = j.GoodsId,
                    Price   = j.Price,
                    Pic     = srcGoods?.Pic,
                    Title   = srcGoods?.Title
                });
            });
            order.Amount = order.GoodsInfos.Sum(k => k.Count * k.Price);
            return(true, order, "");
        }
        /// <summary>
        /// get all orders from user id.
        /// </summary>
        /// <param name="userId">user id</param>
        /// <returns></returns>
        public async Task <List <OrderItemResult> > GetAllOrder(int userId)
        {
            var lstOrder = await Dapper.QueryAsync <OrderItemResult>(
                "select OrderCode,OrderStatus,PayStatus,CreatedOn,Result from `Order` where UserId=@userId order by CreatedOn desc",
                new { userId });

            var lstCode        = lstOrder.Select(i => i.OrderCode).ToList();
            var lstOrderDetail = await Dapper.QueryAsync <NewOrderDetail>(
                "select OrderCode,GoodsId,Count,Price from OrderDetail where OrderCode in @lstCode", new { lstCode });

            var lstGoodsId = lstOrderDetail.Select(i => i.GoodsId).ToList();
            var lstGoods   = await GoodsService.GoodsInfos(lstGoodsId);

            var result = new List <OrderItemResult>();

            lstOrder.ForEach(i =>
            {
                var order = new OrderItemResult
                {
                    CreatedOn   = i.CreatedOn,
                    OrderCode   = i.OrderCode,
                    OrderStatus = i.OrderStatus,
                    PayStatus   = i.PayStatus,
                    Result      = i.Result,
                    GoodsInfos  = new List <GoodsInfoObj>(),
                };
                var lstDetail = lstOrderDetail.Where(j => j.OrderCode == i.OrderCode).ToList();
                lstDetail.ForEach(j =>
                {
                    var srcGoods = lstGoods.FirstOrDefault(k => k.Id == j.GoodsId);
                    order.GoodsInfos.Add(new GoodsInfoObj
                    {
                        Count   = j.Count,
                        GoodsId = j.GoodsId,
                        Price   = j.Price,
                        Pic     = srcGoods?.Pic,
                        Title   = srcGoods?.Title
                    });
                });
                order.Amount = order.GoodsInfos.Sum(k => k.Count * k.Price);
                result.Add(order);
            });
            return(result);
        }