const int ERROR_PASSWORD_NOEXISTS = 332; //登录密码错误 #endregion protected override AuthCodeLoginRD ProcessRequest(APIRequest <MemberLoginRP> pRequest) { AuthCodeLoginRD rd = new AuthCodeLoginRD(); rd.MemberInfo = new MemberInfo(); var vipLoginBLL = new VipBLL(base.CurrentUserInfo); string mobile = "";; var VipLoginInfo = vipLoginBLL.GetLoginInfo(pRequest.Parameters.VipNo, mobile, pRequest.Parameters.Password); if (VipLoginInfo == null) { throw new APIException("会员账号不存在") { ErrorCode = ERROR_VIPID_NOTEXISTS } } ; if (pRequest.Parameters.Password != VipLoginInfo.VipPasswrod) { throw new APIException("登录密码错误") { ErrorCode = ERROR_PASSWORD_NOEXISTS } } ; #region VIP来源更新 switch (pRequest.Parameters.VipSource.Value) { case 4: case 9: VipLoginInfo.VipSourceId = pRequest.Parameters.VipSource.ToString(); vipLoginBLL.Update(VipLoginInfo, null); break; } #endregion if (string.IsNullOrEmpty(VipLoginInfo.ClientID)) { VipLoginInfo.ClientID = pRequest.CustomerID; vipLoginBLL.Update(VipLoginInfo, null); } rd.MemberInfo.Mobile = VipLoginInfo.Phone; //手机号码 rd.MemberInfo.Name = string.IsNullOrEmpty(VipLoginInfo.UserName) ? VipLoginInfo.Phone : VipLoginInfo.UserName; //姓名 rd.MemberInfo.VipID = VipLoginInfo.VIPID; //组标识 rd.MemberInfo.VipName = VipLoginInfo.VipName; //会员名 rd.MemberInfo.VipRealName = VipLoginInfo.VipRealName; rd.MemberInfo.VipNo = VipLoginInfo.VipCode; return(rd); } } }
protected override ChangeVipPWDRD ProcessRequest(DTO.Base.APIRequest <ChangeVipPWDRP> pRequest) { ChangeVipPWDRD rd = new ChangeVipPWDRD(); pRequest.Parameters.Validate(); #region 验证用户 var bll = new VipBLL(base.CurrentUserInfo); var entity = bll.GetByID(pRequest.Parameters.VipID); if (entity != null) { if (entity.VipPasswrod != pRequest.Parameters.SourcePWD) { throw new APIException("原密码错误") { ErrorCode = ERROR_LOGGIN_PWD }; } else { entity.VipPasswrod = pRequest.Parameters.NewPWD; bll.Update(entity); } } else { throw new APIException("用户不存在") { ErrorCode = ERROR_LOGGIN_NOUSER }; } #endregion return(rd); }
/// <summary> /// 更新会员信息 /// </summary> /// <returns></returns> public string UpdateUserInfo() { string content = string.Empty; var respData = new ambassadorLoginInRespData(); try { //接收参数 string reqContent = HttpContext.Current.Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ambassadorLoginInReqData>(); reqObj = reqObj == null ? new ambassadorLoginInReqData() : reqObj; //获取客户ID if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } //初始化返回对象 respData.content = new ambassadorLoginInRespContentData(); respData.content.vipList = new List <ambassadorLoginInRespContentDataItem>(); //用户登录信息 var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); VipBLL vipBLL = new VipBLL(loggingSessionInfo); VipEntity entity = new VipEntity(); //是否有此人 var vip = vipBLL.Query(new IWhereCondition[] { new EqualsCondition() { FieldName = "VipID", Value = reqObj.special.vipID }, new EqualsCondition() { FieldName = "ClientID", Value = customerId } }, null).FirstOrDefault(); if (vip != null) { entity = vipBLL.GetByID(vip.VIPID); entity.Col16 = reqObj.special.remark; entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); } respData.code = "200"; respData.description = "操作成功"; } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
/// <summary> /// 关联领奖人和推荐人 /// </summary> /// <returns></returns> public string BindRecommender() { string content = string.Empty; var respData = new Default.LowerRespData(); string reqContent = Request["ReqContent"]; Loggers.Debug(new DebugLogInfo() { Message = string.Format("getItemList: {0}", reqContent) }); try { //解析请求字符串 var reqObj = reqContent.DeserializeJSONTo <BindRecommenderReqData>(); //判断客户ID是否传递 if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); var vipBLL = new VipBLL(loggingSessionInfo); var vip = vipBLL.GetVipDetailByVipID(reqObj.common.userId); //更新推荐人openId if (reqObj.special.Recommender != null && reqObj.special.Recommender != "") { string vipID = GetVipIDByOpenID(loggingSessionInfo, reqObj.special.Recommender); if ((vip.HigherVipID == null || vip.HigherVipID == "") && reqObj.common.userId != vipID) { vip.HigherVipID = vipID; vipBLL.Update(vip); //查看推荐人成功推荐人数,满足条件给奖励 CouponBLL couponService = new CouponBLL(loggingSessionInfo); //TODO:added by zhangwei20141009,保存上下线记录 couponService.UpdateVipRecommandTrace(reqObj.common.userId, vipID); couponService.RecommenderPrize(vipID, null); } } } catch (Exception ex) { respData.code = "103"; respData.description = ex.Message; } content = respData.ToJSON(); return(content); }
/// <summary> /// 保存会员 /// </summary> public string SaveVipData() { var service = new VipBLL(CurrentUserInfo); VipEntity vip = new VipEntity(); string content = string.Empty; var responseData = new ResponseData(); string key = string.Empty; string vip_id = string.Empty; if (Request("vip") != null && Request("vip") != string.Empty) { key = Request("vip").ToString().Trim(); } if (Request("VipId") != null && Request("VipId") != string.Empty) { vip_id = Request("VipId").ToString().Trim(); } vip = key.DeserializeJSONTo <VipEntity>(); if (vip.VipName == null || vip.VipName.Trim().Length == 0) { responseData.success = false; responseData.msg = "会员名称不能为空"; return(responseData.ToJSON()); } bool status = true; string message = "保存成功"; if (vip.VIPID.Trim().Length == 0) { vip.VIPID = Utils.NewGuid(); vip.ClientID = this.CurrentUserInfo.CurrentUser.customer_id; vip.Status = 1; service.Create(vip); } else { vip.VIPID = vip_id; service.Update(vip, false); } responseData.success = status; responseData.msg = message; content = responseData.ToJSON(); return(content); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <UpdateVipRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //会员 var VipBLL = new VipBLL(loggingSessionInfo); try { VipEntity UpData = VipBLL.GetByID(para.VipID); if (UpData == null) { throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER } } ; //UpData.VipName = para.VipName; UpData.VipRealName = para.VipName; UpData.Phone = para.Phone; if (!string.IsNullOrWhiteSpace(para.Col22)) { if (para.Col22.Equals("Y")) { UpData.Birthday = para.Birthday; UpData.Col22 = "N"; } } UpData.Gender = para.Gender; UpData.IDNumber = para.IDNumber; VipBLL.Update(UpData); } catch (APIException apiEx) { throw new APIException(apiEx.ErrorCode, apiEx.Message); } return(rd); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetVipDealerRP> pRequest) { var rd = new EmptyResponseData(); var VipBLL = new VipBLL(CurrentUserInfo); bool Flag = VipBLL.IsSetVipDealer(pRequest.UserID); try { if (Flag) { VipEntity Entity = VipBLL.GetByID(pRequest.UserID); if (Entity != null) { Entity.Col48 = "1"; VipBLL.Update(Entity); } else { throw new APIException("会员不存在!") { ErrorCode = 103 }; } } else { //var Result = VipBLL.GetSetVipDealerUpset(); throw new APIException("您当前会员卡等级不符合!") { ErrorCode = 105 }; } } catch (Exception ex) { throw new APIException(ex.Message); } return(rd); }
/// <summary> /// 添加会员 /// </summary> /// <returns></returns> public string GenerateQR() { string content = string.Empty; var respData = new ambassadorLoginInRespData(); try { //接收参数 string reqContent = HttpContext.Current.Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ambassadorLoginInReqData>(); reqObj = reqObj == null ? new ambassadorLoginInReqData() : reqObj; //获取客户ID if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } //初始化返回对象 respData.content = new ambassadorLoginInRespContentData(); respData.content.vipList = new List <ambassadorLoginInRespContentDataItem>(); //用户登录信息 var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); VipBLL vipBLL = new VipBLL(loggingSessionInfo); VipEntity entity = new VipEntity(); //是否有此人 var vip = vipBLL.Query(new IWhereCondition[] { new EqualsCondition() { FieldName = "VipID", Value = reqObj.common.userId }, new EqualsCondition() { FieldName = "ClientID", Value = customerId } }, null).FirstOrDefault(); if (vip != null) { string QRCode = null; if (!string.IsNullOrEmpty(vip.Col6)) { QRCode = vip.Col6; } if (reqObj.special.generater) { QRCode = GeneratedQR(reqObj.special.url, vip.VIPID); entity = vipBLL.GetByID(vip.VIPID); entity.Col6 = QRCode; entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); } else { QRCode = GeneratedQR(reqObj.special.url, vip.VIPID); entity = vipBLL.GetByID(vip.VIPID); entity.Col6 = QRCode; entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); } List <ambassadorLoginInRespContentDataItem> list = new List <ambassadorLoginInRespContentDataItem>(); ambassadorLoginInRespContentDataItem info = new ambassadorLoginInRespContentDataItem(); info.VipID = vip.VIPID; info.VipName = vip.VipName; info.Phone = vip.Phone; info.DeliveryAddress = vip.DeliveryAddress; info.VipRealName = vip.VipRealName; info.QRCode = QRCode; info.Code = vip.Col4; list.Add(info); respData.content.vipList = list; } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
/// <summary> /// 校园专家 重置密码 /// </summary> /// <returns></returns> public string ForgetPassword() { string content = string.Empty; var respData = new ambassadorLoginInRespData(); try { //接收参数 string reqContent = HttpContext.Current.Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ambassadorLoginInReqData>(); reqObj = reqObj == null ? new ambassadorLoginInReqData() : reqObj; //获取客户ID if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } //初始化返回对象 respData.content = new ambassadorLoginInRespContentData(); respData.content.vipList = new List <ambassadorLoginInRespContentDataItem>(); //用户登录信息 var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); OnlineShoppingItemBLL itemService = new OnlineShoppingItemBLL(loggingSessionInfo); var vipInfo = itemService.ForgetPassword(reqObj.special.email); if (vipInfo != null && vipInfo.Count > 0) { //生成随机数 6位 Random rd = new Random(); string code = rd.Next(100000, 999999).ToString(); VipBLL vipBLL = new VipBLL(loggingSessionInfo); VipEntity entity = new VipEntity(); entity = vipBLL.GetByID(vipInfo[0].VIPID); entity.VipPasswrod = MD5Helper.Encryption(MD5Helper.Encryption(code) + entity.Col4); entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); #region 邮件发送 try { XmlManager xml = new XmlManager(ConfigurationManager.AppSettings["xmlFile"]); FromSetting fs = new FromSetting(); fs.SMTPServer = xml.SelectNodeText("//Root/AsusMail//SMTPServer", 0); fs.SendFrom = xml.SelectNodeText("//Root/AsusMail//MailSendFrom", 0); fs.UserName = xml.SelectNodeText("//Root/AsusMail//MailUserName", 0); fs.Password = xml.SelectNodeText("//Root/AsusMail//MailUserPassword", 0); Mail.SendMail(fs, entity.Col7 + "," + xml.SelectNodeText("//Root/AsusMail//MailTo", 0), xml.SelectNodeText("//Root/AsusMail//MailTitle", 0), entity.VipRealName + ":你好,你的新密码为:" + code, null); } catch { respData.code = "111"; respData.description = "邮箱发送失败,请稍后重试"; content = respData.ToJSON(); return(content); } #endregion List <ambassadorLoginInRespContentDataItem> list = new List <ambassadorLoginInRespContentDataItem>(); foreach (var item in vipInfo) { ambassadorLoginInRespContentDataItem info = new ambassadorLoginInRespContentDataItem(); info.VipID = item.VIPID; info.VipPassword = code; info.Email = item.Email; list.Add(info); } respData.content.vipList = list; } else { respData.code = "111"; respData.description = "邮箱不存在"; } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
protected override BeSuperRetailTraderRD ProcessRequest(DTO.Base.APIRequest <BeSuperRetailTraderRP> pRequest) { var rd = new BeSuperRetailTraderRD(); var para = pRequest.Parameters; LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); var vipBll = new VipBLL(loggingSessionInfo); var userBll = new T_UserBLL(loggingSessionInfo); var T_SuperRetailTraderEntityBll = new T_SuperRetailTraderBLL(loggingSessionInfo); var InnerGroupNewsbll = new InnerGroupNewsBLL(loggingSessionInfo);//目前还没有针对单对单通知的站内信 WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession("")); string customerCode = menuServer.GetCustomerCodeByCustomerID(loggingSessionInfo.CurrentUser.customer_id); if (!string.IsNullOrEmpty(para.BeRYType)) { VipEntity VipInfo = null; //会员实体 T_UserEntity T_UserInfo = null; //员工实体 T_SuperRetailTraderEntity T_SuperRetailTraderInfo = null; //超级分销商实体 T_SuperRetailTraderInfo = T_SuperRetailTraderEntityBll.QueryByEntity(new T_SuperRetailTraderEntity() { CustomerId = loggingSessionInfo.CurrentUser.customer_id, SuperRetailTraderFromId = para.SuperRetailTraderFromId }, null).FirstOrDefault(); //判断是否已成为分销商 if (T_SuperRetailTraderInfo == null) { var SuperRetailTraderEntity = new T_SuperRetailTraderEntity(); //不是分销商 就判断分销商来源类型 if (para.BeRYType == "Vip") { //查询会员信息 VipInfo = vipBll.QueryByEntity(new VipEntity() { ClientID = loggingSessionInfo.CurrentUser.customer_id, VIPID = para.SuperRetailTraderFromId }, null).FirstOrDefault(); if (VipInfo != null) { try { SuperRetailTraderEntity.SuperRetailTraderID = Guid.NewGuid(); SuperRetailTraderEntity.SuperRetailTraderCode = VipInfo.VipCode; SuperRetailTraderEntity.SuperRetailTraderName = VipInfo.VipRealName == null ? VipInfo.VipName : VipInfo.VipRealName; SuperRetailTraderEntity.SuperRetailTraderLogin = VipInfo.Phone; string strSuperPwd = StringUtil.GetRandomStr(6);//生成6位随机数,为超级分销商密码生成使用 SuperRetailTraderEntity.SuperRetailTraderPass = EncryptManager.Hash(strSuperPwd, HashProviderType.MD5); SuperRetailTraderEntity.SuperRetailTraderPassData = strSuperPwd; SuperRetailTraderEntity.SuperRetailTraderMan = VipInfo.VipRealName == null ? VipInfo.VipName : VipInfo.VipRealName; SuperRetailTraderEntity.SuperRetailTraderPhone = VipInfo.Phone; SuperRetailTraderEntity.SuperRetailTraderAddress = "";//目前因为没有填写详细地址的地方,给空值 SuperRetailTraderEntity.SuperRetailTraderFrom = para.BeRYType; SuperRetailTraderEntity.SuperRetailTraderFromId = VipInfo.VIPID; if (!string.IsNullOrEmpty(para.HigheSuperRetailTraderID)) { SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(para.HigheSuperRetailTraderID); } if (!string.IsNullOrEmpty(VipInfo.Col20)) { SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(VipInfo.Col20); } SuperRetailTraderEntity.JoinTime = System.DateTime.Now; SuperRetailTraderEntity.CreateTime = System.DateTime.Now; SuperRetailTraderEntity.CreateBy = VipInfo.VIPID; SuperRetailTraderEntity.LastUpdateBy = VipInfo.VIPID; SuperRetailTraderEntity.LastUpdateTime = System.DateTime.Now; SuperRetailTraderEntity.IsDelete = 0; SuperRetailTraderEntity.CustomerId = loggingSessionInfo.CurrentUser.customer_id; SuperRetailTraderEntity.Status = "00"; T_SuperRetailTraderEntityBll.Create(SuperRetailTraderEntity); rd.IsSuperRetailTrader = 1; rd.SuperRetailTraderLogin = VipInfo.Phone; rd.SuperRetailTraderPass = strSuperPwd; VipInfo.Col26 = SuperRetailTraderEntity.SuperRetailTraderID.ToString(); vipBll.Update(VipInfo, false); } catch { rd.IsSuperRetailTrader = 0; } } } //不是分销商 就判断分销商来源类型 if (para.BeRYType == "User") { //查询员工信息 T_UserInfo = userBll.QueryByEntity(new T_UserEntity() { customer_id = loggingSessionInfo.CurrentUser.customer_id, user_id = para.SuperRetailTraderFromId }, null).FirstOrDefault(); if (T_UserInfo != null) { try { SuperRetailTraderEntity.SuperRetailTraderID = Guid.NewGuid(); SuperRetailTraderEntity.SuperRetailTraderCode = T_UserInfo.user_code; SuperRetailTraderEntity.SuperRetailTraderName = T_UserInfo.user_name; SuperRetailTraderEntity.SuperRetailTraderLogin = T_UserInfo.user_code; SuperRetailTraderEntity.SuperRetailTraderPass = T_UserInfo.user_password; SuperRetailTraderEntity.SuperRetailTraderMan = T_UserInfo.user_name; SuperRetailTraderEntity.SuperRetailTraderPhone = T_UserInfo.user_telephone != null ? T_UserInfo.user_telephone : T_UserInfo.user_cellphone; SuperRetailTraderEntity.SuperRetailTraderAddress = T_UserInfo.user_address; SuperRetailTraderEntity.SuperRetailTraderFrom = para.BeRYType; SuperRetailTraderEntity.SuperRetailTraderFromId = T_UserInfo.user_id; if (!string.IsNullOrEmpty(para.HigheSuperRetailTraderID)) { SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(para.HigheSuperRetailTraderID); } SuperRetailTraderEntity.JoinTime = System.DateTime.Now; SuperRetailTraderEntity.CreateTime = System.DateTime.Now; SuperRetailTraderEntity.CreateBy = T_UserInfo.user_id; SuperRetailTraderEntity.LastUpdateBy = T_UserInfo.user_id; SuperRetailTraderEntity.LastUpdateTime = System.DateTime.Now; SuperRetailTraderEntity.IsDelete = 0; SuperRetailTraderEntity.CustomerId = loggingSessionInfo.CurrentUser.customer_id; SuperRetailTraderEntity.Status = "00"; T_SuperRetailTraderEntityBll.Create(SuperRetailTraderEntity); rd.IsSuperRetailTrader = 1;//成功成为分销商 } catch { rd.IsSuperRetailTrader = 0;//成为分销商失败 } } } //如果成为分销商 则需要增加站内信通知 if (rd.IsSuperRetailTrader == 1) { } } else { rd.IsSuperRetailTrader = 2;//已成为分销商 rd.SuperRetailTraderLogin = T_SuperRetailTraderInfo.SuperRetailTraderLogin; rd.SuperRetailTraderPass = T_SuperRetailTraderInfo.SuperRetailTraderPassData; } } if (!string.IsNullOrEmpty(customerCode)) { rd.CustomerCode = customerCode; } return(rd); }
/// <summary> /// 页面跳转 /// </summary> /// <param name="openId"></param> private void PageRedict(string applicationId, string openId, string token) { //if (goUrl.IndexOf("HtmlApp/Lj/auth.html?pageName=GoodsList")>0) //{ // goUrl = goUrl.Replace("HtmlApp/Lj/auth.html?pageName=GoodsList", "HtmlApps/auth.html?pageName=GoodsList"); // Loggers.Debug(new DebugLogInfo() // { // Message = string.Format("url替换:old={0};new={1};", "HtmlApp/Lj/auth.html?pageName=GoodsList", "HtmlApps/auth.html?pageName=GoodsList") // }); //} //if (goUrl.IndexOf("HtmlApp/Lj/auth.html?pageName=MyOrder") > 0) //{ // goUrl = goUrl.Replace("HtmlApp/Lj/auth.html?pageName=MyOrder", "HtmlApps/auth.html?pageName=MyOrder"); // Loggers.Debug(new DebugLogInfo() // { // Message = string.Format("url替换:old={0};new={1};", "HtmlApp/Lj/auth.html?pageName=MyOrder", "HtmlApps/auth.html?pageName=MyOrder") // }); //} //if (goUrl.IndexOf("HtmlApp/Lj/auth.html?pageName=JiFenShop") > 0) //{ // goUrl = goUrl.Replace("HtmlApp/Lj/auth.html?pageName=JiFenShop", "HtmlApps/auth.html?pageName=JiFenShop"); // Loggers.Debug(new DebugLogInfo() // { // Message = string.Format("url替换:old={0};new={1};", "HtmlApp/Lj/auth.html?pageName=JiFenShop", "HtmlApps/auth.html?pageName=JiFenShop") // }); //} var decodeUrl = HttpUtility.UrlDecode(goUrl); if (!decodeUrl.StartsWith("http://")) { goUrl = "http://" + decodeUrl; } else { goUrl = decodeUrl; } Loggers.Debug(new DebugLogInfo() { Message = string.Format("zk goUrl:{0}", goUrl) }); if (!string.IsNullOrWhiteSpace(this.pageName)) { //根据pageName进行路径替换 var configBll = new WeiXinH5ConfigBLL(loggingSessionInfo); var pagePath = configBll.GetPagePathByPageName(customerId, pageName); Loggers.Debug(new DebugLogInfo() { Message = string.Format("4x: pagePath:{0};goUrl:{1}", pagePath, goUrl) }); goUrl = goUrl.Replace("_pageName_", pagePath); } if (openId == null || openId.Equals(""))//没有获取到相应的openid,也跳转 { Random rad = new Random(); if (goUrl.IndexOf("?") > 0) { goUrl = goUrl + "&CheckOAuth=unAttention" + "&rid=" + rad.Next(1000, 100000) + ""; } else { goUrl = goUrl + "?CheckOAuth=unAttention" + "&rid=" + rad.Next(1000, 100000) + ""; } Loggers.Debug(new DebugLogInfo() { Message = string.Format("没有获得会员的OPEN ID时的跳转URL:{0}", goUrl) }); Response.Redirect(goUrl); } else { VipBLL vipServer = new VipBLL(loggingSessionInfo); VipEntity vipInfo = new VipEntity(); vipInfo = authBll.GetUserIdByOpenId(loggingSessionInfo, openId);//根据openid获取会员信息 //Loggers.Debug(new DebugLogInfo() //{ // Message = string.Format("66x: openId:{0};", "进来了" + openId + "--openId") //}); #region 本系统中不存在这个会员 或者未关注 if (vipInfo == null || vipInfo.VIPID.Equals("") || vipInfo.Status == 0) //会员不存在或没有关注,从微信里查找会员信息,新增一条vip数据 { Response.Write("会员不存在或没有关注"); VipEntity vipInfotmp = new VipEntity(); #region snsapi_userinfo 这种模式的 if (scope.Equals("1")) { //封装方法,调用第四步,根据第四步的数据,新增一条vip数据 if (null == vipInfo || vipInfo.VIPID.Equals("")) { vipInfotmp.VIPID = authBll.SetVipInfoByToken(token, openId, loggingSessionInfo, this.Response);//根据token和openid获取会员信息 if (objectType.Equals("Coupon"))//如果是优惠券根据给定的VipSourceId=27给定 { vipInfotmp.VipSourceId = "26"; // vipInfo.VipSourceName = "优惠券二维码"; } else if (objectType.Equals("SetoffPoster"))//如果是海报根据给定的VipSourceId=29给定 { vipInfotmp.VipSourceId = "28"; // vipInfo.VipSourceName = "集客海报二维码"; } else if (objectType.Equals("Goods")) { vipInfotmp.VipSourceId = "31"; //vipInfo.VipSourceName = "员工集客"; } else if (objectType.Equals("CTW")) { vipInfotmp.VipSourceId = "24"; } else if (objectType.Equals("Material")) { vipInfotmp.VipSourceId = "32"; } vipServer.Update(vipInfotmp, false); } else //状态为未关注,vipInfo.Status == 0 { if (vipInfo.Status == 0) { if (objectType.Equals("Coupon"))//如果是优惠券根据给定的VipSourceId=27给定 { vipInfo.VipSourceId = "26"; // vipInfo.VipSourceName = "优惠券二维码"; } else if (objectType.Equals("SetoffPoster"))//如果是海报根据给定的VipSourceId=29给定 { vipInfo.VipSourceId = "28"; // vipInfo.VipSourceName = "集客海报二维码"; } else if (objectType.Equals("Goods")) { vipInfo.VipSourceId = "31"; //vipInfo.VipSourceName = "员工集客"; } else if (objectType.Equals("CTW")) { vipInfo.VipSourceId = "24"; } else if (objectType.Equals("Material")) { vipInfo.VipSourceId = "32"; } } vipInfo.IsDelete = 0; // vipInfo.Status = 1; //潜在用户?这个时候如果没关注,也算潜在用户吗?没关注不算潜在用户,所以不改变他的状态** vipServer.Update(vipInfo, false); vipInfotmp.VIPID = vipInfo.VIPID; } } #endregion #region snsapi_base这种情况下,,获取不到会员的详细信息,只能获取到openid else { #region Jermyn20140604,会员没有关注,先采集信息 if (vipInfo == null || vipInfo.VIPID == null) { vipInfotmp.VIPID = authBll.SetVipInfoByToken(token, openId, loggingSessionInfo, this.Response); #region previous logic /****** * vipInfotmp.VIPID = Guid.NewGuid().ToString().Replace("-", ""); * vipInfotmp.VipCode = vipServer.GetVipCode(); * vipInfotmp.WeiXinUserId = openId; * vipInfotmp.Status = 0; * vipInfotmp.VipSourceId = "3"; * vipInfotmp.ClientID = customerId; * vipInfotmp.WeiXin = strWeiXinId; * vipInfotmp.VipPasswrod = "e10adc3949ba59abbe56e057f20f883e"; * vipInfotmp.Col50 = "通过Auth认证时,未关注,主动采取的信息。"; * vipServer.Create(vipInfotmp); ********/ #endregion if (objectType.Equals("Coupon"))//如果是优惠券根据给定的VipSourceId=27给定 { vipInfo.VipSourceId = "26"; // vipInfo.VipSourceName = "优惠券二维码"; } else if (objectType.Equals("SetoffPoster"))//如果是海报根据给定的VipSourceId=29给定 { vipInfo.VipSourceId = "28"; // vipInfo.VipSourceName = "集客海报二维码"; } else if (objectType.Equals("Goods")) { vipInfo.VipSourceId = "31"; //vipInfo.VipSourceName = "员工集客"; } else if (objectType.Equals("CTW")) { vipInfo.VipSourceId = "24"; } else if (objectType.Equals("Material")) { vipInfo.VipSourceId = "32"; } vipServer.Update(vipInfotmp, false); } else { vipInfotmp.VIPID = vipInfo.VIPID;//设置vipid } #endregion } #endregion Random rad = new Random(); //if (goUrl.IndexOf("?") > 0) //{ // goUrl = goUrl + "&customerId=" + customerId + "&applicationId=" + applicationId + "&openId=" + openId + "&userId=" + vipInfotmp.VIPID + "&CheckOAuth=unAttention" + "&rid=" + rad.Next(1000, 100000) + ""; //} //else //{ // goUrl = goUrl + "?customerId=" + customerId + "&applicationId=" + applicationId + "&openId=" + openId + "&userId=" + vipInfotmp.VIPID + "&CheckOAuth=unAttention" + "&rid=" + rad.Next(1000, 100000) + ""; //} if (goUrl.IndexOf("?") > 0) { goUrl = goUrl + "&customerId=" + customerId + "&applicationId=" + applicationId + "&CheckOAuth=unAttention" + "&rid=" + rad.Next(1000, 100000) + ""; } else { goUrl = goUrl + "?customerId=" + customerId + "&applicationId=" + applicationId + "&CheckOAuth=unAttention" + "&rid=" + rad.Next(1000, 100000) + ""; } Response.Cookies["openId_" + customerId].Value = openId; Response.Cookies["userId_" + customerId].Value = vipInfotmp.VIPID;//vipInfo.VIPID; Loggers.Debug(new DebugLogInfo() { Message = string.Format("会员没有关注时的跳转URL:{0}", goUrl) }); //在这里建立上下线关系 SetShareVip(vipInfotmp.VIPID, openId); Response.Redirect(goUrl); } #endregion #region 会员已经存在(关注过) else { Response.Write("获取vip信息"); Response.Write("</br>"); // string strGotoUrl = "";//"/OnlineClothing/tmpGoUrl.html?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + ""; Random rad = new Random(); //if (goUrl.IndexOf("?") > 0) //{ // strGotoUrl = goUrl + "&customerId=" + customerId + "&applicationId=" + applicationId + "&openId=" + openId + "&userId=" + vipInfo.VIPID + "&rid=" + rad.Next(1000, 100000) + ""; //} //else //{ // strGotoUrl = goUrl + "?customerId=" + customerId + "&applicationId=" + applicationId + "&openId=" + openId + "&userId=" + vipInfo.VIPID + "&rid=" + rad.Next(1000, 100000) + ""; //} if (goUrl.IndexOf("?") > 0) { strGotoUrl = goUrl + "&customerId=" + customerId + "&applicationId=" + applicationId + "&rid=" + rad.Next(1000, 100000) + ""; } else { strGotoUrl = goUrl + "?customerId=" + customerId + "&applicationId=" + applicationId + "&rid=" + rad.Next(1000, 100000) + ""; } Response.Cookies["openId_" + customerId].Value = openId; Response.Cookies["userId_" + customerId].Value = vipInfo.VIPID; Response.Write(strGotoUrl); Loggers.Debug(new DebugLogInfo() { Message = string.Format("有会员信息时的跳转URL:{0}", strGotoUrl) }); //在这里建立上下线关系 //SetShareVip(vipInfotmp.VIPID); SetShareVip(vipInfo.VIPID, openId); Response.Redirect(strGotoUrl); } #endregion } }
/// <summary> /// 我的小店增加商品 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string VipStoreAddItem(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <VipStoreRP> >(); LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); //先判断商品是否存在 if (string.IsNullOrWhiteSpace(rp.Parameters.ItemID)) { return(new ErrorResponse(500, "没有添加商品信息").ToJSON()); } //要传入的商品id组 string[] items = rp.Parameters.ItemID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //给用户增加商品 VipStoreBLL vipStoreBlll = new VipStoreBLL(loggingSessionInfo); List <string> arrItem = new List <string>(); for (int i = 0; i < items.Length; i++) { string itemID = items[i]; VipStoreEntity vipstoreEntityO = vipStoreBlll.QueryByEntity( new VipStoreEntity() { ItemID = itemID, VIPID = rp.UserID }, null ).FirstOrDefault(); //如果加入该商品就加入 if (vipstoreEntityO == null && !arrItem.Contains(itemID)) { arrItem.Add(itemID); } } IDbTransaction tran = new JIT.CPOS.BS.DataAccess.Base.TransactionHelper(loggingSessionInfo).CreateTransaction(); foreach (var item in arrItem) { VipStoreEntity vipStoreEntity = new VipStoreEntity() { vipStoreID = Guid.NewGuid().ToString(), VIPID = rp.UserID, ItemID = item, SoldCount = 0 }; vipStoreBlll.Create(vipStoreEntity, tran); } tran.Commit(); //用户是否开通小店 VipBLL vipBll = new VipBLL(loggingSessionInfo); VipEntity vipEntity = vipBll.GetByID(rp.UserID); vipEntity.IsSotre = vipEntity.IsSotre ?? 0; if (vipEntity != null && vipEntity.IsSotre == 0) { vipEntity.IsSotre = 1; vipBll.Update(vipEntity); } return(new SuccessResponse <IAPIResponseData>().ToJSON()); }
public string SetSignUp() { string content = string.Empty; var respData = new SetSignUpRespData(); try { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetSignUp: {0}", reqContent) }); #region //解析请求字符串 chech var reqObj = reqContent.DeserializeJSONTo <SetSignUpReqData>(); if (reqObj.special == null) { respData.code = "101"; respData.description = "没有特殊参数"; return(respData.ToJSON().ToString()); } if (reqObj.special.phone == null || reqObj.special.phone.Equals("")) { respData.code = "102"; respData.description = "电话不能为空"; return(respData.ToJSON().ToString()); } #endregion #region //判断客户ID是否传递 if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); #endregion //#region 判断客户是否扫过活动二维码 QRCodeScanLogBLL qRCodeScanLogBLL = new QRCodeScanLogBLL(loggingSessionInfo); if (!qRCodeScanLogBLL.CheckVipEventQRCode(reqObj.common.userId, reqObj.special.eventId)) { respData.code = "2206"; respData.description = "请先扫描本次活动的二维码"; return(respData.ToJSON().ToString()); } //#endregion VipBLL vipBLL = new VipBLL(loggingSessionInfo); EventVipBLL eventVipBLL = new EventVipBLL(loggingSessionInfo); var tmpPhoneVip = vipBLL.GetVipByPhone(reqObj.special.phone, reqObj.common.userId, "2"); Loggers.Debug(new DebugLogInfo() { Message = "tmpPhoneVip: " + tmpPhoneVip.ToJSON() }); if (tmpPhoneVip != null && tmpPhoneVip.VIPID != reqObj.common.userId) { respData.code = "2201"; respData.description = "您填写的手机号码已经被其他参会人员认证。如需帮助,请联系现场工作人员。"; return(respData.ToJSON().ToString()); } var tmpEventVipList = eventVipBLL.QueryByEntity(new EventVipEntity() { Phone = reqObj.special.phone, EventId = reqObj.special.eventId }, null); var tmpVipList = vipBLL.QueryByEntity(new VipEntity() { VIPID = reqObj.common.userId , ClientID = customerId }, null); #region 与会嘉宾中存在该手机号 if (tmpEventVipList != null && tmpEventVipList.Length > 0) { #region 会员表中存在该会员 if (tmpVipList != null && tmpVipList.Length > 0) { //签到 vipBLL.Update(new VipEntity() { VIPID = reqObj.common.userId, VipRealName = tmpEventVipList[0].VipName, Phone = reqObj.special.phone, Status = 2 }, false); respData.code = "200"; respData.description = "恭喜您签到成功!"; } #endregion } #endregion else { respData.code = "2202"; respData.description = "在参会嘉宾中未查询到您输入的手机号码,请确认您输入是否有误。如需帮助,请联系现场工作人员。"; return(respData.ToJSON().ToString()); } if (!string.IsNullOrEmpty(tmpEventVipList[0].Seat)) { respData.content = new SetSignUpRespContentData(); respData.description += "您的座位是:" + tmpEventVipList[0].Seat + ",请就坐。"; } string error = ""; var sendFlag = eventVipBLL.SetEventVipSeatPush(tmpVipList[0].VIPID, reqObj.special.eventId, out error); if (!sendFlag) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetStaffSeatsPush: {0}", error) }); } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); Loggers.Exception(new ExceptionLogInfo() { ErrorMessage = ex.ToJSON() }); } content = respData.ToJSON(); return(content); }
public string UpdateVip() { string content = string.Empty; var respData = new UpdateVipRespData(); respData.content = new UpdateVipRespContentData(); try { string reqContent = Request["ReqContent"]; Loggers.Debug(new DebugLogInfo() { Message = string.Format("UpdateVip: {0}", reqContent) }); #region //解析请求字符串 chech var reqObj = reqContent.DeserializeJSONTo <UpdateVipReqData>(); reqObj = reqObj == null ? new UpdateVipReqData() : reqObj; if (reqObj.special == null) { respData.code = "102"; respData.description = "没有特殊参数"; return(respData.ToJSON().ToString()); } if (reqObj.special.vipRealName == null || reqObj.special.vipRealName.Equals("")) { respData.code = "2201"; respData.description = "姓名不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.phone == null || reqObj.special.phone.Equals("")) { respData.code = "2202"; respData.description = "电话不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.school == null || reqObj.special.school.Equals("")) { respData.code = "2203"; respData.description = "学校不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.className == null || reqObj.special.className.Equals("")) { respData.code = "2204"; respData.description = "班级不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.company == null || reqObj.special.company.Equals("")) { respData.code = "2205"; respData.description = "公司不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.position == null || reqObj.special.position.Equals("")) { respData.code = "2206"; respData.description = "职位不能为空"; return(respData.ToJSON().ToString()); } #endregion #region //判断客户ID是否传递 if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); #endregion #region 设置参数 vipBLL = new VipBLL(loggingSessionInfo); VipEntity vipInfo = vipBLL.Query( new IWhereCondition[] { new EqualsCondition() { FieldName = "Phone", Value = reqObj.special.phone } , new EqualsCondition() { FieldName = "ClientId", Value = customerId } } , null).FirstOrDefault(); bool newFlag = false; if (vipInfo == null) { newFlag = true; vipInfo = new VipEntity(); vipInfo.VIPID = Utils.NewGuid(); vipInfo.Phone = reqObj.special.phone; vipInfo.VipLevel = 1; vipInfo.Status = 1; vipInfo.ClientID = customerId; vipInfo.RegistrationTime = DateTime.Now; vipInfo.IsDelete = 0; vipInfo.CreateTime = DateTime.Now; vipInfo.CreateBy = vipInfo.VIPID; } else { vipInfo.LastUpdateTime = DateTime.Now; vipInfo.LastUpdateBy = reqObj.common.userId; } vipInfo.VipRealName = reqObj.special.vipRealName; vipInfo.Col41 = reqObj.special.school; vipInfo.Col42 = reqObj.special.className; vipInfo.Col43 = reqObj.special.company; vipInfo.Col44 = reqObj.special.position; vipInfo.Email = reqObj.special.email; vipInfo.Col46 = reqObj.special.hobby; vipInfo.Col47 = reqObj.special.myValue; vipInfo.Col48 = reqObj.special.needValue; vipInfo.SinaMBlog = reqObj.special.sinaMBlog; vipInfo.TencentMBlog = reqObj.special.weixin; // CreateQrcode var qrImageUrl = ""; var qrFlag = cUserService.CreateQrcode(vipInfo.VipRealName, vipInfo.Email, "", vipInfo.Phone, "", vipInfo.Col43, vipInfo.Col44, "", "", ref qrImageUrl); if (qrFlag) { vipInfo.QRVipCode = qrImageUrl; } else { respData.code = "2207"; respData.description = "用户二维码数据保存失败"; return(respData.ToJSON().ToString()); } #endregion string strError = string.Empty; if (newFlag) { vipBLL.Create(vipInfo); } else { vipBLL.Update(vipInfo, false); } respData.content.VipId = vipInfo.VIPID; } catch (Exception ex) { Loggers.Exception(new ExceptionLogInfo() { ErrorMessage = ex.Message }); respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
/// <summary> /// 验证真伪得积分 /// </summary> public string SetCheckReal() { string content = string.Empty; var respData = new SetCheckRealRespData(); try { string openId = Request["openID"]; //openId = "o8Y7Ejl1zl5RHXDvPONCNqoC5Md8"; Loggers.Debug(new DebugLogInfo() { Message = string.Format( "OpenID:{0}", openId) }); var currentUser = Default.GetLoggingSession(); VipBLL vipBLL = new VipBLL(currentUser); IntegralRuleBLL integralRuleBLL = new IntegralRuleBLL(currentUser); VipIntegralDetailBLL vipIntegralDetailBLL = new VipIntegralDetailBLL(currentUser); VipIntegralBLL vipIntegralBLL = new VipIntegralBLL(currentUser); string vipId = null; if (true) { VipEntity vipIdData = null; var vipIdDataList = vipBLL.QueryByEntity(new VipEntity() { WeiXinUserId = openId }, null); if (vipIdDataList == null || vipIdDataList.Length == 0 || vipIdDataList[0] == null || vipIdDataList[0].VIPID == null) { respData.Code = "103"; respData.Description = "数据库操作错误"; respData.Exception = "未查询到Vip会员"; return(respData.ToJSON()); } else { vipIdData = vipIdDataList[0]; vipId = vipIdData.VIPID; } } // SysIntegralSource: 10 string integralSourceId = "10"; int integralValue = 0; if (true) { IntegralRuleEntity integralRuleData = null; var integralRuleDataList = integralRuleBLL.QueryByEntity(new IntegralRuleEntity() { IntegralSourceID = integralSourceId }, null); if (integralRuleDataList == null || integralRuleDataList.Length == 0 || integralRuleDataList[0] == null) { respData.Code = "103"; respData.Description = "数据库操作错误"; respData.Exception = "未查询到积分规则"; return(respData.ToJSON()); } else { integralRuleData = integralRuleDataList[0]; integralValue = int.Parse(integralRuleData.Integral); } } #region 保存积分 if (true) { string tmpVipId = vipId; int tmpIntegralValue = integralValue; string tmpIntegralSourceId = integralSourceId; string tmpOpenId = openId; string msgModel = "【验真品,送积分】活动,您本次验证赢得{0}点积分。您当前的总积分是{1}点。"; // 插入积分明细 VipIntegralDetailEntity vipIntegralDetailEntity = new VipIntegralDetailEntity(); vipIntegralDetailEntity.VipIntegralDetailID = CPOS.Common.Utils.NewGuid(); vipIntegralDetailEntity.VIPID = tmpVipId; vipIntegralDetailEntity.FromVipID = tmpVipId; vipIntegralDetailEntity.SalesAmount = 0; vipIntegralDetailEntity.Integral = tmpIntegralValue; vipIntegralDetailEntity.IntegralSourceID = tmpIntegralSourceId; vipIntegralDetailEntity.IsAdd = 1; //vipIntegralDetailBLL.Create(vipIntegralDetailEntity); // 更新积分 VipIntegralEntity vipIntegralEntity = new VipIntegralEntity(); var vipIntegralDataList = vipIntegralBLL.QueryByEntity( new VipIntegralEntity() { VipID = vipId }, null); if (vipIntegralDataList == null || vipIntegralDataList.Length == 0 || vipIntegralDataList[0] == null) { vipIntegralEntity.VipID = tmpVipId; vipIntegralEntity.BeginIntegral = 0; // 期初积分 vipIntegralEntity.InIntegral = tmpIntegralValue; // 增加积分 vipIntegralEntity.OutIntegral = 0; //消费积分 vipIntegralEntity.EndIntegral = tmpIntegralValue; //积分余额 vipIntegralEntity.InvalidIntegral = 0; // 累计失效积分 vipIntegralEntity.ValidIntegral = tmpIntegralValue; // 当前有效积分 //vipIntegralBLL.Create(vipIntegralEntity); } else { vipIntegralEntity.VipID = tmpVipId; vipIntegralEntity.InIntegral = vipIntegralDataList[0].InIntegral + tmpIntegralValue;; // 增加积分 //vipIntegralEntity.OutIntegral = 0; //消费积分 vipIntegralEntity.EndIntegral = vipIntegralDataList[0].EndIntegral + tmpIntegralValue; //积分余额 //vipIntegralEntity.InvalidIntegral = 0; // 累计失效积分 vipIntegralEntity.ValidIntegral = vipIntegralDataList[0].ValidIntegral + tmpIntegralValue; // 当前有效积分 //vipIntegralBLL.Update(vipIntegralEntity, false); } // 更新VIP VipEntity vipEntity = new VipEntity(); var vipEntityDataList = vipBLL.QueryByEntity( new VipEntity() { VIPID = tmpVipId }, null); if (vipEntityDataList == null || vipEntityDataList.Length == 0 || vipEntityDataList[0] == null) { vipEntity.VIPID = tmpVipId; vipEntity.Integration = vipIntegralEntity.ValidIntegral; //vipEntity.HigherVipID = highOpenId; vipEntity.ClientID = currentUser.CurrentUser.customer_id; vipEntity.Status = 1; vipBLL.Create(vipEntity); } else { vipEntity.VIPID = tmpVipId; vipEntity.Integration = vipIntegralEntity.ValidIntegral; //vipEntity.HigherVipID = highOpenId; vipEntity.ClientID = currentUser.CurrentUser.customer_id; vipBLL.Update(vipEntity, false); } // 推送消息 string msgUrl = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim(); string msgText = string.Format(msgModel, tmpIntegralValue, vipEntity.Integration); string msgData = "<xml><OpenID><![CDATA[" + tmpOpenId + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>"; var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); Loggers.Debug(new DebugLogInfo() { Message = string.Format("PushMsgResult:{0}", msgResult) }); respData.Data = tmpIntegralValue.ToString(); } #endregion } catch (Exception ex) { respData.Code = "103"; respData.Description = "数据库操作错误"; respData.Exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
protected override GetEventPrizesRD ProcessRequest(DTO.Base.APIRequest <GetEventPrizesRP> pRequest) { GetEventPrizesRD rd = new GetEventPrizesRD(); string vipID = pRequest.UserID; //string vipID = "f3d925e364e34bf69dfda34fcedc58f8"; string vipName = string.Empty; string reCommandId = pRequest.Parameters.RecommandId; string eventId = pRequest.Parameters.EventId; float longitude = pRequest.Parameters.Longitude; float latitude = pRequest.Parameters.Latitude; string customerId = this.CurrentUserInfo.ClientID; int pointsLotteryFlag = pRequest.Parameters.PointsLotteryFlag; if (string.IsNullOrEmpty(customerId)) { customerId = "f6a7da3d28f74f2abedfc3ea0cf65c01"; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); #region 是否在活动现场 //respData.content.isSite = "1"; rd.content = new EventPrizesInfo { IsSite = 1 }; #endregion #region 判断活动是否需要注册 var leventsBll = new LEventsBLL(this.CurrentUserInfo); var enableFlag = leventsBll.GetEnableFlagByEventId(eventId); var vipService = new VipBLL(loggingSessionInfo); rd.SignFlag = 1; //如果需要注册,则判断该会员有没有注册,没有返回 if (enableFlag.Substring(0, 1) == "1") { var vipEntity = vipService.GetByID(vipID); if (vipEntity == null) { rd.SignFlag = 0; return(rd); } else { rd.SignFlag = 1; vipID = vipEntity.VIPID; vipName = vipEntity.VipName; } } #endregion #region 获取VIPID #endregion #region Loggers.Debug(new DebugLogInfo() { Message = "vipName = " + vipName + ",vipID =" + vipID + ",eventId=" + eventId + ",longitude" + longitude + ",latitude" + latitude + ",customerId" + customerId + ",reCommandId" + reCommandId }); LPrizePoolsBLL poolsServer = new LPrizePoolsBLL(loggingSessionInfo); var ds = poolsServer.GetEventWinningInfo(vipName, vipID, eventId, longitude, latitude, customerId, reCommandId, pointsLotteryFlag); int isLottery = Convert.ToInt32(ds.Tables[0].Rows[0]["IsLottery"]); int winnerFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["WinnerFlag"]);//是否中奖 string prizeName = ds.Tables[0].Rows[0]["prizeName"].ToString(); string prizesId = ds.Tables[0].Rows[0]["prizesId"].ToString(); rd.content.IsLottery = isLottery; rd.content.IsWinning = winnerFlag; rd.content.WinningDesc = prizeName; rd.content.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); rd.content.WinningExplan = ds.Tables[0].Rows[0]["PrizeDesc"].ToString(); rd.content.EventRound = ds.Tables[0].Rows[0]["EventRoundId"].ToString(); rd.content.Status = Convert.ToInt32(ds.Tables[0].Rows[0]["step"].ToString()); rd.content.PrizesTypeName = ds.Tables[0].Rows[0]["prizeTypeName"].ToString(); rd.content.PrizesName = ds.Tables[0].Rows[0]["prizesName"].ToString(); rd.content.EventPoints = Convert.ToInt32(ds.Tables[0].Rows[0]["EventPoints"].ToString()); #region update by wzq 2014/07/01 积分兑换标识(活动,个人) rd.content.PersonPointsLotteryFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["PersonPointsLotteryFlag"].ToString()); rd.content.EventPointsLotteryFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["EventPointsLotteryFlag"].ToString()); #endregion #endregion #region 推荐人 //活动是否分享 var isShare = leventsBll.GetIsShareByEventId(eventId); rd.IsShare = isShare; Loggers.Debug(new DebugLogInfo() { Message = "isShare = " + isShare }); CouponBLL couponService = new CouponBLL(loggingSessionInfo); //Updated by Willie Yan on 2014-05-30 必须是新推荐的会员 if (isShare == 1 && !couponService.IfRecordedRecommendTrace(vipID, reCommandId)) { Loggers.Debug(new DebugLogInfo() { Message = "reCommandId = " + reCommandId + ", VipID = " + vipID }); if (reCommandId != "" && !string.IsNullOrEmpty(reCommandId)) { if (reCommandId != vipID) { var vipEntity = vipService.GetByID(vipID); vipEntity.HigherVipID = reCommandId; vipService.Update(vipEntity); Loggers.Debug(new DebugLogInfo() { Message = "Update HigherVipID = " + reCommandId + "for vipid=" + vipID }); //查看推荐人成功推荐人数,满足条件给奖励 //TODO:added by zhangwei20141009,保存上下线记录 couponService.UpdateVipRecommandTrace(vipID, reCommandId); Loggers.Debug(new DebugLogInfo() { Message = "UpdateVipRecommandTrace vipid=" + vipID + ",reCommandId= " + reCommandId }); couponService.RecommenderPrize(reCommandId, eventId); Loggers.Debug(new DebugLogInfo() { Message = "RecommenderPrize reCommandId= " + reCommandId }); } } } //推荐人是否为空 //推荐人跟vipId是否相同 #endregion #region 奖品集合 LPrizesBLL prizesService = new LPrizesBLL(loggingSessionInfo); var orderby = new List <OrderBy> { new OrderBy() { FieldName = "DisplayIndex", Direction = OrderByDirections.Asc } }; var prizesList = prizesService.QueryByEntity(new LPrizesEntity() { EventId = eventId }, orderby.ToArray()); rd.content.PrizesList = new List <PrizesEntity>(); if (prizesList != null && prizesList.Length > 0) { foreach (var item in prizesList) { var entity = new PrizesEntity() { PrizesID = item.PrizesID, PrizeName = item.PrizeName, PrizeDesc = item.PrizeDesc, DisplayIndex = item.DisplayIndex.ToString(), CountTotal = item.CountTotal.ToString(), ImageUrl = item.ImageUrl, Sponsor = item.ContentText }; if (prizesId == item.PrizesID) { rd.content.PrizeIndex = item.DisplayIndex; } rd.content.PrizesList.Add(entity); } } #endregion #region 中奖集合 var winDs = poolsServer.GetPersonWinnerList(vipID, eventId); rd.content.WinnerList = new List <WinnerList>(); if (winDs != null && winDs.Tables.Count > 0 && winDs.Tables[0].Rows.Count > 0) { rd.content.WinnerList = DataTableToObject.ConvertToList <WinnerList>(winDs.Tables[0]); } #endregion #region 新增字段 var leventsInfoDs = leventsBll.GetLeventsInfoDataSet(eventId); if (leventsInfoDs.Tables[0].Rows.Count > 0) { rd.BootUrl = leventsInfoDs.Tables[0].Rows[0]["BootUrl"].ToString(); rd.OverRemark = leventsInfoDs.Tables[0].Rows[0]["OverRemark"].ToString(); rd.PosterImageUrl = leventsInfoDs.Tables[0].Rows[0]["PosterImageUrl"].ToString(); rd.ShareRemark = leventsInfoDs.Tables[0].Rows[0]["ShareRemark"].ToString(); rd.ShareLogoUrl = leventsInfoDs.Tables[0].Rows[0]["ShareLogoUrl"].ToString(); } #endregion #region 添加引导页URL //var bootDs = leventsBll.GetBootUrlByEventId(eventId); //if (bootDs.Tables[0].Rows.Count > 0) //{ // rd.ShareRemark = bootDs.Tables[0].Rows[0]["ShareRemark"].ToString(); // rd.OverRemark = bootDs.Tables[0].Rows[0]["OverRemark"].ToString(); // rd.PosterImageUrl = bootDs.Tables[0].Rows[0]["PosterImageUrl"].ToString(); // rd.BootUrl = bootDs.Tables[0].Rows[0]["BootUrl"].ToString(); //} #endregion return(rd); }
protected override GetMemberInfoRD ProcessRequest(DTO.Base.APIRequest <GetMemberInfoRP> pRequest) { GetMemberInfoRD rd = new GetMemberInfoRD(); rd.MemberInfo = new MemberInfo(); var vipLoginBLL = new VipBLL(base.CurrentUserInfo); //如果有一个查询标识非空,就用查询标识查,发现没有会员就报错 if (!string.IsNullOrEmpty(pRequest.Parameters.SearchFlag)) { List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "ClientID", Value = CurrentUserInfo.ClientID }); var cond1 = new LikeCondition() { FieldName = "VipName", Value = "%" + pRequest.Parameters.SearchFlag + "%" }; var cond2 = new LikeCondition() { FieldName = "VipRealName", Value = "%" + pRequest.Parameters.SearchFlag + "%" }; var com1 = new ComplexCondition() { Left = cond1, Right = cond2, Operator = LogicalOperators.Or }; var cond3 = new EqualsCondition() { FieldName = "Phone", Value = pRequest.Parameters.SearchFlag }; var com2 = new ComplexCondition() { Left = com1, Right = cond3, Operator = LogicalOperators.Or }; complexCondition.Add(com2); complexCondition.Add(new DirectCondition("(WeiXinUserId!='' Or WeiXinUserId IS NOT NULL)")); var tempVipList = vipLoginBLL.Query(complexCondition.ToArray(), null); if (tempVipList != null && tempVipList.Length != 0) { pRequest.UserID = pRequest.Parameters.MemberID = tempVipList[0].VIPID; } } string m_MemberID = ""; if (!string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID)) { m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID) ? pRequest.UserID : pRequest.Parameters.OwnerVipID; } else { m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.MemberID) ? pRequest.UserID : pRequest.Parameters.MemberID; } string UserID = m_MemberID; var VipLoginInfo = vipLoginBLL.GetByID(UserID); if (VipLoginInfo == null) { throw new APIException("用户不存在") { ErrorCode = 330 } } ; #region 20140909 kun.zou 发现状态为0,改为1 if (VipLoginInfo.Status.HasValue && VipLoginInfo.Status == 0) { VipLoginInfo.Status = 1; vipLoginBLL.Update(VipLoginInfo, false); var log = new VipLogEntity() { Action = "更新", ActionRemark = "vip状态为0的改为1.", CreateBy = UserID, CreateTime = DateTime.Now, VipID = VipLoginInfo.VIPID, LogID = Guid.NewGuid().ToString("N") }; var logBll = new VipLogBLL(base.CurrentUserInfo); logBll.Create(log); } #endregion int couponCount = vipLoginBLL.GetVipCoupon(UserID); rd.MemberInfo.Mobile = VipLoginInfo.Phone; //手机号码 rd.MemberInfo.Name = VipLoginInfo.UserName; //姓名 rd.MemberInfo.VipID = VipLoginInfo.VIPID; //组标识 rd.MemberInfo.VipName = VipLoginInfo.VipName; //会员名 rd.MemberInfo.ImageUrl = VipLoginInfo.HeadImgUrl; //会员头像 add by Henry 2014-12-5 rd.MemberInfo.VipRealName = VipLoginInfo.VipRealName; rd.MemberInfo.VipNo = VipLoginInfo.VipCode; rd.MemberInfo.IsDealer = VipLoginInfo.Col48 != null?int.Parse(VipLoginInfo.Col48) : 0; //超级分销体系配置表 为判断是否存在分销体系使用 var T_SuperRetailTraderConfigbll = new T_SuperRetailTraderConfigBLL(CurrentUserInfo); //获取分销体系信息 var T_SuperRetailTraderConfigInfo = T_SuperRetailTraderConfigbll.QueryByEntity(new T_SuperRetailTraderConfigEntity() { IsDelete = 0, CustomerId = CurrentUserInfo.CurrentUser.customer_id }, null).FirstOrDefault(); if (T_SuperRetailTraderConfigInfo != null) { rd.MemberInfo.CanBeSuperRetailTrader = 1; } else { rd.MemberInfo.CanBeSuperRetailTrader = 0; } rd.MemberInfo.SuperRetailTraderID = VipLoginInfo.Col26; //rd.MemberInfo.Integration = VipLoginInfo.Integration ?? 0;//会员积分 #region 会员有效积分 var vipIntegralBLL = new VipIntegralBLL(CurrentUserInfo); var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = UserID, VipCardCode = VipLoginInfo.VipCode }, null).FirstOrDefault(); if (vipIntegralInfo != null) { rd.MemberInfo.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0; } #endregion //会员等级 //rd.MemberInfo.VipLevelName = string.IsNullOrEmpty(vipLoginBLL.GetVipLeave(UserID)) ? null : vipLoginBLL.GetVipLeave(UserID); #region 会员卡名称 var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); var vipCardBLL = new VipCardBLL(CurrentUserInfo); var vipCardTypeBLL = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardRuleBLL = new VipCardRuleBLL(CurrentUserInfo); var vipT_InoutBLL = new T_InoutBLL(CurrentUserInfo); VipAmountBLL vipAmountBLL = new VipAmountBLL(CurrentUserInfo); ShoppingCartBLL service = new ShoppingCartBLL(CurrentUserInfo); ShoppingCartEntity queryEntity = new ShoppingCartEntity(); queryEntity.VipId = UserID; int totalQty = service.GetListQty(queryEntity); rd.MemberInfo.ShopCartCount = totalQty; //定义当前自定义等级 int?CurVipLevel = 0; var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = UserID, CustomerID = CurrentUserInfo.ClientID }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).FirstOrDefault(); if (vipCardMappingInfo != null) { var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1 }, null).FirstOrDefault(); if (vipCardInfo != null) { var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardTypeID = vipCardInfo.VipCardTypeID }, null).FirstOrDefault(); if (vipCardTypeInfo != null) { rd.MemberInfo.VipLevelName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : ""; rd.MemberInfo.CardTypeImageUrl = vipCardTypeInfo.PicUrl != null ? vipCardTypeInfo.PicUrl : ""; rd.MemberInfo.CardTypePrice = vipCardTypeInfo.Prices != null ? vipCardTypeInfo.Prices.Value : 0; rd.MemberInfo.IsExtraMoney = vipCardTypeInfo.IsExtraMoney != null ? vipCardTypeInfo.IsExtraMoney : 0; CurVipLevel = vipCardTypeInfo.VipCardLevel; rd.MemberInfo.IsPrepaid = vipCardTypeInfo.Isprepaid; if (CurVipLevel > 1) { var VipCardTypeSysInfo = vipCardTypeBLL.GetBindVipCardTypeInfo(CurrentUserInfo.ClientID, VipLoginInfo.Phone, pRequest.UserID, CurVipLevel); if (VipCardTypeSysInfo == null || VipCardTypeSysInfo.Tables[0].Rows.Count == 0) { rd.MemberInfo.IsNeedCard = 2; } } else { rd.MemberInfo.IsNeedCard = 1; } //因为卡等级不能重复,知道当前等级后查找相应的下一级是否是自动升级(消费升级) var NextVipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardLevel = CurVipLevel + 1, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (NextVipCardTypeInfo != null) { //获取当前会员的消费金额信息 decimal CurVipConsumptionAmount = 0; decimal VipConsumptionInfo = vipT_InoutBLL.GetVipSumAmount(UserID); if (VipConsumptionInfo > 0) { CurVipConsumptionAmount = Convert.ToDecimal(Convert.ToDecimal(VipConsumptionInfo).ToString("0.00")); } //知道下一等级后要判断,升级条件是否是消费升级 //定义累积消费金额 decimal AccumulatedAmount = 0; var vipCardTypeUpGradeInfo = vipCardTypeBLL.GetVipCardTypeUpGradeInfo(CurrentUserInfo.ClientID, CurVipLevel); if (vipCardTypeUpGradeInfo != null && vipCardTypeUpGradeInfo.Tables[0].Rows.Count > 0) { //判断拉取的所有卡等级里的最近的一级满足条件即可返回提示所需的值 int flag = 0; foreach (DataRow dr in vipCardTypeUpGradeInfo.Tables[0].Rows) { AccumulatedAmount = Convert.ToDecimal(Convert.ToDecimal(dr["BuyAmount"].ToString()).ToString("0.00")); //获取消费升级还需多少钱 if (AccumulatedAmount > CurVipConsumptionAmount && flag == 0) { flag = 1; rd.MemberInfo.UpGradeNeedMoney = AccumulatedAmount - CurVipConsumptionAmount; if (rd.MemberInfo.UpGradeNeedMoney > 0) { rd.MemberInfo.UpgradePrompt = "还需要消费" + rd.MemberInfo.UpGradeNeedMoney + "元可以升级啦,快点通知会员!"; } } } } } var VipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity() { CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = vipCardTypeInfo.VipCardTypeID }, null).FirstOrDefault(); if (VipCardRuleInfo != null) { rd.MemberInfo.CardDiscount = Convert.ToDecimal(Convert.ToDecimal((VipCardRuleInfo.CardDiscount / 10)).ToString("0.00")); } } } } else { //表示需要领卡,并展示等级为1的默认卡 rd.MemberInfo.IsNeedCard = 0; var VipCardTypeData = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardLevel = 1, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (VipCardTypeData != null) { rd.MemberInfo.CardTypeImageUrl = VipCardTypeData.PicUrl != null ? VipCardTypeData.PicUrl : ""; } } //获取红利/// decimal[0]=总收入(红利) decimal[2]=支出余额 decimal[1]=总提现金额 decimal[] array = vipAmountBLL.GetVipSumAmountByCondition(UserID, CurrentUserInfo.ClientID, true); if (array[0] != null) { rd.MemberInfo.ProfitAmount = array[0]; } //是否有付费的会员卡 List <IWhereCondition> freeCardCon = new List <IWhereCondition> { }; freeCardCon.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); freeCardCon.Add(new DirectCondition("Prices>0")); var freeCardTypeInfo = vipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault(); if (freeCardTypeInfo != null) { rd.MemberInfo.IsCostCardType = 1; } else { rd.MemberInfo.IsCostCardType = 0; } #endregion rd.MemberInfo.Status = VipLoginInfo.Status.HasValue ? VipLoginInfo.Status.Value : 1; rd.MemberInfo.CouponsCount = couponCount; rd.MemberInfo.IsActivate = (VipLoginInfo.IsActivate.HasValue && VipLoginInfo.IsActivate.Value == 1 ? true : false); var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); //获取标签信息 TagsBLL TagsBLL = new TagsBLL(base.CurrentUserInfo); var dsIdentity = TagsBLL.GetVipTagsList("", UserID);//“车主标签” 传7 if (dsIdentity != null && dsIdentity.Tables.Count > 0 && dsIdentity.Tables[0].Rows.Count > 0) { rd.IdentityTagsList = DataTableToObject.ConvertToList <TagsInfo>(dsIdentity.Tables[0]).ToArray(); //“年龄段” 传8 } #region 获取注册表单的列明和值 var vipEntity = vipLoginBLL.QueryByEntity(new VipEntity() { VIPID = UserID }, null); if (vipEntity == null || vipEntity.Length == 0) { return(rd); } else { var ds = vipLoginBLL.GetVipColumnInfo(CurrentUserInfo.ClientID, "online005"); var vipDs = vipLoginBLL.GetVipInfo(UserID); if (ds.Tables[0].Rows.Count > 0) { var temp = ds.Tables[0].AsEnumerable().Select(t => new MemberControlInfo() { ColumnName = t["ColumnName"].ToString(), ControlType = Convert.ToInt32(t["ControlType"]), ColumnValue = vipDs.Tables[0].Rows[0][t["ColumnName"].ToString()].ToString(), ColumnDesc = t["columnDesc"].ToString() }); rd.MemberControlList = temp.ToArray(); } } //var vipamountBll = new VipAmountBLL(this.CurrentUserInfo); //var vipAmountEntity = vipamountBll.GetByID(UserID); var unitBll = new UnitBLL(this.CurrentUserInfo); //Hashtable htPara = new Hashtable(); //htPara["MemberID"] = UserID; //htPara["CustomerID"] = CurrentUserInfo.ClientID; //htPara["PageIndex"] = 1; //htPara["PageSize"] = 10; //DataSet dsMyAccount = unitBll.GetMyAccount(htPara); //if (dsMyAccount.Tables[0].Rows.Count > 0) //{ // //rd.AccountList = DataTableToObject.ConvertToList<AccountInfo>(dsMyAccount.Tables[0]); // //rd.MemberInfo.Balance = Convert.ToDecimal(dsMyAccount.Tables[0].Rows[0]["Total"].ToString()); // //rd.TotalPageCount = int.Parse(dsMyAccount.Tables[0].Rows[0]["PageCount"].ToString()); //} //else // rd.MemberInfo.Balance = 0; //返现 add by Henry 2015-4-15 var vipAmountBll = new VipAmountBLL(CurrentUserInfo); //var vipAmountInfo = vipAmountBll.GetByID(UserID); var vipAmountInfo = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = UserID, VipCardCode = VipLoginInfo.VipCode }, null).FirstOrDefault(); decimal returnAmount = 0; decimal amount = 0; if (vipAmountInfo != null) { returnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value; amount = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value; } rd.MemberInfo.ReturnAmount = returnAmount; //返现 rd.MemberInfo.Balance = amount; //余额 #endregion //获取订单的日期和订单的里的商品名称、商品单价、商品数量 //先获取订单列表,再获取订单详细信息 int? pageSize = 3; //rp.Parameters.PageSize;,只取三条记录 int? pageIndex = 1; //rp.Parameters.PageIndex; string OrderBy = ""; string OrderType = ""; T_InoutBLL T_InoutBLL = new T_InoutBLL(CurrentUserInfo); InoutService InoutService = new InoutService(CurrentUserInfo); //只取状态为700的 //根据订单列表取订单详情 DataSet dsOrder = T_InoutBLL.GetOrdersByVipID(rd.MemberInfo.VipID, pageIndex ?? 1, pageSize ?? 15, OrderBy, OrderType);//获取会员信息 if (dsOrder != null && dsOrder.Tables.Count != 0 && dsOrder.Tables[0].Rows.Count != 0) { List <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo> orderList = DataTableToObject.ConvertToList <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo>(dsOrder.Tables[1]); foreach (JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo oi in orderList) { IList <InoutDetailInfo> detailList = InoutService.GetInoutDetailInfoByOrderId(oi.order_id); oi.DetailList = detailList; } rd.OrderList = orderList; } MessageInfo message = new MessageInfo(); InnerGroupNewsBLL InnerGroupNewsService = new InnerGroupNewsBLL(CurrentUserInfo); SetoffToolsBLL setofftoolsService = new SetoffToolsBLL(CurrentUserInfo); //1=微信用户 2=APP员工 int UnReadInnerMessageCount = InnerGroupNewsService.GetVipInnerGroupNewsUnReadCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, null, Convert.ToDateTime(VipLoginInfo.CreateTime)); var setofftoolsMessageCount = setofftoolsService.GetUnReadSetoffToolsCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, 1); message.InnerGroupNewsCount = UnReadInnerMessageCount; message.SetoffToolsCount = setofftoolsMessageCount; var VipUpNewsInfo = InnerGroupNewsService.GetVipInnerNewsInfo(CurrentUserInfo.ClientID, 2, 1, 3, 0); if (VipUpNewsInfo != null && VipUpNewsInfo.Tables[0].Rows.Count > 0) { message.UpGradeSucess = VipUpNewsInfo.Tables[0].Rows[0]["Text"] != null ? VipUpNewsInfo.Tables[0].Rows[0]["Text"].ToString() : ""; //获取通知信息 并更新已读状态 数据如果不是一条进行更新所有数据 var newsUserMappingBLL = new NewsUserMappingBLL(CurrentUserInfo); if (VipUpNewsInfo.Tables[0].Rows.Count > 1)//数据如果不是一条进行更新所有数据 { foreach (DataRow VipNewsdr in VipUpNewsInfo.Tables[0].Rows) { var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity() { CustomerId = CurrentUserInfo.ClientID, MappingID = VipNewsdr["MappingID"].ToString() }, null).FirstOrDefault(); if (vipNewsInfo != null) { vipNewsInfo.HasRead = 1; newsUserMappingBLL.Update(vipNewsInfo); } } } else { var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity() { CustomerId = CurrentUserInfo.ClientID, MappingID = VipUpNewsInfo.Tables[0].Rows[0]["MappingID"].ToString() }, null).FirstOrDefault(); if (vipNewsInfo != null) { vipNewsInfo.HasRead = 1; newsUserMappingBLL.Update(vipNewsInfo); } } } else { message.UpGradeSucess = ""; } rd.MessageInfo = message; return(rd); } }
public HttpResponseMessage ScanQRCode([FromBody] ScanQRCodeRequestModel requestParameter) { var json = new JavaScriptSerializer().Serialize(requestParameter); Loggers.Debug(new DebugLogInfo() { Message = $"[api/Order/ScanQRCode]接口,参数:\"{json}\"" }); try { #region MyRegion string customerId = ConfigurationManager.AppSettings["CustomerId"].Trim(); string content = string.Empty; #endregion #region var loggingSessionInfo = Default.GetLoggingSession(customerId, "1"); if (string.IsNullOrWhiteSpace(requestParameter.ParaTmp)) { throw new APIException("paraTmp不能为空") { ErrorCode = 302 }; } #endregion #region 创建临时匹配表 VipDCodeBLL vipDCodeServer = new VipDCodeBLL(loggingSessionInfo); VipDCodeEntity info = new VipDCodeEntity(); //由于CodeId有重复的概率,因此只取出最新的一条记录 info = vipDCodeServer.QueryByEntity( new VipDCodeEntity() { DCodeId = ToStr(requestParameter.ParaTmp.Replace(" ", "")) } //又去掉了中间的空格 , new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } } )[0]; string status = string.Empty; string vipId = string.Empty; string openId = string.Empty; if (info == null || info.DCodeId == null) { throw new APIException("不存在对应的记录") { ErrorCode = 303 }; } else { status = info.Status; openId = info.OpenId; vipId = info.VipId; } string mode = "Inbound"; //if ((RP.Parameters.special.Mode == null || (!string.IsNullOrEmpty(RP.Parameters.special.Mode) && RP.Parameters.special.Mode.Equals("Inbound"))) && !string.IsNullOrEmpty(info.VipId) && info.VipId != RP.UserID) if ((mode == null || (!string.IsNullOrEmpty(mode) && mode.Equals("Inbound"))) && !string.IsNullOrEmpty(info.VipId) && info.VipId != requestParameter.UserId) { VipBLL vipBll = new VipBLL(loggingSessionInfo); var unitBll = new t_unitBLL(loggingSessionInfo); var UserBll = new T_UserBLL(loggingSessionInfo); var vipInfo = vipBll.GetByID(info.VipId); var tt = vipBll.GetUnitByUserId(requestParameter.UserId); //获取员工的会集店**** var UserEntity = UserBll.GetByID(vipInfo.SetoffUserId); //当前会员集客员工 // string UserStatus = ""; if (UserEntity != null) { UserStatus = UserEntity.user_status; } #region 会员会籍店、集客员工变动处理 //string.IsNullOrWhiteSpace(vipInfo.CouponInfo) || string.IsNullOrWhiteSpace(vipInfo.SetoffUserId) 目前未用到 if (string.IsNullOrWhiteSpace(vipInfo.HigherVipID) && string.IsNullOrWhiteSpace(vipInfo.SetoffUserId)) { //当会员会籍店、集客员工为空时 if (!string.IsNullOrEmpty(tt)) { vipInfo.CouponInfo = tt; //设为门店 vipInfo.SetoffUserId = requestParameter.UserId; //设为门店员工 vipInfo.Col21 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间***** vipInfo.Col23 = "1"; } if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId) { //rsp.Message = "恭喜你集客成功。会员需要用心经营才会有订单哦!"; } } else { if (vipInfo != null && !string.IsNullOrEmpty(vipInfo.CouponInfo) && vipInfo.SetoffUserId != requestParameter.UserId) { //rsp.Message = "此客户已是会员,无需再集客。老会员更要服务好哦!"; } else if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId && !string.IsNullOrEmpty(vipInfo.Col21) && Convert.ToDateTime(vipInfo.Col21).AddSeconds(3) < DateTime.Now) //col21:员工集客/或者分销商集客时间 { //rsp.Message = "此客户此前已经被您集客,无需重复集客。!"; } } if (UserStatus.Trim().Equals("-1")) { // 当前会员的集客员工离职时 if (!string.IsNullOrEmpty(tt)) { vipInfo.CouponInfo = tt; //设为门店 vipInfo.SetoffUserId = requestParameter.UserId; //设为门店员工 vipInfo.Col21 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间***** vipInfo.Col23 = "1"; } } #endregion vipBll.Update(vipInfo); } #endregion var responseModel = new ScanQRCodeResponseModel() { IsSucess = true, Status = status, VipId = vipId }; return(Request.CreateResponse(HttpStatusCode.OK, responseModel)); } catch (Exception ex) { var responseModel = new ScanQRCodeResponseModel() { IsSucess = false, ErrorMessage = ex.Message }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, "error")); } }
protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <SetVipCardRP> pRequest) { var rd = new SetVipCardRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; #region 业务对象 //会员卡 var VipCardBLL = new VipCardBLL(loggingSessionInfo); //余额变动记录 var VipCardBalanceChangeBLL = new VipCardBalanceChangeBLL(loggingSessionInfo); //卡状态变更记录 var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //卡关系 var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //图片 var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo); //会员 var VipBLL = new VipBLL(loggingSessionInfo); var vipCardTransLogBLL = new VipCardTransLogBLL(loggingSessionInfo); //丰收日交易记录对象示例化 var unitBLL = new TUnitBLL(loggingSessionInfo); //门店业务对象 //事务 var pTran = VipCardBLL.GetTran(); #endregion using (pTran.Connection) { try { if (string.IsNullOrWhiteSpace(para.VipCardID) || para.OperationType <= 0) { throw new APIException("卡ID或者操作类型参数不合法!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; } //定位当前卡业务对象 VipCardEntity changeEntity = VipCardBLL.GetByID(para.VipCardID); if (changeEntity == null) { throw new APIException("当前卡信息对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } #region 返回卡ID rd.VipCardID = changeEntity.VipCardID; #endregion changeEntity.RechargeTotalAmount = changeEntity.RechargeTotalAmount ?? 0; changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; string OldVipCardCode = changeEntity.VipCardCode ?? ""; //原卡号 string NewVipCardCode = ""; //新卡号,获取新卡赋值 decimal OldMoney = changeEntity.BalanceAmount.Value; //原卡当前余额 decimal NewMoney = changeEntity.BalanceAmount.Value + para.BalanceMoney; //原卡当余额+调整金额 //原卡会员映射关系 VipCardVipMappingEntity OldVipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = para.VipCardID }, null).FirstOrDefault(); if (OldVipCardVipMappingData == null) { throw new APIException("原卡会员关系映射对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //门店Entity var UnitData = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId); //会员 VipEntity VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); #region 卡状态记录对象 VipCardStatusChangeLogEntity AddVCStatusEntity = new VipCardStatusChangeLogEntity(); AddVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddVCStatusEntity.VipCardID = para.VipCardID; AddVCStatusEntity.Reason = para.ChangeReason; AddVCStatusEntity.OldStatusID = changeEntity.VipCardStatusId; AddVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddVCStatusEntity.Remark = para.Remark; AddVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; #endregion #region 新卡 VipCardEntity NewChangeVipCardData = new VipCardEntity(); if (!string.IsNullOrWhiteSpace(para.NewCardCode)) { //查询参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; if (!string.IsNullOrEmpty(para.NewCardCode)) { complexCondition.Add(new DirectCondition("VipCardCode='" + para.NewCardCode + "' or VipCardISN='" + para.NewCardCode.ToString() + "' ")); } //新卡对象 NewChangeVipCardData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); if (NewChangeVipCardData == null) { throw new APIException("新卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //新卡号赋值 NewVipCardCode = NewChangeVipCardData.VipCardCode ?? ""; //新卡数据赋值 NewChangeVipCardData.VipCardGradeID = changeEntity.VipCardGradeID; NewChangeVipCardData.BatchNo = changeEntity.BatchNo; NewChangeVipCardData.BeginDate = changeEntity.BeginDate; NewChangeVipCardData.EndDate = changeEntity.EndDate; NewChangeVipCardData.TotalAmount = changeEntity.TotalAmount == null ? 0 : changeEntity.TotalAmount.Value; NewChangeVipCardData.BalanceAmount = changeEntity.BalanceAmount == null ? 0 : changeEntity.BalanceAmount.Value; NewChangeVipCardData.BalancePoints = changeEntity.BalancePoints == null ? 0 : changeEntity.BalancePoints.Value; NewChangeVipCardData.BalanceBonus = changeEntity.BalanceBonus == null ? 0 : changeEntity.BalanceBonus.Value; NewChangeVipCardData.CumulativeBonus = changeEntity.CumulativeBonus == null ? 0 : changeEntity.CumulativeBonus.Value; NewChangeVipCardData.PurchaseTotalAmount = changeEntity.PurchaseTotalAmount == null ? 0 : changeEntity.PurchaseTotalAmount.Value; NewChangeVipCardData.PurchaseTotalCount = changeEntity.PurchaseTotalCount == null ? 0 : changeEntity.PurchaseTotalCount.Value; NewChangeVipCardData.CheckCode = changeEntity.CheckCode; NewChangeVipCardData.SingleTransLimit = changeEntity.SingleTransLimit == null ? 0 : changeEntity.SingleTransLimit.Value; NewChangeVipCardData.IsOverrunValid = changeEntity.IsOverrunValid == null ? 0 : changeEntity.IsOverrunValid.Value; NewChangeVipCardData.RechargeTotalAmount = changeEntity.RechargeTotalAmount == null ? 0 : changeEntity.RechargeTotalAmount.Value; NewChangeVipCardData.LastSalesTime = changeEntity.LastSalesTime; NewChangeVipCardData.IsGift = changeEntity.IsGift == null ? 0 : changeEntity.IsGift.Value; NewChangeVipCardData.SalesAmount = changeEntity.SalesAmount; NewChangeVipCardData.SalesUserId = changeEntity.SalesUserId; NewChangeVipCardData.CustomerID = changeEntity.CustomerID; NewChangeVipCardData.MembershipTime = changeEntity.MembershipTime; NewChangeVipCardData.SalesUserName = changeEntity.SalesUserName == null ? "" : changeEntity.SalesUserName; NewChangeVipCardData.CreateBy = changeEntity.CreateBy; } #endregion switch (para.OperationType) { case 1: #region 调整卡余额 //卡更新 //卡内总金额 if (para.BalanceMoney > 0) { changeEntity.RechargeTotalAmount += para.BalanceMoney; if (changeEntity.RechargeTotalAmount < 0) { throw new APIException("调整后的余额小于0!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } } //changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; // changeEntity.BalanceAmount = NewMoney; //执行更新 VipCardBLL.Update(changeEntity, pTran); //新增余额变动记录 VipCardBalanceChangeEntity AddEntity = new VipCardBalanceChangeEntity(); AddEntity.ChangeID = System.Guid.NewGuid().ToString(); AddEntity.VipCardCode = changeEntity.VipCardCode; AddEntity.ChangeAmount = para.BalanceMoney; //变动前卡内余额 AddEntity.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddEntity.ChangeAfterBalance = NewMoney; AddEntity.ChangeReason = para.ChangeReason; AddEntity.Status = 1; AddEntity.Remark = para.Remark; AddEntity.CustomerID = loggingSessionInfo.ClientID; AddEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; //执行新增 VipCardBalanceChangeBLL.Create(AddEntity, pTran); //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddEntity.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } #region 充值记录 //读取最近一次积分变更记录 List <OrderBy> lstOrder = new List <OrderBy> { }; //排序参数 lstOrder.Add(new OrderBy() { FieldName = "TransTime", Direction = OrderByDirections.Desc }); var transLogInfo = vipCardTransLogBLL.QueryByEntity(new VipCardTransLogEntity() { VipCardCode = changeEntity.VipCardCode, TransType = "C" }, lstOrder.ToArray()).FirstOrDefault(); //期末积分 int newValue = transLogInfo != null ? (transLogInfo.NewValue ?? 0) : 0; var vipCardTransLogEntity = new VipCardTransLogEntity() { VipCardCode = VipData == null ? "" : VipData.VipCode, UnitCode = UnitData == null ? "" : UnitData.UnitCode, TransContent = "余额", TransType = "C", TransTime = DateTime.Now, TransAmount = para.BalanceMoney, LastValue = newValue, //期初金额 NewValue = Convert.ToInt32(para.BalanceMoney) + newValue, //期末金额 CustomerID = loggingSessionInfo.ClientID }; vipCardTransLogBLL.Create(vipCardTransLogEntity, pTran); #endregion #endregion break; case 2: #region 卡升级 //卡类型升级 if (para.VipCardTypeId != 0) { VipCardVipMappingBLL.updateVipCardByType(VipData.VIPID, para.VipCardTypeId, para.ChangeReason, para.Remark, VipData.VipCode, pTran); } //卡号升级 else { #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 //changeEntity.BalanceAmount = 0; //changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "卡升级"; AddVCStatusEntity.Remark += "已升级为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddOldCardBalanceData = new VipCardBalanceChangeEntity(); // AddOldCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddOldCardBalanceData.VipCardCode = changeEntity.VipCardCode; // AddOldCardBalanceData.ChangeAmount = -OldMoney; // //变动前卡内余额 // AddOldCardBalanceData.ChangeBeforeBalance = OldMoney; // //变动后卡内余额 // AddOldCardBalanceData.ChangeAfterBalance = 0; // AddOldCardBalanceData.ChangeReason = para.ChangeReason; // AddOldCardBalanceData.Status = 1; // AddOldCardBalanceData.Remark = para.Remark; // AddOldCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // AddOldCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; // VipCardBalanceChangeBLL.Create(AddOldCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddOldCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion #region 新卡 VipData.VipCode = para.NewCardCode; VipBLL.Update(VipData, pTran); #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value == changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级相同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddVipCardVipMappingData = new VipCardVipMappingEntity(); AddVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity SJ_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); //if (VipData == null) // throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; //VipData.VipCode = NewChangeVipCardData.VipCardCode; //VipBLL.Update(VipData, pTran);//执行 #endregion #region 新增新卡状态记录 //新增新卡状态记录 VipCardStatusChangeLogEntity AddNewVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewVCStatusEntity.VipCardStatusID = 1; AddNewVCStatusEntity.Reason = para.ChangeReason; AddNewVCStatusEntity.OldStatusID = 0; AddNewVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewVCStatusEntity.Action = "卡升级"; AddNewVCStatusEntity.Remark = para.Remark + "由旧卡:" + changeEntity.VipCardCode + "升级"; AddNewVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 //新增余额记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddNewCardBalanceData = new VipCardBalanceChangeEntity(); // AddNewCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddNewCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; // AddNewCardBalanceData.ChangeAmount = OldMoney; // //变动前卡内余额 // AddNewCardBalanceData.ChangeBeforeBalance = 0; // //变动后卡内余额 // AddNewCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; // AddNewCardBalanceData.ChangeReason = para.ChangeReason; // AddNewCardBalanceData.Status = 1; // AddNewCardBalanceData.Remark = para.Remark; // AddNewCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // VipCardBalanceChangeBLL.Create(AddNewCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddNewCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion } #endregion break; case 3: #region 挂失 changeEntity.VipCardStatusId = 4; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行 AddVCStatusEntity.VipCardStatusID = 4; AddVCStatusEntity.PicUrl = para.ImageUrl; AddVCStatusEntity.Action = "挂失"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 4: #region 冻结 changeEntity.VipCardStatusId = 2; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 2; AddVCStatusEntity.Action = "冻结"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 5: #region 转卡 #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 changeEntity.BalanceAmount = 0; changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "转卡"; AddVCStatusEntity.Remark += "已转移为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddOldZKCardBalanceData = new VipCardBalanceChangeEntity(); AddOldZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddOldZKCardBalanceData.VipCardCode = changeEntity.VipCardCode; AddOldZKCardBalanceData.ChangeAmount = -OldMoney; //变动前卡内余额 AddOldZKCardBalanceData.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddOldZKCardBalanceData.ChangeAfterBalance = 0; AddOldZKCardBalanceData.ChangeReason = para.ChangeReason; AddOldZKCardBalanceData.Status = 1; AddOldZKCardBalanceData.Remark = para.Remark; AddOldZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddOldZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddOldZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddOldZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #region 新卡 #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value != changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级不同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddZKVipCardVipMappingData = new VipCardVipMappingEntity(); AddZKVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddZKVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddZKVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddZKVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddZKVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity ZK_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); if (VipData == null) { throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; VipData.VipCode = NewChangeVipCardData.VipCardCode; VipBLL.Update(VipData, pTran); //执行 #endregion #region 新增新卡状态记录 VipCardStatusChangeLogEntity AddNewZKVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewZKVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewZKVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewZKVCStatusEntity.VipCardStatusID = 1; AddNewZKVCStatusEntity.Reason = para.ChangeReason; AddNewZKVCStatusEntity.OldStatusID = 0; AddNewZKVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewZKVCStatusEntity.Action = "转卡"; AddNewZKVCStatusEntity.Remark = para.Remark + para.Remark + "由旧卡:" + changeEntity.VipCardCode + "转移"; AddNewZKVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewZKVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddNewZKCardBalanceData = new VipCardBalanceChangeEntity(); AddNewZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddNewZKCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; AddNewZKCardBalanceData.ChangeAmount = OldMoney; //变动前卡内余额 AddNewZKCardBalanceData.ChangeBeforeBalance = 0; //变动后卡内余额 AddNewZKCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; AddNewZKCardBalanceData.ChangeReason = para.ChangeReason; AddNewZKCardBalanceData.Status = 1; AddNewZKCardBalanceData.Remark = para.Remark; AddNewZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddNewZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddNewZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddNewZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #endregion break; case 6: #region 解挂 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解挂"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 7: #region 解冻 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解冻"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 8: #region 作废 changeEntity.VipCardStatusId = 3; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "作废"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 9: #region 唤醒 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "唤醒"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 10: #region 激活 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "激活"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; default: throw new APIException("当前操作类型不匹配!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; break; } ; pTran.Commit(); #region 卡升级,转卡操作转移消费记录表 if ((para.OperationType == 2 || para.OperationType == 5) && string.IsNullOrEmpty(para.VipCardTypeId.ToString())) //卡类型升级不执行此操作 { string StrSql = string.Format("update VipCardTransLog set VipCardCode='{0}',OldVipCardCode='{1}' where VipCardCode='{1}'", NewVipCardCode, OldVipCardCode); vipCardTransLogBLL.UpdateVipCardTransLog(StrSql);//执行 } #endregion var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = VipData.VIPID }; eventService.PublishMsg(vipMsg); } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事务 throw new APIException(ex.Message); } } return(rd); }
const int MEMBER_HAVECARDNOTIPS = 320; //领取成功 不提示 但跳到实体卡 #endregion protected override AuthCodeLoginRD ProcessRequest(DTO.Base.APIRequest <AuthCodeLoginRP> pRequest) { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); //参数验证 if (string.IsNullOrEmpty(pRequest.Parameters.Mobile)) { throw new APIException("请求参数中缺少Mobile或值为空.") { ErrorCode = ERROR_LACK_MOBILE }; } if (pRequest.Parameters.VipSource.HasValue == false) { pRequest.Parameters.VipSource = 1; //throw new APIException("请求参数中缺少VipSource或值为空.") { ErrorCode = ERROR_LACK_VIP_SOURCE }; } // AuthCodeLoginRD rd = new AuthCodeLoginRD(); var bll = new VipBLL(this.CurrentUserInfo); var codebll = new RegisterValidationCodeBLL(base.CurrentUserInfo); VipEntity vipByID = null; //根据VIP ID查找出来的VIP记录 VipEntity vipByPhone = null; //根据手机号查找出来的VIP记录 //var list = codebll.QueryByEntity(new RegisterValidationCodeEntity() //{ // Mobile = pRequest.Parameters.Mobile //}, null); //bool b = false; //if (list != null) //{ // foreach (var entity in list) // { // if (entity == null) // throw new APIException("未找到此手机的验证信息") {ErrorCode = ERROR_AUTHCODE_NOTEXISTS}; // //if (entity.IsValidated.Value == 1) // // throw new APIException("此验证码已被使用") {ErrorCode = ERROR_AUTHCODE_WAS_USED}; // //if (entity.Expires.Value < DateTime.Now) // // throw new APIException("此验证码已失效") {ErrorCode = ERROR_AUTHCODE_INVALID}; // if (entity.Code == pRequest.Parameters.AuthCode) // b = true; // } //} //if (!b) //{ // throw new APIException("验证码不正确.") { ErrorCode = ERROR_AUTHCODE_NOT_EQUALS }; //} #region 验证验证码 var entity = codebll.GetByMobile(pRequest.Parameters.Mobile); if (entity == null) { throw new APIException("未找到此手机的验证信息") { ErrorCode = ERROR_AUTHCODE_NOTEXISTS } } ; if (entity.IsValidated.Value == 1) { throw new APIException("此验证码已被使用") { ErrorCode = ERROR_AUTHCODE_WAS_USED } } ; if (entity.Expires.Value < DateTime.Now) { throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_INVALID } } ; if (entity.Code != pRequest.Parameters.AuthCode) { throw new APIException("验证码不正确.") { ErrorCode = ERROR_AUTHCODE_NOT_EQUALS } } ; #endregion #region 获取会员权益 var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); var memberBenefit = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); var bllPrize = new LPrizesBLL(CurrentUserInfo); #endregion //自定义没有实体卡,有实体卡时变为1 int HaveVipcard = 0; //要发送给rabbitmq的信息 var eventService = new EventService(); EventContract vipMsg = null; switch (pRequest.Parameters.VipSource.Value) { case 3: //来源是微信时,做自动合并 { #region 根据手机号查找下,看下是否存在同样手机号的VIP记录 { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); //潜在或者正式会员 wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByPhone = result[0]; } if (vipByPhone != null && vipByPhone.VipSourceId == "3" && vipByPhone.Status.Value >= 2) { throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; } } #endregion #region 根据VIP ID查找下,看下是否存在该VIP的记录 if (!string.IsNullOrEmpty(pRequest.UserID)) { List <IWhereCondition> wheres = new List <IWhereCondition>(); //wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = true }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByID = result[0]; } } else { //如果前端未指定VIP ID则后台指定 pRequest.UserID = Guid.NewGuid().ToString("N"); } //判断用户是从点击领取过来的 还是从点击绑定实体卡过来的 int?RegisterType = 0; if (pRequest.Parameters.registerType != null) { RegisterType = pRequest.Parameters.registerType; } //当手机号不为空时需要查询是否存在实体卡 if (!string.IsNullOrEmpty(pRequest.Parameters.Mobile) && (!string.IsNullOrEmpty(pRequest.UserID) || !string.IsNullOrEmpty(vipByPhone.VIPID))) { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); wheres.Add(new DirectCondition("VipID!='" + pRequest.UserID + "'")); var vipInfo = bll.Query(wheres.ToArray(), null); //若是从绑定实体卡进入,进行实体卡的判断,并不注册成功 if (RegisterType == 2) { if (vipInfo == null || vipInfo.Length == 0) { throw new APIException("未检测到实体卡") { ErrorCode = MEMBER_HAVENOCARD }; } else { vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); HaveVipcard = 1; //需要给绑定实体卡的提示 } } else { vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //若是从"点击领取"进入则进行判断有没有实体卡 有没有实体卡都进行领卡成功的提示 if (vipInfo != null && vipInfo.Length > 0) { HaveVipcard = 1; //需要给绑定实体卡的提示 } else { HaveVipcard = 2; //注册成功但没有实体卡 } } } if (vipByID == null && vipByPhone == null) //根据vipid查不出记录,并且根据手机号也查不出记录 新增一条vip { //如果不存在则首先创建一条VIP记录,补充记录 vipByID = new VipEntity() { Phone = pRequest.Parameters.Mobile, VipName = pRequest.Parameters.Mobile, UserName = pRequest.Parameters.Mobile, VipRealName = pRequest.Parameters.VipRealName, VIPID = pRequest.UserID, Status = 2, ClientID = pRequest.CustomerID, VipCode = "Vip" + bll.GetNewVipCode(pRequest.CustomerID), VipSourceId = pRequest.Parameters.VipSource.ToString(), WeiXinUserId = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, RegistrationTime = DateTime.Now }; bll.Create(vipByID); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion } else if (vipByID != null) { VipEntity vipUpdateInfo = new VipEntity(); List <IWhereCondition> wheres = new List <IWhereCondition>(); //wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = true }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipUpdateInfo = result[0]; } vipUpdateInfo.Phone = pRequest.Parameters.Mobile; if (!string.IsNullOrEmpty(pRequest.Parameters.VipRealName)) { vipUpdateInfo.VipRealName = pRequest.Parameters.VipRealName; } vipUpdateInfo.Status = 2; vipUpdateInfo.RegistrationTime = DateTime.Now; bll.Update(vipUpdateInfo); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion #region 会员金矿、注册集客奖励 bll.SetOffActionReg(vipByID); #endregion } #endregion #region 根据VIP ID及手机号查询出的结果,尝试自动合并会员 (因目前会员注册不自动绑卡,实现用户自行选择绑卡业务故将绑卡业务注释掉) //if (vipByPhone == null) //{//如果未有相同手机号的用户,则无须绑定,直接使用VIP ID对应的VIP记录作为当前注册用户的记录 // rd.MemberInfo = new MemberInfo() // { // Mobile = vipByID.Phone // , // VipID = vipByID.VIPID // , // Name = vipByID.UserName // , // VipName = vipByID.VipName // , // VipNo = vipByID.VipCode // , // MemberBenefits = memberBenefit // , // IsActivate = vipByID.IsActivate.HasValue && vipByID.IsActivate.Value == 1 ? true : false // }; // //处理绑卡业务 add by Henry 2015/10/28 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //} //else //{//否则调用存储过程,做自动会员合并 // //如果会员已经注册过,并且来源是微信的则表示该帐号已经被注册过不能再次绑定 // if (vipByPhone.VipSourceId == "3" && vipByPhone.Status.Value >= 2) // { // throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; // } // //否则做会员合并 // if (!bll.MergeVipInfo(pRequest.CustomerID, pRequest.UserID, pRequest.Parameters.Mobile)) // { // throw new APIException("自动绑定会员信息失败") { ErrorCode = ERROR_AUTO_MERGE_MEMBER_FAILED }; // } // //合并成功后重新读取信息 // List<IWhereCondition> wheres = new List<IWhereCondition>(); // wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); // wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); // wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); // var result = bll.Query(wheres.ToArray(), null); // vipByID = result[0]; // rd.MemberInfo = new MemberInfo() // { // Mobile = vipByID.Phone // , // VipID = vipByID.VIPID // , // Name = vipByID.UserName // , // VipName = vipByID.VipName // , // VipNo = vipByID.VipCode // , // MemberBenefits = memberBenefit // , // IsActivate = vipByID.IsActivate.HasValue && vipByID.IsActivate.Value == 1 ? true : false // }; // //处理绑卡业务 add by Henry 2015/10/28 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //} #endregion } //注册会员信息发布到rabbitmq vipMsg = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.Vip, Id = pRequest.UserID }; eventService.PublishMsg(vipMsg); break; default: //其他来源则为自动注册 { #region 根据手机号查找下,看下是否存在同样手机号的VIP记录 { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByPhone = result[0]; } if (vipByPhone != null && vipByPhone.Status.Value >= 2) { throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; } } #endregion #region 没有找到相同电话的会员则自动注册 if (vipByPhone == null) { //没有找到相同电话的会员则自动注册 vipByPhone = new VipEntity() { Phone = pRequest.Parameters.Mobile, VipName = pRequest.Parameters.Mobile, UserName = pRequest.Parameters.Mobile, VipRealName = pRequest.Parameters.VipRealName, VIPID = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, Status = 2, //状态为注册 VipCode = "Vip" + bll.GetNewVipCode(pRequest.CustomerID), ClientID = pRequest.CustomerID, VipSourceId = pRequest.Parameters.VipSource.ToString(), WeiXinUserId = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, RegistrationTime = DateTime.Now }; bll.Create(vipByPhone); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion } #endregion #region decimal EndAmount = 0; VipAmountBLL AmountBLL = new VipAmountBLL(this.CurrentUserInfo); VipAmountEntity amountEntity = AmountBLL.GetByID(vipByPhone.VIPID); if (amountEntity != null) { EndAmount = amountEntity.EndAmount.HasValue ? amountEntity.EndAmount ?? 0 : 0; } #endregion #region 返回用户信息 rd.MemberInfo = new MemberInfo() { Mobile = vipByPhone.Phone , VipID = vipByPhone.VIPID , Name = vipByPhone.UserName , VipName = vipByPhone.VipName , VipRealName = vipByPhone.VipRealName , VipNo = vipByPhone.VipCode , MemberBenefits = memberBenefit , IsActivate = false , Integration = vipByPhone.Integration ?? 0 , Balance = EndAmount }; #endregion } //注册会员信息发布到rabbitmq vipMsg = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.Vip, Id = rd.MemberInfo.VipID }; eventService.PublishMsg(vipMsg); break; } T_LEventsRegVipLogBLL lEventRegVipLogBll = new T_LEventsRegVipLogBLL(CurrentUserInfo); if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId)) { lEventRegVipLogBll.CTWRegOrFocusLog(pRequest.Parameters.CTWEventId, pRequest.UserID, "", CurrentUserInfo, "Reg"); } //如果是通过优惠券进来的就有couponId 新注册的需要加记录 if (!string.IsNullOrEmpty(pRequest.Parameters.couponId)) { lEventRegVipLogBll.CouponRegOrFocusLog(pRequest.Parameters.couponId, pRequest.UserID, "", CurrentUserInfo, "Reg"); } //当手机号不为空时需要查询是否存在实体卡 //if (!string.IsNullOrEmpty(pRequest.Parameters.Mobile) && (!string.IsNullOrEmpty(pRequest.UserID) || !string.IsNullOrEmpty(vipByPhone.VIPID))) //{ // List<IWhereCondition> wheres = new List<IWhereCondition>(); // wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); // wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); // wheres.Add(new DirectCondition("VipID!='" + pRequest.UserID + "'")); // var vipInfo = bll.Query(wheres.ToArray(), null); // if (vipInfo != null && vipInfo.Length > 0) // { // throw new APIException("检测到会员相关实体卡") { ErrorCode = MEMBER_HAVECARD }; // } // else // { // //如果会员当前没有实体卡,则默认绑定等级为1的卡 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); // throw new APIException("未检测到实体卡") { ErrorCode = MEMBER_HAVENOCARD }; // } //} //判定是否有可绑卡的定义 1=有可绑卡 if (HaveVipcard == 1 || HaveVipcard == 2) { //有积分的话给相应领取成功的积分提示 var contactEventBLL = new ContactEventBLL(CurrentUserInfo); int sendIntegral = 0; if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId)) { sendIntegral = contactEventBLL.GetContactEventIntegral(CurrentUserInfo.ClientID, "Reg", "Point", 1); } else { sendIntegral = contactEventBLL.GetContactEventIntegral(CurrentUserInfo.ClientID, "Reg", "Point", 0); } if (sendIntegral > 0) { if (pRequest.Parameters.registerType != 2 && HaveVipcard == 2) { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_GETSUCCESS }; //领取成功不跳转跳转到实体卡 } else if (pRequest.Parameters.registerType == 2 && HaveVipcard == 1) { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_HAVECARD_Integral }; //检测到有相关实体卡前端不提示领取成功 并跳到实体卡列表 } else { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_HAVECARD }; //领取成功,提示领取成功,并跳到相关实体卡 } } else { if (pRequest.Parameters.registerType != 2 && HaveVipcard == 2) { throw new APIException("领取成功") { ErrorCode = MEMBER_GETSUCCESS }; //领取成功不跳转跳转到实体卡 } else if (pRequest.Parameters.registerType == 2 && HaveVipcard == 1) { throw new APIException("检测到有相关实体卡") { ErrorCode = MEMBER_HAVECARD }; //检测到有相关实体卡前端不提示领取成功 并跳到实体卡列表 } else if (pRequest.Parameters.registerType != 2 && HaveVipcard == 1) { throw new APIException("领取成功") { ErrorCode = MEMBER_HAVECARD }; //领取成功有实体卡,并跳转 } else { throw new APIException("检测到有相关实体卡") { ErrorCode = MEMBER_HAVECARD }; //领取成功,提示领取成功,并跳到相关实体卡 } } } #region 将验证码设置为已验证 //entity.IsValidated = 1; //codebll.Update(entity); #endregion return(rd); //AuthCodeLoginRD rd = new AuthCodeLoginRD(); //rd.MemberInfo = new MemberInfo(); //var codebll = new RegisterValidationCodeBLL(base.CurrentUserInfo); //var entity = codebll.GetByMobile(pRequest.Parameters.Mobile); //if (entity == null) // throw new APIException("未找到此手机的验证信息") { ErrorCode = ERROR_AUTHCODE_NOTEXISTS }; //if (entity.IsValidated.Value == 1) // throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_FAILURE }; //if (entity.Expires.Value < DateTime.Now) // throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_FAILURE }; //var vipbll = new VipBLL(base.CurrentUserInfo); //var vipinfo = vipbll.GetByMobile(pRequest.Parameters.Mobile, pRequest.CustomerID); //#region VIP来源更新 //switch (pRequest.Parameters.VipSource.Value) //{ // case 4: // case 9: // vipinfo.VipSourceId = pRequest.Parameters.VipSource.ToString(); // vipbll.Update(vipinfo); // break; //} //#endregion //if (string.IsNullOrEmpty(vipinfo.ClientID)) //{ // vipinfo.ClientID = pRequest.CustomerID; // vipbll.Update(vipinfo); //} //rd.MemberInfo.Mobile = vipinfo.Phone; //rd.MemberInfo.Name = vipinfo.UserName; //rd.MemberInfo.VipID = vipinfo.VIPID; //rd.MemberInfo.VipName = vipinfo.VipName; //var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); //rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); //entity.IsValidated = 1; //codebll.Update(entity); //return rd; } } }
// /// <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); }
public VipEntity GetUserIdByOpenId(LoggingSessionInfo loggingSessionInfo, string OpenId) { VipEntity vipInfo = new VipEntity(); try { string vipId = string.Empty; string status = "0"; VipBLL server = new VipBLL(loggingSessionInfo); WXUserInfoBLL wxUserInfoBLL = new WXUserInfoBLL(loggingSessionInfo); //var vipObjs = server.QueryByEntityAbsolute(new VipEntity //{ // WeiXinUserId = OpenId //}, null); var vipObjs = server.QueryByEntity(new VipEntity //先从会员表里取 { WeiXinUserId = OpenId, ClientID = loggingSessionInfo.ClientID }, null); if (vipObjs == null || vipObjs.Length == 0 || vipObjs[0] == null)//找不到会员信息 { //优先从支持多号运营的表中取 var wxUserInfo = wxUserInfoBLL.QueryByEntity(new WXUserInfoEntity() { CustomerID = loggingSessionInfo.ClientID, WeiXinUserID = OpenId }, null).FirstOrDefault(); if (wxUserInfo != null) { var vipEntity = server.QueryByEntity(new VipEntity() { ClientID = loggingSessionInfo.ClientID, UnionID = wxUserInfo.UnionID }, null).FirstOrDefault(); //从会员表里取 if (vipEntity != null) { vipId = vipEntity.VIPID; status = vipEntity.Status.ToString(); vipInfo = vipEntity; } else { vipInfo = null; } } else { //请求获取用户信息 //Jermyn20130911 从总部导入vip信息 bool bReturn = server.GetVipInfoFromApByOpenId(OpenId, null); var vipObjs1 = server.QueryByEntityAbsolute(new VipEntity { WeiXinUserId = OpenId }, null); if (vipObjs1 == null || vipObjs1.Length == 0 || vipObjs1[0] == null) { vipInfo = null; } else { vipId = vipObjs1[0].VIPID; status = vipObjs1[0].Status.ToString(); vipInfo = vipObjs1[0]; } } } else //查到会员信息了 { vipId = vipObjs[0].VIPID; status = vipObjs[0].Status.ToString(); vipInfo = vipObjs[0]; //获取UnionID if (string.IsNullOrEmpty(vipInfo.UnionID)) { var vipService = new VipBLL(loggingSessionInfo); var vipEntity = new VipEntity(); var commonBll = new CommonBLL(); var application = new WApplicationInterfaceDAO(loggingSessionInfo); var appEntity = application.QueryByEntity(new WApplicationInterfaceEntity() { WeiXinID = vipInfo.WeiXin, CustomerId = loggingSessionInfo.ClientID }, null).FirstOrDefault(); if (appEntity != null) { //获取调用微信接口的凭证(普通的获取accestoken的地方) var accessToken = commonBll.GetAccessTokenByCache(appEntity.AppID, appEntity.AppSecret, loggingSessionInfo); //通过openID获取用户信息 // (这种情况下,因为已经有会员信息了,并且已经关注了,才能获取到会员信息) var userInfo = commonBll.GetUserInfo(accessToken.access_token, vipInfo.WeiXinUserId); if (!string.IsNullOrEmpty(userInfo.unionid)) { var vipEntitys = vipService.QueryByEntity(new VipEntity { UnionID = userInfo.unionid, ClientID = loggingSessionInfo.ClientID }, null); if (vipEntitys != null && vipEntitys.Length > 0)//已经存在有UnionID的数据 { var wxUserInfo = wxUserInfoBLL.QueryByEntity(new WXUserInfoEntity() { CustomerID = loggingSessionInfo.ClientID, VipID = vipEntitys[0].VIPID, WeiXinUserID = OpenId, UnionID = userInfo.unionid }, null).FirstOrDefault(); if (wxUserInfo == null) { var wxuiEntity = new WXUserInfoEntity() { WXUserID = Guid.NewGuid(), VipID = vipEntitys[0].VIPID,//vipInfo.VIPID, WeiXin = vipInfo.WeiXin, WeiXinUserID = vipInfo.WeiXinUserId, UnionID = userInfo.unionid, CustomerID = vipInfo.ClientID, CreateBy = "auth", LastUpdateBy = "auth" }; wxUserInfoBLL.Create(wxuiEntity); } //删除冗余vip记录 vipInfo.LastUpdateBy = "auth-delete"; vipService.Delete(vipInfo); } else { //更新微信用户信息 vipInfo.VipName = userInfo.nickname; vipInfo.City = userInfo.city; vipInfo.Gender = Convert.ToInt32(userInfo.sex); vipInfo.HeadImgUrl = userInfo.headimgurl; vipInfo.UnionID = userInfo.unionid; server.Update(vipInfo); } } } } } return(vipInfo); } catch (Exception ex) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("GetUserIdByOpenId用户用户信息出错: {0}", ex.ToString()) }); //Response.Write("GetUserIdByOpenId用户用户信息出错:" + ex.ToString()); return(vipInfo); } }