|
|
@@ -270,6 +270,7 @@ async function doNormalOrder(iData, willPrice, priceFloatInterval){
|
|
|
} else {
|
|
|
magicJS.notification.post(scriptName, "", `🎉产品【${iData.seriesName}】快捷下单成功,需前往支付!`, 'https://luanshu.hbcpre.com/order/ls/?id=2');
|
|
|
}
|
|
|
+ await checkAuthority();
|
|
|
}
|
|
|
} else {
|
|
|
magicJS.logger.info(buyRet.message);
|
|
|
@@ -409,6 +410,63 @@ async function doOrderPay(payType, orderId) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+async function checkAuthority(){
|
|
|
+ let reqData = {
|
|
|
+ address: gAppToken,
|
|
|
+ };
|
|
|
+ const headers = gCommonHeaders;
|
|
|
+ const md5 = createWMd5();
|
|
|
+ headers['trans-id'] = md5.hex_md5_32Upper(`${new Date().getTime()}`);
|
|
|
+ const baseConfig = getBaseConfig();
|
|
|
+ let api = '/mall/collector/checkAuthority';
|
|
|
+ let url = `${baseConfig.api_host}${api}`;
|
|
|
+ const options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: `${magicJS.objToQueryStr(reqData)}`,
|
|
|
+ };
|
|
|
+ magicJS.logger.info(`检查刷新token`);
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
+ try {
|
|
|
+ const body = response.body;
|
|
|
+ if (typeof body === "object") {
|
|
|
+ // magicJS.logger.log(JSON.stringify(body));
|
|
|
+ if(body.code == 200){
|
|
|
+ let headers = response.headers;
|
|
|
+ if(headers['Set-Cookie']){
|
|
|
+ let newAuthorization = null;
|
|
|
+ let cookieSetStr = headers['Set-Cookie'];
|
|
|
+ let cookieData = magicJs.parseSetCookies(cookieSetStr);
|
|
|
+ for(let i=0; i < cookieData.length; i++){
|
|
|
+ let info = cookieData[i];
|
|
|
+ let name = info.name;
|
|
|
+ let value = info.value;
|
|
|
+ if(value == ''){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(name == 'JSESSIONID'){
|
|
|
+ if(gAppToken != value){
|
|
|
+ gAppToken = value;
|
|
|
+ updateRequestHeaders();
|
|
|
+ magicJS.logger.info('token发生变化');
|
|
|
+ } else {
|
|
|
+ magicJS.logger.info('token没有变化');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return body;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `发生异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
async function browserOpenUrl(url, headers) {
|
|
|
let options = {
|
|
|
url: `${url}`,
|