예제 #1
0
 public static bool CutNeedPoint(int needPoint, string orderId, PointTradeType pType, int userId)
 {
     Hidistro.Entities.Members.MemberInfo user = Users.GetUser(userId);
     if (user != null)
     {
         PointDetailInfo pointDetailInfo = new PointDetailInfo();
         pointDetailInfo.OrderId   = orderId;
         pointDetailInfo.UserId    = user.UserId;
         pointDetailInfo.TradeDate = DateTime.Now;
         pointDetailInfo.TradeType = pType;
         pointDetailInfo.Reduced   = needPoint;
         pointDetailInfo.Points    = user.Points - needPoint;
         pointDetailInfo.Remark    = "订单 " + orderId;
         if (pointDetailInfo.Points > 2147483647 || pointDetailInfo.Points < 0)
         {
             pointDetailInfo.Points = 0;
         }
         if (new PointDetailDao().Add(pointDetailInfo, null) > 0)
         {
             user.Points = pointDetailInfo.Points;
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
        private static bool AddPoints(MemberInfo member, int points, PointTradeType type)
        {
            PointDetailDao  pointDetailDao  = new PointDetailDao();
            PointDetailInfo pointDetailInfo = new PointDetailInfo();

            pointDetailInfo.UserId    = member.UserId;
            pointDetailInfo.TradeDate = DateTime.Now;
            pointDetailInfo.TradeType = type;
            pointDetailInfo.Increased = points;
            pointDetailInfo.Points    = points + member.Points;
            if (pointDetailInfo.Points > 2147483647)
            {
                pointDetailInfo.Points = 2147483647;
            }
            if (pointDetailInfo.Points < 0)
            {
                pointDetailInfo.Points = 0;
            }
            pointDetailInfo.Remark = "评论获得积分";
            member.Points          = pointDetailInfo.Points;
            return(pointDetailDao.Add(pointDetailInfo, null) > 0);
        }
예제 #3
0
        private void AddPointDetail(Hidistro.Entities.Members.MemberInfo member, string orderId, int points, int?deductionPoints, PointTradeType pType, DbTransaction dbTran)
        {
            PointDetailInfo pointDetailInfo = new PointDetailInfo();

            pointDetailInfo.OrderId   = orderId;
            pointDetailInfo.UserId    = member.UserId;
            pointDetailInfo.TradeDate = DateTime.Now;
            pointDetailInfo.TradeType = pType;
            switch (pType)
            {
            case PointTradeType.Bounty:
                pointDetailInfo.Increased = points;
                pointDetailInfo.Points    = points + member.Points;
                break;

            case PointTradeType.ShoppingDeduction:
                pointDetailInfo.Reduced = (deductionPoints.HasValue ? deductionPoints.Value : 0);
                pointDetailInfo.Points  = member.Points - (deductionPoints.HasValue ? deductionPoints.Value : 0);
                break;
            }
            if (pointDetailInfo.Points > 2147483647)
            {
                pointDetailInfo.Points = 2147483647;
            }
            if (pointDetailInfo.Points < 0)
            {
                pointDetailInfo.Points = 0;
            }
            if (pointDetailInfo.Increased > 0 || pointDetailInfo.Reduced > 0)
            {
                BaseDao baseDao = new BaseDao();
                baseDao.Add(pointDetailInfo, dbTran);
                member.Points = pointDetailInfo.Points;
            }
        }