/// <summary>
        /// 充值处理
        /// </summary>
        /// <param name="BalanceStatus"></param>
        /// <param name="TradeNo"></param>
        /// <param name="payment"></param>
        /// <param name="AmountType"></param>
        public static void UpdateMall_UserBalanceStatus(int BalanceStatus, string TradeNo, Payment payment = null, int AmountType = 1, string PaymentMethod = "")
        {
            //充值赠与处理
            Dictionary <string, object> BackObject = new Dictionary <string, object>();
            Mall_UserBalance            data       = null;

            if (BalanceStatus == 1)
            {
                data = GetMall_UserBalanceByTradeNo(TradeNo);
                if (data == null)
                {
                    return;
                }
                Mall_AmountRule.GetBackAmountPoint(data.BalanceValue, out BackObject, new int[] { }, new int[] { }, AmountType: AmountType, UserID: data.UserID);
                //AmountRuleID = Utility.Tools.GetValueFromDic<int>(BackObject, "AmountRuleID");
                //BackAmount = Utility.Tools.GetValueFromDic<decimal>(BackObject, "BackAmount");
            }
            string Title        = "充值赠与";
            int    CategoryType = 5;
            User   user         = null;
            var    user_level   = Mall_UserLevel.GetMall_UserLevelByUserID(data.UserID, out user);

            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    data.BalanceStatus = 1;
                    data.Save(helper);
                    if (user != null && user_level != null)
                    {
                        if (user.UserLevelID != user_level.ID)
                        {
                            string LevelTitle = "充值满" + user_level.StartAmount.ToString("0.00") + "升到到合伙人(" + user_level.Name + ")";
                            Mall_UserLevelApprove.Insert_Mall_UserLevelApprove(data.UserID, LevelTitle, user_level.ID, helper: helper, IncomingAmount: data.BalanceValue, IncomingType: data.PaymentMethodDesc, UserBalanceID: data.ID);
                        }
                    }
                    decimal  BackAmount            = Utility.Tools.GetValueFromDic <decimal>(BackObject, "BackAmount");
                    int      AmountRuleID          = Utility.Tools.GetValueFromDic <int>(BackObject, "AmountRuleID");
                    bool     AmountIsSendNow       = Utility.Tools.GetValueFromDic <bool>(BackObject, "AmountIsSendNow");
                    DateTime AmountIsReadySendTime = Utility.Tools.GetValueFromDic <DateTime>(BackObject, "AmountIsReadySendTime");
                    if (BackAmount > 0 && AmountRuleID > 0)
                    {
                        Insert_Mall_UserBalance(data.UserID, 1, BackAmount, Title, "BalaceID:" + data.ID, CategoryType, "System", 1, "", RelatedID: data.ID, AmountRuleID: AmountRuleID, helper: helper, PaymentMethod: PaymentMethod, IsSent: AmountIsSendNow, IsReadySendTime: AmountIsReadySendTime);
                    }
                    int      BackPoint            = Utility.Tools.GetValueFromDic <int>(BackObject, "BackPoint");
                    int      PointRuleID          = Utility.Tools.GetValueFromDic <int>(BackObject, "PointRuleID");
                    bool     PointIsSendNow       = Utility.Tools.GetValueFromDic <bool>(BackObject, "PointIsSendNow");
                    DateTime PointIsReadySendTime = Utility.Tools.GetValueFromDic <DateTime>(BackObject, "PointIsReadySendTime");
                    if (BackPoint > 0 && PointRuleID > 0)
                    {
                        Mall_UserPoint.Insert_Mall_UserPoint(data.UserID, 1, 0, Title, "BalaceID:" + data.ID, CategoryType, "System", 1, "", 0, helper, RelatedID: data.ID, PointValue: BackPoint, AmountRuleID: PointRuleID, IsSent: PointIsSendNow, IsReadySendTime: PointIsReadySendTime);
                    }
                    List <int> CouponIDList          = Utility.Tools.GetValueFromDic <List <int> >(BackObject, "CouponIDList");
                    int        CouponRuleID          = Utility.Tools.GetValueFromDic <int>(BackObject, "CouponRuleID");
                    bool       CouponIsSendNow       = Utility.Tools.GetValueFromDic <bool>(BackObject, "CouponIsSendNow");
                    DateTime   CouponIsReadySendTime = Utility.Tools.GetValueFromDic <DateTime>(BackObject, "CouponIsReadySendTime");
                    int        SendCouponCount       = Utility.Tools.GetValueFromDic <int>(BackObject, "SendCouponCount");
                    if (CouponIDList != null && CouponIDList.Count > 0 && CouponRuleID > 0)
                    {
                        foreach (var CouponID in CouponIDList)
                        {
                            for (int i = 0; i < SendCouponCount; i++)
                            {
                                Mall_CouponUser.Insert_Mall_CouponUser(data.UserID, CouponID, 1, CouponRuleID, CouponIsReadySendTime, helper: helper, IsSent: CouponIsSendNow);
                            }
                        }
                    }
                    if (payment != null)
                    {
                        payment.Save(helper);
                    }
                    helper.Commit();
                }
                catch (Exception ex)
                {
                    helper.Rollback();
                    Utility.LogHelper.WriteError("Mall_UserBalance.cs", "UpdateMall_UserBalanceStatus", ex);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="BalanceType">1-充值 2-消费</param>
        /// <param name="BalanceValue"></param>
        /// <param name="Title"></param>
        /// <param name="Summary"></param>
        /// <param name="CategoryType">1-购买商品消费 2-微信充值 3-支付宝充值 4-订单退款返还 5-充值赠与 6-消费赠与 7-退款消费赠与取消 8-线下充值 9-业主结算</param>
        /// <param name="AddUserName"></param>
        /// <param name="BalanceStatus">0-未入账 1-已入账</param>
        /// <param name="TradeNo"></param>
        /// <param name="helper"></param>
        public static void Insert_Mall_UserBalance(int UserID, int BalanceType, decimal BalanceValue, string Title, string Summary, int CategoryType, string AddUserName, int BalanceStatus, string TradeNo, int RelatedID = 0, int AmountRuleID = 0, SqlHelper helper = null, string PaymentMethod = "", bool IsSent = true, DateTime?IsReadySendTime = null, bool IsManualIncoming = false, int UserLevelApproveID = 0, string Remark = "")
        {
            if (UserID <= 0)
            {
                return;
            }
            if (CategoryType == 4)
            {
                var mall_balance = Mall_UserBalance.GetMall_UserBalanceByOrderID(RelatedID, 1, helper: helper);
                if (mall_balance == null)
                {
                    return;
                }
                if (mall_balance.BalanceStatus == 0)
                {
                    if (helper == null)
                    {
                        mall_balance.Delete();
                    }
                    else
                    {
                        mall_balance.Delete(helper);
                    }
                    return;
                }
                BalanceValue = -mall_balance.BalanceValue;
            }
            if (CategoryType == 7)
            {
                var mall_balance = Mall_UserBalance.GetMall_UserBalanceByOrderID(RelatedID, 6, helper: helper);
                if (mall_balance == null)
                {
                    return;
                }
                if (mall_balance.BalanceStatus == 0)
                {
                    if (helper == null)
                    {
                        mall_balance.Delete();
                    }
                    else
                    {
                        mall_balance.Delete(helper);
                    }
                    return;
                }
                BalanceValue = -mall_balance.BalanceValue;
            }
            var data = new Mall_UserBalance();

            data.UserID             = UserID;
            data.BalanceType        = BalanceType;
            data.BalanceValue       = BalanceValue;
            data.Title              = Title;
            data.Summary            = Summary;
            data.CategoryType       = CategoryType;
            data.AddUserName        = AddUserName;
            data.BalanceStatus      = 0;
            data.AddTime            = DateTime.Now;
            data.TradeNo            = TradeNo;
            data.RelatedID          = RelatedID;
            data.PaymentMethod      = PaymentMethod;
            data.IsSent             = IsSent;
            data.IsManualIncoming   = IsManualIncoming;
            data.UserLevelApproveID = UserLevelApproveID;
            data.Remark             = Remark;
            if (data.IsSent)
            {
                data.SentTime      = DateTime.Now;
                data.BalanceStatus = 1;
            }
            if (BalanceStatus == 0)
            {
                data.BalanceStatus = BalanceStatus;
            }
            if (IsReadySendTime.HasValue)
            {
                data.IsReadySendTime = Convert.ToDateTime(IsReadySendTime);
            }
            if (helper == null)
            {
                data.Save();
                return;
            }
            data.Save(helper);
        }