|
|
@@ -89,11 +89,12 @@ async function tryFirstGrab() {
|
|
|
let userHashId = getUserHashId();
|
|
|
let artData = await getWillFirstArtData();
|
|
|
if (artData) {
|
|
|
- let retData = await doCreateFirstOrder(userHashId, artData.artId, 1, artData.price);
|
|
|
- if (retData.code == 200) {
|
|
|
+ // let retPreOrderInfo = await doConfirmArtInfo(artData.artId);
|
|
|
+ let retOrderData = await doCreateFirstOrder(userHashId, artData.artId, 1, artData.price);
|
|
|
+ if (retOrderData.code == 200) {
|
|
|
magicJS.notification.appendNotifyInfo(`🎉抢购首发产品[${artData.title}]成功`);
|
|
|
} else {
|
|
|
- magicJS.logger.appendNotifyInfo(`❌抢购首发产品[${artData.title}]失败,原因:${retData.msg}`);
|
|
|
+ magicJS.logger.appendNotifyInfo(`❌抢购首发产品[${artData.title}]失败,原因:${retOrderData.msg}`);
|
|
|
}
|
|
|
} else {
|
|
|
magicJS.logger.error(`不存在匹配的首发产品`);
|
|
|
@@ -202,6 +203,31 @@ async function queryFirstArtList(type, page) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+async function doConfirmArtInfo(artId) {
|
|
|
+ const url = `https://api.wubian.pro/vmf/app/market/confirmArtInfo`;
|
|
|
+ const reqData = {
|
|
|
+ artId: artId,
|
|
|
+ };
|
|
|
+ let options = {
|
|
|
+ url: url,
|
|
|
+ headers: gCommonHeaders,
|
|
|
+ body: JSON.stringify(reqData),
|
|
|
+ };
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
+ try {
|
|
|
+ let rspData = response.body;
|
|
|
+ magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
+ return rspData;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `请求首发下单确认信息异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
async function doCreateFirstOrder(userHashId, artHashId, num = 1, price = 0) {
|
|
|
const url = `https://api.wubian.pro/vmf/app/order/createFirstOrder?token=${userHashId}`;
|
|
|
const reqData = {
|