/// <summary> /// 获取近期关注的会员 /// </summary> /// <param name="Weixin"></param> /// <param name="TimeLength"></param> /// <returns></returns> public IList <VipShowLogEntity> GetRecentfollowers(string Weixin, string TimeLength) { IList <VipShowLogEntity> vipShowLogInfoList = new List <VipShowLogEntity>(); DataSet ds = new DataSet(); ds = _currentDAO.GetRecentfollowers(Weixin, TimeLength); if (ds != null && ds.Tables[0].Rows.Count > 0) { vipShowLogInfoList = DataTableToObject.ConvertToList <VipShowLogEntity>(ds.Tables[0]); if (vipShowLogInfoList != null && vipShowLogInfoList.Count > 0) { VipBLL vipService = new VipBLL(this.CurrentUserInfo); foreach (var info in vipShowLogInfoList) { if (info.VipCode == null || info.VipCode.Equals("")) { VipEntity vipInfo = new VipEntity(); vipInfo.VipCode = vipService.GetVipCode(); info.VipCode = vipInfo.VipCode; vipInfo.VIPID = info.VIPID; vipService.Update(vipInfo, false); } } } } return(vipShowLogInfoList); }
/// <summary> /// 支付回调/收款处理虚拟商品订单 /// </summary> public void SetVirtualItem(LoggingSessionInfo loggingSessionInfo, string orderId) { var inoutBLL = new T_InoutBLL(loggingSessionInfo); var inoutInfo = this._currentDAO.GetByID(orderId); if (inoutInfo != null) { //如果是经销商订单,付款完成后,订单状态修改成完成状态 if (inoutInfo.data_from_id == "21") { inoutInfo.Field7 = "700"; inoutInfo.status = "700"; inoutBLL.Update(inoutInfo); InoutService inoutService = new InoutService(loggingSessionInfo); T_VirtualItemTypeSettingBLL virtualItemTypeSettingBLL = new T_VirtualItemTypeSettingBLL(loggingSessionInfo); VipCardVipMappingBLL vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); T_Inout_DetailBLL inoutDetailBLL = new T_Inout_DetailBLL(loggingSessionInfo); var VipBLL = new VipBLL(loggingSessionInfo); var inoutDetail = inoutService.GetInoutDetailInfoByOrderId(orderId).FirstOrDefault(); string itemId = inoutDetail.item_id; var virtualItemTypeSettingInfo = virtualItemTypeSettingBLL.QueryByEntity(new T_VirtualItemTypeSettingEntity() { ItemId = itemId }, null).FirstOrDefault(); if (virtualItemTypeSettingInfo != null) { int objectTypeId = int.Parse(virtualItemTypeSettingInfo.ObjecetTypeId); string objectNo = vipCardVipMappingBLL.BindVirtualItem(inoutInfo.vip_no, inoutInfo.VipCardCode, "", objectTypeId); //将卡/券的编号保存到订单明细 T_Inout_DetailEntity inoutDetailEntity = inoutDetailBLL.GetByID(inoutDetail.order_detail_id); if (inoutDetailEntity != null) { inoutDetailEntity.Field10 = objectNo; inoutDetailBLL.Update(inoutDetailEntity); } } //将Col48至为1 var VipData = VipBLL.GetByID(inoutInfo.vip_no); if (VipData != null) { VipData.Col48 = "1"; VipBLL.Update(VipData); } // 判断客户是否是符合潜在经销商条件 var isCan = VipBLL.IsSetVipDealer(inoutInfo.vip_no); if (isCan) { new RetailTraderBLL(loggingSessionInfo).CreatePrepRetailTrader(loggingSessionInfo, inoutInfo.vip_no); // 创建潜在经销商 } } } }
/// <summary> /// 会员微信注册绑卡 /// </summary> /// <param name="vipId"></param> /// <param name="vipCode"></param> /// <param name="unitId">会籍店</param> public void BindVipCard(string vipId, string vipCode, string unitId) { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); var sysVipCardTypeBLL = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardBLL = new VipCardBLL(CurrentUserInfo); var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(CurrentUserInfo); UnitService unitServer = new UnitService(CurrentUserInfo); if (string.IsNullOrEmpty(unitId)) { unitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识 } //根据vipid查询VipCardVipMapping,判断是否有绑卡,没绑卡默认给等级1的卡 var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = vipId }, null).FirstOrDefault(); if (vipCardMappingInfo == null) { //判断商户是否有付费的会员卡,有付费会员卡时,不自动绑卡 List <IWhereCondition> freeCardCon = new List <IWhereCondition> { }; freeCardCon.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); freeCardCon.Add(new DirectCondition("VipCardLevel=1")); var orderBys = new OrderBy[1]; orderBys[0] = new OrderBy() { FieldName = "VipCardLevel", Direction = OrderByDirections.Asc }; var freeCardTypeInfo = sysVipCardTypeBLL.Query(freeCardCon.ToArray(), orderBys).FirstOrDefault(); if (freeCardTypeInfo != null) { //查询最低等级的会员卡类型 var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardLevel = 1 }, new OrderBy[] { new OrderBy() { FieldName = "vipcardlevel", Direction = OrderByDirections.Asc } }).FirstOrDefault(); if (vipCardTypeInfo != null) { //查询此类型会员卡是否存在 var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID, VipCardStatusId = 0, MembershipUnit = "" }, null).FirstOrDefault(); //不存在,制卡 if (vipCardInfo == null) { vipCardInfo = new VipCardEntity(); vipCardInfo.VipCardID = Guid.NewGuid().ToString(); vipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardInfo.VipCardTypeName = vipCardTypeInfo.VipCardTypeName; vipCardInfo.VipCardCode = vipCode; vipCardInfo.VipCardStatusId = 1;//正常 vipCardInfo.MembershipUnit = unitId; vipCardInfo.MembershipTime = DateTime.Now; vipCardInfo.CustomerID = CurrentUserInfo.ClientID; vipCardBLL.Create(vipCardInfo); } else//存在更新成现在的 { vipCardInfo.VipCardStatusId = 1;//正常 vipCardInfo.MembershipUnit = unitId; vipCardInfo.MembershipTime = DateTime.Now; vipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardBLL.Update(vipCardInfo); //存在导入的卡时,更新当前会员的VipCode var vipbll = new VipBLL(CurrentUserInfo); List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0 }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = vipId }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = CurrentUserInfo.ClientID }); var VipInfo = vipbll.Query(wheres.ToArray(), null).FirstOrDefault(); if (VipInfo != null && !string.IsNullOrEmpty(VipInfo.VIPID)) { VipInfo.VipCode = vipCardInfo.VipCardCode; //更新VipCode信息 vipbll.Update(VipInfo); } } //新增会员卡操作状态信息 var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = vipCardInfo.VipCardStatusId, VipCardID = vipCardInfo.VipCardID, Action = "注册", UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity); //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = vipId, VipCardID = vipCardInfo.VipCardID, CustomerID = CurrentUserInfo.ClientID }; vipCardVipMappingBLL.Create(vipCardVipMappingEntity); //开卡礼 var vipCardUpgradeRewardBll = new VipCardUpgradeRewardBLL(CurrentUserInfo); var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID }, null); var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); if (vipCardUpgradeRewardEntityList.Length > 0) { foreach (var vipCardUpgradeRewardEntity in vipCardUpgradeRewardEntityList) { for (int i = 0; i < vipCardUpgradeRewardEntity.CouponNum; i++) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = CurrentUserInfo.ClientID, CouponTypeId = vipCardUpgradeRewardEntity.CouponTypeId.ToString() }, vipCardUpgradeRewardEntity.CardUpgradeRewardId.ToString(), vipId, "OpenVipCard"); } } } } else { throw new APIException("系统未创建会员卡类型") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } }; } } else //更新旧卡 需要确认旧卡是否为卡体系内的卡 { var oldVipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); int oldVipCardTypeID = oldVipCardInfo.VipCardTypeID ?? 0; //查询最低等级的会员卡类型 var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardLevel = 1 }, new OrderBy[] { new OrderBy() { FieldName = "vipcardlevel", Direction = OrderByDirections.Asc } }).FirstOrDefault(); if (vipCardTypeInfo == null) { throw new APIException("系统未创建会员卡类型体系") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } if (oldVipCardInfo != null) { //旧卡不为空时,确认当前VipCardTypeID是否属于卡体系 var curvipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardTypeID = oldVipCardInfo.VipCardTypeID }, new OrderBy[] { new OrderBy() { FieldName = "VipCardTypeID", Direction = OrderByDirections.Asc } }).FirstOrDefault(); if (curvipCardTypeInfo == null) //若为空 则更新为当前信息 { oldVipCardInfo.VipCardStatusId = 1; //正常 oldVipCardInfo.MembershipUnit = unitId; oldVipCardInfo.MembershipTime = DateTime.Now; oldVipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardBLL.Update(oldVipCardInfo); //存在导入的卡时,更新当前会员的VipCode var vipbll = new VipBLL(CurrentUserInfo); List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0 }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = vipId }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = CurrentUserInfo.ClientID }); var VipInfo = vipbll.Query(wheres.ToArray(), null).FirstOrDefault(); if (VipInfo != null && !string.IsNullOrEmpty(VipInfo.VIPID)) { VipInfo.VipCode = oldVipCardInfo.VipCardCode; //更新VipCode信息 vipbll.Update(VipInfo); } //开卡礼 var vipCardUpgradeRewardBll = new VipCardUpgradeRewardBLL(CurrentUserInfo); var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID }, null); var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); if (vipCardUpgradeRewardEntityList.Length > 0) { foreach (var vipCardUpgradeRewardEntity in vipCardUpgradeRewardEntityList) { for (int i = 0; i < vipCardUpgradeRewardEntity.CouponNum; i++) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = CurrentUserInfo.ClientID, CouponTypeId = vipCardUpgradeRewardEntity.CouponTypeId.ToString() }, vipCardUpgradeRewardEntity.CardUpgradeRewardId.ToString(), vipId, "OpenVipCard"); } } } } } //老卡操作状态信息 var oldVipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = oldVipCardInfo.VipCardStatusId, VipCardID = oldVipCardInfo.VipCardID, Action = "注册", UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(oldVipCardStatusChangeLogEntity); } //记录会员信息改变,并且把旧的会员的标识也放在契约里 var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = vipId, }; eventService.PublishMsg(vipMsg); }