kyle 2 anni fa
parent
commit
37d894a9ca

+ 18
- 2
app/Http/Controllers/Web/Api2021Controller.php Vedi File

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

+ 5
- 0
app/Http/Services/Web/Api2021Service.php Vedi File

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

+ 31
- 0
public/testapi/testapi.html Vedi File

17
     <form>
17
     <form>
18
         <button class="info">Send Info</button>
18
         <button class="info">Send Info</button>
19
         <button class="game">Send Game</button>
19
         <button class="game">Send Game</button>
20
+        <button class="redeem">Redeem</button>
20
     </form>
21
     </form>
21
     <hr>
22
     <hr>
22
     <div class="output"></div>
23
     <div class="output"></div>
83
                 $.unblockUI();
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
 </script>
118
 </script>
88
 </body>
119
 </body>