/// <summary> /// 增加下载记录 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string AddVersionDownLoadLog(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <AppVersionDownloadLogRP> >(); var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); if (rp.Parameters.Channel == 0 || string.IsNullOrEmpty(rp.CustomerID + rp.Parameters.Plat + rp.Parameters.Version + rp.Parameters.DownloadURL)) { throw new APIException("缺少请求参数。") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER } } ; var appVersionLogBLL = new APPVersionDownloadVIPLogBLL(loggingSessionInfo); var entity = new APPVersionDownloadVIPLogEntity { Channel = rp.Parameters.Channel, Plat = rp.Parameters.Plat, Version = rp.Parameters.Version, DownloadUrl = rp.Parameters.DownloadURL, CustomerId = rp.CustomerID, VipId = rp.Parameters.VipId }; try { appVersionLogBLL.AddAppVersionDownloadLog(entity); var result = new EmptyResponseData(); var rsp = new SuccessResponse <IAPIResponseData>(result); return(rsp.ToJSON()); } catch (APIException ex) { throw new APIException("添加过程中出错."); } }
protected override void AjaxRequest(HttpContext pContext) { //string content = ""; // string method = pContext.Request.QueryString["method"]; MarketNamedApplyBLL marketNameApplyBll = new MarketNamedApplyBLL(CurrentUserInfo); EmptyResponseData emptyRD = new EmptyResponseData(); MarketNamedApplyEntity[] marketNameApplyEntityArray = marketNameApplyBll.QueryByEntity(new MarketNamedApplyEntity() { Status = 20, CustomerId = CurrentUserInfo.CurrentUser.customer_id }, null); if (marketNameApplyEntityArray.Length > 0) { for (int i = 0; i < marketNameApplyEntityArray.Length; i++) { string url = this.GeneratedQR(marketNameApplyEntityArray[i].VipId, marketNameApplyEntityArray[0].MarketEventID); marketNameApplyEntityArray[i].QRCodeUrl = url; marketNameApplyBll.Update(marketNameApplyEntityArray[i]); } this.ExportExcel(pContext, CurrentUserInfo.CurrentUser.customer_id); } //pContext.Response.Write(content); }
public string SendWeixinMessage(string pRequest) { var rd = new EmptyResponseData(); var rp = pRequest.DeserializeJSONTo <APIRequest <SendWeixinMessageRP> >(); var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); var orderId = rp.Parameters.OrderId; var tInoutBll = new TInoutBLL(loggingSessionInfo); var tInoutEntity = tInoutBll.GetByID(orderId); if (tInoutEntity == null) { Loggers.Debug(new DebugLogInfo() { Message = orderId + "无效的订单ID;" }); return(rd.ToJSON()); } var vipBll = new VipBLL(loggingSessionInfo); var vipEntity = vipBll.GetByID(rp.UserID); if (vipEntity == null) { Loggers.Debug(new DebugLogInfo() { Message = rp.UserID + "无效的会员ID;" }); return(rd.ToJSON()); } var message = "亲爱的 " + vipEntity.VipName + "您好,感谢您选择花间堂!您的订单【" + tInoutEntity.OrderNo + "】已收到,正在玩命确认中。您可以进入个人中心页面随时关注订单状态,如有疑问请致电4000 767 123。"; string code = JIT.CPOS.BS.BLL.WX.CommonBLL.SendWeixinMessage(message, "1", loggingSessionInfo, vipEntity); Loggers.Debug(new DebugLogInfo() { Message = "消息推送完成,code=" + code + ", message=" + message }); switch (code) { case "103": Loggers.Debug(new DebugLogInfo() { Message = vipEntity.VipName + "未查询到匹配的公众账号信息;" }); break; case "203": Loggers.Debug(new DebugLogInfo() { Message = vipEntity.VipName + "发送失败;" }); break; default: break; } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
/// <summary> /// 保存客户端错误日志 /// </summary> /// add by donal 2014-9-26 14:50:33 /// <param name="pRequest"></param> /// <returns></returns> private string AddAppLog(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <AppLogRP> >(); if (string.IsNullOrWhiteSpace(rp.Parameters.Base64str) || string.IsNullOrWhiteSpace(rp.Parameters.Extensions) || string.IsNullOrWhiteSpace(rp.Parameters.ProjectName) || string.IsNullOrWhiteSpace(rp.Parameters.Platform) ) { throw new APIException("缺少请求参数。") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; } try { //根目录 string basePath = System.AppDomain.CurrentDomain.BaseDirectory + "logs\\AppLogs"; //文件路径 StringBuilder sbdPath = new StringBuilder(); sbdPath.Append(basePath); #region 根据参数获取地址 string[] PlatformList = new string[] { "ANDROID", "IOS" }; string[] ProjectNameList = new string[] { "ALD", "CUSTOMER", "SERVICE" }; if (PlatformList.Contains(rp.Parameters.Platform.ToUpper())) { sbdPath.Append("\\" + rp.Parameters.Platform.ToUpper()); } else { throw new APIException("平台参数不存在."); } if (ProjectNameList.Contains(rp.Parameters.ProjectName.ToUpper())) { sbdPath.Append("\\" + rp.Parameters.ProjectName.ToUpper()); } else { throw new APIException("项目名称参数不存在."); } string fileName = string.Format("{0}{1}{2}{3}{4}{5}{6}" , DateTime.Now.Year.ToString() , DateTime.Now.Month.ToString() , DateTime.Now.Day.ToString() , DateTime.Now.Hour.ToString() , DateTime.Now.Minute.ToString() , DateTime.Now.Second.ToString() , DateTime.Now.Millisecond.ToString()); sbdPath.Append(string.Format("\\{0}.{1}", fileName, rp.Parameters.Extensions)); #endregion //转base64的编码,获取流 MemoryStream stream = new MemoryStream(Convert.FromBase64String(rp.Parameters.Base64str)); byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); stream.Seek(0, SeekOrigin.Begin); // 把 byte[] 写入文件 FileStream fs = new FileStream(sbdPath.ToString(), FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); bw.Write(bytes); bw.Close(); fs.Close(); //记录上传的日志 string logpath = string.Format("{0}\\{1}\\{2}{3}{4}.txt", basePath, "UpLogs", DateTime.Today.Year.ToString(), DateTime.Today.Month.ToString(), DateTime.Today.Day.ToString()); using (StreamWriter sw = File.AppendText(logpath)) { string w = string.Format("{0} [Platform:{1}]-[ProjectName:{2}]-[FileName:{3}]-[Extensions:{4}]" , DateTime.Now.ToString(), rp.Parameters.Platform, rp.Parameters.ProjectName , rp.Parameters.FileName, rp.Parameters.Extensions); sw.WriteLine(w); sw.Close(); } var result = new EmptyResponseData(); var rsp = new SuccessResponse <IAPIResponseData>(result); return(rsp.ToJSON()); } catch (APIException ex) { throw new APIException("添加过程中出错."); } }
/// <summary> /// 设置商户自己的支付方式 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> public string SetPayChannel(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <SetPayChannel> >(); if (rp.Parameters.AddPayChannelData.Length == 0) { throw new APIException("请求参数中缺少AddPayChannelData或值为空.") { ErrorCode = 121 }; } var paymentTypeId = rp.Parameters.AddPayChannelData[0].PaymentTypeId; CheckCustomerMapping(paymentTypeId);//判断是否重复配置同类型支付信息 var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo); var customerId = loggingSessionInfo.ClientID; //获取该支付通道的信息 var tPaymeentTypeCusMapEntity = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity() { ChannelId = Convert.ToString(rp.Parameters.AddPayChannelData[0].ChannelId), CustomerId = customerId }, null); //if (tPaymeentTypeCusMapEntity != null && tPaymeentTypeCusMapEntity.Length > 0) //{ // var payDeloyType = tPaymeentTypeCusMapEntity[0].PayDeplyType; // //如果该支付通道之前为默认配置,将channelId设置为0,这样支付中心会生成一条新的数据 // if (payDeloyType == 0) // { // rp.Parameters.AddPayChannelData[0].ChannelId = 0; // } //} var tPaymentTypeCustomerMappingEntityList = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity() { PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId, CustomerId = customerId }, null); if (rp.Parameters.AddPayChannelData[0].PayType > 0) //非货到付款 { var paychannelUrl = ConfigurationManager.AppSettings["payChannelUrl"]; string reqs = "request" + pRequest; string str = "{\"ClientID\":\"" + loggingSessionInfo.ClientID + "\"," + "\"UserID\":\"" + loggingSessionInfo.UserID + "\"," + "\"Token\":null,\"AppID\":1," + "\"Parameters\":" + rp.Parameters.ToJSON() + "}"; var result = HttpWebClient.DoHttpRequest(paychannelUrl + "Gateway.ashx?action=SetPayChannel", "request=" + HttpUtility.UrlEncode(str)); string loggerStr = paychannelUrl + "Gateway.ashx?action=SetPayChannel&" + str; Loggers.Debug(new DebugLogInfo() { Message = loggerStr }); var channelList = result.DeserializeJSONTo <PayChannelReturnResult>(); if (channelList.Datas == null) { throw new APIException("创建失败:" + result) { ErrorCode = 122 }; } if (channelList.Datas.PayChannelIdList[0].ChannelId == 0) { throw new APIException("创建失败:" + result) { ErrorCode = 122 }; } else { if (tPaymentTypeCustomerMappingEntityList != null && tPaymentTypeCustomerMappingEntityList.Length > 0) { tPaymentTypeCustomerMappingBll.Delete(tPaymentTypeCustomerMappingEntityList); } var tPaymentTypeCustomerMappingEntity = new TPaymentTypeCustomerMappingEntity(); tPaymentTypeCustomerMappingEntity.MappingId = Guid.NewGuid(); tPaymentTypeCustomerMappingEntity.CustomerId = loggingSessionInfo.ClientID; tPaymentTypeCustomerMappingEntity.PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId; tPaymentTypeCustomerMappingEntity.APPId = "1"; tPaymentTypeCustomerMappingEntity.Currency = 1; tPaymentTypeCustomerMappingEntity.PayDeplyType = 1; tPaymentTypeCustomerMappingBll.Create(tPaymentTypeCustomerMappingEntity); var payTypeId = rp.Parameters.AddPayChannelData[0].PayType; var updateSql = ""; if (payTypeId == 1 || payTypeId == 2) { var unionPayData = rp.Parameters.AddPayChannelData[0].UnionPayData; var merchantId = unionPayData.MerchantID; var certificateFilePath = unionPayData.CertificateFilePath; var certificateFilePassword = unionPayData.CertificateFilePassword; var decryptCertificateFilePath = unionPayData.DecryptCertificateFilePath; var packetEncryptKey = unionPayData.PacketEncryptKey; updateSql = "PayAccountNumber = '" + merchantId + "'," + "EncryptionCertificate = '" + certificateFilePath + "'," + "EncryptionPwd ='" + certificateFilePassword + "'," + "DecryptionCertificate ='" + decryptCertificateFilePath + "'," + "DecryptionPwd ='" + packetEncryptKey + "'," + "PayDeplyType=1"; } if (payTypeId == 3 || payTypeId == 4) { var wapData = rp.Parameters.AddPayChannelData[0].WapData; var partner = wapData.Partner; var sellerAccountName = wapData.SellerAccountName; var RSA_PublicKey = wapData.RSA_PublicKey; var RSA_PrivateKey = wapData.RSA_PrivateKey; var MD5Key = wapData.MD5Key; var SCAN_AppID = wapData.SCAN_AppID; var PayEncryptedPwd = wapData.PayEncryptedPwd; updateSql = "PayAccountNumber ='" + partner + "'," + "PayAccounPublic='" + RSA_PublicKey + "'," + "PayPrivate='" + RSA_PrivateKey + "'," + "SalesTBAccess='" + sellerAccountName + "'," + "ApplyMD5Key='" + MD5Key + "'," + "EncryptionCertificate='" + SCAN_AppID + "'," + "PayEncryptedPwd='" + PayEncryptedPwd + "'," + "PayDeplyType=1"; } if (payTypeId == 5 || payTypeId == 6) { var wxData = rp.Parameters.AddPayChannelData[0].WxPayData; var appID = wxData.AppID; //var appSecret = wxData.AppSecret; //var parnterID = wxData.ParnterID; //var parnterKey = wxData.ParnterKey; //var PaySignKey = wxData.PaySignKey; var mch_id = wxData.Mch_ID; var signKey = wxData.SignKey; updateSql = "AccountIdentity='" + appID + "'," //+ "PublicKey='" + appSecret + "'," //+ "TenPayIdentity='" + parnterID + "'," //+ "TenPayKey='" + parnterKey + "'," //+ "PayEncryptedPwd='" + PaySignKey + "'," + "TenPayIdentity='" + mch_id + "'," + "TenPayKey='" + signKey + "'," + "PayDeplyType=1"; } tPaymentTypeCustomerMappingBll.UpdatePaymentMap(updateSql, channelList.Datas.PayChannelIdList[0].ChannelId + 1 , rp.Parameters.AddPayChannelData[0].PaymentTypeId, customerId); } } else //货到付款 { if (tPaymentTypeCustomerMappingEntityList != null && tPaymentTypeCustomerMappingEntityList.Length > 0) { tPaymentTypeCustomerMappingBll.Delete(tPaymentTypeCustomerMappingEntityList); } var tPaymentTypeCustomerMappingEntity = new TPaymentTypeCustomerMappingEntity(); tPaymentTypeCustomerMappingEntity.MappingId = Guid.NewGuid(); tPaymentTypeCustomerMappingEntity.CustomerId = loggingSessionInfo.ClientID; tPaymentTypeCustomerMappingEntity.PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId; tPaymentTypeCustomerMappingEntity.APPId = "1"; tPaymentTypeCustomerMappingEntity.Currency = 1; tPaymentTypeCustomerMappingEntity.PayDeplyType = 1; tPaymentTypeCustomerMappingBll.Create(tPaymentTypeCustomerMappingEntity); } var rd = new EmptyResponseData(); var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
/// <summary> /// 启用连锁掌柜默认的支付方式 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> public string SetDefaultPayChannel(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <SetPayChannel> >(); if (rp.Parameters.AddPayChannelData.Length == 0) { throw new APIException("请求参数中缺少AddPayChannelData或值为空.") { ErrorCode = 121 }; } var paymentTypeId = rp.Parameters.AddPayChannelData[0].PaymentTypeId; CheckCustomerMapping(paymentTypeId);//判断是否重复配置同类型支付信息 var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo); var customerId = loggingSessionInfo.ClientID; //获取要修改的支付方式 var tPaymentTypeCustomerMappingEntityList = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity() { PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId, CustomerId = customerId }, null); //从ap库里面获取该支付方式的channelID var channelId = tPaymentTypeCustomerMappingBll.GetChannelIdByPaymentTypeAndCustomer(paymentTypeId, customerId); if (channelId == "-1") { throw new APIException("未找到默认的支付通道.") { ErrorCode = 122 }; } else { //逻辑删除原有配置 if (tPaymentTypeCustomerMappingEntityList != null && tPaymentTypeCustomerMappingEntityList.Length > 0) { tPaymentTypeCustomerMappingBll.Delete(tPaymentTypeCustomerMappingEntityList); } //重新启用 var tPaymentTypeCustomerMappingEntity = new TPaymentTypeCustomerMappingEntity(); tPaymentTypeCustomerMappingEntity.MappingId = Guid.NewGuid(); tPaymentTypeCustomerMappingEntity.PaymentTypeID = paymentTypeId; tPaymentTypeCustomerMappingEntity.CustomerId = customerId; tPaymentTypeCustomerMappingEntity.ChannelId = channelId; tPaymentTypeCustomerMappingEntity.APPId = "1"; tPaymentTypeCustomerMappingEntity.Currency = 1; tPaymentTypeCustomerMappingEntity.PayDeplyType = 0; tPaymentTypeCustomerMappingBll.Create(tPaymentTypeCustomerMappingEntity); //设置默认的channelID数据,不需要设置 //string updateSql = " PayDeplyType=0 "; //tPaymentTypeCustomerMappingBll.UpdatePaymentMap(updateSql, Convert.ToInt32(channelId) // , paymentTypeId, customerId); } var rd = new EmptyResponseData(); var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
public HttpResponseMessage Password(string vipId, string password) { Loggers.Debug(new DebugLogInfo() { Message = $"[api/Vip/Password]接口,参数:\"vipId:{vipId}&&password:{password}\"" }); try { if (string.IsNullOrEmpty(password)) { throw new APIException("请求参数中缺少Password或值为空.") { ErrorCode = 121 }; } if (string.IsNullOrEmpty(password)) { throw new APIException("请求参数中缺少Password或值为空.") { ErrorCode = 121 }; } var rd = new EmptyResponseData(); string customerid = ConfigurationManager.AppSettings["CustomerId"].Trim(); var loggingSessionInfo = Default.GetLoggingSession(customerid, "1"); var vipbll = new VipBLL(loggingSessionInfo); var vipEntity = vipbll.GetByID(vipId); if (vipEntity == null) { throw new APIException("无效的会员ID【VipId】") { ErrorCode = 121 }; } var bll = new VipAmountBLL(loggingSessionInfo); var vipAmountEntity = bll.GetByID(vipId); if (vipAmountEntity == null) { throw new APIException("该会员暂无绑定账户") { ErrorCode = 121 }; } else { if (vipAmountEntity.PayPassword != password) { throw new APIException("密码不正确") { ErrorCode = 122 }; } } var responseModel = new BaseResponeModel { IsSucess = true }; return(Request.CreateResponse(HttpStatusCode.OK, responseModel)); } catch (Exception ex) { var responseModel = new BaseResponeModel { IsSucess = false, ErrorMessage = ex.Message }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, responseModel)); } }