Exemplo n.º 1
0
        /// <summary>
        /// 会员购买力列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static QueryPageModel <DTO.MemberPurchasingPower> GetPurchasingPowerMember(MemberPowerQuery query)
        {
            var result = _iMemberService.GetPurchasingPowerMember(query);
            QueryPageModel <DTO.MemberPurchasingPower> model = new QueryPageModel <MemberPurchasingPower>();

            model.Total  = result.Total;
            model.Models = AutoMapper.Mapper.Map <List <DTO.MemberPurchasingPower> >(result.Models);

            var userIds = model.Models.Select(p => p.Id).ToArray();

            var memberCategorys = _iMemberService.GetMemberBuyCategoryByUserIds(userIds);

            var grades = MemberGradeApplication.GetMemberGradeList();

            var integrals = MemberIntegralApplication.GetMemberIntegrals(userIds);

            foreach (var item in model.Models)
            {
                var intergral = integrals.Where(a => a.MemberId == item.Id).Select(a => a.HistoryIntegrals).FirstOrDefault();
                //填充等级数据
                item.GradeName = MemberGradeApplication.GetMemberGradeByIntegral(grades, intergral).GradeName;

                //填充分类数据
                var categoryNames = memberCategorys.Where(p => p.UserId == item.Id).Select(p => p.CategoryName).Take(3).ToArray();
                if (categoryNames.Length == 0)
                {
                    continue;
                }
                item.CategoryNames = string.Join(",", categoryNames);
            }

            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据查询条件分页获取会员信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static QueryPageModel <DTO.Members> GetMemberList(MemberQuery query)
        {
            if (query.GradeId.HasValue)
            {
                var expenditureRange = MemberApplication.GetMemberGradeRange(query.GradeId.Value);
                query.MinIntegral = expenditureRange.MinIntegral;
                query.MaxIntegral = expenditureRange.MaxIntegral;
            }
            var list    = _iMemberService.GetMembers(query);
            var members = Mapper.Map <QueryPageModel <DTO.Members> >(list);
            var grades  = MemberGradeApplication.GetMemberGradeList();

            foreach (var m in members.Models)
            {
                var memberIntegral = MemberIntegralApplication.GetMemberIntegral(m.Id);
                //获取等级
                m.GradeName = MemberGradeApplication.GetMemberGradeByIntegral(grades, memberIntegral.HistoryIntegrals).GradeName;
                if (memberIntegral != null)
                {
                    m.AvailableIntegral = memberIntegral.AvailableIntegrals;
                    m.HistoryIntegral   = memberIntegral.HistoryIntegrals;
                }
            }
            return(members);
        }
Exemplo n.º 3
0
        public static MemberGradeInfo GetGradeByMember(long memberId)
        {
            var integral = MemberIntegralApplication.GetMemberIntegral(memberId);
            var grades   = GetMemberGrades();
            var info     = GetMemberGradeByIntegral(grades, integral.HistoryIntegrals);

            return(info);
        }
Exemplo n.º 4
0
        public static QueryPageModel <ManagerInfo> GetMemberList(ManagerQuery query)
        {
            var list    = _iManagerService.GetManagersList(query);
            var members = Mapper.Map <QueryPageModel <ManagerInfo> >(list);
            var grades  = MemberGradeApplication.GetMemberGradeList();

            foreach (var m in members.Models)
            {
                var memberIntegral = MemberIntegralApplication.GetMemberIntegral(m.Id);
                m.GradeName = MemberGradeApplication.GetMemberGradeByIntegral(grades, memberIntegral.HistoryIntegrals).GradeName;
                if (memberIntegral != null)
                {
                    m.AvailableIntegral = memberIntegral.AvailableIntegrals;
                    m.HistoryIntegral   = memberIntegral.HistoryIntegrals;
                }
            }
            return(members);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取商家信息列表
        /// </summary>
        public static QueryPageModel <ManagerInfo> GetMemberList(ManagerQuery query)
        {
            var list    = _iManagerService.GetManagersList(query);
            var members = Mapper.Map <QueryPageModel <ManagerInfo> >(list);
            var grades  = MemberGradeApplication.GetMemberGradeList();

            foreach (var m in members.Models)
            {
                //获取用户积分
                var member         = _iMemberService.GetMemberByName(m.UserName);
                var memberIntegral = MemberIntegralApplication.GetMemberIntegral(member.Id);
                m.GradeName = MemberGradeApplication.GetMemberGradeByIntegralandType(grades, memberIntegral.HistoryIntegrals, Convert.ToInt32(m.MemberGradeId), m.BondMoney).GradeName;
                if (memberIntegral != null)
                {
                    m.AvailableIntegral = memberIntegral.AvailableIntegrals;
                    m.HistoryIntegral   = memberIntegral.HistoryIntegrals;
                }
            }
            return(members);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 会员领取优惠券的前置状态判断
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="vshopId"></param>
        /// <param name="couponId"></param>
        /// <returns></returns>
        public static int GetReceiveStatus(long userid, long vshopId, long couponId)
        {
            var couponService = ServiceProvider.Instance <ICouponService> .Create;
            var couponInfo    = couponService.GetCouponInfo(couponId);

            if (couponInfo.EndTime < DateTime.Now)
            {
                return(2);                                  //已经失效
            }
            if (userid > 0)
            {
                CouponRecordQuery crQuery = new CouponRecordQuery();
                crQuery.CouponId = couponId;
                crQuery.UserId   = userid;
                QueryPageModel <CouponRecordInfo> pageModel = couponService.GetCouponRecordList(crQuery);
                if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
                {
                    return(3);                                                               //达到个人领取最大张数
                }
                crQuery = new CouponRecordQuery()
                {
                    CouponId = couponId
                };
                pageModel = couponService.GetCouponRecordList(crQuery);
                if (pageModel.Total >= couponInfo.Num)
                {
                    return(4);                                  //达到领取最大张数
                }
                if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange)
                {
                    var integral = MemberIntegralApplication.GetAvailableIntegral(userid);
                    if (integral < couponInfo.NeedIntegral)
                    {
                        return(5);                                   //积分不足
                    }
                }
            }
            return(1);//可正常领取
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取会员信息
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public static Himall.DTO.Members GetMembers(long UserId)
        {
            //  var model = _iMemberService.GetMember(UserId);
            // Mapper.CreateMap<Himall.Model.UserMemberInfo, Himall.DTO.Members>();
            // return Mapper.Map<Himall.Model.UserMemberInfo, Himall.DTO.Members>(model);

            var model = _iMemberService.GetMember(UserId);
            var m     = Mapper.Map <Himall.Model.UserMemberInfo, Himall.DTO.Members>(model);

            if (model.InviteUserId.HasValue)
            {
                var inviteUser = _iMemberService.GetMember(model.InviteUserId.Value);
                if (inviteUser != null)
                {
                    m.InviteUserName = inviteUser.UserName;
                }
            }
            m.MemberLabels = MemberLabelApplication.GetMemberLabelList(UserId).Models;
            var userInte  = MemberIntegralApplication.GetMemberIntegral(UserId);
            var userGrade = MemberGradeApplication.GetMemberGradeByUserIntegral(userInte.HistoryIntegrals);

            m.GradeName = userGrade.GradeName;//方法内部包含获取等级的方法
            return(m);
        }
Exemplo n.º 8
0
 public static void WinnerSubmit(WeiActivityWinModel winModel)
 {
     Entities.WeiActivityInfoInfo model = _iActivityInfoService.GetActivityModel(winModel.activityId);
     //添加中奖信息记录
     Entities.WeiActivityWinInfoInfo activityWinInfo = new Entities.WeiActivityWinInfoInfo();
     activityWinInfo.ActivityId = winModel.activityId;
     activityWinInfo.AddDate    = DateTime.Now;
     activityWinInfo.UserId     = winModel.userId;
     activityWinInfo.IsWin      = winModel.isWin;
     //消耗积分
     if (winModel.integrals > 0)
     {
         var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create;
         Himall.Entities.MemberIntegralRecordInfo info = new Himall.Entities.MemberIntegralRecordInfo();
         info.UserName   = MemberApplication.GetMember(activityWinInfo.UserId).UserName;
         info.MemberId   = activityWinInfo.UserId;
         info.RecordDate = DateTime.Now;
         info.ReMark     = ((WeiActivityType)model.ActivityType).ToDescription() + "消耗";
         info.TypeId     = Entities.MemberIntegralInfo.IntegralType.WeiActivity;
         var memberIntegral = factoryService.Create(Himall.Entities.MemberIntegralInfo.IntegralType.WeiActivity, -winModel.integrals);
         MemberIntegralApplication.AddMemberIntegral(info, memberIntegral);
     }
     if (activityWinInfo.IsWin)
     {
         if (winModel.awardType == WeiActivityAwardType.Integral)//积分
         {
             activityWinInfo.AwardName = winModel.awardName + " 积分";
             //新增积分记录
             var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create;
             Entities.MemberIntegralRecordInfo info = new Entities.MemberIntegralRecordInfo();
             info.UserName   = MemberApplication.GetMember(activityWinInfo.UserId).UserName;
             info.MemberId   = activityWinInfo.UserId;
             info.RecordDate = DateTime.Now;
             info.ReMark     = ((WeiActivityType)model.ActivityType).ToDescription() + "中奖";
             info.TypeId     = Himall.Entities.MemberIntegralInfo.IntegralType.WeiActivity;
             var memberIntegral = factoryService.Create(Entities.MemberIntegralInfo.IntegralType.WeiActivity, Convert.ToInt32(winModel.awardName));//winModel.integrals为消耗积分 此处不是用户总积分
             MemberIntegralApplication.AddMemberIntegral(info, memberIntegral);
         }
         else if (winModel.awardType == WeiActivityAwardType.Bonus)//红包
         {
             activityWinInfo.AwardName = winModel.awardName;
             BonusApplication.SetShareByUserId(winModel.bonusId, false, winModel.userId);//添加红包记录
             BonusApplication.IncrReceiveCount(winModel.bonusId);
         }
         else
         {
             activityWinInfo.AwardName = winModel.awardName;
             //添加优惠券记录
             Entities.CouponRecordInfo recordInfo = new Entities.CouponRecordInfo();
             recordInfo.UserId   = winModel.userId;
             recordInfo.UserName = MemberApplication.GetMember(winModel.userId).UserName;
             recordInfo.ShopId   = CouponApplication.GetCouponInfo(winModel.couponId).ShopId;
             recordInfo.CouponId = winModel.couponId;
             CouponApplication.AddCouponRecord(recordInfo);
         }
     }
     else
     {
         activityWinInfo.AwardName = winModel.awardName;
     }
     activityWinInfo.AwardId = winModel.awardId;
     _iWeiActivityWinService.AddWinner(activityWinInfo);
 }