Skip to content

Commit 4707b37

Browse files
authored
Update rewardReport.php
1 parent 170181c commit 4707b37

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

settings/rewardReport.php

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,45 @@
22
include_once '../baseInfo.php';
33
include_once '../config.php';
44

5-
if(file_exists("botstate.json")){
6-
$botState = json_decode(file_get_contents("botstate.json"),true);
7-
$sellState=$botState['sellState']=="off"?"خاموش ❌":"روشن ✅";
8-
$searchState=$botState['searchState']=="off"?"خاموش ❌":"روشن ✅";
9-
$rewaredTime = ($botState['rewaredTime']??0);
10-
$rewaredChannel = $botState['rewardChannel'];
115

12-
if($rewaredTime>0 && $rewaredChannel != null){
13-
$lastTime = $botState['lastRewardMessage']??0;
14-
if(time() > $lastTime){
15-
$time = time() - ($rewaredTime * 60 * 60);
16-
$stmt = $connection->prepare("SELECT SUM(amount) as total FROM `orders_list` WHERE `date` > ?");
17-
$stmt->bind_param("i", $time);
18-
$stmt->execute();
19-
$totalRewards = number_format($stmt->get_result()->fetch_assoc()['total']) . " تومان";
20-
$stmt->close();
21-
$botState['lastRewardMessage']=time() + ($rewaredTime * 60 * 60);
22-
file_put_contents("botstate.json",json_encode($botState));
23-
$txt = "   
6+
$sellState=$botState['sellState']=="off"?"خاموش ❌":"روشن ✅";
7+
$searchState=$botState['searchState']=="off"?"خاموش ❌":"روشن ✅";
8+
$rewaredTime = ($botState['rewaredTime']??0);
9+
$rewaredChannel = $botState['rewardChannel'];
10+
11+
if($rewaredTime>0 && $rewaredChannel != null){
12+
$lastTime = $botState['lastRewardMessage']??0;
13+
if(time() > $lastTime){
14+
$time = time() - ($rewaredTime * 60 * 60);
15+
$stmt = $connection->prepare("SELECT SUM(amount) as total FROM `orders_list` WHERE `date` > ?");
16+
$stmt->bind_param("i", $time);
17+
$stmt->execute();
18+
$totalRewards = number_format($stmt->get_result()->fetch_assoc()['total']) . " تومان";
19+
$stmt->close();
20+
21+
$botState['lastRewardMessage']=time() + ($rewaredTime * 60 * 60);
22+
23+
$stmt = $connection->prepare("SELECT * FROM `setting` WHERE `type` = 'BOT_STATES'");
24+
$stmt->execute();
25+
$isExists = $stmt->get_result();
26+
$stmt->close();
27+
if($isExists->num_rows>0) $query = "UPDATE `setting` SET `value` = ? WHERE `type` = 'BOT_STATES'";
28+
else $query = "INSERT INTO `setting` (`type`, `value`) VALUES ('BOT_STATES', ?)";
29+
$newData = json_encode($botState);
30+
31+
$stmt = $connection->prepare($query);
32+
$stmt->bind_param("s", $newData);
33+
$stmt->execute();
34+
$stmt->close();
35+
36+
$txt = "   
2437
🔰درآمد من در $rewaredTime ساعت گذشته
2538
2639
💰مبلغ : $totalRewards تومان
2740
2841
☑️ $channelLock
2942
3043
";
31-
sendMessage($txt, null, null, $rewaredChannel);
32-
}
33-
}
34-
}
44+
sendMessage($txt, null, null, $rewaredChannel);
45+
}
46+
}

0 commit comments

Comments
 (0)