/// <summary> /// 保存角色 /// </summary> public string SaveWQRCodeManagerData() { var wQRCodeManagerService = new WQRCodeManagerBLL(CurrentUserInfo); WQRCodeManagerEntity obj = new WQRCodeManagerEntity(); string content = string.Empty; string error = ""; var responseData = new ResponseData(); string key = string.Empty; string wQRCodeManager_id = string.Empty; if (Request("wQRCodeManager") != null && Request("wQRCodeManager") != string.Empty) { key = Request("wQRCodeManager").ToString().Trim(); } if (Request("wQRCodeManager_id") != null && Request("wQRCodeManager_id") != string.Empty) { wQRCodeManager_id = Request("wQRCodeManager_id").ToString().Trim(); } obj = key.DeserializeJSONTo <WQRCodeManagerEntity>(); //if (obj.TypeCode == null || obj.TypeCode.Trim().Length == 0) //{ // responseData.success = false; // responseData.msg = "编码不能为空"; // return responseData.ToJSON(); //} //if (obj.TypeName == null || obj.TypeName.Trim().Length == 0) //{ // responseData.success = false; // responseData.msg = "名称不能为空"; // return responseData.ToJSON(); //} if (wQRCodeManager_id.Trim().Length == 0 || wQRCodeManager_id == "null" || wQRCodeManager_id == "undefined") { obj.QRCodeId = Guid.NewGuid(); obj.CustomerId = CurrentUserInfo.CurrentUser.customer_id; wQRCodeManagerService.Create(obj); } else { obj.QRCodeId = Guid.Parse(wQRCodeManager_id); wQRCodeManagerService.Update(obj, false); } responseData.success = true; responseData.msg = error; content = responseData.ToJSON(); return(content); }
//生成员工二维码 public string CreateUserWxCode(UserInfo user, string unitName, LoggingSessionInfo loggingSessionInfo, out string errorMsg) { errorMsg = ""; #region 生成员工二维码 //微信 公共平台 //兼容模式 var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity { CustomerId = loggingSessionInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault();//取默认的第一个微信 var QRCodeId = Guid.NewGuid(); var QRCodeManagerentity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity { ObjectId = user.User_Id }, null).FirstOrDefault(); if (QRCodeManagerentity != null) { QRCodeId = (Guid)QRCodeManagerentity.QRCodeId; } if (QRCodeManagerentity == null) { //二维码类别 var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity( new WQRCodeTypeEntity { TypeCode = "UserQrCode" } , null).FirstOrDefault(); if (wqrentity == null) { //responseData.success = false; //responseData.msg = "无法获取员工二维码类别"; //return responseData.ToJSON(); errorMsg = "无法获取员工二维码类别"; } //生成了微信二维码 var wxCode = CretaeWxCode(loggingSessionInfo);//*** //如果名称不为空,就把图片放在一定的背景下面 if (!string.IsNullOrEmpty(user.User_Name) && wxCode.success == true) { try { string apiDomain = ConfigurationManager.AppSettings["original_url"]; wxCode.ImageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", wxCode.ImageUrl, unitName + "-" + user.User_Name); } catch { errorMsg = "生成二维码失败"; } } else { errorMsg = "生成二维码失败"; } var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);//兼容模式 // Guid QRCodeId = Guid.NewGuid(); if (!string.IsNullOrEmpty(wxCode.ImageUrl)) { WQRCodeManagerbll.Create(new WQRCodeManagerEntity { QRCodeId = QRCodeId, QRCode = wxCode.MaxWQRCod.ToString(), QRCodeTypeId = wqrentity.QRCodeTypeId, IsUse = 1, ObjectId = user.User_Id, CreateBy = loggingSessionInfo.UserID,//兼容模式 ApplicationId = wapentity.ApplicationId, IsDelete = 0, ImageUrl = wxCode.ImageUrl, CustomerId = loggingSessionInfo.ClientID }); } return(wxCode.ImageUrl);//生成新的二维码地址 } else { return(QRCodeManagerentity.ImageUrl); } #endregion }
/// <summary> /// 生成关注的二维码 /// </summary> /// <param name="para"></param> /// <param name="wapentity"></param> /// <param name="strQRCode"></param> /// <param name="QRCodeUrl"></param> public void CreateFocusQRCode(SetCTWEventRP para, string strLogoUrl, WApplicationInterfaceEntity wapentity, out string QRCodeUrl, out string QRCodeId, out bool IsSuccess) { QRCodeUrl = string.Empty; QRCodeId = string.Empty; var wqrCodeManagerEntity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity() { ObjectId = strCTWEventId }, null).FirstOrDefault(); //#region 生成二维码 var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity( new WQRCodeTypeEntity { TypeCode = "CreativeCode" } , null).FirstOrDefault(); var wxCode = CretaeWxCode(); IsSuccess = true; if (string.IsNullOrEmpty(wxCode.ImageUrl)) { IsSuccess = false; } QRCodeUrl = wxCode.ImageUrl; if (!string.IsNullOrEmpty(QRCodeUrl)) { if (!string.IsNullOrEmpty(strLogoUrl)) //如果有值则生成二维码中间带图 { string targetPath = HttpContext.Current.Server.MapPath("/QRCodeImage/"); ////二维码中奖加图片 string currentDomain = "http://" + HttpContext.Current.Request.Url.Host; //当前项目域名 string strFileNmae = QRCodeUrl.Substring(QRCodeUrl.LastIndexOf("/") + 1); string strQRCodeFilePath = targetPath + strFileNmae; string logoImage = "~" + strLogoUrl.Substring(currentDomain.Length); System.IO.MemoryStream MStream1 = new System.IO.MemoryStream(); Utils.CombinImage(QRCodeUrl, HttpContext.Current.Server.MapPath(logoImage)).Save(MStream1, System.Drawing.Imaging.ImageFormat.Png); Image ii = Image.FromStream(MStream1); ii.Save(strQRCodeFilePath, System.Drawing.Imaging.ImageFormat.Png); MStream1.Dispose(); QRCodeUrl = currentDomain + "/QRCodeImage/" + strFileNmae; } var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo); if (wqrCodeManagerEntity == null) { wqrCodeManagerEntity = new WQRCodeManagerEntity() { QRCodeId = Guid.NewGuid(), QRCode = wxCode.MaxWQRCod.ToString(), QRCodeTypeId = wqrentity.QRCodeTypeId, IsUse = 1, ObjectId = strCTWEventId, Remark = "CTW", CreateBy = loggingSessionInfo.UserID, ApplicationId = wapentity.ApplicationId, IsDelete = 0, ImageUrl = QRCodeUrl, CustomerId = loggingSessionInfo.ClientID }; WQRCodeManagerbll.Create(wqrCodeManagerEntity); } else { wqrCodeManagerEntity.ImageUrl = QRCodeUrl; WQRCodeManagerbll.Update(wqrCodeManagerEntity); } QRCodeId = wqrCodeManagerEntity.QRCodeId.ToString(); } }
public void CreateH5QRCode(SetCTWEventRP para, WApplicationInterfaceEntity wapentity, out string strQRCode, out string QRCodeUrl, out string RedirectUrl) { #region 图文,二维码 #region 生成图文素材 #region 获取Page信息 var pageBll = new SysPageBLL(loggingSessionInfo); var textBll = new WMaterialTextBLL(loggingSessionInfo); //组织图文实体 var entity = new WMaterialTextEntity() { ApplicationId = wapentity.ApplicationId, //用自己取出来的 CoverImageUrl = para.MaterialText.ImageUrl, //图片地址 PageId = Guid.NewGuid(), //页面模块的标识 PageParamJson = para.MaterialText.PageParamJson, //这个比较重要 Text = para.MaterialText.Text, TextId = "", //为空时在后面保存时生成 Title = para.MaterialText.Title, TypeId = para.MaterialText.TypeId }; #endregion #region 生成URL var Domain = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", ""); var Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", ""); string URL = string.Empty; bool IsAuth = false; URL = ConfigurationManager.AppSettings["LinKinUrl"] + "id=" + para.EventThemeInfo.WorksId; entity.IsAuth = Convert.ToInt32(IsAuth); entity.PageParamJson = para.MaterialText.PageParamJson; #endregion #endregion entity.OriginalUrl = URL;//图文素材要跳转到的页面 RedirectUrl = URL; #endregion #region 保存 var unionMappingBll = new WModelTextMappingBLL(loggingSessionInfo); entity.TextId = Guid.NewGuid().ToString("N"); textBll.Create(entity);//创建图文素材 #endregion string strQRCodeObjectId = Guid.NewGuid().ToString(); //活动的二维码自己查找QRCodeId var wqrCodeManagerEntity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity() { ObjectId = strQRCodeObjectId }, null).FirstOrDefault(); Guid QRCodeId; if (wqrCodeManagerEntity == null) { #region 生成二维码 var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity( new WQRCodeTypeEntity { TypeCode = "CreativeCode" } , null).FirstOrDefault(); var wxCode = CretaeWxCode(); var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo); QRCodeId = Guid.NewGuid(); if (!string.IsNullOrEmpty(wxCode.ImageUrl)) { wqrCodeManagerEntity = new WQRCodeManagerEntity() { QRCodeId = QRCodeId, QRCode = wxCode.MaxWQRCod.ToString(), QRCodeTypeId = wqrentity.QRCodeTypeId, IsUse = 1, ObjectId = strQRCodeObjectId, CreateBy = loggingSessionInfo.UserID, ApplicationId = wapentity.ApplicationId, IsDelete = 0, ImageUrl = wxCode.ImageUrl, CustomerId = loggingSessionInfo.ClientID }; WQRCodeManagerbll.Create(wqrCodeManagerEntity); } else { throw new APIException(wxCode.msg) { ErrorCode = 342 }; } #endregion //throw new APIException("活动没有生成二维码!") { ErrorCode = 342 }; } QRCodeId = (Guid)wqrCodeManagerEntity.QRCodeId;//活动二维码的标识 ////根据二维码标识查找是否有他的关键字回复 var WKeywordReplyentity = new WKeywordReplyBLL(loggingSessionInfo).QueryByEntity(new WKeywordReplyEntity() { Keyword = QRCodeId.ToString() //二维码的标识 }, null).FirstOrDefault(); var ReplyBLL = new WKeywordReplyBLL(loggingSessionInfo); var ReplyId = Guid.NewGuid().ToString();//创建临时 if (WKeywordReplyentity == null) { ReplyBLL.Create(new WKeywordReplyEntity() { ReplyId = ReplyId, Keyword = QRCodeId.ToString(), ReplyType = 3, //用图文素材 KeywordType = 4, //标识 IsDelete = 0, CreateBy = loggingSessionInfo.UserID, ApplicationId = wapentity.ApplicationId, }); } else { ReplyId = WKeywordReplyentity.ReplyId; //用取出来的数据查看 WKeywordReplyentity.Text = ""; WKeywordReplyentity.ReplyType = 3; //图文素材 ReplyBLL.Update(WKeywordReplyentity); } #region 添加图文消息 WMenuMTextMappingBLL MenuMTextMappingServer = new WMenuMTextMappingBLL(loggingSessionInfo); WMenuMTextMappingEntity MappingEntity = new WMenuMTextMappingEntity(); MappingEntity.MenuId = ReplyId; MappingEntity.TextId = entity.TextId; // 用图文素材标识****** MappingEntity.DisplayIndex = 1; //排列顺序 MappingEntity.CustomerId = loggingSessionInfo.ClientID; MappingEntity.MappingId = Guid.NewGuid(); MenuMTextMappingServer.Create(MappingEntity); strQRCode = QRCodeId.ToString(); QRCodeUrl = wqrCodeManagerEntity.ImageUrl; #endregion }
protected override DownloadQRCodeRD ProcessRequest(DTO.Base.APIRequest <DownloadQRCodeRP> pRequest) { string content = string.Empty; string customerId = string.Empty; var RD = new DownloadQRCodeRD(); try { #region 解析传入参数 //解析请求字符串 var RP = pRequest.Parameters; //判断客户ID是否传递 customerId = CurrentUserInfo.CurrentUser.customer_id; #endregion var imageUrl = string.Empty; Random ro = new Random(); var iUp = 100000000; var iDown = 50000000; if (string.IsNullOrEmpty(RP.VipDCode.ToString()) || RP.VipDCode == 0) { throw new APIException("VipDCode参数不能为空"); } var rpVipDCode = 0; //临时二维码 var iResult = ro.Next(iDown, iUp); //随机数 if (RP.VipDCode == 9) //永久二维码 { var userQRCodeBll = new WQRCodeManagerBLL(CurrentUserInfo); var marketEventBll = new MarketEventBLL(CurrentUserInfo); var marketEventEntity = marketEventBll.QueryByEntity(new MarketEventEntity() { EventCode = "CA00002433", CustomerId = CurrentUserInfo.ClientID }, null).FirstOrDefault(); var userQRCode = userQRCodeBll.QueryByEntity(new WQRCodeManagerEntity() { ObjectId = marketEventEntity.MarketEventID, CustomerId = CurrentUserInfo.ClientID }, null); // if (userQRCode != null && userQRCode.Length > 0) { RD.imageUrl = userQRCode[0].ImageUrl; return(RD); } //获取当前二维码 最大值 iResult = new WQRCodeManagerBLL(CurrentUserInfo).GetMaxWQRCod() + 1; rpVipDCode = 1; //永久 #region 获取微信帐号 //门店关联的公众号 var tueBll = new TUnitExpandBLL(CurrentUserInfo); var tueEntity = new TUnitExpandEntity(); if (!string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId)) { tueEntity = tueBll.QueryByEntity(new TUnitExpandEntity() { UnitId = CurrentUserInfo.CurrentUserRole.UnitId }, null).FirstOrDefault(); } var server = new WApplicationInterfaceBLL(CurrentUserInfo); var wxObj = new WApplicationInterfaceEntity(); if (tueEntity != null && !string.IsNullOrEmpty(tueEntity.Field1)) { wxObj = server.QueryByEntity(new WApplicationInterfaceEntity { AppID = tueEntity.Field1, CustomerId = customerId }, null).FirstOrDefault(); } else { wxObj = server.QueryByEntity(new WApplicationInterfaceEntity { CustomerId = customerId }, null).FirstOrDefault(); } if (wxObj == null) { throw new APIException("没有对应公众号"); } else { var commonServer = new CommonBLL(); imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID , wxObj.AppSecret , rpVipDCode.ToString("") //二维码类型 0: 临时二维码 1:永久二维码 , iResult, CurrentUserInfo); //iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000 if (imageUrl != null && !imageUrl.Equals("")) { CPOS.Common.DownloadImage downloadServer = new DownloadImage(); string downloadImageUrl = ConfigurationManager.AppSettings["website_WWW"]; imageUrl = downloadServer.DownloadFile(imageUrl, downloadImageUrl); //如果名称不为空,就把图片放在一定的背景下面 //if (!string.IsNullOrEmpty(RP.Parameters.RetailTraderName)) //{ // string apiDomain = ConfigurationManager.AppSettings["website_url"]; // imageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", imageUrl, RP.Parameters.RetailTraderName + "合作二维码"); //} } } #endregion if (!string.IsNullOrEmpty(imageUrl)) //永久二维码 { #region 创建店员永久二维码匹配表 var userQrTypeBll = new WQRCodeTypeBLL(CurrentUserInfo); var userQrType = userQrTypeBll.QueryByEntity(new WQRCodeTypeEntity() { TypeName = "签到" }, null); //"UserQrCode" if (userQrType != null && userQrType.Length > 0) { var userQrCodeBll = new WQRCodeManagerBLL(CurrentUserInfo); var userQrCode = new WQRCodeManagerEntity(); userQrCode.QRCode = iResult.ToString();//记录传过去的二维码场景值 userQrCode.QRCodeTypeId = userQrType[0].QRCodeTypeId; userQrCode.IsUse = 1; userQrCode.CustomerId = CurrentUserInfo.CurrentUser.customer_id; userQrCode.ImageUrl = imageUrl; userQrCode.ApplicationId = wxObj.ApplicationId; //objectId 为店员ID userQrCode.ObjectId = marketEventEntity.MarketEventID; userQrCodeBll.Create(userQrCode); } #endregion } } RD.imageUrl = imageUrl; } catch { throw new APIException("生成二维码错误"); } return(RD); }
protected override GetVipDealerSpreadCodeRD ProcessRequest(DTO.Base.APIRequest <GetVipDealerSpreadCodeRP> pRequest) { var rd = new GetVipDealerSpreadCodeRD(); var VipBLL = new VipBLL(CurrentUserInfo); var WQRCodeManagerBLL = new WQRCodeManagerBLL(this.CurrentUserInfo); var WQRCodeTypeBLL = new WQRCodeTypeBLL(this.CurrentUserInfo); try { var UserID = pRequest.UserID; // string imageUrl = string.Empty; string QRCodeId = string.Empty; string VipName = string.Empty; string HeadImgUrl = string.Empty; //分享处理 if (!string.IsNullOrWhiteSpace(pRequest.Parameters.ShareUserId)) { UserID = pRequest.Parameters.ShareUserId; } //微信 公共平台 var wapentity = new WApplicationInterfaceBLL(this.CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity { CustomerId = this.CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault(); var VipDealerType = WQRCodeTypeBLL.QueryByEntity(new WQRCodeTypeEntity() { TypeCode = "VipDealerCode" }, null).FirstOrDefault(); if (VipDealerType == null) { throw new APIException("静态二位经销商类型无此类型!"); } if (!string.IsNullOrWhiteSpace(pRequest.Parameters.QRCodeId)) { #region 分享出去的二维码 var WQRCodeManagerData = WQRCodeManagerBLL.GetByID(pRequest.Parameters.QRCodeId); if (WQRCodeManagerData == null) { throw new APIException("此二维码不存在!"); } var VipData = VipBLL.GetByID(WQRCodeManagerData.ObjectId); if (VipData == null) { throw new APIException("此二维码会员不存在!"); } //二维码图片地址,ID赋值,会员名称,头像地址赋值 imageUrl = WQRCodeManagerData.ImageUrl; QRCodeId = WQRCodeManagerData.QRCodeId.ToString(); VipName = VipData.VipName; HeadImgUrl = VipData.HeadImgUrl; #endregion } else { #region 获取去自己静态推广二维码 var WQRCodeManagerData = WQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity() { ObjectId = UserID, QRCodeTypeId = VipDealerType.QRCodeTypeId }, null).FirstOrDefault(); if (WQRCodeManagerData != null) { //二维码图片地址,ID赋值 imageUrl = WQRCodeManagerData.ImageUrl; QRCodeId = WQRCodeManagerData.QRCodeId.ToString(); } else { //获取当前二维码 最大值 var MaxWQRCod = new WQRCodeManagerBLL(this.CurrentUserInfo).GetMaxWQRCod() + 1; if (wapentity == null) { throw new APIException("无设置微信公众平台!"); } #region 生成二维码 JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL(); imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim() , wapentity.AppSecret.Trim() , "1", MaxWQRCod , this.CurrentUserInfo); if (string.IsNullOrEmpty(imageUrl)) { throw new APIException("二维码生成失败!"); } else { string host = ConfigurationManager.AppSettings["original_url"]; CPOS.Common.DownloadImage downloadServer = new DownloadImage(); //二维码赋值 imageUrl = downloadServer.DownloadFile(imageUrl, host); if (!string.IsNullOrEmpty(UserID)) { var WQRQrCode = new WQRCodeManagerEntity(); WQRQrCode.QRCodeId = Guid.NewGuid(); WQRQrCode.QRCode = MaxWQRCod.ToString(); WQRQrCode.QRCodeTypeId = VipDealerType.QRCodeTypeId; WQRQrCode.IsUse = 1; WQRQrCode.CustomerId = this.CurrentUserInfo.ClientID; WQRQrCode.ImageUrl = imageUrl; WQRQrCode.ApplicationId = wapentity.ApplicationId;//微信公众号的编号 //objectId 为会员ID WQRQrCode.ObjectId = UserID; WQRCodeManagerBLL.Create(WQRQrCode); //二维码ID赋值 QRCodeId = WQRQrCode.QRCodeId.ToString(); } } #endregion } //会员名称,头像地址 var VipData = VipBLL.GetByID(UserID); if (VipData == null) { throw new APIException("会员不存在!"); } VipName = VipData.VipName; HeadImgUrl = VipData.HeadImgUrl; #endregion } //响应参数赋值 rd.imageUrl = imageUrl; rd.VipName = VipName; rd.HeadImgUrl = HeadImgUrl; rd.QRCodeId = QRCodeId; } catch (Exception ex) { throw new APIException(ex.Message); } return(rd); }
const int ERROR_LOAD_WRONG = 302; //打开出错 protected override GetSetoffToolDetailRD ProcessRequest(APIRequest <GetSetoffToolDetailRP> pRequest) { string content = string.Empty; string customerId = string.Empty; GetSetoffToolDetailRD setoffToolDetailRD = new GetSetoffToolDetailRD(); var para = pRequest.Parameters; customerId = CurrentUserInfo.CurrentUser.customer_id; try { var imageUrl = string.Empty; Random ro = new Random(); var iUp = 100000000; var iDown = 50000000; var rpVipDCode = 0; //临时二维码 var iResult = ro.Next(iDown, iUp); //随机数 var userQrCodeBll = new WQRCodeManagerBLL(CurrentUserInfo); var imgBll = new ObjectImagesBLL(CurrentUserInfo); var setOffPosterBLL = new SetoffPosterBLL(CurrentUserInfo); var SetoffToolUserViewBLL = new SetoffToolUserViewBLL(CurrentUserInfo); var SetoffToolsBll = new SetoffToolsBLL(CurrentUserInfo); var SetOffPosterInfo = setOffPosterBLL.QueryByEntity(new SetoffPosterEntity() { SetoffPosterID = new Guid(para.ObjectId) }, null); //获取集客海报信息 var setoffEventBLL = new SetoffEventBLL(CurrentUserInfo); var setoffEventInfo = setoffEventBLL.QueryByEntity(new SetoffEventEntity() { Status = "10", SetoffType = 1, CustomerId = customerId }, null); //var SetoffToolsInfo = SetoffToolsBll.QueryByEntity(new SetoffToolsEntity() { ObjectId = para.ObjectId, Status = "10", ToolType = para.ToolType, SetoffEventID = setoffEventInfo[0].SetoffEventID }, null);//获取工具信息 //VipDcode=9生成永久二维码 if (para.VipDCode == 9) { //根据分享人ID和对象ID获取永久二维码信息 var userQrCode = userQrCodeBll.QueryByEntity(new WQRCodeManagerEntity() { ObjectId = para.ObjectId }, null); if (userQrCode != null && userQrCode.Length > 0) { if (para.ToolType == "Coupon")//如果类型为优惠券则返回二维码 { setoffToolDetailRD.ToolType = para.ToolType; } if (para.ToolType == "SetoffPoster")//如果为集客海报则返回背景图和二维码 { if (SetOffPosterInfo != null) { var backImgInfo = imgBll.QueryByEntity(new ObjectImagesEntity() { ObjectId = SetOffPosterInfo[0].ImageId }, null); setoffToolDetailRD.ToolType = para.ToolType; setoffToolDetailRD.imageUrl = userQrCode[0].ImageUrl; setoffToolDetailRD.paraTemp = userQrCode[0].QRCode; setoffToolDetailRD.backImgUrl = backImgInfo[0].ImageURL; } } setoffToolDetailRD.imageUrl = userQrCode[0].ImageUrl; setoffToolDetailRD.paraTemp = userQrCode[0].QRCode; return(setoffToolDetailRD); } //获取当前二维码 最大值 iResult = new WQRCodeManagerBLL(CurrentUserInfo).GetMaxWQRCod() + 1; rpVipDCode = 1; } #region 获取微信帐号 var server = new WApplicationInterfaceBLL(CurrentUserInfo); var wxObj = new WApplicationInterfaceEntity(); wxObj = server.QueryByEntity(new WApplicationInterfaceEntity { CustomerId = customerId }, null).FirstOrDefault(); if (wxObj == null) { throw new APIException("不存在对应的微信帐号.") { ErrorCode = ERROR_NULL_WXOBJ }; } else { var commonServer = new CommonBLL(); //rpVipDCode 二维码类型 0: 临时二维码 1:永久二维码 imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID, wxObj.AppSecret, rpVipDCode.ToString(""), iResult, CurrentUserInfo);//iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000 //供本地测试时使用 "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGN7zoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1dreENCS1htX0xxQk94SEJ6MktIAAIEUk88VwMECAcAAA=="; } #endregion if (para.VipDCode == 9 && !string.IsNullOrEmpty(imageUrl)) //永久二维码 { #region 创建店员永久二维码匹配表 var userQrTypeBll = new WQRCodeTypeBLL(CurrentUserInfo); string pTypeCode = string.Empty; if (para.ToolType.ToLower() == "coupon") { pTypeCode = "CouponQrCode"; } if (para.ToolType.ToLower() == "setoffposter") { pTypeCode = "SetoffPosterQrCode"; } if (para.ToolType.ToLower() == "superretail") { pTypeCode = "SuperRetailQrCode"; } var userQrType = userQrTypeBll.QueryByEntity(new WQRCodeTypeEntity() { TypeCode = pTypeCode }, null); //"SuperRetailQrCode=超级分销商二维码" if (userQrType != null && userQrType.Length > 0) { var userQrcodeBll = new WQRCodeManagerBLL(CurrentUserInfo); var userQrCode = new WQRCodeManagerEntity(); userQrCode.QRCode = iResult.ToString();//记录传过去的二维码场景值 userQrCode.QRCodeTypeId = userQrType[0].QRCodeTypeId; userQrCode.IsUse = 1; userQrCode.CustomerId = customerId; userQrCode.ImageUrl = imageUrl; userQrCode.ApplicationId = wxObj.ApplicationId; //objectId 为集客海报ID或者优惠券ID userQrCode.ObjectId = para.ObjectId; userQrcodeBll.Create(userQrCode); } #endregion } else { #region 创建临时匹配表 VipDCodeBLL vipDCodeServer = new VipDCodeBLL(CurrentUserInfo); VipDCodeEntity info = new VipDCodeEntity(); info.DCodeId = iResult.ToString();//记录传过去的二维码场景值****(保存到数据库时没加空格) info.CustomerId = customerId; VipBLL vipBll = new VipBLL(CurrentUserInfo); info.UnitId = ""; info.Status = "0"; info.IsReturn = 0; info.DCodeType = para.VipDCode; info.CreateBy = CurrentUserInfo.UserID; info.ImageUrl = imageUrl; info.VipId = ""; info.ObjectId = para.ObjectId; //工具对象ID(优惠券或集客海报对象ID) info.OwnerUserId = para.ShareVipId; //分享人ID vipDCodeServer.Create(info); #endregion } int flag = 0;//定义是否需要新增打开数据,0=不需要新增,1=需要新增 var UserViewData = SetoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity() { ObjectId = para.ObjectId, UserID = CurrentUserInfo.UserID }, null); if (!string.IsNullOrEmpty(para.SetoffToolID)) { UserViewData = SetoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity() { ObjectId = para.ObjectId, UserID = CurrentUserInfo.UserID, SetoffToolID = new Guid(para.SetoffToolID) }, null); } if (UserViewData.Length == 0 && !string.IsNullOrEmpty(para.SetoffToolID) && para.PlatformType != "3") { flag = 1; //当为1时进行增加打开工具记录 } if (para.ToolType == "Coupon") //如果类型为优惠券则返回二维码 { #region 用户领优惠券过程 var CouponTypeBLL = new CouponTypeBLL(CurrentUserInfo); var couponBLL = new CouponBLL(CurrentUserInfo); var CouponSourceBLL = new CouponSourceBLL(CurrentUserInfo); var VipCouponMappingBLL = new VipCouponMappingBLL(CurrentUserInfo); int?SurplusCount = 0; //先获得剩余张数 int hasCouponCount = 0; //已领张数 如果>0表示已领取过就不让他领,=0就领取 var couponTypeInfo = CouponTypeBLL.QueryByEntity(new CouponTypeEntity() { CouponTypeID = new Guid(para.ObjectId) }, null); if (couponTypeInfo != null) { string couponIsVocher = string.Empty; if (couponTypeInfo[0].IsVoucher == null) { SurplusCount = couponTypeInfo[0].IssuedQty - 0; } else { SurplusCount = couponTypeInfo[0].IssuedQty - couponTypeInfo[0].IsVoucher; } if (SurplusCount != 0 && para.ShareVipId != null && para.ShareVipId != "")// 通过列表进详细自己不能领券 { //当剩余数量不为0时,进行下一步判断是否存在已领券的信息 hasCouponCount = VipCouponMappingBLL.GetReceiveCouponCount(CurrentUserInfo.UserID, para.ObjectId, "Share"); if (hasCouponCount == 0)//如果等于零,开始领券流程 { //关联优惠券让用户领券 var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); try { //执行领取操作 redisVipMappingCouponBLL.InsertDataBase(CurrentUserInfo.CurrentUser.customer_id, CurrentUserInfo.UserID, para.SetoffToolID, "Share", new CC_Coupon() { CustomerId = CurrentUserInfo.CurrentUser.customer_id, CouponTypeId = para.ObjectId }); setoffToolDetailRD.Name = couponTypeInfo[0].CouponTypeName + ",已飞入您的账户"; } catch (Exception ex) { setoffToolDetailRD.Name = "很遗憾此次优惠券" + couponTypeInfo[0].CouponTypeName + "的分享已失效,下次请及时领取."; } } } else { //如果剩余数量为0时,给出已领完提示 if (para.ShareVipId != null && para.ShareVipId != "") { setoffToolDetailRD.Name = "很遗憾您来迟一步优惠券" + couponTypeInfo[0].CouponTypeName + "已被领完."; //throw new APIException("很遗憾您来迟一步券已被领完.") { ErrorCode = ERROR_LOAD_WRONG }; } } if (setoffToolDetailRD.Name == null || setoffToolDetailRD.Name == "") { setoffToolDetailRD.Name = couponTypeInfo[0].CouponTypeName; } setoffToolDetailRD.StartTime = couponTypeInfo[0].BeginTime == null?Convert.ToDateTime(couponTypeInfo[0].CreateTime).ToString("yyyy-MM-dd") : Convert.ToDateTime(couponTypeInfo[0].BeginTime).ToString("yyyy-MM-dd"); setoffToolDetailRD.EndTime = couponTypeInfo[0].EndTime == null ? "" : Convert.ToDateTime(couponTypeInfo[0].EndTime).ToString("yyyy-MM-dd"); setoffToolDetailRD.ServiceLife = couponTypeInfo[0].ServiceLife.ToString(); } #endregion setoffToolDetailRD.ToolType = para.ToolType; //返回工具类别 setoffToolDetailRD.imageUrl = imageUrl; //返回临时二维码 setoffToolDetailRD.paraTemp = iResult.ToString().Insert(4, " "); //加空格,加空格有什么作用? } if (para.ToolType == "SetoffPoster") //如果为集客海报则返回背景图和二维码 { if (SetOffPosterInfo != null && SetOffPosterInfo.Length > 0) { var backImgInfo = imgBll.QueryByEntity(new ObjectImagesEntity() { ImageId = SetOffPosterInfo[0].ImageId }, null); setoffToolDetailRD.ToolType = para.ToolType; setoffToolDetailRD.imageUrl = imageUrl; setoffToolDetailRD.paraTemp = iResult.ToString().Insert(4, " "); //加空格,加空格有什么作用? setoffToolDetailRD.backImgUrl = backImgInfo[0].ImageURL; setoffToolDetailRD.Name = SetOffPosterInfo[0].Name; } } if (flag == 1)//当为1是需进行打开工具的记录 { var SetoffToolUserView = new SetoffToolUserViewEntity(); SetoffToolUserView.SetoffToolUserViewID = Guid.NewGuid(); SetoffToolUserView.SetoffEventID = setoffEventInfo[0].SetoffEventID; SetoffToolUserView.SetoffToolID = new Guid(para.SetoffToolID); SetoffToolUserView.ToolType = para.ToolType; SetoffToolUserView.ObjectId = para.ObjectId; SetoffToolUserView.NoticePlatformType = 1; SetoffToolUserView.UserID = CurrentUserInfo.UserID; SetoffToolUserView.IsOpen = 1; SetoffToolUserView.OpenTime = System.DateTime.Now; SetoffToolUserView.CustomerId = customerId; SetoffToolUserView.CreateTime = System.DateTime.Now; SetoffToolUserView.CreateBy = CurrentUserInfo.UserID; SetoffToolUserView.LastUpdateTime = System.DateTime.Now; SetoffToolUserView.LastUpdateBy = CurrentUserInfo.UserID; SetoffToolUserView.IsDelete = 0; SetoffToolUserViewBLL.Create(SetoffToolUserView); } } catch (Exception ex) { throw new APIException(ex.Message) { ErrorCode = ERROR_CODES.DEFAULT_ERROR }; } return(setoffToolDetailRD); }