예제 #1
0
        /// <summary>
        /// 根据微信端客户信息获取绑定的主系统信息(如果已绑定)
        /// </summary>
        /// <param name="FanList">微信端客户列表</param>
        /// <returns>会员完整信息</returns>
        private ICollection <MemberMasterVM> AttachMemberWebInfo(IEnumerable <Fan> FanList)
        {
            Collection <MemberMasterVM> VM = new Collection <MemberMasterVM>();
            var OSvc = ORSService;
            var svc  = Service;

            if (FanList != null && FanList.Any())
            {
                #region 微信端订单数量信息

                var    idSets = FanList.Select(c => c.ID ?? 0);
                long[] fanids = new long[idSets.Count()];
                for (int i = 0; i < fanids.Length; i++)
                {
                    fanids[i] = idSets.ToList()[i];
                }

                //获取微信端客户订单情况
                var weChatOrderQuery = new SaleOrderQuery
                {
                    FanIDs = fanids,
                    State  = (int)OrderState.Finished
                };
                var weChatOrder = svc.SelectOrEmpty(weChatOrderQuery);

                #endregion

                #region 获取微信端客户绑定主系统情况

                var relateQuery = new MemberRelatedQuery
                {
                    FanIDs = fanids
                };

                //memberSet 微信端和主系统绑定记录 id-fanid-customerid
                var memberSet = svc.SelectOrEmpty(relateQuery).OrderBy(c => c.FanID);

                #endregion

                #region 绑定信息不为空,则获取对应绑定的主系统上的基本信息

                if (memberSet != null && memberSet.Any())
                {
                    var memberids = memberSet.Select(c => c.CustomerID ?? 0).Distinct().OfType <long>().ToArray();

                    var CIQuery = new CustomerIdentityQuery
                    {
                        CustomerIDs = memberids
                    };
                    //CustomerIdentity表 记录不同的登陆Code
                    var CIdentity = OSvc.SelectOrEmpty(CIQuery);//.OrderBy(c => c.CustomerID);

                    //主系统订单情况
                    var WebOrderQuery = new OrderQuery
                    {
                        CustomerIDs = memberids
                    };
                    var webOrder = OSvc.SelectOrEmpty(WebOrderQuery);

                    //主系统会员积分信息
                    //CustomerBalance表和Customer表一一对应
                    //建立在这个前提下,下文直接以关联下标代替balance下标信息
                    var balanceQuery = new CustomerBalanceQuery
                    {
                        IDs = memberids
                    };
                    var balanceSets = OSvc.SelectOrEmpty(balanceQuery);

                    MemberMasterVM item         = new MemberMasterVM();
                    int            webCount     = 0;//线上登陆方式遍历计数
                    int            relatedCount = memberSet.Count();
                    long           _FanId       = -1;
                    long           _CustomerId  = -1;

                    if (CIdentity != null && CIdentity.Any())
                    {
                        webCount = CIdentity.Count();
                    }
                    for (int i = 0; i < FanList.Count(); i++)
                    {
                        item = new MemberMasterVM();
                        item.CustomerCode = new Collection <string>();
                        //微信端基本信息
                        item.WeChatMember = FanList.ToList()[i];
                        _FanId            = item.WeChatMember.ID ?? -1;

                        var relatedItem = memberSet.Where(c => c.FanID == _FanId).FirstOrDefault();
                        _CustomerId = -1;
                        if (relatedItem != null)
                        {
                            _CustomerId = relatedItem.CustomerID ?? -1;
                        }

                        //微信端订单数量信息
                        item.WeChatOrderCount = GetWechatOrderCount(weChatOrder, _FanId);

                        //主系统订单数量信息
                        item.WebOrderCount = GetWebOrderCount(webOrder, _CustomerId);

                        //补齐系统编号到八位,显示用
                        item.DisplayID = string.Format("{0:D8}", item.WeChatMember.ID ?? 0);

                        //主系统联名登陆信息的获取----一并获取积分信息
                        item.CustomerCode = GetIdentities(CIdentity, _CustomerId);

                        //积分信息
                        item.WebCreadit = GetCredits(balanceSets, _CustomerId);

                        VM.Add(item);
                    }
                }

                #endregion

                #region 绑定信息为空,则直接将微信端用户信息绑定返回

                else
                {
                    MemberMasterVM item = new MemberMasterVM();
                    for (int i = 0; i < FanList.Count(); i++)
                    {
                        item = new MemberMasterVM();
                        //微信端用户基本信息
                        item.WeChatMember = FanList.ToList()[i];

                        //微信端订单数量信息
                        item.WeChatOrderCount = GetWechatOrderCount(weChatOrder, item.WeChatMember.ID ?? -1);

                        //补齐系统编号到八位,显示用
                        item.DisplayID = string.Format("{0:D8}", item.WeChatMember.ID ?? 0);

                        //补齐线上默认信息
                        item.CustomerCode = new Collection <string>();
                        item.CustomerCode.Add("--");
                        item.WebCreadit    = 0;
                        item.WebOrderCount = 0;

                        VM.Add(item);
                    }
                }

                #endregion

                return(VM);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        //public ActionResult UnBind

        /// <summary>
        /// 会员个人信息详情页
        /// <param name="id">会员微信系统编号</param>
        /// </summary>
        /// <returns></returns>
        public ActionResult MemberDetail(long id)
        {
            var svc    = Service;
            var OSvc   = ORSService;
            var CSvc   = CONService;
            var Member = svc.SelectOrEmpty(new FanQuery()
            {
                IDs = new long[] { id }
            }).FirstOrDefault();
            MemberPersonalVM PersonalVM = new MemberPersonalVM();

            #region 微信端用户基本信息

            if (Member != null)
            {
                UserInfo UInfo = CSvc.RequeUserInfo(OwnerID, Member.Code);
                //微信系统用户基本信息
                PersonalVM.WeChatMember = Member;

                PersonalVM.WeChatExtra = new WeChatPersonalExtra();

                PersonalVM.WeChatExtra.City       = UInfo.city;
                PersonalVM.WeChatExtra.Province   = UInfo.province;
                PersonalVM.WeChatExtra.Country    = UInfo.country;
                PersonalVM.WeChatExtra.Gender     = UInfo.sex;
                PersonalVM.WeChatExtra.GenderName = ((MemberGender)UInfo.sex).GetDescription();
                PersonalVM.WeChatExtra.NickName   = UInfo.nickname;
                PersonalVM.WeChatExtra.FollowDate = FollowTime(UInfo.subscribe_time);
            }

            #endregion

            #region 主系统关联信息

            var relatedQuery = new MemberRelatedQuery {
                FanIDs = new long[] { id }
            };
            var relatedRecord = svc.SelectOrEmpty(relatedQuery).FirstOrDefault();
            if (relatedRecord != null)
            {
                var webQuery = new CustomerQuery
                {
                    IDs = new long[] { relatedRecord.CustomerID ?? -1 }
                };
                var webMember = OSvc.SelectOrEmpty(webQuery).FirstOrDefault();
                if (webMember != null)
                {
                    PersonalVM.WebExtra = new WebPersonalExtra();

                    PersonalVM.WebExtra.CustomerMobile = webMember.Mobile;
                    PersonalVM.WebExtra.CustomerEmail  = webMember.Email;

                    //主系统会员等级信息
                    var rankQuery = new CustomerRankQuery
                    {
                        IDs = new long[] { webMember.RankID ?? -1 }
                    };
                    var rankItem = OSvc.SelectOrEmpty(rankQuery).FirstOrDefault();
                    if (rankItem != null)
                    {
                        PersonalVM.WebExtra.CustomerRank = rankItem.Name;
                    }

                    //主系统会员积分信息
                    var balanceQuery = new CustomerBalanceQuery
                    {
                        IDs = new long[] { webMember.ID ?? -1 }
                    };
                    var balanceItem = OSvc.SelectOrEmpty(balanceQuery).FirstOrDefault();
                    if (balanceItem != null)
                    {
                        PersonalVM.WebExtra.CustomerCredit = balanceItem.Point;
                    }

                    //主系统会员登陆名信息
                    var identityQuery = new CustomerIdentityQuery
                    {
                        CustomerIDs = new long[] { webMember.ID ?? -1 }
                    };
                    var identityList = OSvc.SelectOrEmpty(identityQuery);
                    if (identityList != null && identityList.Any())
                    {
                        PersonalVM.WebExtra.CustomerId = new List <string>();
                        foreach (var identityItem in identityList)
                        {
                            PersonalVM.WebExtra.CustomerId.Add(identityItem.Code);
                        }
                    }
                }

                return(View(PersonalVM));
            }

            #endregion

            return(View(PersonalVM));
        }