public string CretaeWxCode() { var responseData = new ResponseData(); try { //微信 公共平台 var wapentity = new WApplicationInterfaceBLL(this.CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity { CustomerId = this.CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault(); //获取当前二维码 最大值 var MaxWQRCod = new WQRCodeManagerBLL(this.CurrentUserInfo).GetMaxWQRCod() + 1; if (wapentity == null || wapentity.ApplicationId == null) { responseData.success = false; responseData.msg = "无设置微信公众平台!"; return(responseData.ToJSON()); } string imageUrl = string.Empty; #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)) { responseData.success = false; responseData.msg = "二维码生成失败!"; } else { string host = ConfigurationManager.AppSettings["DownloadImageUrl"]; CPOS.Common.DownloadImage downloadServer = new DownloadImage(); imageUrl = downloadServer.DownloadFile(imageUrl, host); } #endregion responseData.success = true; responseData.msg = "二维码生成成功!"; var rp = new ReposeData() { imageUrl = imageUrl, MaxWQRCod = MaxWQRCod }; responseData.data = rp; return(responseData.ToJSON()); } catch (Exception ex) { throw new APIException(ex.Message); } }
public WxCode CretaeWxCode() { var responseData = new WxCode(); responseData.success = false; responseData.msg = "二维码生成失败!"; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; try { //微信 公共平台 var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity { CustomerId = loggingSessionInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault(); //获取当前二维码 最大值 var MaxWQRCod = new WQRCodeManagerBLL(loggingSessionInfo).GetMaxWQRCod() + 1; if (wapentity == null) { responseData.success = false; responseData.msg = "无设置微信公众平台!"; return(responseData); } string imageUrl = string.Empty; #region 生成二维码 JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL(); try { imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim() , wapentity.AppSecret.Trim() , "1", MaxWQRCod , loggingSessionInfo); } catch (Exception e) { responseData.success = false; responseData.msg = e.Message;// "二维码生成失败!"; return(responseData); } if (!string.IsNullOrEmpty(imageUrl)) { string host = ConfigurationManager.AppSettings["DownloadImageUrl"]; CPOS.Common.DownloadImage downloadServer = new DownloadImage(); imageUrl = downloadServer.DownloadFile(imageUrl, host); } #endregion responseData.success = true; responseData.msg = ""; responseData.ImageUrl = imageUrl; responseData.MaxWQRCod = MaxWQRCod; return(responseData); } catch (Exception ex) { //throw new APIException(ex.Message); return(responseData); } }
/// <summary> /// 获取门店二维码 /// </summary> /// <returns></returns> public string SetUnitWXCode() { #region 参数处理 string WeiXinId = Request("WeiXinId"); string UnitId = Request("UnitId"); string WXCode = Request("WXCode"); var responseData = new ResponseData(); if (WeiXinId == null || WeiXinId.Trim().Length == 0) { responseData.success = false; responseData.msg = "公众号不能为空"; return(responseData.ToJSON()); } //if (UnitId == null || UnitId.Trim().Length == 0) //{ // responseData.success = false; // responseData.msg = "门店标识不能为空"; // return responseData.ToJSON(); //} //if (WXCode == null || WXCode.Equals("")) //{ // VwUnitPropertyBLL unitServer = new VwUnitPropertyBLL(CurrentUserInfo); // WXCode = unitServer.GetUnitWXCode(UnitId).ToString(); //} #endregion #region 获取微信公众号信息 WApplicationInterfaceBLL server = new WApplicationInterfaceBLL(CurrentUserInfo); var wxObj = server.QueryByEntity(new WApplicationInterfaceEntity { CustomerId = CurrentUserInfo.CurrentUser.customer_id , IsDelete = 0 , ApplicationId = WeiXinId }, null); if (wxObj == null || wxObj.Length == 0) { responseData.success = false; responseData.msg = "不存在对应的微信帐号"; return(responseData.ToJSON().ToString()); } else { JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL(); string imageUrl = commonServer.GetQrcodeUrl(wxObj[0].AppID.ToString().Trim() , wxObj[0].AppSecret.Trim() , "1" , Convert.ToInt32(WXCode), CurrentUserInfo); if (imageUrl != null && !imageUrl.Equals("")) { string host = ConfigurationManager.AppSettings["DownloadImageUrl"]; try { CPOS.Common.DownloadImage downloadServer = new DownloadImage(); imageUrl = downloadServer.DownloadFile(imageUrl, host); responseData.success = true; responseData.msg = imageUrl; responseData.status = WXCode; } catch (Exception ex) { responseData.success = false; responseData.data = imageUrl; responseData.msg = ex.ToString(); return(responseData.ToJSON().ToString()); } return(responseData.ToJSON().ToString()); } else { responseData.success = false; responseData.msg = "图片不存在"; return(responseData.ToJSON().ToString()); } } #endregion }
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); }