提交 e1b7fb9e 编写于 作者: 王国树's avatar 王国树 😑

Initial commit

上级
流水线 #28313 已失败 ,包含阶段
in 1 minute 和 58 second
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "5.0.6",
"commands": [
"dotnet-ef"
]
}
}
}
\ No newline at end of file
文件已添加
{
"Version": 1,
"WorkspaceRootPath": "E:\\ASC\u5F00\u53D1\\WCP\\WCP\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}
\ No newline at end of file
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Libs;
using WCP.Models;
namespace WCP.Business
{
/// <summary>
/// 支付成功后的回调通知
/// </summary>
public class CallBackNotify
{
private readonly string _url;
private readonly string _param;
private readonly string _orderId;
private readonly string _httpMethod;
private readonly string _transactionId;
private readonly Dictionary<string, string> _headers;
private readonly string _formatStr;
public CallBackNotify(
Dictionary<string, string> headers,
string url,
string param,
string orderId,
string httpMethod,
string transactionId
)
{
this._url = url;
this._param = param;
this._headers = headers;
this._orderId = orderId;
this._httpMethod = httpMethod;
this._transactionId = transactionId;
_formatStr = string.Format(param, orderId, transactionId);
}
public string CallBack()
{
var data = new { orderId = _orderId };
string dataStr = JsonConvert.SerializeObject(data);
Console.WriteLine($"_这是url+formatStr_:{_url+_formatStr}");
Console.WriteLine($"_这是header_:{_headers}");
Console.WriteLine($"_这是data_:{dataStr}");
string result = "";
switch (_httpMethod)
{
case "GET":
result = HttpHelper.HttpGet(url: _url + _formatStr, headers: _headers);
break;
case "POST":
result = HttpHelper.HttpPost(url: _url + _formatStr, headers: _headers, postData: dataStr, contentType: "application/json", timeOut: 30);
break;
case "PUT":
result = HttpHelper.HttpPut(url: _url + _formatStr, headers: _headers, putData: dataStr, contentType: "application/json", timeOut: 30);
break;
}
return result;
}
}
}
using LitJson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using WCP.Libs;
namespace WCP.Business
{
public class JsApiPay
{
public JsApiPay()
{
}
public PayData unifiedOrderResult { get; set; }
/**
* 调用统一下单,获得下单结果
* @return 统一下单结果
* @失败时抛异常WxPayException
*/
public PayData GetUnifiedOrderResult(string openid, int total_fee, string body, string attach, string goods_tag)
{
//统一下单
PayData data = new PayData();
data.SetValue("body", body);
data.SetValue("attach", attach);
data.SetValue("out_trade_no", PayApi.GenerateOutTradeNo());
data.SetValue("total_fee", total_fee);
data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
data.SetValue("goods_tag", string.IsNullOrEmpty(goods_tag) ? "": goods_tag);
data.SetValue("trade_type", "JSAPI");
data.SetValue("openid", openid);
PayData result = PayApi.UnifiedOrder(data);
if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "")
{
//PayLog.Error(this.GetType().ToString(), "UnifiedOrder response error!");
throw new PayException("UnifiedOrder response error!");
}
unifiedOrderResult = result;
return result;
}
/**
*
* 从统一下单成功返回的数据中获取微信浏览器调起jsapi支付所需的参数,
* 微信浏览器调起JSAPI时的输入参数格式如下:
* {
* "appId" : "wx2421b1c4370ec43b", //公众号名称,由商户传入
* "timeStamp":" 1395712654", //时间戳,自1970年以来的秒数
* "nonceStr" : "e61463f8efa94090b1f366cccfbbb444", //随机串
* "package" : "prepay_id=u802345jgfjsdfgsdg888",
* "signType" : "MD5", //微信签名方式:
* "paySign" : "70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名
* }
* @return string 微信浏览器调起JSAPI时的输入参数,json格式可以直接做参数用
* 更详细的说明请参考网页端调起支付API:http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7
*
*/
public string GetJsApiParameters()
{
PayLog.Debug(this.GetType().ToString(), "JsApiPay::GetJsApiParam is processing...");
PayData jsApiParam = new PayData();
jsApiParam.SetValue("appId", unifiedOrderResult.GetValue("appid"));
jsApiParam.SetValue("timeStamp", PayApi.GenerateTimeStamp());
jsApiParam.SetValue("nonceStr", PayApi.GenerateNonceStr());
jsApiParam.SetValue("package", "prepay_id=" + unifiedOrderResult.GetValue("prepay_id"));
jsApiParam.SetValue("signType", "MD5");
jsApiParam.SetValue("paySign", jsApiParam.MakeSign());
string parameters = jsApiParam.ToJson();
PayLog.Debug(this.GetType().ToString(), "Get jsApiParam : " + parameters);
return parameters;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using WCP.Libs;
namespace WCP.Business
{
public class NativeNotify : PayNotify
{
public NativeNotify(Stream stream) : base(stream)
{
}
public override string ProcessNotify()
{
PayData notifyData = GetNotifyData(Stream);
//检查openid和product_id是否返回
if (!notifyData.IsSet("openid") || !notifyData.IsSet("product_id"))
{
PayData res = new PayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "回调数据异常");
PayLog.Info(this.GetType().ToString(), "The data WeChat post is error : " + res.ToXml());
return res.ToXml();
}
//调统一下单接口,获得下单结果
string openid = notifyData.GetValue("openid").ToString();
string product_id = notifyData.GetValue("product_id").ToString();
PayData unifiedOrderResult = new PayData();
try
{
unifiedOrderResult = UnifiedOrder(openid, product_id);
}
catch (Exception)//若在调统一下单接口时抛异常,立即返回结果给微信支付后台
{
PayData res = new PayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "统一下单失败");
PayLog.Error(this.GetType().ToString(), "UnifiedOrder failure : " + res.ToXml());
return res.ToXml();
}
//若下单失败,则立即返回结果给微信支付后台
if (!unifiedOrderResult.IsSet("appid") || !unifiedOrderResult.IsSet("mch_id") || !unifiedOrderResult.IsSet("prepay_id"))
{
PayData res = new PayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "统一下单失败");
PayLog.Error(this.GetType().ToString(), "UnifiedOrder failure : " + res.ToXml());
return res.ToXml();
}
//统一下单成功,则返回成功结果给微信支付后台
PayData data = new PayData();
data.SetValue("return_code", "SUCCESS");
data.SetValue("return_msg", "OK");
data.SetValue("appid", PayConfig.GetConfig().GetAppID());
data.SetValue("mch_id", PayConfig.GetConfig().GetMchID());
data.SetValue("nonce_str", PayApi.GenerateNonceStr());
data.SetValue("prepay_id", unifiedOrderResult.GetValue("prepay_id"));
data.SetValue("result_code", "SUCCESS");
data.SetValue("err_code_des", "OK");
data.SetValue("sign", data.MakeSign());
PayLog.Info(this.GetType().ToString(), "UnifiedOrder success , send data to WeChat : " + data.ToXml());
return data.ToXml();
}
private PayData UnifiedOrder(string openId, string productId)
{
//统一下单
PayData req = new PayData();
req.SetValue("body", "test");
req.SetValue("attach", "test");
req.SetValue("out_trade_no", PayApi.GenerateOutTradeNo());
req.SetValue("total_fee", 1);
req.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
req.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
req.SetValue("goods_tag", "test");
req.SetValue("trade_type", "NATIVE");
req.SetValue("openid", openId);
req.SetValue("product_id", productId);
PayData result = PayApi.UnifiedOrder(req);
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Libs;
namespace WCP.Business
{
public class NativePay
{
/**
* 生成扫描支付模式一URL
* @param productId 商品ID
* @return 模式一URL
*/
public string GetPrePayUrl(string productId)
{
PayLog.Info(this.GetType().ToString(), "Native pay mode 1 url is producing...");
PayData data = new PayData();
data.SetValue("appid", PayConfig.GetConfig().GetAppID());//公众帐号id
data.SetValue("mch_id", PayConfig.GetConfig().GetMchID());//商户号
data.SetValue("time_stamp", PayApi.GenerateTimeStamp());//时间戳
data.SetValue("nonce_str", PayApi.GenerateNonceStr());//随机字符串
data.SetValue("product_id", productId);//商品ID
data.SetValue("sign", data.MakeSign());//签名
string str = ToUrlParams(data.GetValues());//转换为URL串
string url = "weixin://wxpay/bizpayurl?" + str;
PayLog.Info(this.GetType().ToString(), "Get native pay mode 1 url : " + url);
return url;
}
/**
* 生成直接支付url,支付url有效期为2小时,模式二
* @param productId 商品ID
* @return 模式二URL
*/
public string GetPayUrl(string product_id, int total_fee, string body, string attach, string goods_tag)
{
PayLog.Info(this.GetType().ToString(), "Native pay mode 2 url is producing...");
PayData data = new PayData();
data.SetValue("body", body);//商品描述
data.SetValue("attach", attach);//附加数据
data.SetValue("out_trade_no", PayApi.GenerateOutTradeNo());//随机字符串
data.SetValue("total_fee", total_fee);//总金额
data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));//交易起始时间
data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));//交易结束时间
data.SetValue("goods_tag", string.IsNullOrEmpty(goods_tag) ? "" : goods_tag);//商品标记
data.SetValue("trade_type", "NATIVE");//交易类型
data.SetValue("product_id", product_id);//商品ID
PayData result = PayApi.UnifiedOrder(data);//调用统一下单接口
string url = result.GetValue("code_url").ToString();//获得统一下单接口返回的二维码链接
PayLog.Info(this.GetType().ToString(), "Get native pay mode 2 url : " + url);
return url;
//return "";
}
/**
* 参数数组转换为url格式
* @param map 参数名与参数值的映射表
* @return URL字符串
*/
private string ToUrlParams(SortedDictionary<string, object> map)
{
string buff = "";
foreach (KeyValuePair<string, object> pair in map)
{
buff += pair.Key + "=" + pair.Value + "&";
}
buff = buff.Trim('&');
return buff;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Libs;
namespace WCP.Business
{
public class OrderQuery
{
/***
* 订单查询完整业务流程逻辑
* @param transaction_id 微信订单号(优先使用)
* @param out_trade_no 商户订单号
* @return 订单查询结果(xml格式)
*/
public static string Run(string transaction_id, string out_trade_no)
{
PayLog.Info("OrderQuery", "OrderQuery is processing...");
PayData data = new PayData();
if (!string.IsNullOrEmpty(transaction_id))//如果微信订单号存在,则以微信订单号为准
{
data.SetValue("transaction_id", transaction_id);
}
else//微信订单号不存在,才根据商户订单号去查单
{
data.SetValue("out_trade_no", out_trade_no);
}
PayData result = PayApi.OrderQuery(data);//提交订单查询请求给API,接收返回数据
PayLog.Info("OrderQuery", "OrderQuery process complete, result : " + result.ToXml());
return result.ToJson();
}
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using WCP.Interfaces;
using WCP.Libs;
using WCP.Models;
namespace WCP.Business
{
/// <summary>
/// 支付结果通知回调处理类
/// 负责接收微信支付后台发送的支付结果并对订单有效性进行验证,将验证结果反馈给微信支付后台
/// </summary>
public class ResultNotify : PayNotify
{
public ResultNotify(Stream stream) : base(stream)
{
}
public override string ProcessNotify()
{
PayData notifyData = GetNotifyData(Stream);
//检查支付结果中transaction_id是否存在
if (!notifyData.IsSet("transaction_id"))
{
//若transaction_id不存在,则立即返回结果给微信支付后台
PayData res = new PayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "支付结果中微信订单号不存在");
PayLog.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
return res.ToJson();
}
string transaction_id = notifyData.GetValue("transaction_id").ToString();
//查询订单,判断订单真实性
if (!ResultNotifyExtensions.QueryOrder(transaction_id))
{
//若订单查询失败,则立即返回结果给微信支付后台
PayData res = new PayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "订单查询失败");
PayLog.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
return res.ToJson();
}
else
{
//查询订单成功
PayData res = new PayData();
res.SetValue("return_code", "SUCCESS");
res.SetValue("return_msg", "OK");
PayLog.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
string resStr = OrderQuery.Run(transaction_id: transaction_id, out_trade_no: "");
return resStr;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Libs;
namespace WCP.Business
{
public static class ResultNotifyExtensions
{
//查询订单
public static bool QueryOrder(string transaction_id)
{
PayData req = new PayData();
req.SetValue("transaction_id", transaction_id);
PayData res = PayApi.OrderQuery(req);
if (res.GetValue("return_code").ToString() == "SUCCESS" &&
res.GetValue("result_code").ToString() == "SUCCESS")
{
return true;
}
else
{
return false;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Trevor.Awesome;
namespace WCP.Controllers
{
[EnableCors("AllowCros")]
[Route("api/[controller]")]
[ApiController]
public class MessageController : ControllerBase
{
/// <summary>
/// 参数为空
/// </summary>
/// <returns></returns>
[HttpGet("ParamIsBlank")]
public ActionResult<BaseMessage> ParamIsBlank(string msg = null)
{
var response = new ResponseInstance<DBNull>(null, "10002", msg ?? null);
return Ok(response.CreateResponseInstance());
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WCP.Business;
using WCP.Interfaces;
using WCP.Libs;
using WCP.Models;
namespace WCP.Controllers
{
[EnableCors("AllowCros")]
[Route("api/[controller]")]
[ApiController]
public class SystemNotifyController : ControllerBase
{
private readonly IMapper _iMapper = null;
private readonly ISystemParamService _iSystemParamService = null;
private readonly ISystemNotifyService _iSystemNotifyService = null;
public SystemNotifyController(
IMapper mapper,
ISystemParamService systemParamService,
ISystemNotifyService systemNotifyService
)
{
this._iMapper = mapper;
this._iSystemParamService = systemParamService;
this._iSystemNotifyService = systemNotifyService;
}
/// <summary>
/// 测试返回xml
/// </summary>
/// <returns></returns>
[HttpGet("TestXML")]
public ActionResult TestXML()
{
PayData res = new PayData();
res = "1" == "SUCCESS" ? res.ResponseSuccess() : res.ResponseFailure();
return Ok(res.ToXml());
}
/// <summary>
/// 测试支付
/// </summary>
/// <returns></returns>
[HttpGet("TestCallBack")]
public ActionResult TestCallBack(string orderId)
{
var param = _iSystemParamService.GetSystemParamWithValue("k3sq8q5sbv2qe3r48o0pc7137t3jzg1e");
Dictionary<string, string> dict = new Dictionary<string, string>
{
{ "Authorization", "PayKey k3sq8q5sbv2qe3r48o0pc7137t3jzg1e" }
};
CallBackNotify callBackNotify = new CallBackNotify(
url: param.CallBack,
param: param.Param,
headers: dict,
orderId: orderId,
httpMethod: param.HttpMethod,
transactionId: "12"
);
return Ok(callBackNotify.CallBack());
}
/// <summary>
/// 微信返回通知结果
/// </summary>
/// <returns></returns>
[HttpPost("ResultNotifyPage")]
public async Task<ActionResult<string>> ResultNotifyPage()
{
// 读流
using (MemoryStream memoryStream = new MemoryStream())
{
#region 读取流文件
// 读取流文件
await Request.Body.CopyToAsync(memoryStream);
var myByteArray = memoryStream.ToArray();
string postStr = System.Text.Encoding.UTF8.GetString(myByteArray);
memoryStream.Position = 0;
#endregion
#region 结果通知并解析查询的订单
// 结果通知并解析查询的订单
ResultNotify resultNotify = new ResultNotify(memoryStream);
string notify = resultNotify.ProcessNotify();
Console.WriteLine(notify);
PayQueryEntity order = JsonConvert.DeserializeObject<PayQueryEntity>(notify);
#endregion
#region 创建记录
// 创建记录
TSystemNotify systemNotify = _iMapper.Map<PayQueryEntity, TSystemNotify>(order);
{
systemNotify.Stream = postStr;
systemNotify.XmlStr = notify;
}
_iSystemNotifyService.CreateSystemNotify(systemNotify);
#endregion
#region 支付成功结果回调
// 支付成功结果回调
PayAttach payAttach = JsonConvert.DeserializeObject<PayAttach>(systemNotify.Attach);
var param = _iSystemParamService.GetSystemParamWithValue(payAttach.Value);
Console.WriteLine($"_这是sysParam_:{JsonConvert.SerializeObject(param)}");
Dictionary<string, string> dict = new Dictionary<string, string>
{
{ "Authorization", param.Key + " " + param.Value }
};
CallBackNotify callBackNotify = new CallBackNotify(
url: param.CallBack,
param: param.Param,
headers: dict,
orderId: payAttach.OrderId,
httpMethod: param.HttpMethod,
transactionId: systemNotify.TransactionId
);
var result = callBackNotify.CallBack();
Console.WriteLine($"_这是回调结果_:{result}");
#endregion
#region 返回结果
// 返回结果
PayData res = new PayData();
res = systemNotify.ResultCode == "SUCCESS" ? res.ResponseSuccess() : res.ResponseFailure();
return Ok(res.ToXml());
#endregion
}
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Trevor.Awesome;
using WCP.Business;
using WCP.Filters;
using WCP.Interfaces;
using WCP.Libs;
using WCP.Models;
namespace WCP.Controllers
{
[EnableCors("AllowCros")]
[Route("api/[controller]")]
[ApiController]
public class SystemPayController : ControllerBase
{
private readonly IMapper _iMapper = null;
private readonly ISystemParamService _iSystemParamService = null;
public SystemPayController(
IMapper mapper,
ISystemParamService systemParamService)
{
this._iMapper = mapper;
this._iSystemParamService = systemParamService;
}
/// <summary>
/// 测试支付
/// </summary>
/// <returns></returns>
[HttpGet("TestPay")]
public ActionResult<BaseMessage> TestPay()
{
PayLog.Info(this.GetType().ToString(), "page load");
NativePay nativePay = new NativePay();
string qrcode = nativePay.GetPayUrl(product_id: "test_123456", total_fee: 1, body: "测试支付", attach: "测试附加", goods_tag: "测试标记");
List<string> datas = new List<string>();
datas.Add(qrcode);
var response = new ResponseInstance<string>(datas, "1", null);
return Ok(response.CreateResponseInstance());
}
/// <summary>
/// 创建支付
/// </summary>
/// <param name="productId"></param>
/// <param name="totalFee">分</param>
/// <param name="body">显示实体</param>
/// <param name="attach">订单id</param>
/// <param name="goodsTag">优惠券</param>
/// <returns></returns>
[HttpPost("CreateNativePay")]
[TypeFilter(typeof(AuthPayKeyAttribute))]
public ActionResult<BaseMessage> CreateNativePay(
[FromForm]string productId,
[FromForm]int totalFee,
[FromForm]string body,
[FromForm]string attach,
[FromForm]string goodsTag)
{
// 创建日志
PayLog.Info(this.GetType().ToString(), "page load");
// Attach重新赋值
PayAttach payAttach = new PayAttach();
{
payAttach.Key = Request.Headers["Authorization"].ToString().Split(" ")[0];
payAttach.Value = Request.Headers["Authorization"].ToString().Split(" ")[1];
payAttach.OrderId = attach;
}
attach = JsonConvert.SerializeObject(payAttach);
// 创建NATIVE支付
NativePay nativePay = new NativePay();
List<string> datas = new List<string>()
{
nativePay.GetPayUrl(product_id: productId, total_fee: totalFee, body: body, attach: attach, goods_tag: goodsTag)
};
var response = new ResponseInstance<string>(datas, "1", null);
return Ok(response.CreateResponseInstance());
}
/// <summary>
/// 创建JSAPI支付
/// </summary>
/// <param name="openid">用户个人openId</param>
/// <param name="totalFee">分</param>
/// <param name="body">显示实体</param>
/// <param name="attach">订单id</param>
/// <param name="goodsTag">优惠券</param>
/// <returns></returns>
[HttpPost("CreateJsApiPay")]
[TypeFilter(typeof(AuthPayKeyAttribute))]
public ActionResult<string> CreateJsApiPay(
[FromForm]string openid,
[FromForm]int totalFee,
[FromForm]string body,
[FromForm]string attach,
[FromForm]string goodsTag
)
{
// 创建日志
PayLog.Info(this.GetType().ToString(), "page load");
// Attach重新赋值
PayAttach payAttach = new PayAttach();
{
payAttach.Key = Request.Headers["Authorization"].ToString().Split(" ")[0];
payAttach.Value = Request.Headers["Authorization"].ToString().Split(" ")[1];
payAttach.OrderId = attach;
}
attach = JsonConvert.SerializeObject(payAttach);
// 发起统一下单并获取返回结果
JsApiPay jsApiPay = new JsApiPay();
jsApiPay.GetUnifiedOrderResult(openid: openid, total_fee: totalFee, body: body, attach: attach, goods_tag: goodsTag);
string wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数
PayLog.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
return wxJsApiParam;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace WCP.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Interfaces;
namespace WCP.Filters
{
public class AuthPayKeyAttribute : ActionFilterAttribute
{
private readonly ISystemParamService _iSystemParamService = null;
public AuthPayKeyAttribute(ISystemParamService systemParamService)
{
this._iSystemParamService = systemParamService;
}
/// <summary>
/// 在动作执行前
/// 如果Header头部携带的PayKey查询不到那就结束
/// </summary>
/// <param name="context"></param>
public override void OnActionExecuting(ActionExecutingContext context)
{
var auth = context.HttpContext.Request.Headers["Authorization"].ToString();
var key = auth.Split(" ")[0];
var value = auth.Split(" ")[1];
if ((!_iSystemParamService.KeyHasExisted(key))||
(!_iSystemParamService.ValueHasExisted(value)))
{
context.Result = new RedirectResult("~/api/message/paramisblank");
};
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Models;
namespace WCP.Interfaces
{
public interface ISystemNotifyService: IDisposable
{
TSystemNotify GetSystemNotify(string id);
List<TSystemNotify> GetSystemNotifies();
List<TSystemNotify> GetSystemNotifiesWithMchId(string MchId);
bool CreateSystemNotify(TSystemNotify systemNotify);
bool CreateSystemNotifies(List<TSystemNotify> systemNotifies);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Models;
namespace WCP.Interfaces
{
public interface ISystemParamService : IDisposable
{
TSystemParam GetSystemParam(string id);
List<TSystemParam> GetSystemParams();
TSystemParam GetSystemParamWithKey(string key);
TSystemParam GetSystemParamWithValue(string value);
bool KeyHasExisted(string key);
bool ValueHasExisted(string value);
}
}
using Microsoft.Extensions.Configuration;
namespace WCP.Libs
{
/// <summary>
/// 配置帮助者
/// </summary>
public class ConfigHelper
{
private static IConfigurationSection _appSection = null;
public static void SetSection(IConfigurationSection section)
{
_appSection = section;
}
public static T Get<T>(string key)
{
if (_appSection.GetSection(key) != null)
{
return _appSection.GetSection(key).Get<T>();
}
return default;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace WCP.Libs
{
public static class HttpHelper
{
/// <summary>
/// 发起POST同步请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="postData">post的数据</param>
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
/// <param name="timeOut"></param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static string HttpPost(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
{
Console.WriteLine(url);
Console.WriteLine(headers);
postData ??= "";
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
using (HttpContent httpContent = new StringContent(postData, Encoding.UTF8))
{
if (contentType != null)
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
HttpResponseMessage response = client.PostAsync(url, httpContent).Result;
return response.Content.ReadAsStringAsync().Result;
}
}
}
/// <summary>
/// 发起POST异步请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="postData">post的数据</param>
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
/// <param name="timeOut"></param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static async Task<string> HttpPostAsync(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
{
Console.WriteLine(url);
Console.WriteLine(headers);
postData ??= "";
using (HttpClient client = new HttpClient())
{
client.Timeout = new TimeSpan(0, 0, timeOut);
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
using (HttpContent httpContent = new StringContent(postData, Encoding.UTF8))
{
if (contentType != null)
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
HttpResponseMessage response = await client.PostAsync(url, httpContent);
return await response.Content.ReadAsStringAsync();
}
}
}
/// <summary>
/// 发起PUT同步请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="putData">post的数据</param>
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
/// <param name="timeOut"></param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static string HttpPut(string url, string putData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
{
Console.WriteLine(url);
Console.WriteLine(headers);
putData ??= "";
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
using (HttpContent httpContent = new StringContent(putData, Encoding.UTF8))
{
if (contentType != null)
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
HttpResponseMessage response = client.PutAsync(url, httpContent).Result;
return response.Content.ReadAsStringAsync().Result;
}
}
}
/// <summary>
/// 发起POST异步请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="putData">post的数据</param>
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
/// <param name="timeOut"></param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static async Task<string> HttpPutAsync(string url, string putData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
{
Console.WriteLine(url);
Console.WriteLine(headers);
putData ??= "";
using (HttpClient client = new HttpClient())
{
client.Timeout = new TimeSpan(0, 0, timeOut);
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
using (HttpContent httpContent = new StringContent(putData, Encoding.UTF8))
{
if (contentType != null)
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
HttpResponseMessage response = await client.PutAsync(url, httpContent);
return await response.Content.ReadAsStringAsync();
}
}
}
/// <summary>
/// 发起GET同步请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static string HttpGet(string url, Dictionary<string, string> headers = null)
{
Console.WriteLine(url);
Console.WriteLine(headers);
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
HttpResponseMessage response = client.GetAsync(url).Result;
return response.Content.ReadAsStringAsync().Result;
}
}
/// <summary>
/// 发起GET异步请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null)
{
Console.WriteLine(url);
Console.WriteLine(headers);
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
HttpResponseMessage response = await client.GetAsync(url);
return await response.Content.ReadAsStringAsync();
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace WCP.Libs
{
/// <summary>
/// http连接基础类,负责底层的http通信
/// </summary>
public class HttpService
{
private static string USER_AGENT = string.Format("WXPaySDK/{3} ({0}) .net/{1} {2}",
Environment.OSVersion, Environment.Version, PayConfig.GetConfig().GetMchID(), typeof(HttpService).Assembly.GetName().Version);
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
//直接确认,否则打不开
return true;
}
public static string Post(string xml, string url, bool isUseCert, int timeout)
{
System.GC.Collect();//垃圾回收,回收没有正常关闭的http连接
string result = "";//返回结果
HttpWebRequest request = null;
HttpWebResponse response = null;
Stream reqStream = null;
try
{
//设置最大连接数
ServicePointManager.DefaultConnectionLimit = 200;
//设置https验证方式
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(CheckValidationResult);
}
/***************************************************************
* 下面设置HttpWebRequest的相关属性
* ************************************************************/
request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = USER_AGENT;
request.Method = "POST";
request.Timeout = timeout * 1000;
//设置代理服务器
//WebProxy proxy = new WebProxy(); //定义一个网关对象
//proxy.Address = new Uri(WxPayConfig.PROXY_URL); //网关服务器端口:端口
//request.Proxy = proxy;
//设置POST的数据类型和长度
request.ContentType = "text/xml";
byte[] data = System.Text.Encoding.UTF8.GetBytes(xml);
request.ContentLength = data.Length;
//是否使用证书
if (isUseCert)
{
//.net core 还未找到解决发难
string path = "";
//string path = HttpContext.Current.Request.PhysicalApplicationPath;
X509Certificate2 cert = new X509Certificate2(path + PayConfig.GetConfig().GetSSlCertPath(), PayConfig.GetConfig().GetSSlCertPassword());
request.ClientCertificates.Add(cert);
PayLog.Debug("WxPayApi", "PostXml used cert");
}
//往服务器写入数据
reqStream = request.GetRequestStream();
reqStream.Write(data, 0, data.Length);
reqStream.Close();
//获取服务端返回
response = (HttpWebResponse)request.GetResponse();
//获取服务端返回数据
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
result = sr.ReadToEnd().Trim();
sr.Close();
}
catch (System.Threading.ThreadAbortException e)
{
PayLog.Error("HttpService", "Thread - caught ThreadAbortException - resetting.");
PayLog.Error("Exception message: {0}", e.Message);
System.Threading.Thread.ResetAbort();
}
catch (WebException e)
{
PayLog.Error("HttpService", e.ToString());
if (e.Status == WebExceptionStatus.ProtocolError)
{
PayLog.Error("HttpService", "StatusCode : " + ((HttpWebResponse)e.Response).StatusCode);
PayLog.Error("HttpService", "StatusDescription : " + ((HttpWebResponse)e.Response).StatusDescription);
}
throw new PayException(e.ToString());
}
catch (Exception e)
{
PayLog.Error("HttpService", e.ToString());
throw new PayException(e.ToString());
}
finally
{
//关闭连接和流
if (response != null)
{
response.Close();
}
if (request != null)
{
request.Abort();
}
}
return result;
}
/// <summary>
/// 处理http GET请求,返回数据
/// </summary>
/// <param name="url">请求的url地址</param>
/// <returns>http GET成功后返回的数据,失败抛WebException异常</returns>
public static string Get(string url)
{
System.GC.Collect();
string result = "";
HttpWebRequest request = null;
HttpWebResponse response = null;
//请求url以获取数据
try
{
//设置最大连接数
ServicePointManager.DefaultConnectionLimit = 200;
//设置https验证方式
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(CheckValidationResult);
}
/***************************************************************
* 下面设置HttpWebRequest的相关属性
* ************************************************************/
request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = USER_AGENT;
request.Method = "GET";
//获取服务器返回
response = (HttpWebResponse)request.GetResponse();
//获取HTTP返回数据
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
result = sr.ReadToEnd().Trim();
sr.Close();
}
catch (System.Threading.ThreadAbortException e)
{
PayLog.Error("HttpService", "Thread - caught ThreadAbortException - resetting.");
PayLog.Error("Exception message: {0}", e.Message);
System.Threading.Thread.ResetAbort();
}
catch (WebException e)
{
PayLog.Error("HttpService", e.ToString());
if (e.Status == WebExceptionStatus.ProtocolError)
{
PayLog.Error("HttpService", "StatusCode : " + ((HttpWebResponse)e.Response).StatusCode);
PayLog.Error("HttpService", "StatusDescription : " + ((HttpWebResponse)e.Response).StatusDescription);
}
throw new PayException(e.ToString());
}
catch (Exception e)
{
PayLog.Error("HttpService", e.ToString());
throw new PayException(e.ToString());
}
finally
{
//关闭连接和流
if (response != null)
{
response.Close();
}
if (request != null)
{
request.Abort();
}
}
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Libs
{
public interface IPayParamConfig
{
//=======【基本信息设置】=====================================
/* 微信公众号信息配置
* APPID:绑定支付的APPID(必须配置)
* MCHID:商户号(必须配置)
* KEY:商户支付密钥,参考开户邮件设置(必须配置),请妥善保管,避免密钥泄露
* APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置),请妥善保管,避免密钥泄露
*/
string GetAppID();
string GetMchID();
string GetKey();
string GetAppSecret();
//=======【证书路径设置】=====================================
/* 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要)
* 1.证书文件不能放在web服务器虚拟目录,应放在有访问权限控制的目录中,防止被他人下载;
* 2.建议将证书文件名改为复杂且不容易猜测的文件
* 3.商户服务器要做好病毒和木马防护工作,不被非法侵入者窃取证书文件。
*/
string GetSSlCertPath();
string GetSSlCertPassword();
//=======【支付结果通知url】=====================================
/* 支付结果通知回调url,用于商户接收支付结果
*/
string GetNotifyUrl();
//=======【商户系统后台机器IP】=====================================
/* 此参数可手动配置也可在程序中自动获取
*/
string GetIp();
//=======【代理服务器设置】===================================
/* 默认IP和端口号分别为0.0.0.0和0,此时不开启代理(如有需要才设置)
*/
string GetProxyUrl();
//=======【上报信息配置】===================================
/* 测速上报等级,0.关闭上报; 1.仅错误时上报; 2.全量上报
*/
int GetReportLevel();
//=======【日志级别】===================================
/* 日志等级,0.不输出日志;1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息
*/
int GetLogLevel();
}
}
此差异已折叠。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Libs
{
/**
* 配置账号信息
*/
public class PayConfig
{
private static volatile IPayParamConfig config;
private static object syncRoot = new object();
public static IPayParamConfig GetConfig()
{
if (config == null)
{
lock (syncRoot)
{
if (config == null)
config = new PayParamConfig();
}
}
return config;
}
}
}
此差异已折叠。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Libs
{
public static class PayDataExtension
{
public static PayData ResponseSuccess(this PayData payData)
{
payData.SetValue("return_code", "SUCCESS");
payData.SetValue("return_msg", "OK");
return payData;
}
public static PayData ResponseFailure(this PayData payData)
{
payData.SetValue("return_code", "FAILURE");
payData.SetValue("return_msg", "NO");
return payData;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Libs
{
public class PayException : Exception
{
public PayException(string msg) : base(msg)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Libs
{
public class PayLog
{
/**
* 向日志写入调试信息
* @param className 类名
* @param content 写入内容
*/
public static void Debug(string className, string content)
{
if (PayConfig.GetConfig().GetLogLevel() >= 3)
{
WriteLog("DEBUG", className, content);
}
}
/**
* 向日志写入运行时信息
* @param className 类名
* @param content 写入内容
*/
public static void Info(string className, string content)
{
if (PayConfig.GetConfig().GetLogLevel() >= 2)
{
WriteLog("INFO", className, content);
}
}
/**
* 向日志写入出错信息
* @param className 类名
* @param content 写入内容
*/
public static void Error(string className, string content)
{
if (PayConfig.GetConfig().GetLogLevel() >= 1)
{
WriteLog("ERROR", className, content);
}
}
/**
* 实际的写日志操作
* @param type 日志记录类型
* @param className 类名
* @param content 写入内容
*/
protected static void WriteLog(string type, string className, string content)
{
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");//获取当前系统时间
//日志内容
string write_content = time + " " + type + " " + className + ": " + content;
//需要用户自定义日志实现形式
Console.WriteLine(write_content);
}
}
}
using System.IO;
using System.Linq;
using System.Text;
namespace WCP.Libs
{
/// <summary>
/// 回调处理基类
/// 主要负责接收微信支付后台发送过来的数据,对数据进行签名验证
/// 子类在此类基础上进行派生并重写自己的回调处理过程
/// </summary>
public class PayNotify
{
public Stream Stream { get; set; }
public PayNotify(Stream stream)
{
this.Stream = stream;
}
string x;
/// <summary>
/// 接收从微信支付后台发送过来的数据并验证签名
/// </summary>
/// <returns>微信支付后台返回的数据</returns>
public PayData GetNotifyData(Stream stream)
{
//接收从微信后台POST过来的数据
int count = 0;
byte[] buffer = new byte[1024];
StringBuilder builder = new StringBuilder();
while ((count = Stream.Read(buffer, 0, 1024)) > 0)
{
builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
}
stream.Flush();
stream.Close();
stream.Dispose();
PayLog.Info(this.GetType().ToString(), "Receive data from WeChat : " + builder.ToString());
//转换数据格式并验证签名
PayData data = new PayData();
try
{
data.FromXml(builder.ToString());
}
catch (PayException ex)
{
//若签名错误,则立即返回结果给微信支付后台
PayData res = new PayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", ex.Message);
PayLog.Error(this.GetType().ToString(), "Sign check error : " + res.ToXml());
x = res.ToXml();
}
PayLog.Info(this.GetType().ToString(), "Check sign success");
return data;
}
//派生类需要重写这个方法,进行不同的回调处理
public virtual string ProcessNotify()
{
return "";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Models;
namespace WCP.Libs
{
public class PayParamConfig : IPayParamConfig
{
public PayParamConfig()
{
}
//=======【基本信息设置】=====================================
/* 微信公众号信息配置
* APPID:绑定支付的APPID(必须配置)
* MCHID:商户号(必须配置)
* KEY:商户支付密钥,参考开户邮件设置(必须配置),请妥善保管,避免密钥泄露
* APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置),请妥善保管,避免密钥泄露
*/
public string GetAppID()
{
return ConfigHelper.Get<PaySetting>("PaySettings").AppId;
}
public string GetMchID()
{
return ConfigHelper.Get<PaySetting>("PaySettings").MchId;
}
public string GetKey()
{
return ConfigHelper.Get<PaySetting>("PaySettings").Key;
}
public string GetAppSecret()
{
return ConfigHelper.Get<PaySetting>("PaySettings").AppSecret;
}
//public string GetAppID()
//{
// return "wx60a4e73ddf6c8a60";
//}
//public string GetMchID()
//{
// return "1533994581";
//}
//public string GetKey()
//{
// //return "sadjfkljdl243Y3ds2nwfWd343QCdsw1";
// return "dsfYsdnfM344hsdf2JU34208sereu894";
//}
//public string GetAppSecret()
//{
// return "8e3cc775c597cb0484e15670b54d8865";
//}
//public string GetAppID()
//{
// return "wx2893ab4287e8d018";
//}
//public string GetMchID()
//{
// return "1503477751";
//}
//public string GetKey()
//{
// //return "sadjfkljdl243Y3ds2nwfWd343QCdsw1";
// return "caoyiming11111caoyiming11111caoy";
//}
//public string GetAppSecret()
//{
// return "";
//}
//=======【证书路径设置】=====================================
/* 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要)
* 1.证书文件不能放在web服务器虚拟目录,应放在有访问权限控制的目录中,防止被他人下载;
* 2.建议将证书文件名改为复杂且不容易猜测的文件
* 3.商户服务器要做好病毒和木马防护工作,不被非法侵入者窃取证书文件。
*/
public string GetSSlCertPath()
{
return "";
}
public string GetSSlCertPassword()
{
return "";
}
//=======【支付结果通知url】=====================================
/* 支付结果通知回调url,用于商户接收支付结果
*/
public string GetNotifyUrl()
{
return ConfigHelper.Get<PaySetting>("PaySettings").NotifyUrl;
}
//=======【商户系统后台机器IP】=====================================
/* 此参数可手动配置也可在程序中自动获取
*/
public string GetIp()
{
return "0.0.0.0";
}
//=======【代理服务器设置】===================================
/* 默认IP和端口号分别为0.0.0.0和0,此时不开启代理(如有需要才设置)
*/
public string GetProxyUrl()
{
return "";
}
//=======【上报信息配置】===================================
/* 测速上报等级,0.关闭上报; 1.仅错误时上报; 2.全量上报
*/
public int GetReportLevel()
{
return 0;
}
//=======【日志级别】===================================
/* 日志等级,0.不输出日志;1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息
*/
public int GetLogLevel()
{
return 3;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Libs
{
public class PayQueryOrder
{
public static string Run(string transaction_id, string out_trade_no)
{
PayLog.Info("OrderQuery", "OrderQuery is processing...");
PayData data = new PayData();
if (!string.IsNullOrEmpty(transaction_id))//如果微信订单号存在,则以微信订单号为准
{
data.SetValue("transaction_id", transaction_id);
}
else//微信订单号不存在,才根据商户订单号去查单
{
data.SetValue("out_trade_no", out_trade_no);
}
PayData result = PayApi.OrderQuery(data);//提交订单查询请求给API,接收返回数据
PayLog.Info("OrderQuery", "OrderQuery process complete, result : " + result.ToXml());
return result.ToJson();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace WCP.Libs
{
public class RandomGenerator
{
readonly RNGCryptoServiceProvider csp;
public RandomGenerator()
{
csp = new RNGCryptoServiceProvider();
}
public int Next(int minValue, int maxExclusiveValue)
{
if (minValue >= maxExclusiveValue)
throw new ArgumentOutOfRangeException("minValue must be lower than maxExclusiveValue");
long diff = (long)maxExclusiveValue - minValue;
long upperBound = uint.MaxValue / diff * diff;
uint ui;
do
{
ui = GetRandomUInt();
} while (ui >= upperBound);
return (int)(minValue + (ui % diff));
}
public uint GetRandomUInt()
{
var randomBytes = GenerateRandomBytes(sizeof(uint));
return BitConverter.ToUInt32(randomBytes, 0);
}
private byte[] GenerateRandomBytes(int bytesNumber)
{
byte[] buffer = new byte[bytesNumber];
csp.GetBytes(buffer);
return buffer;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Trevor.Awesome
{
public class ResponseInstance<T>
{
private readonly bool _Logo;
private readonly string _Code;
private readonly string _Message;
private readonly string _Token;
private readonly int _Count;
private readonly List<T> _Result;
private BaseMessage _BaseMessage = new BaseMessage { };
/// <summary>
/// 应答实例构造
/// </summary>
/// <param name="result"></param>
/// <param name="code"></param>
/// <param name="message"></param>
/// <param name="token"></param>
/// <param name="count"></param>
/// <param name="logo"></param>
public ResponseInstance(List<T> result, string code, string message, bool logo = true, string token = null, int count = 0)
{
_Result = result ?? new List<T>();
_Code = string.IsNullOrEmpty(code) ? "0" : code;
_Message = message;
_Token = token;
_Logo = logo;
_Count = count;
}
public BaseMessage CreateResponseInstance()
{
_BaseMessage = _Logo ? ResponseMessageFactory.CreateResponseStatus(_Code) : ResponseMessageFactory.CreateResponseStatus("500");
_BaseMessage.Data = _Result ?? _BaseMessage.Data;
_BaseMessage.Token = _Token ?? null;
_BaseMessage.Count = _Count > 0 ? _Count : _Result.Count;
_BaseMessage.Message = _Message ?? _BaseMessage.Message;
return _BaseMessage;
}
}
}
此差异已折叠。
using System;
using System.Collections.Generic;
using System.Text;
namespace Trevor.Awesome
{
public class ResponseMessageFactory
{
public static BaseMessage CreateResponseStatus(string operationStr)
{
ResponseMessage resOperation = null;
switch (operationStr)
{
case "1":
resOperation = new Status1();
break;
case "10001":
resOperation = new Status10001();
break;
case "10002":
resOperation = new Status10002();
break;
case "10003":
resOperation = new Status10003();
break;
case "10004":
resOperation = new Status10004();
break;
case "20001":
resOperation = new Status20001();
break;
case "20002":
resOperation = new Status20002();
break;
case "20003":
resOperation = new Status20003();
break;
case "20004":
resOperation = new Status20004();
break;
case "40001":
resOperation = new Status40001();
break;
case "50001":
resOperation = new Status50001();
break;
case "50002":
resOperation = new Status50002();
break;
case "50003":
resOperation = new Status50003();
break;
case "60001":
resOperation = new Status60001();
break;
case "60002":
resOperation = new Status60002();
break;
case "60003":
resOperation = new Status60003();
break;
case "60004":
resOperation = new Status60004();
break;
case "60005":
resOperation = new Status60005();
break;
case "60006":
resOperation = new Status60006();
break;
case "70001":
resOperation = new Status70001();
break;
}
return resOperation.ReturnResponseMessage();
}
}
}
using System.Xml;
namespace WCP.Libs
{
public class SafeXmlDocument : XmlDocument
{
public SafeXmlDocument()
{
this.XmlResolver = null;
}
}
}
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Models;
namespace WCP.Mappers
{
public class CustomMapper : Profile
{
public CustomMapper()
{
CreateMap<TSystemParam, PayAttach>();
CreateMap<PayQueryEntity, TSystemNotify>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => Guid.NewGuid().ToString()))
.ForMember(dest => dest.TransactionId, opt => opt.MapFrom(src => src.Transaction_Id))
.ForMember(dest => dest.Attach, opt => opt.MapFrom(src => src.Attach))
.ForMember(dest => dest.BankType, opt => opt.MapFrom(src => src.Bank_Type))
.ForMember(dest => dest.MchId, opt => opt.MapFrom(src => src.Mch_Id))
.ForMember(dest => dest.OpenId, opt => opt.MapFrom(src => src.OpenId))
.ForMember(dest => dest.OutTradeNo, opt => opt.MapFrom(src => src.Out_Trade_No))
.ForMember(dest => dest.ResultCode, opt => opt.MapFrom(src => src.Result_Code))
.ForMember(dest => dest.Sign, opt => opt.MapFrom(src => src.Sign))
.ForMember(dest => dest.TimeEnd, opt => opt.MapFrom(src => src.Time_End))
.ForMember(dest => dest.TotalFee, opt => opt.MapFrom(src => src.Total_Fee));
}
}
}
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Models
{
public class CustomDBContext : WCPContext
{
public CustomDBContext()
{
}
public CustomDBContext(DbContextOptions<WCPContext> options) : base(options)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Models
{
public class JsApiReturnEntity
{
public string appid { get; set; }
public string mch_id { get; set; }
public string nonce_str { get; set; }
public string prepay_id { get; set; }
public string result_code { get; set; }
public string return_code { get; set; }
public string return_msg { get; set; }
public string sign { get; set; }
public string trade_type { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Models
{
public class PayAttach
{
public string Key { get; set; }
public string Value { get; set; }
public string OrderId { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Models
{
public class PayQueryEntity
{
public string AppId { get; set; }
public string Attach { get; set; }
public string Bank_Type { get; set; }
public string Cash_Fee { get; set; }
public string Cash_Fee_Type { get; set; }
public string Fee_Type { get; set; }
public string Is_Subscribe { get; set; }
public string Mch_Id { get; set; }
public string Nonce_Str { get; set; }
public string OpenId { get; set; }
public string Out_Trade_No { get; set; }
public string Result_Code { get; set; }
public string Return_Code { get; set; }
public string Return_Msg { get; set; }
public string Sign { get; set; }
public string Time_End { get; set; }
public string Total_Fee { get; set; }
public string Trade_State { get; set; }
public string Trade_State_Desc { get; set; }
public string Trade_Type { get; set; }
public string Transaction_Id { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml;
namespace WCP.Models
{
public partial class PayReturnXML
{
public string return_code { get; set; }
public string return_msg { get; set; }
}
public partial class PayXML
{
public PayReturnXML xml { get; set; }
}
public partial class PaySuccessXML : PayXML
{
public PaySuccessXML()
{
this.xml = new PayReturnXML();
this.xml.return_code = "<![CDATA[SUCCESS]]>";
this.xml.return_msg = "<![CDATA[OK]]>";
}
}
public partial class PayFailurXML : PayXML
{
public PayFailurXML()
{
this.xml = new PayReturnXML();
this.xml.return_code = "![CDATA[FAILURE]]";
this.xml.return_msg = "![CDATA[NO]]";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WCP.Models
{
public class PaySetting
{
public string Key { get; set; }
public string AppId { get; set; }
public string MchId { get; set; }
public string AppSecret { get; set; }
public string NotifyUrl { get; set; }
}
}
using System;
using System.Collections.Generic;
namespace WCP.Models
{
public partial class TSystemNotify
{
public string Id { get; set; }
public string Stream { get; set; }
public string TransactionId { get; set; }
public string Attach { get; set; }
public string BankType { get; set; }
public string MchId { get; set; }
public string OpenId { get; set; }
public string OutTradeNo { get; set; }
public string ResultCode { get; set; }
public string Sign { get; set; }
public string TimeEnd { get; set; }
public string TotalFee { get; set; }
public string XmlStr { get; set; }
}
}
using System;
using System.Collections.Generic;
namespace WCP.Models
{
public partial class TSystemParam
{
public string Id { get; set; }
public string Key { get; set; }
public string Value { get; set; }
public string Param { get; set; }
public string HttpMethod { get; set; }
public string CallBack { get; set; }
public string ContentType { get; set; }
public string RouteType { get; set; }
}
}
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using WCP.Libs;
namespace WCP.Models
{
public partial class WCPContext : DbContext
{
public WCPContext()
{
}
public WCPContext(DbContextOptions<WCPContext> options)
: base(options)
{
}
public virtual DbSet<TSystemNotify> TSystemNotify { get; set; }
public virtual DbSet<TSystemParam> TSystemParam { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlServer(ConfigHelper.Get<string>("WCP_DB_CONNECTION_STR"));
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<TSystemNotify>(entity =>
{
entity.ToTable("T_System_Notify");
entity.Property(e => e.Id).HasMaxLength(64);
});
modelBuilder.Entity<TSystemParam>(entity =>
{
entity.ToTable("T_System_Param");
entity.Property(e => e.Id).HasMaxLength(36);
entity.Property(e => e.CallBack)
.IsRequired()
.HasMaxLength(500);
entity.Property(e => e.ContentType).HasMaxLength(25);
entity.Property(e => e.HttpMethod)
.IsRequired()
.HasMaxLength(5);
entity.Property(e => e.Key)
.IsRequired()
.HasMaxLength(32);
entity.Property(e => e.Param)
.IsRequired()
.HasMaxLength(500);
entity.Property(e => e.RouteType).HasMaxLength(25);
entity.Property(e => e.Value)
.IsRequired()
.HasMaxLength(64);
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using WCP.Libs;
namespace WCP
{
public class Program
{
// 设置搭建是服务的地址
private static readonly string[] urls = ConfigHelper.Get<string[]>("ServerAddresses");
public static void Main(string[] args)
{
#region 加载配置文件
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true)
.Build();
// 设置配置节点
ConfigHelper.SetSection(config.GetSection("MySettings"));
#endregion
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls(urls);
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
此文件由 Web 项目的发布/打包过程使用。可以通过编辑此 MSBuild 文件
自定义此过程的行为。为了解与此相关的更多内容,请访问 https://go.microsoft.com/fwlink/?LinkID=208121。
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>5a219223-5637-42fc-acd2-1aa086823da4</ProjectGuid>
<publishUrl>E:\IIS部署\ASC_WEB\WCP</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<TargetFramework>netcoreapp3.1</TargetFramework>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
此文件由 Web 项目的发布/打包过程使用。可以通过编辑此 MSBuild 文件
自定义此过程的行为。为了解与此相关的更多内容,请访问 https://go.microsoft.com/fwlink/?LinkID=208121。
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<_PublishTargetUrl>E:\IIS部署\ASC_WEB\WCP</_PublishTargetUrl>
<History>True|2021-09-10T01:34:00.3529730Z;True|2021-05-18T11:25:06.4535614+08:00;True|2021-05-18T11:22:20.9110023+08:00;True|2021-05-18T10:50:33.3543643+08:00;True|2021-05-18T10:49:10.0189492+08:00;</History>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:64408",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WCP": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:6999",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Models;
namespace WCP.Services
{
public class ServiceBase
{
protected DbContext DbContext { get; set; }
protected IMapper Mapper { get; }
public ServiceBase(CustomDBContext DbContext, IMapper Mapper)
{
this.Mapper = Mapper;
this.DbContext = DbContext;
}
}
}
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Interfaces;
using WCP.Models;
namespace WCP.Services
{
public class SystemNotifyService : ServiceBase, ISystemNotifyService
{
public SystemNotifyService(CustomDBContext DbContext, IMapper Mapper) : base(DbContext, Mapper)
{
}
public void Dispose()
{
}
public bool CreateSystemNotify(TSystemNotify systemNotify)
{
DbContext.Set<TSystemNotify>().Add(systemNotify);
return DbContext.SaveChanges() > 0 ? true : false;
}
public bool CreateSystemNotifies(List<TSystemNotify> systemNotifies)
{
DbContext.Set<TSystemNotify>().AddRange(systemNotifies);
return DbContext.SaveChanges() > 0 ? true : false;
}
public List<TSystemNotify> GetSystemNotifies()
{
return DbContext.Set<TSystemNotify>().OrderByDescending(p => Convert.ToInt64(p.TimeEnd)).ToList();
}
public TSystemNotify GetSystemNotify(string id)
{
return DbContext.Set<TSystemNotify>().FirstOrDefault(p => p.Id == id);
}
public List<TSystemNotify> GetSystemNotifiesWithMchId(string MchId)
{
return DbContext.Set<TSystemNotify>().Where(p => p.MchId == MchId).ToList();
}
}
}
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WCP.Interfaces;
using WCP.Models;
namespace WCP.Services
{
public class SystemParamService : ServiceBase, ISystemParamService
{
public SystemParamService(CustomDBContext DbContext, IMapper Mapper) : base(DbContext, Mapper)
{
}
public void Dispose()
{
}
public TSystemParam GetSystemParam(string id)
{
return DbContext.Set<TSystemParam>().FirstOrDefault(p => p.Id == id);
}
public List<TSystemParam> GetSystemParams()
{
return DbContext.Set<TSystemParam>().ToList();
}
public List<TSystemParam> GetSystemParams(string id)
{
throw new NotImplementedException();
}
public TSystemParam GetSystemParamWithKey(string key)
{
return DbContext.Set<TSystemParam>().FirstOrDefault(p => p.Key == key);
}
public TSystemParam GetSystemParamWithValue(string value)
{
return DbContext.Set<TSystemParam>().FirstOrDefault(p => p.Value == value);
}
public bool KeyHasExisted(string key)
{
return DbContext.Set<TSystemParam>().Count(p => p.Key == key) == 1;
}
public bool ValueHasExisted(string value)
{
return DbContext.Set<TSystemParam>().Count(p => p.Value == value) == 1;
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using WCP.Interfaces;
using WCP.Libs;
using WCP.Mappers;
using WCP.Models;
using WCP.Services;
namespace WCP
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers(options =>
options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter())
);
// 设置Swagger说明文档
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "微信支付API",
Version = "v1"
});
// 为 Swagger JSON and UI设置xml文档注释路径
//获取应用程序所在目录(绝对,不受工作目录影响,建议采用此方法获取路径)
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
var xmlPath = AppDomain.CurrentDomain.BaseDirectory + "WCP.xml";
options.IncludeXmlComments(xmlPath);
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
{
Description = "Please enter into field the word \"Bearer\" followed by a space and the JWT value",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
});
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference()
{
Id = "Bearer",
Type = ReferenceType.SecurityScheme
}
},
Array.Empty<string>()
}
});
});
// 设置跨域
services.AddCors(options =>
{
options.AddPolicy("AllowCros", builder =>
{
builder
.AllowAnyOrigin()//允许任何来源的主机访问
.WithOrigins() ////允许指定主机访问
.AllowAnyMethod()//允许所有的HTTP方法
.AllowAnyHeader();//允许所有的请求头
});
});
services.AddDbContext<WCPContext>();
services.AddDbContext<CustomDBContext>();
services.AddAutoMapper(typeof(CustomMapper).Assembly);
services.AddTransient<ISystemNotifyService, SystemNotifyService>();
services.AddTransient<ISystemParamService, SystemParamService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint(ConfigHelper.Get<string>("DevelopmentSwaggerJsonAddress"), "教务系统API v1");
});
}
else
{
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint(ConfigHelper.Get<string>("DeploymentSwaggerJsonAddress"), "教务系统API v1");
});
}
app.UseStaticFiles();
app.UseSwagger();
app.UseRouting();
app.UseCors("AllowCros");
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>269cb4c8-8e7c-4f93-9cbf-c01576bfc991</UserSecretsId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1591</NoWarn>
<DocumentationFile>WCP.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Remove="Services\3fqcxeac.fyt~" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="LitJson" Version="0.16.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0-preview.3.20181.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-preview.3.20181.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.3.3" />
</ItemGroup>
<ItemGroup>
<None Update="WCP.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>WCP</ActiveDebugProfile>
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Controller</Controller_SelectedScaffolderCategoryPath>
<WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<WebStackScaffolding_LayoutPageFile />
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
<NameOfLastUsedPublishProfile>E:\ASC开发\WCP\WCP\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34616.47
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCP", "WCP.csproj", "{FA1182D7-07E4-4334-81CA-17725EC06329}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FA1182D7-07E4-4334-81CA-17725EC06329}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA1182D7-07E4-4334-81CA-17725EC06329}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA1182D7-07E4-4334-81CA-17725EC06329}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA1182D7-07E4-4334-81CA-17725EC06329}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C0A890C6-8FA9-480E-937A-3A94C9A6438C}
EndGlobalSection
EndGlobal
此差异已折叠。
using System;
namespace WCP
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"MySettings": {
// 微信支付设置
"PaySettings": {
"AppId": "wx3f0b21f695ff9c5e",
"MchId": "1589727951",
"Key": "Asc225sfgk61esesdvesdvkj21adc63h",
"AppSecret": "29d0ddf56132388fc09a9d1b77990a55",
//"AppId": "wx9feb9171985896dc",
//"MchId": "1536204071",
//"Key": "aic91469027MA5Rh5yf6H65860307AIC",
//"AppSecret": "c87ec4d6e5dd01b33d7f56626ec06a98",
"NotifyUrl": "http://asc.neaic.com/WCP/api/SystemNotify/ResultNotifyPage"
},
// WCP连接字符串
"WCP_DB_CONNECTION_STR": "Data Source=59.50.76.157,9000;Initial Catalog=WCP;User ID=sa;Password=ASC_2019!!!",
// 跨域ip地址限制
"AllowOrigin": [ "*" ],
// 系统名称
"SYSTEM_NAME": "WCP",
// swagger的json地址
"DevelopmentSwaggerJsonAddress": "/swagger/v1/swagger.json",
"DeploymentSwaggerJsonAddress": "/WCP/swagger/v1/swagger.json",
// 第一次登陆时token时间长度,用来获取真正的token
"FirstLoginTokenTime": 5,
// JWT服务器地址设置
"JWTServer": "http://10.168.1.103:5030",
"MaxSuportAPICount": 64, //单个模块支持API的最大数目为64*8个
"MaxSuportRoleCount": 8, //单个模块支持角色的最大数目为8*8个
"SecurityKey": "4ZGQtNDEzYy05Yzc5LTI4NWNhM", //token加密密钥
"ServerAddresses": [ "http://*:6999" ], //服务器地址可设置多个
//单点服务条状地址设置
"SingleSignOnAddress": ""
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或