forked from ccwav/QLScript2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot_jd_bean_change_QL.js
2562 lines (2424 loc) · 83.4 KB
/
bot_jd_bean_change_QL.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
cron "0 0 * * *" bot_jd_bean_change.js, tag:机器人查询专用脚本
*/
//详细说明参考 https://github.com/ccwav/QLScript2
const $ = new Env('机器人查询专用脚本');
const JXUserAgent = $.isNode() ? (process.env.JX_USER_AGENT ? process.env.JX_USER_AGENT : ``) : ``;
//Node.js用户请在jdCookie.js处填写京东ck;
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
let NowHour = new Date().getHours();
let allMessage = '';
let allReceiveMessage = '';
let allWarnMessage = '';
let ReturnMessage = '';
let notifySkipList = "";
let isSignError = false;
let ReturnMessageTitle="";
//IOS等用户直接用NobyDa的jd cookie
let cookiesArr = [], cookie = '';
const JD_API_HOST = 'https://api.m.jd.com/client.action';
let intPerSent = 0;
let i = 0;
let Today = new Date();
let strAllNotify="";
let strSubNotify="";
let llPetError=false;
let strGuoqi="";
let RemainMessage = '';
let TempBaipiao = "";
let llgeterror=false;
let time = new Date().getHours();
const {getEnvByPtPin} = require('./ql');
let userIndex2 = -1;
let userIndex3 = -1;
let userIndex4 = -1;
let decExBean=0;
if ($.isNode()) {
Object.keys(jdCookieNode).forEach((item) => {
cookiesArr.push(jdCookieNode[item])
})
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false')
console.log = () => {};
}
let intcheckckseq=999999;
let strcheckck = process.env.BOTCHECKCODE;
if(!strcheckck){
console.log("【账号🆔】没有获取到要查询的账号");
return
}
for (i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
$.pt_pin = (cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
if (strcheckck == $.pt_pin) {
intcheckckseq = i;
break;
}
}
}
if (intcheckckseq == 999999) {
if (IsNumber(strcheckck)) {
if (parseInt(strcheckck) > cookiesArr.length) {
console.log('【账号'+strcheckck+'🆔】你哪来那么多账号,没点逼数吗');
return
}
intcheckckseq = parseInt(strcheckck) - 1;
}
}
console.log("当前查询的CK序号是:"+(intcheckckseq+1));
//查询开关
let strDisableList = "";
let DisableIndex=-1;
if ($.isNode()) {
strDisableList = process.env.BEANCHANGE_BOTDISABLELIST ? process.env.BEANCHANGE_BOTDISABLELIST.split('&') : [];
}
//喜豆查询
let EnableJxBeans=true;
DisableIndex=strDisableList.findIndex((item) => item === "喜豆查询");
if(DisableIndex!=-1){
console.log("检测到设定关闭喜豆查询");
EnableJxBeans=false
}
//汪汪乐园
let EnableJoyPark=true;
DisableIndex = strDisableList.findIndex((item) => item === "汪汪乐园");
if(DisableIndex!=-1){
console.log("检测到设定关闭汪汪乐园查询");
EnableJoyPark=false
}
//京东赚赚
let EnableJdZZ=true;
DisableIndex = strDisableList.findIndex((item) => item === "京东赚赚");
if(DisableIndex!=-1){
console.log("检测到设定关闭京东赚赚查询");
EnableJdZZ=false;
}
//京东秒杀
let EnableJdMs=true;
DisableIndex = strDisableList.findIndex((item) => item === "京东秒杀");
if(DisableIndex!=-1){
console.log("检测到设定关闭京东秒杀查询");
EnableJdMs=false;
}
//东东农场
let EnableJdFruit=true;
DisableIndex = strDisableList.findIndex((item) => item === "东东农场");
if(DisableIndex!=-1){
console.log("检测到设定关闭东东农场查询");
EnableJdFruit=false;
}
//极速金币
let EnableJdSpeed=true;
DisableIndex = strDisableList.findIndex((item) => item === "极速金币");
if(DisableIndex!=-1){
console.log("检测到设定关闭极速金币查询");
EnableJdSpeed=false;
}
//京喜牧场
let EnableJxMC=true;
DisableIndex= strDisableList.findIndex((item) => item === "京喜牧场");
if(DisableIndex!=-1){
console.log("检测到设定关闭京喜牧场查询");
EnableJxMC=false;
}
//京喜工厂
let EnableJxGC=true;
DisableIndex=strDisableList.findIndex((item) => item === "京喜工厂");
if(DisableIndex!=-1){
console.log("检测到设定关闭京喜工厂查询");
EnableJxGC=false;
}
// 京东工厂
let EnableJDGC=true;
DisableIndex=strDisableList.findIndex((item) => item === "京东工厂");
if(DisableIndex!=-1){
console.log("检测到设定关闭京东工厂查询");
EnableJDGC=false;
}
//领现金
let EnableCash=true;
DisableIndex=strDisableList.findIndex((item) => item === "领现金");
if(DisableIndex!=-1){
console.log("检测到设定关闭领现金查询");
EnableCash=false;
}
//东东萌宠
let EnableJDPet=true;
DisableIndex=strDisableList.findIndex((item) => item === "东东萌宠");
if(DisableIndex!=-1){
console.log("检测到设定关闭东东萌宠查询");
EnableJDPet=false
}
//7天过期京豆
let EnableOverBean=true;
DisableIndex=strDisableList.findIndex((item) => item === "过期京豆");
if(DisableIndex!=-1){
console.log("检测到设定关闭过期京豆查询");
EnableOverBean=false
}
//查优惠券
let EnableChaQuan=true;
DisableIndex=strDisableList.findIndex((item) => item === "查优惠券");
if(DisableIndex!=-1){
console.log("检测到设定关闭优惠券查询");
EnableChaQuan=false
}
!(async() => {
if (!cookiesArr[intcheckckseq]) {
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {
"open-url": "https://bean.m.jd.com/bean/signIndex.action"
});
return;
}
i = intcheckckseq;
if (cookiesArr[i]) {
cookie = cookiesArr[i];
$.pt_pin = (cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
$.CryptoJS = $.isNode() ? require('crypto-js') : CryptoJS;
$.index = i + 1;
$.beanCount = 0;
$.incomeBean = 0;
$.expenseBean = 0;
$.todayIncomeBean = 0;
$.todayOutcomeBean = 0;
$.errorMsg = '';
$.isLogin = true;
$.nickName = '';
$.levelName = '';
$.message = '';
$.balance = 0;
$.expiredBalance = 0;
$.JdzzNum = 0;
$.JdMsScore = 0;
$.JdFarmProdName = '';
$.JdtreeEnergy = 0;
$.JdtreeTotalEnergy = 0;
$.treeState = 0;
$.JdwaterTotalT = 0;
$.JdwaterD = 0;
$.JDwaterEveryDayT = 0;
$.JDtotalcash = 0;
$.JDEggcnt = 0;
$.Jxmctoken = '';
$.DdFactoryReceive = '';
$.jxFactoryInfo = '';
$.jxFactoryReceive = '';
$.jdCash = 0;
$.isPlusVip = 0;
$.JingXiang = "";
$.allincomeBean = 0; //月收入
$.allexpenseBean = 0; //月支出
$.joylevel = 0;
$.beanChangeXi = 0;
$.inJxBean = 0;
$.OutJxBean = 0;
$.todayinJxBean = 0;
$.todayOutJxBean = 0;
$.xibeanCount = 0;
$.PigPet = '';
$.YunFeiTitle = "";
$.YunFeiQuan = 0;
$.YunFeiQuanEndTime = "";
$.YunFeiTitle2 = "";
$.YunFeiQuan2 = 0;
$.YunFeiQuanEndTime2 = "";
TempBaipiao = "";
strGuoqi = "";
await Promise.all([
TotalBean(),
TotalBean2()])
if (!$.isLogin) {
await isLoginByX1a0He();
}
if (!$.isLogin) {
console.log(`【提示】cookie已失效,\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`);
return
}
await Promise.all([
getJoyBaseInfo(), //汪汪乐园
getJdZZ(), //京东赚赚
getMs(), //京东秒杀
getjdfruitinfo(), //东东农场
cash(), //极速金币
jdJxMCinfo(), //京喜牧场
bean(), //京豆查询
getJxFactory(), //京喜工厂
getDdFactoryInfo(), // 京东工厂
jdCash(), //领现金
GetJxBeaninfo() //喜豆查询
])
await showMsg();
}
})()
.catch((e) => {
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.done();
})
async function showMsg() {
//if ($.errorMsg)
//return
ReturnMessageTitle="";
ReturnMessage = "";
var strsummary="";
var temptest = await getEnvByPtPin($.UserName);
var strRemark=getRemark(temptest.remarks);
if(strRemark)
ReturnMessageTitle = `【账号🆔${(intcheckckseq+1)}】`+strRemark+`\n`;
else
ReturnMessageTitle = `【账号${(intcheckckseq+1)}收支情况】\n`;
if ($.levelName || $.JingXiang){
ReturnMessage += `【账号信息】`;
if ($.levelName) {
if ($.levelName.length > 2)
$.levelName = $.levelName.substring(0, 2);
if ($.levelName == "注册")
$.levelName = `😊普通`;
if ($.levelName == "钻石")
$.levelName = `💎钻石`;
if ($.levelName == "金牌")
$.levelName = `🥇金牌`;
if ($.levelName == "银牌")
$.levelName = `🥈银牌`;
if ($.levelName == "铜牌")
$.levelName = `🥉铜牌`;
if ($.isPlusVip == 1)
ReturnMessage += `${$.levelName}Plus`;
else
ReturnMessage += `${$.levelName}会员`;
}
if ($.JingXiang){
if ($.levelName) {
ReturnMessage +=",";
}
ReturnMessage += `${$.JingXiang}`;
}
ReturnMessage +=`\n`;
}
ReturnMessage += `【今日京豆】收${$.todayIncomeBean}豆`;
strsummary+= `【今日京豆】收${$.todayIncomeBean}豆`;
if ($.todayOutcomeBean != 0) {
ReturnMessage += `,支${$.todayOutcomeBean}豆`;
strsummary += `,支${$.todayOutcomeBean}豆`;
}
ReturnMessage += `\n`;
strsummary+= `\n`;
ReturnMessage += `【昨日京豆】收${$.incomeBean}豆`;
if ($.expenseBean != 0) {
ReturnMessage += `,支${$.expenseBean}豆`;
}
ReturnMessage += `\n`;
if ($.beanCount){
ReturnMessage += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
strsummary+= `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
} else {
if($.levelName || $.JingXiang)
ReturnMessage += `【当前京豆】获取失败,接口返回空数据\n`;
else{
ReturnMessage += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
strsummary += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
}
}
if (EnableJxBeans) {
ReturnMessage += `【今日喜豆】收${$.todayinJxBean}豆`;
if ($.todayOutJxBean != 0) {
ReturnMessage += `,支${$.todayOutJxBean}豆`;
}
ReturnMessage += `\n`;
ReturnMessage += `【昨日喜豆】收${$.inJxBean}豆`;
if ($.OutJxBean != 0) {
ReturnMessage += `,支${$.OutJxBean}豆`;
}
ReturnMessage += `\n`;
ReturnMessage += `【当前喜豆】${$.xibeanCount}喜豆(≈${($.xibeanCount/ 100).toFixed(2)}元)\n`;
strsummary += `【当前喜豆】${$.xibeanCount}豆(≈${($.xibeanCount/ 100).toFixed(2)}元)\n`;
}
if ($.JDEggcnt) {
ReturnMessage += `【京喜牧场】${$.JDEggcnt}枚鸡蛋\n`;
}
if ($.JDtotalcash) {
ReturnMessage += `【极速金币】${$.JDtotalcash}币(≈${($.JDtotalcash / 10000).toFixed(2)}元)\n`;
}
if ($.JdzzNum) {
ReturnMessage += `【京东赚赚】${$.JdzzNum}币(≈${($.JdzzNum / 10000).toFixed(2)}元)\n`;
}
if ($.JdMsScore != 0) {
ReturnMessage += `【京东秒杀】${$.JdMsScore}币(≈${($.JdMsScore / 1000).toFixed(2)}元)\n`;
}
if ($.joylevel || $.jdCash) {
ReturnMessage += `【其他信息】`;
if ($.joylevel) {
ReturnMessage += `汪汪:${$.joylevel}级`;
if ($.jdCash) {
ReturnMessage += ",";
}
}
if ($.jdCash) {
ReturnMessage += `领现金:${$.jdCash}元`;
}
ReturnMessage += `\n`;
}
if ($.JdFarmProdName != "") {
if ($.JdtreeEnergy != 0) {
if ($.treeState === 2 || $.treeState === 3) {
ReturnMessage += `【东东农场】${$.JdFarmProdName} 可以兑换了!\n`;
TempBaipiao += `【东东农场】${$.JdFarmProdName} 可以兑换了!\n`;
allReceiveMessage += `【账号🆔】${$.JdFarmProdName} (东东农场)\n`;
} else {
if ($.JdwaterD != 'Infinity' && $.JdwaterD != '-Infinity') {
ReturnMessage += `【东东农场】${$.JdFarmProdName}(${(($.JdtreeEnergy / $.JdtreeTotalEnergy) * 100).toFixed(0)}%,${$.JdwaterD}天)\n`;
} else {
ReturnMessage += `【东东农场】${$.JdFarmProdName}(${(($.JdtreeEnergy / $.JdtreeTotalEnergy) * 100).toFixed(0)}%)\n`;
}
}
} else {
if ($.treeState === 0) {
TempBaipiao += `【东东农场】水果领取后未重新种植!\n`;
allWarnMessage += `【账号🆔】水果领取后未重新种植! (东东农场)\n`;
} else if ($.treeState === 1) {
ReturnMessage += `【东东农场】${$.JdFarmProdName}种植中...\n`;
} else {
TempBaipiao += `【东东农场】状态异常!\n`;
allWarnMessage += `【账号🆔】状态异常! (东东农场)\n`;
//ReturnMessage += `【东东农场】${$.JdFarmProdName}状态异常${$.treeState}...\n`;
}
}
}
if ($.jxFactoryInfo) {
ReturnMessage += `【京喜工厂】${$.jxFactoryInfo}\n`
}
if ($.ddFactoryInfo) {
ReturnMessage += `【东东工厂】${$.ddFactoryInfo}\n`
}
if ($.DdFactoryReceive) {
allReceiveMessage += `【账号🆔】${$.DdFactoryReceive} (东东工厂)\n`;
TempBaipiao += `【东东工厂】${$.ddFactoryInfo} 可以兑换了!\n`;
}
if ($.jxFactoryReceive) {
allReceiveMessage += `【账号🆔】${$.jxFactoryReceive} (京喜工厂)\n`;
TempBaipiao += `【京喜工厂】${$.jxFactoryReceive} 可以兑换了!\n`;
}
if ($.PigPet) {
allReceiveMessage += `【账号🆔】${$.PigPet} (金融养猪)\n`;
TempBaipiao += `【金融养猪】${$.PigPet} 可以兑换了!\n`;
}
if(EnableJDPet){
llPetError=false;
var response ="";
response = await PetRequest('energyCollect');
if(llPetError)
response = await PetRequest('energyCollect');
llPetError=false;
var initPetTownRes = "";
initPetTownRes = await PetRequest('initPetTown');
if(llPetError)
initPetTownRes = await PetRequest('initPetTown');
if(!llPetError && initPetTownRes){
if (initPetTownRes.code === '0' && initPetTownRes.resultCode === '0' && initPetTownRes.message === 'success') {
$.petInfo = initPetTownRes.result;
if ($.petInfo.userStatus === 0) {
ReturnMessage += `【东东萌宠】活动未开启!\n`;
} else if ($.petInfo.petStatus === 5) {
ReturnMessage += `【东东萌宠】${$.petInfo.goodsInfo.goodsName}已可领取!\n`;
TempBaipiao += `【东东萌宠】${$.petInfo.goodsInfo.goodsName}已可领取!\n`;
allReceiveMessage += `【账号🆔】${$.petInfo.goodsInfo.goodsName}可以兑换了! (东东萌宠)\n`;
} else if ($.petInfo.petStatus === 6) {
TempBaipiao += `【东东萌宠】未选择物品! \n`;
allWarnMessage += `【账号🆔】未选择物品! (东东萌宠)\n`;
} else if (response.resultCode === '0') {
ReturnMessage += `【东东萌宠】${$.petInfo.goodsInfo.goodsName}`;
ReturnMessage += `(${(response.result.medalPercent).toFixed(0)}%,${response.result.medalNum}/${response.result.medalNum+response.result.needCollectMedalNum}块)\n`;
} else if (!$.petInfo.goodsInfo) {
ReturnMessage += `【东东萌宠】暂未选购新的商品!\n`;
TempBaipiao += `【东东萌宠】暂未选购新的商品! \n`;
allWarnMessage += `【账号🆔】暂未选购新的商品! (东东萌宠)\n`;
}
}
}
}
if(strGuoqi){
ReturnMessage += `💸💸💸临期京豆明细💸💸💸\n`;
ReturnMessage += `${strGuoqi}`;
}
ReturnMessage += `🧧🧧🧧红包明细🧧🧧🧧\n`;
ReturnMessage += `${$.message}`;
strsummary +=`${$.message}`;
if($.YunFeiQuan){
var strTempYF="【免运费券】"+$.YunFeiQuan+"张";
if($.YunFeiQuanEndTime)
strTempYF+="(有效期至"+$.YunFeiQuanEndTime+")";
strTempYF+="\n";
ReturnMessage +=strTempYF
strsummary +=strTempYF;
}
if($.YunFeiQuan2){
var strTempYF2="【免运费券】"+$.YunFeiQuan2+"张";
if($.YunFeiQuanEndTime2)
strTempYF+="(有效期至"+$.YunFeiQuanEndTime2+")";
strTempYF2+="\n";
ReturnMessage +=strTempYF2
strsummary +=strTempYF2;
}
allMessage += ReturnMessageTitle+ReturnMessage + `\n`;
console.log(`${ReturnMessageTitle+ReturnMessage}`);
}
async function bean() {
// console.log(`北京时间零点时间戳:${parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000}`);
// console.log(`北京时间2020-10-28 06:16:05::${new Date("2020/10/28 06:16:05+08:00").getTime()}`)
// 不管哪个时区。得到都是当前时刻北京时间的时间戳 new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000
//前一天的0:0:0时间戳
const tm = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000 - (24 * 60 * 60 * 1000);
// 今天0:0:0时间戳
const tm1 = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000;
let page = 1,
t = 0,
yesterdayArr = [],
todayArr = [];
do {
let response = await getJingBeanBalanceDetail(page);
// console.log(`第${page}页: ${JSON.stringify(response)}`);
if (response && response.code === "0") {
page++;
let detailList = response.detailList;
if (detailList && detailList.length > 0) {
for (let item of detailList) {
const date = item.date.replace(/-/g, '/') + "+08:00";
if (new Date(date).getTime() >= tm1 && (!item['eventMassage'].includes("退还") && !item['eventMassage'].includes('扣赠'))) {
todayArr.push(item);
} else if (tm <= new Date(date).getTime() && new Date(date).getTime() < tm1 && (!item['eventMassage'].includes("退还") && !item['eventMassage'].includes('扣赠'))) {
//昨日的
yesterdayArr.push(item);
} else if (tm > new Date(date).getTime()) {
//前天的
t = 1;
break;
}
}
} else {
$.errorMsg = `数据异常`;
$.msg($.name, ``, `账号${$.index}:${$.nickName}\n${$.errorMsg}`);
t = 1;
}
} else if (response && response.code === "3") {
console.log(`cookie已过期,或者填写不规范,跳出`)
t = 1;
} else {
console.log(`未知情况:${JSON.stringify(response)}`);
console.log(`未知情况,跳出`)
t = 1;
}
} while (t === 0);
for (let item of yesterdayArr) {
if (Number(item.amount) > 0) {
$.incomeBean += Number(item.amount);
} else if (Number(item.amount) < 0) {
$.expenseBean += Number(item.amount);
}
}
for (let item of todayArr) {
if (Number(item.amount) > 0) {
$.todayIncomeBean += Number(item.amount);
} else if (Number(item.amount) < 0) {
$.todayOutcomeBean += Number(item.amount);
}
}
$.todayOutcomeBean = -$.todayOutcomeBean;
$.expenseBean = -$.expenseBean;
decExBean =0;
if(EnableOverBean)
await queryexpirejingdou();//过期京豆
await redPacket();
if(EnableChaQuan)
await getCoupon();
}
async function jdJxMCinfo(){
if (EnableJxMC) {
llgeterror = false;
await requestAlgo();
if (llgeterror) {
console.log(`等待10秒后再次尝试...`)
await $.wait(10 * 1000);
await requestAlgo();
}
await JxmcGetRequest();
}
return;
}
async function jdCash() {
if (!EnableCash)
return;
let functionId = "cash_homePage";
let sign = `body=%7B%7D&build=167968&client=apple&clientVersion=10.4.0&d_brand=apple&d_model=iPhone13%2C3&ef=1&eid=eidI25488122a6s9Uqq6qodtQx6rgQhFlHkaE1KqvCRbzRnPZgP/93P%2BzfeY8nyrCw1FMzlQ1pE4X9JdmFEYKWdd1VxutadX0iJ6xedL%2BVBrSHCeDGV1&ep=%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22screen%22%3A%22CJO3CMeyDJCy%22%2C%22osVersion%22%3A%22CJUkDK%3D%3D%22%2C%22openudid%22%3A%22CJSmCWU0DNYnYtS0DtGmCJY0YJcmDwCmYJC0DNHwZNc5ZQU2DJc3Zq%3D%3D%22%2C%22area%22%3A%22CJZpCJCmC180ENcnCv80ENc1EK%3D%3D%22%2C%22uuid%22%3A%22aQf1ZRdxb2r4ovZ1EJZhcxYlVNZSZz09%22%7D%2C%22ts%22%3A1648428189%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D&ext=%7B%22prstate%22%3A%220%22%2C%22pvcStu%22%3A%221%22%7D&isBackground=N&joycious=104&lang=zh_CN&networkType=3g&networklibtype=JDNetworkBaseAF&partner=apple&rfs=0000&scope=11&sign=98c0ea91318ef1313786d86d832f1d4d&st=1648428208392&sv=101&uemps=0-0&uts=0f31TVRjBSv7E8yLFU2g86XnPdLdKKyuazYDek9RnAdkKCbH50GbhlCSab3I2jwM04d75h5qDPiLMTl0I3dvlb3OFGnqX9NrfHUwDOpTEaxACTwWl6n//EOFSpqtKDhg%2BvlR1wAh0RSZ3J87iAf36Ce6nonmQvQAva7GoJM9Nbtdah0dgzXboUL2m5YqrJ1hWoxhCecLcrUWWbHTyAY3Rw%3D%3D`
return new Promise((resolve) => {
$.post(apptaskUrl(functionId, sign), async(err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`jdCash API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data.code === 0 && data.data.result) {
$.jdCash = data.data.result.totalMoney || 0;
return
}
}
}
} catch (e) {
$.logErr(e, resp)
}
finally {
resolve(data);
}
})
})
}
function apptaskUrl(functionId = "", body = "") {
return {
url: `${JD_API_HOST}?functionId=${functionId}`,
body,
headers: {
'Cookie': cookie,
'Host': 'api.m.jd.com',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': '',
'User-Agent': 'JD4iPhone/167774 (iPhone; iOS 14.7.1; Scale/3.00)',
'Accept-Language': 'zh-Hans-CN;q=1',
'Accept-Encoding': 'gzip, deflate, br',
},
timeout: 10000
}
}
function getSign(functionId, body) {
return new Promise(async resolve => {
let data = {
functionId,
body: JSON.stringify(body),
"client":"apple",
"clientVersion":"10.3.0"
}
let HostArr = ['jdsign.cf', 'signer.nz.lu']
let Host = HostArr[Math.floor((Math.random() * HostArr.length))]
let options = {
url: `https://cdn.nz.lu/ddo`,
body: JSON.stringify(data),
headers: {
Host,
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88"
},
timeout: 30 * 1000
}
$.post(options, (err, resp, data) => {
try {
if (err) {
console.log(JSON.stringify(err))
console.log(`${$.name} getSign API请求失败,请检查网路重试`)
} else {
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function TotalBean() {
return new Promise(async resolve => {
const options = {
url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion",
headers: {
Cookie: cookie,
"User-Agent": "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
},
timeout: 10000
}
$.get(options, (err, resp, data) => {
try {
if (err) {
$.logErr(err)
} else {
if (data) {
data = JSON.parse(data);
if (data['retcode'] === "1001") {
$.isLogin = false; //cookie过期
return;
}
if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) {
$.nickName = data.data.userInfo.baseInfo.nickname;
$.levelName = data.data.userInfo.baseInfo.levelName;
$.isPlusVip = data.data.userInfo.isPlusVip;
}
if (data['retcode'] === '0' && data.data && data.data['assetInfo']) {
if ($.beanCount == 0)
$.beanCount = data.data && data.data['assetInfo']['beanNum'];
} else {
$.errorMsg = `数据异常`;
}
} else {
$.log('京东服务器返回空数据,将无法获取等级及VIP信息');
}
}
} catch (e) {
$.logErr(e)
}
finally {
resolve();
}
})
})
}
function TotalBean2() {
return new Promise(async(resolve) => {
const options = {
url: `https://wxapp.m.jd.com/kwxhome/myJd/home.json?&useGuideModule=0&bizId=&brandId=&fromType=wxapp×tamp=${Date.now()}`,
headers: {
Cookie: cookie,
'content-type': `application/x-www-form-urlencoded`,
Connection: `keep-alive`,
'Accept-Encoding': `gzip,compress,br,deflate`,
Referer: `https://servicewechat.com/wxa5bf5ee667d91626/161/page-frame.html`,
Host: `wxapp.m.jd.com`,
'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.10(0x18000a2a) NetType/WIFI Language/zh_CN`,
},
timeout: 10000
};
$.post(options, (err, resp, data) => {
try {
if (err) {
$.logErr(err);
} else {
if (data) {
data = JSON.parse(data);
if (!data.user) {
return;
}
const userInfo = data.user;
if (userInfo) {
if (!$.nickName)
$.nickName = userInfo.petName;
if ($.beanCount == 0) {
$.beanCount = userInfo.jingBean;
}
$.JingXiang = userInfo.uclass;
}
} else {
$.log('京东服务器返回空数据');
}
}
} catch (e) {
$.logErr(e);
}
finally {
resolve();
}
});
});
}
function isLoginByX1a0He() {
return new Promise((resolve) => {
const options = {
url: 'https://plogin.m.jd.com/cgi-bin/ml/islogin',
headers: {
"Cookie": cookie,
"referer": "https://h5.m.jd.com/",
"User-Agent": "jdapp;iPhone;10.1.2;15.0;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
},
timeout: 10000
}
$.get(options, (err, resp, data) => {
try {
if (data) {
data = JSON.parse(data);
if (data.islogin === "1") {
console.log(`使用X1a0He写的接口加强检测: Cookie有效\n`)
} else if (data.islogin === "0") {
$.isLogin = false;
console.log(`使用X1a0He写的接口加强检测: Cookie无效\n`)
} else {
console.log(`使用X1a0He写的接口加强检测: 未知返回,不作变更...\n`)
$.error = `${$.nickName} :` + `使用X1a0He写的接口加强检测: 未知返回...\n`
}
}
} catch (e) {
console.log(e);
}
finally {
resolve();
}
});
});
}
function getJingBeanBalanceDetail(page) {
return new Promise(async resolve => {
const options = {
"url": `https://api.m.jd.com/client.action?functionId=getJingBeanBalanceDetail`,
"body": `body=${escape(JSON.stringify({"pageSize": "20", "page": page.toString()}))}&appid=ld`,
"headers": {
'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"),
'Host': 'api.m.jd.com',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': cookie,
}
}
$.post(options, (err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`getJingBeanBalanceDetail API请求失败,请检查网路重试`)
} else {
if (data) {
data = JSON.parse(data);
// console.log(data)
} else {
console.log(`京东服务器返回空数据`)
}
}
} catch (e) {
$.logErr(e, resp)
}
finally {
resolve(data);
}
})
})
}
function queryexpirejingdou() {
return new Promise(async resolve => {
const options = {
"url": `https://wq.jd.com/activep3/singjd/queryexpirejingdou?_=${Date.now()}&g_login_type=1&sceneval=2`,
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-cn",
"Connection": "keep-alive",
"Cookie": cookie,
"Host": "wq.jd.com",
"Referer": "https://wqs.jd.com/promote/201801/bean/mybean.html",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Mobile/15E148 Safari/604.1"
}
}
$.get(options, (err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`queryexpirejingdou API请求失败,请检查网路重试`)
} else {
if (data) {
// console.log(data)
data = JSON.parse(data.slice(23, -13));
if (data.ret === 0) {
data['expirejingdou'].map(item => {
if(item['expireamount']!=0){
strGuoqi+=`【${timeFormat(item['time'] * 1000)}】过期${item['expireamount']}豆\n`;
if (decExBean==0)
decExBean=item['expireamount'];
}
})
}
} else {
console.log(`京东服务器返回空数据`)
}
}
} catch (e) {
$.logErr(e, resp)
}
finally {
resolve();
}
})
})
}
function exchangejxbeans(o) {
return new Promise(async resolve => {
var UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
var JXUA = `jdpingou;iPhone;4.13.0;14.4.2;${UUID};network/wifi;model/iPhone10,2;appBuild/100609;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/${Math.random * 98 + 1};pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`;
const options = {
"url": `https://m.jingxi.com/deal/masset/jd2xd?use=${o}&canpintuan=&setdefcoupon=0&r=${Math.random()}&sceneval=2`,
"headers": {
"Host": "m.jingxi.com",
"Accept": "*/*",
"Cookie": cookie,
"Connection": "keep-alive",
"User-Agent": JXUA,
"Accept-Language": "zh-cn",
"Referer": "https://m.jingxi.com/deal/confirmorder/main",
"Accept-Encoding": "gzip, deflate, br",
}
}
$.get(options, (err, resp, data) => {
try {
if (err) {
console.log(err);
} else {
data = JSON.parse(data);
if (data && data.data && JSON.stringify(data.data) === '{}') {
console.log(JSON.stringify(data))
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data || {});
}
})
})
}
function getUUID(x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", t = 0) {
return x.replace(/[xy]/g, function (x) {
var r = 16 * Math.random() | 0,
n = "x" == x ? r : 3 & r | 8;
return uuid = t ? n.toString(36).toUpperCase() : n.toString(36),
uuid
})
}
function redPacket() {
return new Promise(async resolve => {
const options = {
"url": `https://m.jingxi.com/user/info/QueryUserRedEnvelopesV2?type=1&orgFlag=JD_PinGou_New&page=1&cashRedType=1&redBalanceFlag=1&channel=1&_=${+new Date()}&sceneval=2&g_login_type=1&g_ty=ls`,
"headers": {
'Host': 'm.jingxi.com',
'Accept': '*/*',
'Connection': 'keep-alive',
'Accept-Language': 'zh-cn',
'Referer': 'https://st.jingxi.com/my/redpacket.shtml?newPg=App&jxsid=16156262265849285961',
'Accept-Encoding': 'gzip, deflate, br',
"Cookie": cookie,
'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1")
}
}
$.get(options, (err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`redPacket API请求失败,请检查网路重试`)
} else {
if (data) {
data = JSON.parse(data).data;
$.jxRed = 0,
$.jsRed = 0,
$.jdRed = 0,
$.jdhRed = 0,
$.jxRedExpire = 0,
$.jsRedExpire = 0,
$.jdRedExpire = 0,
$.jdhRedExpire = 0;
let t = new Date();
t.setDate(t.getDate() + 1);
t.setHours(0, 0, 0, 0);
t = parseInt((t - 1) / 1000);
for (let vo of data.useRedInfo.redList || []) {
if (vo.orgLimitStr && vo.orgLimitStr.includes("京喜")) {
$.jxRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jxRedExpire += parseFloat(vo.balance)
}
} else if (vo.activityName.includes("极速版")) {
$.jsRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jsRedExpire += parseFloat(vo.balance)
}
} else if (vo.orgLimitStr && vo.orgLimitStr.includes("京东健康")) {
$.jdhRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jdhRedExpire += parseFloat(vo.balance)
}
} else {
$.jdRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jdRedExpire += parseFloat(vo.balance)