|
|
@@ -18,6 +18,8 @@ const HbcpreConstKey = {
|
|
|
collectionName: 'HbcpreCollectionName',
|
|
|
orderLimitPrice: 'HbcpreOrderLimitPrice',
|
|
|
floatPriceIntaval: 'HbcpreFloatPriceIntaval',
|
|
|
+ itemCntRwData: 'HbcpreItemCntRwData',
|
|
|
+ walletPayPassword: 'HbcpreWalletPayPassword',
|
|
|
};
|
|
|
|
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1`;
|
|
|
@@ -39,6 +41,23 @@ const gCommonHeaders = {
|
|
|
'Accept' : `*/*`,
|
|
|
'Accept-Language' : `zh-CN,zh-Hans;q=0.9`
|
|
|
};
|
|
|
+const gYeepayHeaders = {
|
|
|
+ 'Sec-Fetch-Dest' : `empty`,
|
|
|
+ 'Connection' : `keep-alive`,
|
|
|
+ 'Accept-Encoding' : `gzip, deflate, br`,
|
|
|
+ 'Content-Type' : `application/x-www-form-urlencoded`,
|
|
|
+ 'Sec-Fetch-Site' : `same-origin`,
|
|
|
+ 'Origin' : `https://cash.yeepay.com`,
|
|
|
+ 'User-Agent' : `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1`,
|
|
|
+ 'Sec-Fetch-Mode' : `cors`,
|
|
|
+ 'Cookie' : `aliyungf_tc=deb5a0bf09b2b2914456330284da78f4dd6625813acc42b992eb59069c342eed`,
|
|
|
+ 'Host' : `cash.yeepay.com`,
|
|
|
+ 'Referer' : `https://cash.yeepay.com/newwap/mobile-cashier/index.html`,
|
|
|
+ 'Accept-Language' : `zh-CN,zh-Hans;q=0.9`,
|
|
|
+ 'Accept' : `application/json, text/plain, */*`
|
|
|
+};
|
|
|
+
|
|
|
+let gItemCntRwDict = {};
|
|
|
|
|
|
async function Main() {
|
|
|
if (!magicJS.isRequest) {
|
|
|
@@ -48,6 +67,22 @@ async function Main() {
|
|
|
magicJS.done();
|
|
|
}
|
|
|
|
|
|
+function readItemCntRwDict(){
|
|
|
+ gItemCntRwDict = {};
|
|
|
+ let text = magicJS.data.read(HbcpreConstKey.itemCntRwData, null);
|
|
|
+ if(text){
|
|
|
+ let segments = text.split('|');
|
|
|
+ for (let i = segments.length - 1; i >= 0; i--) {
|
|
|
+ let kvArr = segments[i].trim().split('#');
|
|
|
+ if(kvArr.length == 2){
|
|
|
+ const key = kvArr[0].trim();
|
|
|
+ const value = parseInt(kvArr[1].trim());
|
|
|
+ gItemCntRwDict[key] = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
async function tryFastOrder(){
|
|
|
let itemId = magicJS.data.read(HbcpreConstKey.castingId, null);
|
|
|
let itemName = magicJS.data.read(HbcpreConstKey.collectionName, null);
|
|
|
@@ -101,8 +136,14 @@ async function tryFastOrder(){
|
|
|
// magicJS.notification.appendNotifyInfo(`🎉产品【${iData.title}】快捷下单成功`);
|
|
|
if(buyRet.data.url){
|
|
|
await openUrl(buyRet.data.url);
|
|
|
+ let queryData = magicJS.parseQueryStr(buyRet.data.url);
|
|
|
+ let paySuccFlag = await doYeepay(queryData.token);
|
|
|
+ if(paySuccFlag){
|
|
|
+ magicJS.notification.post(scriptName, "", `🎉产品【${iData.title}】快捷下单成功,并支付成功!`);
|
|
|
+ } else {
|
|
|
+ magicJS.notification.post(scriptName, "", `🎉产品【${iData.title}】快捷下单成功,需前往支付!`, buyRet.data.url);
|
|
|
+ }
|
|
|
}
|
|
|
- magicJS.notification.post(scriptName, "", `🎉产品【${iData.title}】快捷下单成功`, buyRet.data.url);
|
|
|
} else {
|
|
|
magicJS.logger.info(buyRet.message);
|
|
|
}
|
|
|
@@ -112,6 +153,209 @@ async function tryFastOrder(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+async function doYeepay(token){
|
|
|
+ let orderInfo = await yeepayOrderInfo(token);
|
|
|
+ if(!orderInfo){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let promotionData = await yeepayPromotion(token);
|
|
|
+ let bankData = await yeepaySupportBankList(token);
|
|
|
+ if(!bankData){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(orderInfo.amount > bankData.accountBalance){
|
|
|
+ magicJS.notification.appendNotifyInfo(`易宝钱包账户余额:${bankData.accountBalance},不足支付${orderInfo.amount}`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let password = magicJS.data.read(HbcpreConstKey.walletPayPassword, 'AES4254386817B52B8BC242611552B8805D');
|
|
|
+ let payRet = await yeepayWalletPay(token, '', password);
|
|
|
+ if(payRet && payRet.token){
|
|
|
+ let finalRet = await yeepayQueryResult(payRet.token);
|
|
|
+
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+async function yeepayOrderInfo(token){
|
|
|
+ const headers = gYeepayHeaders;
|
|
|
+ headers['Referer'] = `https://cash.yeepay.com/newwap/mobile-cashier/index.html`;
|
|
|
+ const reqData = {
|
|
|
+ token: token,
|
|
|
+ }
|
|
|
+ let url = `https://cash.yeepay.com/newh5/ajax/request/orderInfo`;
|
|
|
+ const options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
+ };
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
+ try {
|
|
|
+ const body = response.body;
|
|
|
+ magicJS.logger.log(JSON.stringify(body));
|
|
|
+ return body;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `发生异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+ if(!result){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if(result.bizStatus != 'success'){
|
|
|
+ magicJS.notification.appendNotifyInfo(`❌获取订单信息失败: ${result.errormsg || '未知原因'}`);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ result.data.token = result.token;
|
|
|
+ return result.data;
|
|
|
+}
|
|
|
+
|
|
|
+async function yeepayPromotion(token){
|
|
|
+ const headers = gYeepayHeaders;
|
|
|
+ headers['Referer'] = `https://cash.yeepay.com/newwap/mobile-cashier/index.html`;
|
|
|
+ const reqData = {
|
|
|
+ token: token,
|
|
|
+ }
|
|
|
+ let url = `https://cash.yeepay.com/cashier/getPromotion`;
|
|
|
+ const options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
+ };
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
+ try {
|
|
|
+ const body = response.body;
|
|
|
+ magicJS.logger.log(JSON.stringify(body));
|
|
|
+ return body;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `发生异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+ if(!result){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if(result.errormsg){
|
|
|
+ magicJS.notification.appendNotifyInfo(`❌获取优惠信息失败: ${result.errormsg || '未知原因'}`);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ result.data.token = result.token;
|
|
|
+ return result.data;
|
|
|
+}
|
|
|
+
|
|
|
+async function yeepaySupportBankList(token){
|
|
|
+ const headers = gYeepayHeaders;
|
|
|
+ headers['Referer'] = `https://cash.yeepay.com/newwap/mobile-cashier/index.html`;
|
|
|
+ const reqData = {
|
|
|
+ token: token,
|
|
|
+ }
|
|
|
+ let url = `https://cash.yeepay.com/wallet/supportbanklist`;
|
|
|
+ const options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
+ };
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
+ try {
|
|
|
+ const body = response.body;
|
|
|
+ magicJS.logger.log(JSON.stringify(body));
|
|
|
+ return body;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `发生异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+ if(!result){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if(result.bizStatus != 'success'){
|
|
|
+ magicJS.notification.appendNotifyInfo(`❌获取支持的银行列表数据失败: ${result.errormsg || '未知原因'}`);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ result.data.token = result.token;
|
|
|
+ return result.data;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+async function yeepayWalletPay(token, bindId, tradePassword){
|
|
|
+ const headers = gYeepayHeaders;
|
|
|
+ headers['Referer'] = `https://cash.yeepay.com/newwap/mobile-cashier/index.html`;
|
|
|
+ const reqData = {
|
|
|
+ token: token,
|
|
|
+ bindId: bindId || '',
|
|
|
+ payType: 'WALLET_BALANCE',
|
|
|
+ tradePassword: tradePassword,
|
|
|
+ }
|
|
|
+ let url = `https://cash.yeepay.com/newh5/ajax/request/wallet/pay`;
|
|
|
+ const options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
+ };
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
+ try {
|
|
|
+ const body = response.body;
|
|
|
+ magicJS.logger.log(JSON.stringify(body));
|
|
|
+ return body;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `发生异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+ if(!result){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if(result.bizStatus != 'success'){
|
|
|
+ magicJS.notification.appendNotifyInfo(`❌请求钱包支付失败: ${result.errormsg || '未知原因'}`);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ result.data.token = result.token;
|
|
|
+ return result.data;
|
|
|
+}
|
|
|
+
|
|
|
+async function yeepayQueryResult(token){
|
|
|
+ const headers = gYeepayHeaders;
|
|
|
+ headers['Referer'] = `https://cash.yeepay.com/newwap/mobile-cashier/index.html`;
|
|
|
+ const reqData = {
|
|
|
+ token: token,
|
|
|
+ }
|
|
|
+ let url = `https://cash.yeepay.com/newh5/ajax/query/result`;
|
|
|
+ const options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
+ };
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
+ try {
|
|
|
+ const body = response.body;
|
|
|
+ magicJS.logger.log(JSON.stringify(body));
|
|
|
+ return body;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `发生异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+ if(!result){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if(result.bizStatus != 'success'){
|
|
|
+ magicJS.notification.appendNotifyInfo(`❌获取订单支付结果数据失败: ${result.errormsg || '未知原因'}`);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ result.data.token = result.token;
|
|
|
+ return result.data;
|
|
|
+}
|
|
|
+
|
|
|
function transformKeys(keyStr) {
|
|
|
let n = 3;
|
|
|
if (arguments.length > 1 && void 0 !== arguments[1]) {
|