nodebb-plugin-niki-loyalty 1.0.14 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/library.js +15 -12
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -7,8 +7,8 @@ const routeHelpers = require.main.require('./src/controllers/helpers');
7
7
  const Plugin = {};
8
8
 
9
9
  const SETTINGS = {
10
- pointsPerHeartbeat: 50,
11
- dailyCap: 2500000,
10
+ pointsPerHeartbeat: 5,
11
+ dailyCap: 250,
12
12
  coffeeCost: 250
13
13
  };
14
14
 
@@ -18,9 +18,9 @@ async function addUserLog(uid, type, amount, desc) {
18
18
  ts: Date.now(),
19
19
  type: type, // 'earn' veya 'spend'
20
20
  amt: amount,
21
- txt: desc // "Kahve Keyfi ☕" gibi metin
21
+ txt: desc
22
22
  };
23
- // Öğrenci geçmişine ekle (Son 50 işlem)
23
+ // Öğrenci geçmişine ekle
24
24
  await db.listAppend(`niki:activity:${uid}`, logEntry);
25
25
  await db.listTrim(`niki:activity:${uid}`, -50, -1);
26
26
  }
@@ -33,7 +33,7 @@ async function addKasaLog(staffUid, customerName, customerUid) {
33
33
  cuid: customerUid,
34
34
  amt: SETTINGS.coffeeCost
35
35
  };
36
- // Kasa defterine ekle (Son 100 işlem)
36
+ // Kasa defterine ekle
37
37
  await db.listAppend('niki:kasa:history', logEntry);
38
38
  await db.listTrim('niki:kasa:history', -100, -1);
39
39
  }
@@ -82,20 +82,22 @@ Plugin.init = async function (params) {
82
82
  dailyScore: dailyScore,
83
83
  dailyCap: SETTINGS.dailyCap,
84
84
  dailyPercent: dailyPercent,
85
- history: (history || []).reverse() // En yeni en üstte
85
+ history: (history || []).reverse()
86
86
  });
87
87
  });
88
88
 
89
- // 3. KASA GEÇMİŞİ (Niki Kasa'nın Görmediği Kısım Burasıydı)
89
+ // --- İŞTE EKSİK OLAN KISIM BURASIYDI ---
90
+ // 3. KASA GEÇMİŞİ (Personel Ekranı İçin)
90
91
  router.get('/api/niki-loyalty/kasa-history', middleware.ensureLoggedIn, async (req, res) => {
91
92
  const isAdmin = await user.isAdministrator(req.uid);
92
93
  const isMod = await user.isGlobalModerator(req.uid);
93
94
 
94
95
  if (!isAdmin && !isMod) return res.status(403).json([]);
95
96
 
97
+ // Veritabanından listeyi çek
96
98
  const history = await db.getListRange('niki:kasa:history', 0, -1);
97
99
 
98
- // Kullanıcı resimlerini de ekleyerek gönder
100
+ // Kullanıcı resimlerini de ekleyerek zenginleştir
99
101
  const enrichedHistory = await Promise.all((history || []).reverse().map(async (item) => {
100
102
  const uData = await user.getUserFields(item.cuid, ['picture']);
101
103
  item.picture = uData.picture;
@@ -104,6 +106,7 @@ Plugin.init = async function (params) {
104
106
 
105
107
  res.json(enrichedHistory);
106
108
  });
109
+ // ---------------------------------------
107
110
 
108
111
  // 4. QR OLUŞTUR
109
112
  router.post('/api/niki-loyalty/generate-qr', middleware.ensureLoggedIn, async (req, res) => {
@@ -119,7 +122,7 @@ Plugin.init = async function (params) {
119
122
  return res.json({ success: true, token: token });
120
123
  });
121
124
 
122
- // 5. QR OKUT (Ödeme Alma + LOGLAMA)
125
+ // 5. QR OKUT (Ödeme Alma)
123
126
  router.post('/api/niki-loyalty/scan-qr', middleware.ensureLoggedIn, async (req, res) => {
124
127
  const { token } = req.body;
125
128
 
@@ -137,13 +140,13 @@ Plugin.init = async function (params) {
137
140
  await user.decrementUserFieldBy(customerUid, 'niki_points', SETTINGS.coffeeCost);
138
141
  await db.delete(`niki:qr:${token}`);
139
142
 
140
- // DETAYLI LOG KAYDI
143
+ // LOGLARI KAYDET
141
144
  const customerData = await user.getUserFields(customerUid, ['username', 'picture']);
142
145
 
143
- // Cüzdan için açıklama: "Kahve Keyfi"
146
+ // Cüzdan için: "Kahve Keyfi"
144
147
  await addUserLog(customerUid, 'spend', SETTINGS.coffeeCost, 'Kahve Keyfi ☕');
145
148
 
146
- // Kasa için kayıt
149
+ // Kasa için: Kayıt
147
150
  await addKasaLog(req.uid, customerData.username, customerUid);
148
151
 
149
152
  return res.json({ success: true, customer: customerData, message: 'Onaylandı!' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-niki-loyalty",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Niki The Cat Coffee Loyalty System - Earn points while studying on IEU Forum.",
5
5
  "main": "library.js",
6
6
  "nbbpm": {