Exemple #1
0
        public static void Insert_Mall_UserLevelApprove(int UserID, string RequestTitle, int ApproveUserLevelID, SqlHelper helper = null, decimal IncomingAmount = 0, string IncomingType = "", int UserBalanceID = 0)
        {
            var data = new Mall_UserLevelApprove();

            data.UserID             = UserID;
            data.RequestTitle       = RequestTitle;
            data.RequestTime        = DateTime.Now;
            data.ApproveTime        = DateTime.Now;
            data.ApproveStatus      = 0;
            data.ApproveUserName    = "******";
            data.ApproveUserLevelID = ApproveUserLevelID;
            data.AddUserName        = "******";
            data.IncomingAmount     = IncomingAmount;
            data.IncomingType       = IncomingType;
            data.UserBalanceID      = UserBalanceID;
            data.IncomingTime       = DateTime.Now;
            if (helper == null)
            {
                data.Save();
                return;
            }
            data.Save(helper);
        }
        /// <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);
                }
            }
        }