public void ProcessRequest(HttpContext context) { string AutoId = context.Request["id"]; KeyVauleDataInfo KeyVauleDataModel = bllKeyValueData.GetByKey <KeyVauleDataInfo>("AutoId", AutoId); if (KeyVauleDataModel == null) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "模板没有找到"; bllKeyValueData.ContextResponse(context, resp); return; } List <KeyVauleDataInfo> oldFieldList = bllKeyValueData.GetKeyVauleDataInfoList(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), KeyVauleDataModel.DataKey , KeyVauleDataModel.WebsiteOwner); resp.isSuccess = true; resp.returnObj = new { id = KeyVauleDataModel.AutoId, data_key = KeyVauleDataModel.DataKey, data_value = KeyVauleDataModel.DataValue, child_list = (from p in oldFieldList select new { data_key = p.DataKey, data_value = p.DataValue }) }; bllKeyValueData.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { string ids = context.Request["ids"]; if (string.IsNullOrWhiteSpace(ids)) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "ids不能为空"; bllKeyValueData.ContextResponse(context, resp); return; } List <KeyVauleDataInfo> dataList = bllKeyValueData.GetListByKey <KeyVauleDataInfo>("AutoId", ids); try { foreach (var item in dataList) { bllKeyValueData.DeleteDataVaule(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), null, item.DataKey, item.WebsiteOwner); bllKeyValueData.DeleteDataVaule(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsg), item.DataKey, item.WebsiteOwner); } resp.errcode = (int)APIErrCode.IsSuccess; resp.isSuccess = true; } catch (Exception ex) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = ex.Message; } bllKeyValueData.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { apiResp.result = Comm.StaticData.zcWxEditorData; apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; bllKeyValueData.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int pageIndex = Convert.ToInt32(context.Request["page"]); int pageSize = Convert.ToInt32(context.Request["rows"]); int totalCount = 0; List <KeyVauleDataInfo> dataList = bllKeyValueData.GetKeyVauleDataInfoList(pageSize, pageIndex, EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsg), null, bllKeyValueData.WebsiteOwner, out totalCount); resp.isSuccess = true; resp.returnObj = new { totalcount = totalCount, list = (from p in dataList select new { id = p.AutoId, data_key = p.DataKey, data_value = p.DataValue }) }; bllKeyValueData.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { string scoreStr = context.Request["score"]; decimal score = Convert.ToDecimal(scoreStr); if (score == 0) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "积分不能为0"; bllKeyValueData.ContextResponse(context, apiResp); return; } if (CurrentUserInfo == null) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.UserIsNotLogin; apiResp.msg = "您还没有登录"; bllKeyValueData.ContextResponse(context, apiResp); return; } BllOrder bllOrder = new BllOrder(); BllPay bllPay = new BllPay(); PayConfig payConfig = bllPay.GetPayConfig(); string rechargeValue = bllKeyValueData.GetDataVaule("Recharge", "100", bllKeyValueData.WebsiteOwner); decimal rechargeFee = Convert.ToDecimal(rechargeValue); decimal totalFee = rechargeFee / 100 * score; string websiteOwner = bllKeyValueData.WebsiteOwner; OrderPay orderPay = new OrderPay(); orderPay.OrderId = bllOrder.GetGUID(TransacType.CommAdd); orderPay.InsertDate = DateTime.Now; orderPay.Status = 0; orderPay.Type = "1"; orderPay.Subject = "积分充值"; orderPay.Total_Fee = totalFee; orderPay.UserId = CurrentUserInfo.UserID; orderPay.WebsiteOwner = websiteOwner; orderPay.Ex1 = scoreStr; var non_str = Payment.WeiXin.CommonUtil.CreateNoncestr();//随机串 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("appid", payConfig.WXAppId); dic.Add("body", "订单" + orderPay.OrderId); dic.Add("mch_id", payConfig.WXMCH_ID);//商户号 dic.Add("nonce_str", non_str); dic.Add("out_trade_no", orderPay.OrderId); dic.Add("spbill_create_ip", context.Request.UserHostAddress); dic.Add("total_fee", (totalFee * 100).ToString("F0")); dic.Add("notify_url", string.Format("http://{0}/WxPayNotify/DoPayWxNotify.aspx", context.Request.Url.Authority)); dic.Add("trade_type", "NATIVE"); dic.Add("product_id", orderPay.OrderId); string strtemp = Payment.WeiXin.CommonUtil.FormatBizQueryParaMap(dic, false); string sign = Payment.WeiXin.MD5SignUtil.Sign(strtemp, payConfig.WXPartnerKey); dic = (from entry in dic orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); dic.Add("sign", sign); string postData = Payment.WeiXin.CommonUtil.ArrayToXml(dic); string url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(postData); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = requestBytes.Length; Stream requestStream = req.GetRequestStream(); requestStream.Write(requestBytes, 0, requestBytes.Length); requestStream.Close(); System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8); string backStr = sr.ReadToEnd(); sr.Close(); res.Close(); var result = System.Xml.Linq.XDocument.Parse(backStr); var return_code = result.Element("xml").Element("return_code").Value; if (!return_code.ToUpper().Equals("SUCCESS")) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "预支付失败"; apiResp.result = new { return_msg = result.Element("xml").Element("return_msg").Value, post_data = postData }; bllKeyValueData.ContextResponse(context, apiResp); return; } var rusult_code = result.Element("xml").Element("result_code").Value; if (return_code.ToUpper().Equals("SUCCESS") && (rusult_code.ToUpper().Equals("SUCCESS"))) { var prepay_id = result.Element("xml").Element("prepay_id").Value; var code_url = result.Element("xml").Element("code_url").Value; orderPay.Trade_No = prepay_id; bllOrder.Add(orderPay); apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "预支付完成"; apiResp.status = true; apiResp.result = new { orderId = orderPay.OrderId, prepay_id = prepay_id, code_url = code_url }; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.result = result.Element("xml").Element("err_code_des").Value; apiResp.msg = "预支付失败"; } bllKeyValueData.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int score = Convert.ToInt32(context.Request["score"]); string moduleName = "积分"; if (!string.IsNullOrWhiteSpace(context.Request["module_name"])) { moduleName = context.Request["module_name"]; } string websiteOwner = bllKeyValueData.WebsiteOwner; if (score <= 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = moduleName + "不能为0"; bllKeyValueData.ContextResponse(context, apiResp); return; } string rechargeValue = bllKeyValueData.GetDataVaule("Recharge", "100", websiteOwner); string minScore = bllKeyValueData.GetDataVaule("MinScore", "1", websiteOwner); string minWithdrawCashScore = bllKeyValueData.GetDataVaule("MinWithdrawCashScore", "1", websiteOwner); if (score < Convert.ToDecimal(minWithdrawCashScore)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "提现数额不能少于" + minWithdrawCashScore + moduleName; bllKeyValueData.ContextResponse(context, apiResp); return; } double curTotalScore = CurrentUserInfo.TotalScore; double sTotalScore = curTotalScore - score; double nScore = Convert.ToDouble(minScore) + score; if (sTotalScore < Convert.ToDouble(minScore)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = moduleName + "不足"; bllKeyValueData.ContextResponse(context, apiResp); return; } decimal rechargeFee = Convert.ToDecimal(rechargeValue); decimal money = rechargeFee / 100 * score; WithdrawCash model = new WithdrawCash(); model.Amount = money; model.UserId = CurrentUserInfo.UserID; model.TrueName = CurrentUserInfo.TrueName; model.WebSiteOwner = websiteOwner; model.WithdrawCashType = "ScoreOnLine"; model.TransfersType = 1; model.Status = 0; model.Score = score; model.RealAmount = money; model.ServerFee = 0; model.Phone = CurrentUserInfo.Phone; model.LastUpdateDate = DateTime.Now; model.InsertDate = DateTime.Now; model.IsPublic = 2; //积分明细 UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo(); scoreModel.AddNote = string.Format("申请提现消耗{0}{1}", score, moduleName); scoreModel.AddTime = DateTime.Now; scoreModel.Score = 0 - score; scoreModel.UserID = CurrentUserInfo.UserID; scoreModel.ScoreType = "WithdrawCash"; scoreModel.TotalScore = sTotalScore; scoreModel.WebSiteOwner = websiteOwner; //通知 BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice(); notice.Ncontent = scoreModel.AddNote; notice.UserId = CurrentUserInfo.UserID; notice.Receivers = CurrentUserInfo.UserID; notice.SendType = 2; notice.SerialNum = bllKeyValueData.GetGUID(TransacType.SendSystemNotice); notice.Title = "申请提现消耗淘股币"; notice.NoticeType = 1; notice.WebsiteOwner = websiteOwner; notice.InsertTime = DateTime.Now; BLLTransaction tran = new BLLTransaction(); if (bllUser.Update(CurrentUserInfo, string.Format("TotalScore=TotalScore-{0}", score), string.Format("AutoID={0} AND WebsiteOwner='{1}' AND TotalScore>{2}", CurrentUserInfo.AutoID, websiteOwner, nScore), tran) > 0 && bllUser.Add(scoreModel, tran) && bllUser.Add(notice, tran) && bllUser.Add(model, tran)) { tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "申请成功"; apiResp.status = true; } else { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "申请失败"; } bllKeyValueData.ContextResponse(context, apiResp); }