/// <summary>
        /// 延迟订单有效期
        /// </summary>
        /// <param name="id">订单id</param>
        /// <param name="sellerId"></param>
        /// <param name="day"></param>
        /// <returns></returns>
        public bool OrderDelay(string id, int sellerId, int day)
        {
            return(Try(nameof(OrderDelay), () =>
            {
                var cmd = SqlBuilder.Update("orderinfo")
                          .Column("ExpiredOn=date_add(now(),interval " + day + " day)")
                          .Where("Id=@Id and SellerId=@sellerId", new { id, sellerId })
                          .ToCommand();

                return TradeConn.Execute(cmd) > 0;
            }));
        }
        /*
         * /// <summary>
         * /// 更新订单状态
         * /// </summary>
         * /// <param name="id">订单id</param>
         * /// <param name="status">订单状态</param>
         * /// <returns></returns>
         * public bool OrderStatusUpdate(string id, OrderStatus status)
         * {
         *  return Try(nameof(OrderStatusUpdate), () =>
         *  {
         *      var sql = @"update orderinfo set status=@statue where id=@id";
         *
         *      return TradeConn.Execute(sql, new { id, status }) > 0;
         *  });
         * }
         */

        /// <summary>
        /// 更新订单已付金额及状态
        /// </summary>
        /// <param name="id">订单id</param>
        /// <param name="amount">本次支付金额</param>
        /// <param name="done">是否已付清(付清后如果是在线支付订单则会更新订单状态为已付款待发货并更新订单有效期)</param>
        /// <returns></returns>
        public bool OrderPaid(string id, decimal amount, bool done)
        {
            var time   = DateTime.Now;
            var expire = time.AddDays(7);

            return(Try(nameof(OrderPaid), () =>
            {
                var sql = @"update orderinfo set Paid=Paid+@amount,PaidOn=@time where status=2 and id=@id";
                if (done)
                {
                    sql = @"update orderinfo set Paid=Paid+@amount,PaidOn=@time,ExpiredOn=@expire,Status=3 where status=2 and id=@id";
                }
                return TradeConn.Execute(sql, new { id, amount, time, expire }) > 0;
            }));
        }
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="id">订单id</param>
        /// <param name="userId">用户id</param>
        /// <param name="isSeller">是否为卖家</param>
        /// <param name="cancelId">取消类型 0为none 1为系统取消 2为买家取消 3为卖家取消</param>
        /// <param name="cancelReason">取消原因</param>
        /// <returns></returns>
        public bool OrderCancel(string id, int userId, bool isSeller, byte cancelId, string cancelReason = "")
        {
            return(Try(nameof(OrderMemoGet), () =>
            {
                var cmd = SqlBuilder.Update("orderinfo")
                          .Column("Status", OrderStatus.Canceled)
                          .Column("CancelId", cancelId)
                          .Column("CancelReason", cancelReason)
                          .Column("FinishedOn", DateTime.Now)
                          .Where(isSeller ? "SellerId=@userId" : "BuyerId=@userId", new { userId })
                          .Where("Id=@Id", new { id })
                          .ToCommand();

                return TradeConn.Execute(cmd) > 0;
            }));
        }
        /// <summary>
        /// 更新订单备注
        /// </summary>
        /// <param name="id">订单id</param>
        /// <param name="userId">用户id</param>
        /// <param name="isSeller">是否为卖家</param>
        /// <param name="flag">标识</param>
        /// <param name="memo">备注</param>
        /// <returns></returns>
        public bool OrderMemoUpdate(string id, int userId, bool isSeller, byte flag, string memo)
        {
            return(Try(nameof(OrderMemoGet), () =>
            {
                var cmd = SqlBuilder.Update("orderinfo")
                          .Column(isSeller, "SellerFlag", flag)
                          .Column(isSeller, "SellerMemo", memo)
                          .Column(!isSeller, "BuyerFlag", flag)
                          .Column(!isSeller, "BuyerMemo", memo)
                          .Where(isSeller ? "SellerId=@userId" : "BuyerId=@userId", new { userId })
                          .Where("Id=@Id", new { id })
                          .ToCommand();

                return TradeConn.Execute(cmd) > 0;
            }));
        }