public static void Insert_Mall_CouponUser(int UserID, int CouponID, int CouponType, int CouponRuleID, DateTime IsReadySendTime, SqlHelper helper = null, bool IsSent = true)
        {
            Mall_Coupon coupon = null;

            if (helper == null)
            {
                coupon = Mall_Coupon.GetMall_Coupon(CouponID);
            }
            else
            {
                coupon = Mall_Coupon.GetMall_Coupon(CouponID, helper);
            }
            if (coupon == null)
            {
                return;
            }
            var coupon_user = new Mall_CouponUser();

            coupon_user.AddTime         = DateTime.Now;
            coupon_user.AddUserMan      = "System";
            coupon_user.UserID          = UserID;
            coupon_user.CouponID        = CouponID;
            coupon_user.IsUsed          = false;
            coupon_user.UseType         = 0;
            coupon_user.CouponType      = CouponType;
            coupon_user.AmountRuleID    = CouponRuleID;
            coupon_user.IsRead          = false;
            coupon_user.IsSent          = IsSent;
            coupon_user.IsReadySendTime = IsReadySendTime;
            coupon_user.IsTaken         = false;
            coupon_user.StartTime       = coupon.StartTime;
            coupon_user.EndTime         = coupon.EndTime;
            coupon_user.IsActive        = true;
            if (helper == null)
            {
                coupon_user.Save();
                return;
            }
            coupon_user.Save(helper);
        }
        private void SetInfo(Foresight.DataAccess.Mall_CouponUser data)
        {
            var user = Foresight.DataAccess.User.GetUser(data.UserID);

            if (user != null)
            {
                this.label_NickName.InnerHtml    = user.NickName;
                this.label_PhoneNumber.InnerHtml = user.PhoneNumber;
            }
            var coupon = Mall_Coupon.GetMall_Coupon(data.CouponID);

            if (coupon != null)
            {
                this.label_CouponName.InnerHtml = coupon.CouponName;
                this.label_CouponType.InnerHtml = coupon.CouponTypeDesc;
                this.label_UseFor.InnerHtml     = coupon.UseForALLDesc;
                this.label_UseRule.InnerHtml    = coupon.UseTypeMoreDesc;
            }
            this.tdStartTime.Value = data.StartTime > DateTime.MinValue ? data.StartTime.ToString("yyyy-MM-dd") : "";
            this.tdEndTime.Value   = data.EndTime > DateTime.MinValue ? data.EndTime.ToString("yyyy-MM-dd") : "";
            this.tdIsActive.Value  = data.IsActive ? "1" : "0";
        }
Beispiel #3
0
        public static Ui.DataGrid GetMall_UserPointGridByKeywords(string Keywords, DateTime StartTime, DateTime EndTime, string orderBy, long startRowIndex, int pageSize)
        {
            long totalRows = 0;
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("([UserID] in (select [UserID] from [Mall_UserPoint]) or [UserID] in (select [UserID] from [Mall_UserBalance]) or [UserID] in (select [UserID] from [Mall_CouponUser]))");
            if (!string.IsNullOrEmpty(Keywords))
            {
                conditions.Add("([NickName] like @Keywords)");
                parameters.Add(new SqlParameter("@Keywords", "%" + Keywords + "%"));
            }
            string     fieldList       = "[User].* ";
            string     Statement       = " from [User] where  " + string.Join(" and ", conditions.ToArray());
            var        user_list       = GetList <User>(fieldList, Statement, parameters, orderBy, startRowIndex, pageSize, out totalRows).ToArray();
            var        user_level_list = Mall_UserLevel.GetMall_UserLevels();
            List <int> UserIDList      = user_list.Select(p => p.UserID).ToList();

            var point_list   = Mall_UserAccountDetail.GetMall_UserPointBalanceList(StartTime, EndTime);
            var balance_list = Mall_UserAccountDetail.GetMall_UserAmountBalanceList(StartTime, EndTime);
            var coupon_list  = Mall_CouponUser.GetMall_CouponUserListByUserIDList(UserIDList);

            if (StartTime > DateTime.MinValue)
            {
                coupon_list = coupon_list.Where(p => p.AddTime >= StartTime).ToArray();
            }
            if (EndTime > DateTime.MinValue)
            {
                coupon_list = coupon_list.Where(p => p.AddTime <= EndTime).ToArray();
            }
            var list = new List <Dictionary <string, object> >();

            foreach (var user in user_list)
            {
                var     my_user_level        = user_level_list.FirstOrDefault(p => p.ID == user.UserLevelID);
                var     my_point_list        = point_list.Where(p => p.UserID == user.UserID).ToArray();
                var     my_balance_list      = balance_list.Where(p => p.UserID == user.UserID).ToArray();
                var     my_coupon_list       = coupon_list.Where(p => p.UserID == user.UserID).ToArray();
                decimal CurrentConsumeAmount = my_balance_list.Sum(p => p.Total);
                decimal AllConsumeAmount     = my_balance_list.Where(p => p.IncomeType == 1).Sum(p => p.Total);

                decimal CurrentPoint = my_point_list.Sum(p => p.Total);
                decimal AllPoint     = my_point_list.Where(p => p.IncomeType == 1).Sum(p => p.Total);

                decimal CurrentFuShunQuan = coupon_list.Where(p => !p.IsUsed).ToArray().Length;
                decimal AllFuShunQuan     = coupon_list.ToArray().Length;

                var dic = new Dictionary <string, object>();
                dic["NickName"]             = string.IsNullOrEmpty(user.NickName) ? user.LoginName : user.NickName;
                dic["MemberLevel"]          = my_user_level == null ? "普通用户" : "合伙人用户(" + my_user_level.Name + ")";
                dic["CurrentConsumeAmount"] = CurrentConsumeAmount;
                dic["AllConsumeAmount"]     = AllConsumeAmount;
                dic["CurrentPoint"]         = CurrentPoint;
                dic["AllPoint"]             = AllPoint;
                dic["CurrentFuShunQuan"]    = CurrentFuShunQuan;
                dic["AllFuShunQuan"]        = AllFuShunQuan;
                list.Add(dic);
            }
            DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
            dg.rows  = list;
            dg.total = user_list.Length;
            dg.page  = pageSize;
            return(dg);
        }
Beispiel #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="AndroidUserID"></param>
 /// <param name="IOSUserID"></param>
 /// <param name="PushContent"></param>
 /// <param name="PushResult"></param>
 /// <param name="PushType">1-客户服务 2-物业公告 3-小区新闻 4-系统通知 5-设备维保 6-限时购通知 7-团购通知 8-生日通知 9-退款通知 10 发货通知 11-绩效考核</param>
 /// <param name="RelatedID"></param>
 public static void Insert_JPushLog(string[] AndroidUserID, string[] IOSUserID, Dictionary <string, object> PushContent, string PushResult, int PushType, int RelatedID, bool IsPushed, string Title, int[] UserIDList = null)
 {
     try
     {
         var data = new JPushLog();
         if (AndroidUserID == null)
         {
             data.AndroidUserID = "ALL";
         }
         else
         {
             data.AndroidUserID = JsonConvert.SerializeObject(AndroidUserID);
         }
         if (IOSUserID == null)
         {
             data.IOSUserID = "ALL";
         }
         else
         {
             data.IOSUserID = JsonConvert.SerializeObject(IOSUserID);
         }
         data.IsPushed = IsPushed;
         if (data.IsPushed)
         {
             data.PushTime = DateTime.Now;
         }
         data.AddTime     = DateTime.Now;
         data.Title       = Title;
         data.PushContent = JsonConvert.SerializeObject(PushContent);
         data.PushResult  = PushResult;
         data.PushType    = PushType;
         data.RelatedID   = RelatedID;
         data.Save();
         var coupon = Mall_Coupon.GetMall_Coupon(RelatedID);
         if (coupon == null)
         {
             return;
         }
         List <Mall_CouponUser> my_coupon_list = new List <Mall_CouponUser>();
         if (data.PushType == 8 && RelatedID > 0 && UserIDList != null)
         {
             foreach (var UserID in UserIDList)
             {
                 var my_coupon = new Mall_CouponUser();
                 my_coupon.CouponID     = RelatedID;
                 my_coupon.UserID       = UserID;
                 my_coupon.AddTime      = DateTime.Now;
                 my_coupon.CouponType   = 2;
                 my_coupon.UseType      = 0;
                 my_coupon.AddUserMan   = "System";
                 my_coupon.IsUsed       = false;
                 my_coupon.AmountRuleID = 0;
                 my_coupon.IsRead       = false;
                 my_coupon.IsSent       = true;
                 my_coupon.SentTime     = DateTime.Now;
                 my_coupon.IsTaken      = false;
                 my_coupon.StartTime    = coupon.StartTime;
                 my_coupon.EndTime      = coupon.EndTime;
                 my_coupon.IsActive     = true;
                 my_coupon_list.Add(my_coupon);
             }
         }
         foreach (var item in my_coupon_list)
         {
             item.Save();
         }
     }
     catch (Exception)
     {
     }
 }
        /// <summary>
        /// 消费处理
        /// </summary>
        /// <param name="order"></param>
        /// <param name="payment"></param>
        public static void GetEarnThroughBuy(Mall_Order order = null, Payment payment = null)
        {
            //消费赠与处理
            if (order == null)
            {
                return;
            }
            int[] ProductIDList = Mall_OrderItem.GetProductIDListByOrderID(order.ID, IsProduct: true);
            int[] ServiceIDList = Mall_OrderItem.GetProductIDListByOrderID(order.ID, IsService: true);
            if (payment == null)
            {
                payment = Payment.GetPaymentByTradeNo(order.TradeNo);
            }
            decimal TotalCost = order.TotalCost;

            if (payment != null)
            {
                TotalCost = payment.Amount / 100;
            }
            Dictionary <string, object> BackObject = new Dictionary <string, object>();

            Mall_AmountRule.GetBackAmountPoint(TotalCost, out BackObject, ProductIDList, ServiceIDList, AmountType: 2, UserID: order.UserID);
            string Title        = "消费赠与";
            int    CategoryType = 6;

            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    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(order.UserID, 1, BackAmount, Title, "BalaceID:" + order.ID, CategoryType, "System", 1, "", RelatedID: order.ID, AmountRuleID: AmountRuleID, helper: helper, PaymentMethod: order.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(order.UserID, 1, 0, Title, "BalaceID:" + order.ID, CategoryType, "System", 1, "", 0, helper, RelatedID: order.ID, PointValue: BackPoint, AmountRuleID: PointRuleID, IsSent: PointIsSendNow, IsReadySendTime: PointIsReadySendTime);
                    }
                    if (order.TotalOrderPointCost > 0)
                    {
                        Mall_UserPoint.Insert_Mall_UserPoint(order.UserID, 2, 0, "购买商品", "OrderID:" + order.ID, 1, "System", 1, order.TradeNo, order.ID, helper, RelatedID: order.ID, PointValue: -order.TotalOrderPointCost, AmountRuleID: 0);
                    }

                    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(order.UserID, CouponID, 3, CouponRuleID, CouponIsReadySendTime, helper: helper, IsSent: CouponIsSendNow);
                            }
                        }
                    }
                    if (payment != null)
                    {
                        payment.Save(helper);
                    }
                    if (order != null)
                    {
                        order.Save(helper);
                    }
                    helper.Commit();
                }
                catch (Exception ex)
                {
                    helper.Rollback();
                    Utility.LogHelper.WriteError("Mall_UserBalance.cs", "GetEarnThroughBuy", ex);
                }
            }
        }
        /// <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);
                }
            }
        }