Commit 922c93bf authored by gaodapeng's avatar gaodapeng

修改了支付内容

parent 90227f26
......@@ -32,6 +32,7 @@ Page({
}
},
/**
......@@ -155,16 +156,17 @@ Page({
if(res == null){
return;
}
if(res.code > 0){
if(res.resultCode == 1){
//成功
console.log("支付回调成功,跳转 " );
// if(data.isCashierClosed == true){
my.ix.offCashierEventReceive();
saveData(list, res);
my.redirectTo({
url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount,
});
// }
}else{
} else {
console.log("支付回调失败,toast提示 ");
my.ix.offCashierEventReceive();
my.showToast({
......@@ -176,6 +178,21 @@ Page({
}.bind(this));
},
/**
* 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息
* @param paySuccessResponse 支付成功响应,即云中台返回响应中的data信息
*/
saveData(paySuccessGoodsList, paySuccessResponse) {
my.setStorageSync({
key: 'paySuccessGoodsList',
data: paySuccessGoodsList
});
my.setStorageSync({
key: 'paySuccessResponse',
data: paySuccessResponse
});
},
});
......@@ -194,16 +194,16 @@ function pay(tradeNo, payCode, payPrice, list, callback, retryCount){
success: (res) => {
//增加数据判断,增加重试
console.log("支付接口回调 ==>" + JSON.stringify(res));
if (res == null|| res.data == null|| res.data.success != true/*||res.data.data == null*/) {
if (res == null|| res.data == null|| res.data.success != true || res.data.data == null) {
console.log("支付未成功 ==>" + JSON.stringify(res.data.message));
retryOrFailed(tradeNo, payCode, payPrice, list, callback, retryCount);
} else {
console.log("支付返回值 ==>" + JSON.stringify(res.data));
console.log("支付返回值 ==>" + JSON.stringify(res.data));
if(res.data.data.tradeStatus == "3"){
onPaySuccess(res.data.data,callback);
onPaySuccess(res.data.data, callback);
} else if(res.data.data.tradeStatus == "1"){//需要查询结果
//轮询查询,最多12次
queryPayStateWithRetry(tradeNo,callback,0);
queryPayStateWithRetry(tradeNo, callback, 0);
} else {
//查询一次
queryPayState(tradeNo,callback);
......@@ -249,7 +249,6 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
callback(response);
return;
}
retryCount++;
var queryStateRequest = api.createCommonRequest();
queryStateRequest.tradeNo = tradeNo;
queryStateRequest.batchNo = "" + Date.parse(new Date());
......@@ -264,6 +263,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
data: queryStateRequest,
success: (res) => {
//增加数据判断,增加重试
console.log("查询结果"+JSON.stringify(res));
if (res == null|| res.data == null|| res.data.success != true||res.data.data == null) {//不知名原因导致失败,直接报失败
console.log("查询失败,支付失败");
var response = {resultCode:-1,message:"支付失败"};
......@@ -272,9 +272,9 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
if(res.data.data.tradeStatus == "3"){//成功直接报成功
onPaySuccess(res.data.data,callback);
} else if(res.data.data.tradeStatus == "1"){//需要查询结果,继续轮询
console.log("查询结果显示支付未成功 ==>" + res.data.message);
console.log("查询结果显示支付未成功,重试 ");
sleep(5000);
queryPayStateWithRetry(tradeNo,callback, retryCount);
queryPayStateWithRetry(tradeNo,callback, ++retryCount);
} else {//其他状况直接报失败
var response = {resultCode:-1,message:"支付失败"};
callback(response);
......@@ -284,7 +284,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
fail: (res) => {//接口访问失败,继续轮询
console.log("查询失败 ==>" + JSON.stringify(res));
sleep(5000);
queryPayStateWithRetry(tradeNo,callback,retryCount);
queryPayStateWithRetry(tradeNo,callback,++retryCount);
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment