// /// <summary> /// 处理会员的上下线关系 /// 会员状态 已经有上级关系 有新的附带上级关系 /// 从未关注的Vip 1 1 重建关系 /// 从未关注的Vip 0 1 重建关系 /// 取消关注的Vip 0 1 重建关系 /// 从未关注的Vip 0 0 /// 从未关注的Vip 1 0 /// 取消关注的Vip 1 0 /// 取消关注的Vip 0 0 /// 取消关注的Vip 1 1 /// ShareVipID 没内容的 return public void SetShareVip(string vipid, string openId) { #region 验证 if (string.IsNullOrEmpty(ShareVipID))//如果没有上级分享人员 { return; } #endregion #region Vip实体 VipBLL vipBll = new VipBLL(loggingSessionInfo); VipEntity vipInfotmp = null; if (string.IsNullOrEmpty(vipid)) { return; } else { vipInfotmp = vipBll.GetByID(vipid); } if (vipInfotmp == null) { return; } #endregion #region UnitId string UnitId = ""; //获取分享人的门店信息 //员工 或者 客服 string shareVipOpenid = ""; if (SourceId == 1 || SourceId == 2) //获取分享员工的默认门店 { UnitId = vipBll.GetUnitByUserId(ShareVipID); //获取员工的默认门店 } else { //获取分享会员的门店 VipEntity shareVip = vipBll.GetByID(ShareVipID); if (shareVip != null) { UnitId = shareVip.CouponInfo;//会员的会籍店 shareVipOpenid = shareVip.WeiXinUserId; } } #endregion #region 判断用户类型 #region 关注的 if (vipInfotmp.Status >= 1)//关注过的 { //当前没有上线,才给他建立一个上线 if (string.IsNullOrEmpty(vipInfotmp.SetoffUserId) && string.IsNullOrEmpty(vipInfotmp.HigherVipID)) { //会员 或者 客服 if (SourceId == 1 || SourceId == 2)//获取分享员工的默认门店 { vipInfotmp.SetoffUserId = ShareVipID; vipInfotmp.HigherVipID = ""; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } //会员 else { vipInfotmp.HigherVipID = ShareVipID; vipInfotmp.SetoffUserId = ""; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } else if (SourceId == 4 && string.IsNullOrEmpty(vipInfotmp.Col20)) { vipInfotmp.Col20 = ShareVipID; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } #endregion #region 取消关注的 else if (vipInfotmp.Status == 0 && vipInfotmp.Col25 == "1")//取消关注的 { if (string.IsNullOrEmpty(vipInfotmp.SetoffUserId) && string.IsNullOrEmpty(vipInfotmp.HigherVipID)) { if (SourceId == 1 || SourceId == 2)//获取分享员工的默认门店 { vipInfotmp.SetoffUserId = ShareVipID; vipInfotmp.HigherVipID = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } else { vipInfotmp.HigherVipID = ShareVipID; vipInfotmp.SetoffUserId = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } else if (SourceId == 4 && string.IsNullOrEmpty(vipInfotmp.Col20)) { vipInfotmp.Col20 = ShareVipID; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } #endregion #region 未关注的 else { //未关注的(oauth认证获取的) //客服 员工 if (SourceId == 1 || SourceId == 2) //获取分享员工的默认门店 { vipInfotmp.SetoffUserId = ShareVipID; vipInfotmp.HigherVipID = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } else if (SourceId == 4) { vipInfotmp.Col20 = ShareVipID; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } //会员 else { vipInfotmp.HigherVipID = ShareVipID; vipInfotmp.SetoffUserId = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } #endregion #endregion if (string.IsNullOrEmpty(UnitId)) { UnitService unitServer = new UnitService(loggingSessionInfo); UnitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识 } vipInfotmp.CouponInfo = UnitId; vipInfotmp.Col24 = ObjectID; vipInfotmp.Col23 = SourceId.ToString(); vipBll.Update(vipInfotmp, false); //分享记录 T_LEventsSharePersonLogBLL t_LEventsSharePersonLogBLL = new T_LEventsSharePersonLogBLL(loggingSessionInfo); //先查看这个会员之前是否已经打开这个图文素材 var t_LEventsSharePersonLogTemp = new T_LEventsSharePersonLogEntity(); t_LEventsSharePersonLogTemp.BusTypeCode = objectType; t_LEventsSharePersonLogTemp.ObjectId = ObjectID; ////分享的链接代表的对象,活动或者商品 t_LEventsSharePersonLogTemp.ShareVipType = SourceId; // 1员工,2客服,3会员 4超级分销商 t_LEventsSharePersonLogTemp.ShareVipID = ShareVipID; t_LEventsSharePersonLogTemp.BeShareVipID = vipid; //被分享人 var t_LEventsSharePersonLogOld = t_LEventsSharePersonLogBLL.QueryByEntity(t_LEventsSharePersonLogTemp, null); //如果已经有这样的记录,就不要再写了 if (t_LEventsSharePersonLogOld != null && t_LEventsSharePersonLogOld.Length > 0) { return; } //第一次打开的时候才创建 var t_LEventsSharePersonLog = new T_LEventsSharePersonLogEntity(); t_LEventsSharePersonLog.SharePersonLogId = Guid.NewGuid(); t_LEventsSharePersonLog.BusTypeCode = objectType; t_LEventsSharePersonLog.ObjectId = ObjectID; ////分享的链接代表的对象,活动或者商品 t_LEventsSharePersonLog.ShareVipType = SourceId; // 1员工,2客服,3会员 t_LEventsSharePersonLog.ShareVipID = ShareVipID; t_LEventsSharePersonLog.ShareOpenID = shareVipOpenid; //如果是会员,取出来 t_LEventsSharePersonLog.BeShareVipID = vipid; //新建的会员会员的vipid t_LEventsSharePersonLog.BeShareOpenID = openId; //本分享人的id t_LEventsSharePersonLog.ShareURL = goUrl; //分享的链接 t_LEventsSharePersonLog.CreateTime = System.DateTime.Now; t_LEventsSharePersonLog.CreateBy = ""; t_LEventsSharePersonLog.LastUpdateBy = ""; t_LEventsSharePersonLog.LastUpdateTime = System.DateTime.Now; t_LEventsSharePersonLog.CustomerId = loggingSessionInfo.ClientID; t_LEventsSharePersonLog.IsDelete = 0; t_LEventsSharePersonLogBLL.Create(t_LEventsSharePersonLog); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(T_LEventsSharePersonLogEntity pEntity, IDbTransaction pTran) { _currentDAO.Update(pEntity, pTran); }
protected override CTWEventShareLogRD ProcessRequest(DTO.Base.APIRequest <CTWEventShareLogRP> pRequest) { var rd = new CTWEventShareLogRD();//返回值 var para = pRequest.Parameters; if (!string.IsNullOrEmpty(para.CTWEventId) && !string.IsNullOrEmpty(para.Sender) && !string.IsNullOrEmpty(para.OpenId)) { var bllLeventShareLog = new T_LEventsSharePersonLogBLL(this.CurrentUserInfo); var entityLeventShareLog = new T_LEventsSharePersonLogEntity(); entityLeventShareLog.ShareVipID = para.Sender; entityLeventShareLog.ShareOpenID = para.OpenId; entityLeventShareLog.BeShareOpenID = para.BeSharedOpenId; entityLeventShareLog.BeShareVipID = para.BEsharedUserId; entityLeventShareLog.BusTypeCode = "CTW"; entityLeventShareLog.ObjectId = para.CTWEventId; entityLeventShareLog.ShareURL = para.ShareURL; entityLeventShareLog.ShareVipType = 3; bllLeventShareLog.Create(entityLeventShareLog); //是否分享给自己 if (para.Sender == para.BEsharedUserId) { return(rd); } //触点奖励 ContactEventBLL bllContactEvent = new ContactEventBLL(this.CurrentUserInfo); var entityContact = bllContactEvent.QueryByEntity(new ContactEventEntity() { EventId = para.CTWEventId, IsDelete = 0, IsCTW = 1, ContactTypeCode = "Share" }, null).SingleOrDefault(); if (entityContact != null) { LPrizesBLL bllPrize = new LPrizesBLL(this.CurrentUserInfo); LPrizeWinnerBLL bllPrizeWinner = new LPrizeWinnerBLL(this.CurrentUserInfo); LLotteryLogBLL bllLottery = new LLotteryLogBLL(this.CurrentUserInfo); ///判断是否已经获得奖励 int intLogCount = bllLottery.GetEventLotteryLogByEventId(entityContact.ContactEventId.ToString(), para.Sender); if (intLogCount > 0) { return(rd); } var prize = DataTableToObject.ConvertToList <LPrizesEntity>(bllPrize.GetCouponTypeIDByEventId(entityContact.ContactEventId.ToString()).Tables[0]).FirstOrDefault(); if (prize != null) { CouponBLL bllCoupon = new CouponBLL(this.CurrentUserInfo); if (prize.PrizeTypeId == "Coupon") { bllCoupon.CouponBindVip(para.Sender, prize.CouponTypeID, entityContact.ContactEventId.ToString(), "Share"); DataSet ds = bllPrize.GetAllCouponTypeByPrize(prize.PrizesID); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); foreach (DataRow dr in ds.Tables[0].Rows) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = this.CurrentUserInfo.ClientID, CouponTypeId = dr["CouponTypeID"].ToString() }, entityContact.ContactEventId.ToString(), para.Sender, "Share"); } } } if (prize.PrizeTypeId == "Point") { #region 调用积分统一接口 var salesReturnBLL = new T_SalesReturnBLL(this.CurrentUserInfo); VipIntegralBLL bllVipIntegral = new VipIntegralBLL(this.CurrentUserInfo); var vipBLL = new VipBLL(this.CurrentUserInfo); var vipInfo = vipBLL.GetByID(para.Sender); var IntegralDetail = new VipIntegralDetailEntity() { Integral = prize.Point, IntegralSourceID = "28", ObjectId = entityContact.ContactEventId.ToString() }; //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = bllVipIntegral.AddIntegral(ref vipInfo, null, IntegralDetail, null, this.CurrentUserInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, this.CurrentUserInfo); } #endregion } #region 奖励日志 LPrizeWinnerEntity entityPrizeWinner = new LPrizeWinnerEntity() { PrizeWinnerID = Guid.NewGuid().ToString(), VipID = para.Sender, PrizeID = prize.PrizesID, PrizeName = prize.PrizeName, PrizePoolID = "", CreateBy = this.CurrentUserInfo.UserID, CreateTime = DateTime.Now, IsDelete = 0 }; bllPrizeWinner.Create(entityPrizeWinner); LLotteryLogEntity lotteryEntity = new LLotteryLogEntity() { LogId = Guid.NewGuid().ToString(), VipId = para.Sender, EventId = entityContact.ContactEventId.ToString(), LotteryCount = 1, IsDelete = 0 }; bllLottery.Create(lotteryEntity); #endregion } } } return(rd); }
/// <summary> /// 创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> public void Create(T_LEventsSharePersonLogEntity pEntity) { _currentDAO.Create(pEntity); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <T_LEventsSharePersonLogEntity> PagedQueryByEntity(T_LEventsSharePersonLogEntity 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 T_LEventsSharePersonLogEntity[] QueryByEntity(T_LEventsSharePersonLogEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(T_LEventsSharePersonLogEntity pEntity) { _currentDAO.Delete(pEntity); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetSharePersonLogRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var t_LEventsSharePersonLogBLL = new T_LEventsSharePersonLogBLL(CurrentUserInfo); var SharePersonLogEntity = new T_LEventsSharePersonLogEntity();//通用分享实体实例化 SharePersonLogEntity.SharePersonLogId = Guid.NewGuid(); string objectType = string.Empty; if (!string.IsNullOrEmpty(para.ToolType))//para.ToolType.ToLower() == "material" { objectType = para.ToolType; switch (para.ToolType.ToLower()) { case "ctw": para.ToolType = "CTW"; break; case "coupon": para.ToolType = "Coupon"; break; case "setoffposter": para.ToolType = "SetoffPoster"; break; case "goods": para.ToolType = "Goods"; break; case "material": para.ToolType = "SuperRetailTraderFToT"; break; default: para.ToolType = "SuperRetailTraderFToT"; break; } } SharePersonLogEntity.BusTypeCode = para.ToolType; SharePersonLogEntity.ObjectId = para.ObjectID; if (string.IsNullOrEmpty(para.ShareVipType)) { para.ShareVipType = "4"; } SharePersonLogEntity.ShareVipType = Convert.ToInt32(para.ShareVipType); SharePersonLogEntity.ShareVipID = CurrentUserInfo.CurrentUser.User_Id; var vipbll = new VipBLL(CurrentUserInfo); var vipInfo = vipbll.QueryByEntity(new VipEntity() { VIPID = CurrentUserInfo.CurrentUser.User_Id }, null).FirstOrDefault(); if (vipInfo != null && !string.IsNullOrEmpty(vipInfo.VIPID)) { SharePersonLogEntity.ShareOpenID = vipInfo.WeiXinUserId; } SharePersonLogEntity.BeShareVipID = "1"; SharePersonLogEntity.CreateTime = System.DateTime.Now; SharePersonLogEntity.CreateBy = CurrentUserInfo.CurrentUser.User_Id; SharePersonLogEntity.CustomerId = CurrentUserInfo.CurrentUser.customer_id; SharePersonLogEntity.IsDelete = 0; t_LEventsSharePersonLogBLL.Create(SharePersonLogEntity); var setoffToolUserViewBLL = new SetoffToolUserViewBLL(CurrentUserInfo); var setOffToolInfo = new SetoffToolsBLL(CurrentUserInfo).QueryByEntity(new SetoffToolsEntity() { SetoffToolID = new Guid(para.SetOffToolID) }, null).FirstOrDefault(); var UserViewData = setoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity() { ObjectId = para.ObjectID, UserID = CurrentUserInfo.CurrentUser.User_Id }, null); if (!string.IsNullOrEmpty(para.ObjectID)) { UserViewData = setoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity() { ObjectId = para.ObjectID, UserID = CurrentUserInfo.CurrentUser.User_Id, SetoffToolID = new Guid(para.ObjectID) }, null); } //如果不存在已读数据则在推送之前 进行已读数据入库 if (UserViewData.Length == 0 && !string.IsNullOrEmpty(para.ObjectID) && setOffToolInfo != null) { var SetoffToolUserView = new SetoffToolUserViewEntity(); SetoffToolUserView.SetoffToolUserViewID = Guid.NewGuid(); SetoffToolUserView.SetoffEventID = setOffToolInfo.SetoffEventID; SetoffToolUserView.ObjectId = para.ObjectID; SetoffToolUserView.SetoffToolID = new Guid(para.SetOffToolID); SetoffToolUserView.ToolType = objectType; SetoffToolUserView.NoticePlatformType = 3; SetoffToolUserView.UserID = CurrentUserInfo.CurrentUser.User_Id; SetoffToolUserView.IsOpen = 1; SetoffToolUserView.OpenTime = System.DateTime.Now; SetoffToolUserView.CustomerId = CurrentUserInfo.CurrentUser.customer_id; SetoffToolUserView.CreateTime = System.DateTime.Now; SetoffToolUserView.CreateBy = CurrentUserInfo.CurrentUser.User_Id; SetoffToolUserView.LastUpdateTime = System.DateTime.Now; SetoffToolUserView.LastUpdateBy = CurrentUserInfo.CurrentUser.User_Id; SetoffToolUserView.IsDelete = 0; setoffToolUserViewBLL.Create(SetoffToolUserView); } return(rd); }