kyle 2 лет назад
Родитель
Сommit
37d894a9ca

+ 18
- 2
app/Http/Controllers/Web/Api2021Controller.php Просмотреть файл

@@ -359,6 +359,7 @@ class Api2021Controller extends Controller
359 359
         $this->sisLog['k'] = $lineId;
360 360
         $this->sisLog['memoIn'] = '';
361 361
         $this->sisLog['memoOut'] = '';
362
+
362 363
         // 打點數量限制
363 364
         // 作用範圍: ALL
364 365
         $redis = new Redis();
@@ -375,6 +376,12 @@ class Api2021Controller extends Controller
375 376
             
376 377
             return response()->json(["succ" => false, "err" => '測試點數不能再打了']);
377 378
         }
379
+
380
+        \Log::debug($rlimitkey);
381
+        \Log::debug($redis::get($rlimitkey));
382
+
383
+        return response()->json(["succ" => true, "err" => 'okok']);
384
+
378 385
         // 業務驗證(防重)
379 386
         // 作用範圍: 以人為單位
380 387
         $rkey = $this->settingManagementSv->getSetting()['GAME_ESI_TEST_EVENT_LIMIT'] . '_' . $lineId;
@@ -385,20 +392,25 @@ class Api2021Controller extends Controller
385 392
             
386 393
             return response()->json(["succ" => false, "err" => '您操作過快,請稍後再試']);
387 394
         }
395
+
396
+//        return response()->json(["succ" => true, "err" => 'okok']);
397
+
388 398
         // 業務驗證(是否加入LINE帳號的好友)
389 399
         if (!$this->aSv->lineFriendCheck($lineId)) {
390 400
             $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
391 401
             $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
392
-            
402
+
393 403
             return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
394 404
         }
405
+
395 406
         // 業務驗證(是否在本地有資料)
396 407
         if (!$this->aSv->isPlayer($lineId)) {
397 408
             $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
398 409
             $this->sisLog['memoOut'] = json_encode(['msg' => '請從首頁進入'], JSON_UNESCAPED_UNICODE);
399
-            
410
+
400 411
             return response()->json(["succ" => false, "err" => '請從首頁進入']);
401 412
         }
413
+
402 414
         // 業務驗證(取得當回合的兌獎狀態,包含所有獎項以及可換與否,拿來比對驗證)
403 415
         $canuse = false;
404 416
         foreach ($this->aSv->goodinfo($lineId) as $g) if ($g['id'] == $gid) if ($g['canuse'] == true) $canuse = true;
@@ -408,6 +420,7 @@ class Api2021Controller extends Controller
408 420
             
409 421
             return response()->json(["succ" => false, "err" => '獎項不存在或沒有兌獎所需吉點']);
410 422
         }
423
+
411 424
         // 參數驗證
412 425
         $name = '';
413 426
         $messages = [
@@ -430,6 +443,7 @@ class Api2021Controller extends Controller
430 443
         } else {
431 444
             $name = $request->input('name', '');
432 445
         }
446
+
433 447
         // 業務邏輯(兌點)
434 448
         $redeeminfo = $this->aSv->redeemGood($lineId, $gid, $name);
435 449
         if (!$redeeminfo) {
@@ -438,9 +452,11 @@ class Api2021Controller extends Controller
438 452
             
439 453
             return response()->json(["succ" => false, "err" => '兌換失敗']);
440 454
         }
455
+
441 456
         // 資料整理
442 457
         $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId, 'gid' => $gid], JSON_UNESCAPED_UNICODE);
443 458
         $this->sisLog['memoOut'] = json_encode(['redeeminfo' => $redeeminfo], JSON_UNESCAPED_UNICODE);
459
+
444 460
         // 防重解鎖
445 461
         $redis::del($rkey);
446 462
         

+ 5
- 0
app/Http/Services/Web/Api2021Service.php Просмотреть файл

@@ -510,6 +510,7 @@ class Api2021Service
510 510
             ->get()
511 511
             ->toArray();
512 512
         // 一定有獎項所以不防呆
513
+
513 514
         // 回合資訊 (注意用於兌獎資訊的日期區間判定與玩遊戲不同)
514 515
         $roundinfo = $this->roundManagementDb
515 516
             ->select(['id'])
@@ -525,6 +526,7 @@ class Api2021Service
525 526
         } else {
526 527
             $roundinfo = $roundinfo->toArray();
527 528
         }
529
+
528 530
         // player 準備資料
529 531
         $playerinfo = $this->playerManagementDb->select(['gp'])->where('lineId', $lineId)->get();
530 532
         if (count($playerinfo) == 0) {
@@ -533,6 +535,7 @@ class Api2021Service
533 535
             $playerinfo = $playerinfo->toArray();
534 536
         }
535 537
         $mygp = $playerinfo[0]['gp'];
538
+
536 539
         // 兌獎資訊
537 540
         $redeeminfo = $this->sessionManagementDb
538 541
             ->select(['cid']) // 獎項 ID
@@ -543,6 +546,7 @@ class Api2021Service
543 546
             ->toArray();
544 547
         $redeemIds = [];
545 548
         foreach ($redeeminfo as $r) $redeemIds[] = $r['cid'];
549
+
546 550
         // 整理
547 551
         $res = [];
548 552
         foreach ($goodinfo as $g) {
@@ -567,6 +571,7 @@ class Api2021Service
567 571
             }
568 572
             // 最後一道防線就是新添加的 active 欄位(一般來說如果其他三個偵測有任何一個是 true 的話,canuse 就是 false ;但是當其他三個偵測都是 false 的情況如果 canuse 也是 false 就是該獎項被關閉)
569 573
             if ($g['active'] == GeneralConst::ACTIVE_NO) $canuse = false;
574
+
570 575
             $res[] = [
571 576
                 'id'         => $g['id'],
572 577
                 'lp'         => $g['lp'], // 獎項名

+ 31
- 0
public/testapi/testapi.html Просмотреть файл

@@ -17,6 +17,7 @@
17 17
     <form>
18 18
         <button class="info">Send Info</button>
19 19
         <button class="game">Send Game</button>
20
+        <button class="redeem">Redeem</button>
20 21
     </form>
21 22
     <hr>
22 23
     <div class="output"></div>
@@ -83,6 +84,36 @@
83 84
                 $.unblockUI();
84 85
             });
85 86
         });
87
+
88
+        $(".redeem").click(function (e) {
89
+            e.preventDefault();
90
+
91
+            $.blockUI({
92
+                message: $('.spinner-border'),
93
+                css: {
94
+                    backgroundColor: 'transparent',
95
+                    border: '0'
96
+                },
97
+            });
98
+
99
+            $.ajax({
100
+                type: "post",
101
+                url: 'https://declarepre.taiwanpay.com.tw/api2021/redeem/U4cc26c80531ba9a354a62630307e6a2d/2',
102
+                data: {
103
+                    "name": "Jojo"
104
+                },
105
+                dataType: "json",
106
+                contentType: "application/json;charset=utf-8"
107
+            }).done(function (result) {
108
+                console.log(result)
109
+
110
+            }).fail(function (jqXHR, textStatus) {
111
+                console.log(jqXHR);
112
+                console.log(textStatus);
113
+            }).always(function () {
114
+                $.unblockUI();
115
+            });
116
+        });
86 117
     });
87 118
 </script>
88 119
 </body>