该时间段订单量过大,请换个时间尝试重试
ctmb520 opened this issue · 3 comments
在客户端部分做好防止重复创建订单的工作
该系统的支付处理能力为5分钟10个,太多会影响收益
如果你需要提高处理能力,请手动修改 /protected/model/Order.php第489行中的
for ($i = 0; $i < 10; $i++) {
将10改成更大的数字就行,但是相应的,数字越大,同一时间内支付,金额越小
No description provided.
送上.net 测试代码
` public void CreateOrder()
{
string payId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
string appid = "3";
string key = "7AwxYT7cpYTcF76tyBi6wiZEnNm3X7sKzjBWY7AmMjS43pnCF8BDRWa2hBwKTSRspyee7nEPFBwScWEeKZjjxMQyaDA6RfEaGS5FrSGriiRKRXrCjMRPPmMQpMDEaZne";
//string explain = "测试";
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("payId", payId);
dic.Add("price", "0.02");
dic.Add("param", "");
dic.Add("type", "2");
dic.Add("isHtml", "1");
dic.Add("appid", appid);
string sign = SHA256EncryptString(GetParamAscii(dic) + "key=" + key).ToUpper();
dic.Add("sign", sign);
string baseurl = "http://pay.xxxx.com/CreateOrder";
var client = new RestClient(baseurl);
var request = new RestRequest(Method.GET);
request.Timeout = 10000;
//string contentType = "application/json";
foreach (var p in dic)
{
request.AddParameter(p.Key, p.Value);
}
//request.AddParameter(contentType,null, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var obj = JsonConvert.DeserializeObject<ResultMod>(response.Content);
if(obj.code==0)
{
Response.Write(obj.data);
}
else
{
Response.Write(obj.msg);
}
}`
` private string GetParamAscii(Dictionary<string, string> sArray)
{
StringBuilder str = new StringBuilder();
string[] arrKeys = sArray.Keys.ToArray();
Array.Sort(arrKeys, string.CompareOrdinal);
foreach (var key in arrKeys)
{
string value = sArray[key];
str.Append(key + "=" + value + "&");
}
return str.ToString();
}
public string SHA256EncryptString(string data)
{
byte[] bytes = Encoding.UTF8.GetBytes(data);
byte[] hash = SHA256.Create().ComputeHash(bytes);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
builder.Append(hash[i].ToString("x2"));
}
return builder.ToString();
}`
我们sdk的处理方案是在生成payId之前进行检查,假设函数名为a
也就是在这一步之前
string payId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
a需要两个参数price
和param
,利用这两个参数计算出唯一的id,比如最简单的md5(price+param)
,存储到Session中,并且将超时时间也存储到Session中。
当有一个新的订单进行创建时,会通过这个函数进行检查,如果Session中存在这个id并且还没超时,就返回上一个创建的payId,否则就新建一个payId并存储到Session中。