|
|
@@ -137,7 +137,7 @@ async function tryFastOrder(){
|
|
|
if(buyRet.data.url){
|
|
|
// await openUrl(buyRet.data.url);
|
|
|
let queryData = magicJS.parseQueryStr(buyRet.data.url);
|
|
|
- let paySuccFlag = await doYeepay(queryData.token);
|
|
|
+ let paySuccFlag = await doYeepay(queryData.token, parseFloat(iData.pay_price));
|
|
|
if(paySuccFlag){
|
|
|
magicJS.notification.post(scriptName, "", `🎉产品【${iData.title}】快捷下单成功,并支付成功!`);
|
|
|
} else {
|
|
|
@@ -153,7 +153,8 @@ async function tryFastOrder(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function doYeepay(token){
|
|
|
+async function doYeepay(token, referPrice){
|
|
|
+ magicJS.logger.info(`尝试使用易宝钱包余额进行自动支付`);
|
|
|
let orderInfo = await yeepayOrderInfo(token);
|
|
|
if(!orderInfo){
|
|
|
return false;
|
|
|
@@ -163,6 +164,12 @@ async function doYeepay(token){
|
|
|
if(!bankData){
|
|
|
return false;
|
|
|
}
|
|
|
+ if(referPrice){
|
|
|
+ if(orderInfo.amount > referPrice){
|
|
|
+ magicJS.notification.appendNotifyInfo(`产品价格过高:${orderInfo.amount},期望价格:${referPrice}`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
if(orderInfo.amount > bankData.accountBalance){
|
|
|
magicJS.notification.appendNotifyInfo(`易宝钱包账户余额:${bankData.accountBalance},不足支付${orderInfo.amount}`);
|
|
|
return false;
|
|
|
@@ -189,6 +196,7 @@ async function yeepayOrderInfo(token){
|
|
|
headers: headers,
|
|
|
body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
};
|
|
|
+ magicJS.logger.info(`请求查询订单信息`);
|
|
|
let result = await magicJS.http.post(options).then(response => {
|
|
|
try {
|
|
|
const body = response.body;
|
|
|
@@ -205,7 +213,7 @@ async function yeepayOrderInfo(token){
|
|
|
return null;
|
|
|
}
|
|
|
if(result.bizStatus != 'success'){
|
|
|
- magicJS.notification.appendNotifyInfo(`❌获取订单信息失败: ${result.errormsg || '未知原因'}`);
|
|
|
+ magicJS.notification.appendNotifyInfo(`❌查询订单信息失败: ${result.errormsg || '未知原因'}`);
|
|
|
return null;
|
|
|
}
|
|
|
result.data.token = result.token;
|
|
|
@@ -224,6 +232,7 @@ async function yeepayPromotion(token){
|
|
|
headers: headers,
|
|
|
body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
};
|
|
|
+ magicJS.logger.info(`请求查询优惠信息`);
|
|
|
let result = await magicJS.http.post(options).then(response => {
|
|
|
try {
|
|
|
const body = response.body;
|
|
|
@@ -259,6 +268,7 @@ async function yeepaySupportBankList(token){
|
|
|
headers: headers,
|
|
|
body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
};
|
|
|
+ magicJS.logger.info(`请求查询钱包银行账户信息`);
|
|
|
let result = await magicJS.http.post(options).then(response => {
|
|
|
try {
|
|
|
const body = response.body;
|
|
|
@@ -298,6 +308,7 @@ async function yeepayWalletPay(token, bindId, tradePassword){
|
|
|
headers: headers,
|
|
|
body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
};
|
|
|
+ magicJS.logger.info(`请求钱包余额发起支付`);
|
|
|
let result = await magicJS.http.post(options).then(response => {
|
|
|
try {
|
|
|
const body = response.body;
|
|
|
@@ -333,6 +344,7 @@ async function yeepayQueryResult(token){
|
|
|
headers: headers,
|
|
|
body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
};
|
|
|
+ magicJS.logger.info(`请求查询订单支付结果`);
|
|
|
let result = await magicJS.http.post(options).then(response => {
|
|
|
try {
|
|
|
const body = response.body;
|