/// 内部消息 /// </summary> public string GetGroupNewsByID(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <GetGroupNewsByIDRP> >();//不需要参数 string userId = rp.UserID; string customerId = rp.CustomerID; if (string.IsNullOrEmpty(rp.Parameters.GroupNewsID)) { throw new APIException("缺少参数【GroupNewsID】或参数值为空") { ErrorCode = 135 }; } LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); // var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; InnerGroupNewsBLL bll = new InnerGroupNewsBLL(loggingSessionInfo); var rd = new GetGroupNewsByIDRD(); var ds = bll.GetByID(rp.Parameters.GroupNewsID); // if (ds != null && !string.IsNullOrEmpty(ds.CreateBy)) { //t_user从取创建用户 T_UserBLL bll2 = new T_UserBLL(loggingSessionInfo); //更新为已读 T_UserEntity t_user = bll2.GetByID(ds.CreateBy); if (t_user != null) { ds.CreateBy = t_user.user_name; } else { ds.CreateBy = ""; } //把该条信息设置为已经读过 NewsUserMappingBLL bll3 = new NewsUserMappingBLL(loggingSessionInfo); NewsUserMappingEntity en = new NewsUserMappingEntity(); en.UserID = rp.UserID; en.GroupNewsID = rp.Parameters.GroupNewsID; NewsUserMappingEntity[] lsen = bll3.QueryByEntity(en, null); if (lsen != null && lsen.Length != 0) { en = lsen[0]; en.HasRead = 1; bll3.Update(en, null); } } rd.InnerGroupNewsInfo = ds; var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(NewsUserMappingEntity pEntity, IDbTransaction pTran) { _currentDAO.Update(pEntity, pTran); }
/// <summary> /// 创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> public void Create(NewsUserMappingEntity pEntity) { _currentDAO.Create(pEntity); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <NewsUserMappingEntity> PagedQueryByEntity(NewsUserMappingEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex) { return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex)); }
/// <summary> /// 根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public NewsUserMappingEntity[] QueryByEntity(NewsUserMappingEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(NewsUserMappingEntity pEntity) { _currentDAO.Delete(pEntity); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> public void Update(NewsUserMappingEntity pEntity) { _currentDAO.Update(pEntity); }
/// <summary> /// 支付完成时注册绑卡 (目前可用于绑卡列表处的绑卡升级处理) /// </summary> /// <param name="vipId"></param> /// <param name="vipCode"></param> /// <param name="unitId"></param> /// <param name="ObjecetTypeId">卡类型Id</param> /// <param name="OrderType">订单类型 SalesCard=销售 Recharge=充值</param> /// <param name="OperationType">操作类型 1-手动 2-自动</param> /// <returns></returns> public string BindVirtualItem(string vipId, string vipCode, string unitId, int ObjecetTypeId, string OrderType = "SalesCard", int OperationType = 1, string orderId = "") { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); var sysVipCardTypeBLL = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardBLL = new VipCardBLL(CurrentUserInfo); var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(CurrentUserInfo); string ObjectNo = string.Empty;//卡号或券号 try { UnitService unitServer = new UnitService(CurrentUserInfo); if (string.IsNullOrEmpty(unitId)) { unitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识 } //根据vipid查询VipCardVipMapping,判断是否有绑卡 var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = vipId }, null).FirstOrDefault(); //判断商户是否有付费的会员卡,有付费会员卡时,不自动绑卡 //List<IWhereCondition> freeCardCon = new List<IWhereCondition> { }; //freeCardCon.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); //freeCardCon.Add(new DirectCondition("Prices>0")); //var freeCardTypeInfo = sysVipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault(); //if (freeCardTypeInfo == null) //{ ////查询最低等级的会员卡类型 //var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0 }, new OrderBy[] { new OrderBy() { FieldName = "vipcardlevel", Direction = OrderByDirections.Asc } }).FirstOrDefault(); //if (vipCardTypeInfo != null) //{ if (vipCardMappingInfo == 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) { throw new APIException("系统未创建会员卡类型") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //查询此类型会员卡是否存在 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); } ObjectNo = vipCardInfo.VipCardCode; //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = vipId, VipCardID = vipCardInfo.VipCardID, CustomerID = CurrentUserInfo.ClientID }; vipCardVipMappingBLL.Create(vipCardVipMappingEntity); vipCardMappingInfo = vipCardVipMappingEntity; //新增会员卡操作状态信息 var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = vipCardInfo.VipCardStatusId, VipCardID = vipCardInfo.VipCardID, Action = "注册", UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity); } #region 老卡业务处理 ObjectNo = vipCode; //老卡信息获取 var oldVipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID }, null).FirstOrDefault(); //老卡卡类型ID int oldVipCardTypeID = 0; if (oldVipCardInfo != null) { //获取老卡的类型 var oldVipCardType = sysVipCardTypeBLL.GetByID(oldVipCardInfo.VipCardTypeID); //获取即将升级卡的类型 var newVipCardType = sysVipCardTypeBLL.GetByID(ObjecetTypeId); if (newVipCardType.VipCardLevel > oldVipCardType.VipCardLevel) { //老卡卡类型ID oldVipCardTypeID = oldVipCardInfo.VipCardTypeID ?? 0; //更新卡信息 oldVipCardInfo.VipCardTypeID = ObjecetTypeId; vipCardBLL.Update(oldVipCardInfo); //老卡操作状态信息 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 vipCardGradeChangeLogBll = new VipCardGradeChangeLogBLL(CurrentUserInfo); var vipCardUpgradeRuleBll = new VipCardUpgradeRuleBLL(CurrentUserInfo); var vipCardUpgradeRuleEntity = vipCardUpgradeRuleBll.QueryByEntity(new VipCardUpgradeRuleEntity() { CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = ObjecetTypeId }, null).FirstOrDefault(); var VipCardGradeChangeLogEntity = new VipCardGradeChangeLogEntity() { ChangeLogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardUpgradeRuleId = vipCardUpgradeRuleEntity.VipCardUpgradeRuleId, OrderType = OrderType, VipCardID = oldVipCardInfo.VipCardID, ChangeBeforeVipCardID = oldVipCardInfo.VipCardID, ChangeBeforeGradeID = oldVipCardTypeID, NowGradeID = oldVipCardInfo.VipCardTypeID, ChangeReason = "upgrade", OperationType = OperationType, ChangeTime = DateTime.Now, UnitID = unitId, OrderId = orderId, CustomerID = CurrentUserInfo.ClientID, }; vipCardGradeChangeLogBll.Create(VipCardGradeChangeLogEntity); //开卡礼 var vipCardUpgradeRewardBll = new VipCardUpgradeRewardBLL(CurrentUserInfo); var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity() { VipCardTypeID = ObjecetTypeId }, 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"); } } } //消费升级 if (OperationType == 2) { //群发消息表 var InnerGroupNewsBll = new InnerGroupNewsBLL(CurrentUserInfo); var innerGroupNewsEntity = new InnerGroupNewsEntity() { GroupNewsId = Guid.NewGuid().ToString().Replace("-", ""), SentType = 2, NoticePlatformType = 1, BusType = 3, Title = "升级提醒", Text = "升级成功", CustomerID = CurrentUserInfo.ClientID }; InnerGroupNewsBll.Create(innerGroupNewsEntity); //消息和用户关系表 var newsUserMappingBll = new NewsUserMappingBLL(CurrentUserInfo); var newsUserMappingEntity = new NewsUserMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), UserID = vipId, GroupNewsID = innerGroupNewsEntity.GroupNewsId, CustomerId = CurrentUserInfo.ClientID, HasRead = 0 }; newsUserMappingBll.Create(newsUserMappingEntity); } } } #endregion } catch { throw new APIException("升级失败!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; }; //记录会员信息改变,并且把旧的会员的标识也放在契约里 var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = vipId, }; eventService.PublishMsg(vipMsg); return(ObjectNo); }
/// <summary> /// 消息详情展示{业务:查看详情信息并且标识为已读账户} /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override GetInnerGroupNewsByIdRD ProcessRequest(DTO.Base.APIRequest <GetInnerGroupNewsByIdRP> pRequest) { #region 设置参数 var parameter = pRequest.Parameters; var rd = new GetInnerGroupNewsByIdRD(); //返回数据 LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); InnerGroupNewsBLL bll = new InnerGroupNewsBLL(loggingSessionInfo); NewsUserMappingBLL newsusermappingService = new NewsUserMappingBLL(loggingSessionInfo); #endregion //分页查找消息列表 DateTime CreateTime = DateTime.Now; var vipinfo = new VipBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (vipinfo != null) //按照时间过滤 { CreateTime = Convert.ToDateTime(vipinfo.CreateTime); } var userinfo = new T_UserBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (userinfo != null) { CreateTime = Convert.ToDateTime(userinfo.create_time); } if (vipinfo == null && userinfo == null) { var T_SuperRetailTrader = new T_SuperRetailTraderBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (T_SuperRetailTrader != null) { userinfo = new T_UserBLL(loggingSessionInfo).GetByID(T_SuperRetailTrader.SuperRetailTraderFromId); if (userinfo != null) { CreateTime = Convert.ToDateTime(userinfo.create_time); } else { vipinfo = new VipBLL(loggingSessionInfo).GetByID(T_SuperRetailTrader.SuperRetailTraderFromId); if (vipinfo != null) //按照时间过滤 { CreateTime = Convert.ToDateTime(vipinfo.CreateTime); } } } } var model = bll.GetVipInnerGroupNewsDetailsByPaging(parameter.Operationtype, pRequest.CustomerID, parameter.NoticePlatformTypeId, parameter.GroupNewsID, CreateTime); if (model == null || String.IsNullOrEmpty(model.GroupNewsId)) { if (parameter.Operationtype == 1) //0=当前消息 1=下一条消息 2=上一条消息 { throw new APIException("已经是最后一条消息啦。") { ErrorCode = 135 }; } else if (parameter.Operationtype == 2) { throw new APIException("已经是第一条消息啦。") { ErrorCode = 135 }; } } List <IWhereCondition> lstWhereCondition = new List <IWhereCondition>(); lstWhereCondition.Add(new EqualsCondition() { FieldName = "CustomerID", Value = pRequest.CustomerID }); lstWhereCondition.Add(new EqualsCondition() { FieldName = "NoticePlatformType", Value = parameter.NoticePlatformTypeId }); lstWhereCondition.Add(new EqualsCondition() { FieldName = "IsDelete", Value = "0" }); lstWhereCondition.Add(new DirectCondition() { Expression = "BusType <> 3 " }); lstWhereCondition.Add(new DirectCondition() { Expression = "CreateTime>='" + CreateTime + "'" }); var MessageList = bll.PagedQuery(lstWhereCondition.ToArray(), null, 1, 1); //分页获取数据 rd.TotalPageCount = MessageList.RowCount; //获取总数据 if (model != null) { //获取上一条数据 或者下一条 数据 rd.NewsInfo = new InnerGroupNewsInfo() { Title = model.Title, Text = model.Text, CreateTime = model.CreateTime, GroupNewsId = model.GroupNewsId }; bool IsRead = bll.CheckUserIsReadMessage(pRequest.UserID, pRequest.CustomerID, rd.NewsInfo.GroupNewsId); if (IsRead) { NewsUserMappingEntity _model = new NewsUserMappingEntity() { CustomerId = pRequest.CustomerID, UserID = pRequest.UserID, GroupNewsID = rd.NewsInfo.GroupNewsId, HasRead = 1, IsDelete = 0 }; _model.GroupNewsID = rd.NewsInfo.GroupNewsId; newsusermappingService.Create(_model); } if (parameter.Operationtype == 1) //0=当前消息 1=下一条消息 2=上一条消息 { rd.PageIndex = -(model.PageIndex - rd.TotalPageCount) + 1; } else if (parameter.Operationtype == 2 || parameter.Operationtype == 0) { rd.PageIndex = model.PageIndex; } } return(rd); }