Exemple #1
0
 public override bool AddMemberPoint(UserPointInfo point)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO distro_PointDetails (OrderId,UserId, TradeDate, TradeType, Increased, Reduced, Points, Remark)VALUES(@OrderId,@UserId, @TradeDate, @TradeType, @Increased, @Reduced, @Points, @Remark)");
     this.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, point.OrderId);
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, point.UserId);
     this.database.AddInParameter(sqlStringCommand, "TradeDate", DbType.DateTime, point.TradeDate);
     this.database.AddInParameter(sqlStringCommand, "TradeType", DbType.Int32, (int) point.TradeType);
     this.database.AddInParameter(sqlStringCommand, "Increased", DbType.Int32, point.Increased.HasValue ? point.Increased.Value : 0);
     this.database.AddInParameter(sqlStringCommand, "Reduced", DbType.Int32, point.Reduced.HasValue ? point.Reduced.Value : 0);
     this.database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, point.Points);
     this.database.AddInParameter(sqlStringCommand, "Remark", DbType.String, point.Remark);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Exemple #2
0
 public abstract bool AddMemberPoint(UserPointInfo point);
Exemple #3
0
 static void UpdateUserAccount(OrderInfo order)
 {
     int userId = order.UserId;
     if (userId == 0x44c)
     {
         userId = 0;
     }
     IUser user = Users.GetUser(userId, false);
     if ((user != null) && (user.UserRole == UserRole.Member))
     {
         Member member = user as Member;
         UserPointInfo point = new UserPointInfo();
         point.OrderId = order.OrderId;
         point.UserId = member.UserId;
         point.TradeDate = DateTime.Now;
         point.TradeType = UserPointTradeType.Bounty;
         point.Increased = new int?(order.GetTotalPoints());
         point.Points = order.GetTotalPoints() + member.Points;
         if ((point.Points > 0x7fffffff) || (point.Points < 0))
         {
             point.Points = 0x7fffffff;
         }
         SalesProvider.Instance().AddMemberPoint(point);
         int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct;
         if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0))
         {
             IUser user2 = Users.GetUser(member.ReferralUserId.Value, false);
             if ((user2 != null) && (user2.UserRole == UserRole.Member))
             {
                 Member member2 = user2 as Member;
                 if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance)
                 {
                     decimal num3 = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M);
                     BalanceDetailInfo balanceDetail = new BalanceDetailInfo();
                     balanceDetail.UserId = member2.UserId;
                     balanceDetail.UserName = member2.Username;
                     balanceDetail.TradeDate = DateTime.Now;
                     balanceDetail.TradeType = TradeTypes.ReferralDeduct;
                     balanceDetail.Income = new decimal?((order.GetTotal() * referralDeduct) / 100M);
                     balanceDetail.Balance = num3;
                     balanceDetail.Remark = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId);
                     MemberProvider.Instance().InsertBalanceDetail(balanceDetail);
                 }
             }
         }
         SalesProvider.Instance().UpdateUserAccount(order.GetTotal(), order.UserId);
         int historyPoint = SalesProvider.Instance().GetHistoryPoint(member.UserId);
         SalesProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint);
         Users.ClearUserCache(user);
     }
 }
Exemple #4
0
 static void ReducedPoint(OrderInfo order, Member member)
 {
     UserPointInfo point = new UserPointInfo();
     point.OrderId = order.OrderId;
     point.UserId = member.UserId;
     point.TradeDate = DateTime.Now;
     point.TradeType = UserPointTradeType.Refund;
     point.Reduced = new int?(Convert.ToInt32((decimal)(order.RefundAmount / HiContext.Current.SiteSettings.PointsRate)));
     point.Points = member.Points - point.Reduced.Value;
     SalesProvider.Instance().AddMemberPoint(point);
 }
Exemple #5
0
 static void ReducedPoint(OrderInfo order, Member member)
 {
     UserPointInfo point = new UserPointInfo();
     point.OrderId = order.OrderId;
     point.UserId = member.UserId;
     point.TradeDate = DateTime.Now;
     point.TradeType = UserPointTradeType.Refund;
     SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
     point.Reduced = new int?(Convert.ToInt32((decimal)(order.RefundAmount / masterSettings.PointsRate)));
     point.Points = member.Points - point.Reduced.Value;
     SubsiteSalesProvider.Instance().AddMemberPoint(point);
 }
Exemple #6
0
 public static bool PointChageCoupon(int couponId, int needPoint, int currentPoint)
 {
     Member user = HiContext.Current.User as Member;
     UserPointInfo point = new UserPointInfo();
     point.OrderId = string.Empty;
     point.UserId = user.UserId;
     point.TradeDate = DateTime.Now;
     point.TradeType = UserPointTradeType.ChangeCoupon;
     point.Increased = null;
     point.Reduced = new int?(needPoint);
     point.Points = currentPoint - needPoint;
     if ((point.Points >= 0) && TradeProvider.Instance().AddMemberPoint(point))
     {
         CouponItemInfo couponItem = new CouponItemInfo();
         couponItem.CouponId = couponId;
         couponItem.UserId = new int?(user.UserId);
         couponItem.EmailAddress = user.Email;
         couponItem.ClaimCode = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
         couponItem.GenerateTime = DateTime.Now;
         Users.ClearUserCache(user);
         if (TradeProvider.Instance().SendClaimCodes(couponItem))
         {
             return true;
         }
     }
     return false;
 }
Exemple #7
0
 public static bool UserPayOrder(OrderInfo order, bool isBalancePayOrder)
 {
     bool flag = false;
     if (order.CheckAction(OrderActions.BUYER_PAY))
     {
         using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
         {
             connection.Open();
             DbTransaction dbTran = connection.BeginTransaction();
             try
             {
                 if (!TradeProvider.Instance().UserPayOrder(order, isBalancePayOrder, dbTran))
                 {
                     dbTran.Rollback();
                     return false;
                 }
                 if ((HiContext.Current.SiteSettings.IsDistributorSettings && (order.GroupBuyId <= 0)) && !PurchaseOrderProvider.CreateInstance().CreatePurchaseOrder(order, dbTran))
                 {
                     dbTran.Rollback();
                     return false;
                 }
                 flag = true;
                 dbTran.Commit();
             }
             catch
             {
                 dbTran.Rollback();
                 return false;
             }
             finally
             {
                 connection.Close();
             }
         }
         if (!flag)
         {
             return flag;
         }
         if (!HiContext.Current.SiteSettings.IsDistributorSettings)
         {
             TradeProvider.Instance().UpdateStockPayOrder(order.OrderId);
         }
         TradeProvider.Instance().UpdateProductSaleCounts(order.LineItems);
         if ((order.UserId == 0) || (order.UserId == 0x44c))
         {
             return flag;
         }
         IUser user = Users.GetUser(order.UserId, false);
         if (((user == null) || (user.UserRole != UserRole.Member)) && ((user == null) || (user.UserRole != UserRole.Underling)))
         {
             return flag;
         }
         Member member = user as Member;
         UserPointInfo point = new UserPointInfo();
         point.OrderId = order.OrderId;
         point.UserId = member.UserId;
         point.TradeDate = DateTime.Now;
         point.TradeType = UserPointTradeType.Bounty;
         point.Increased = new int?(order.GetTotalPoints());
         point.Points = order.GetTotalPoints() + member.Points;
         if ((point.Points > 0x7fffffff) || (point.Points < 0))
         {
             point.Points = 0x7fffffff;
         }
         TradeProvider.Instance().AddMemberPoint(point);
         int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct;
         if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0))
         {
             IUser user2 = Users.GetUser(member.ReferralUserId.Value, false);
             if ((user2 != null) && ((user2.UserRole == UserRole.Member) || (user2.UserRole == UserRole.Underling)))
             {
                 Member member2 = user2 as Member;
                 if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance)
                 {
                     decimal num2 = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M);
                     BalanceDetailInfo balanceDetails = new BalanceDetailInfo();
                     balanceDetails.UserId = member2.UserId;
                     balanceDetails.UserName = member2.Username;
                     balanceDetails.TradeDate = DateTime.Now;
                     balanceDetails.TradeType = TradeTypes.ReferralDeduct;
                     balanceDetails.Income = new decimal?((order.GetTotal() * referralDeduct) / 100M);
                     balanceDetails.Balance = num2;
                     balanceDetails.Remark = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId);
                     PersonalProvider.Instance().AddBalanceDetail(balanceDetails);
                 }
             }
         }
         TradeProvider.Instance().UpdateUserAccount(order.GetTotal(), point.Points, order.UserId);
         int historyPoint = TradeProvider.Instance().GetHistoryPoint(member.UserId);
         TradeProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint);
         Users.ClearUserCache(user);
     }
     return flag;
 }
Exemple #8
0
 public static bool CutNeedPoint(int needPoint)
 {
     Member user = HiContext.Current.User as Member;
     UserPointInfo point = new UserPointInfo();
     point.UserId = user.UserId;
     point.TradeDate = DateTime.Now;
     point.TradeType = UserPointTradeType.Change;
     point.Reduced = new int?(needPoint);
     point.Points = user.Points - needPoint;
     if ((point.Points > 0x7fffffff) || (point.Points < 0))
     {
         point.Points = 0;
     }
     if (ShoppingProvider.Instance().AddMemberPoint(point))
     {
         Users.ClearUserCache(user);
         return true;
     }
     return false;
 }