master
elf 3 years ago
parent 7906e1b5c6
commit eb7a9f6390

@ -790,4 +790,75 @@ class ConsoleController extends Think {
M('spend', 'tab_')->where(['promote_id' => ['in', $ids], 'spend_time' => ['egt', $orderTime]])->save(['market_admin_id' => $toPromote['admin_id']]);
} */
}
public function roleHash()
{
$lastId = 0;
do {
$records = M('user_play_info', 'tab_')->field(['id', 'role_id', 'user_id', 'base_game_id'])->where(['id' => ['gt', $lastId]])->limit(1000)->select();
$count = 0;
foreach ($records as $record) {
$lastId = $record['id'];
$salt = 0;
$count ++;
$value = $record['base_game_id'] . '#' . $record['user_id'] . '#' . 0 . '#' . $record['role_id'] . '#' . $salt;
$hashCode = $this->hashCode64($value);
$key = 'role_key:' . $hashCode;
if ($existRecord = Redis::get($key)) {
$existRecord = json_decode($existRecord, true);
if ($record['base_game_id'] == $existRecord['base_game_id'] && $record['user_id'] == $existRecord['user_id'] && $record['role_id'] == $existRecord['role_id']) {
} else {
[$salt, $hashCode] = $this->getNewSalt($record);
M('user_play_info', 'tab_')->where(['id' => $record['id']])->save([
'role_key' => $hashCode,
'role_key_salt' => $salt,
]);
$key = 'role_key:' . $hashCode;
Redis::set($key, json_encode($record));
echo 'UPDATE: ' . $record['id'];
echo "\n";
}
} else {
Redis::set($key, json_encode($record));
}
/* M('user_play_info', 'tab_')->where(['id' => $record['id']])->save([
'role_key' => $hashCode,
'role_key_salt' => $salt,
]); */
}
echo 'SUCCESS_COUNT: ' . $count . ' LAST_ID:' . $lastId;
echo "\n";
} while ($count > 0);
}
private function getNewSalt($record)
{
$salt = 0;
$hashCode = 0;
do {
$salt += 1;
$value = $record['game_id'] . '#' . $record['user_id'] . '#' . 0 . '#' . $record['role_id'] . '#' . $salt;
$hashCode = $this->hashCode64($value);
$key = 'role_key:' . $hashCode;
$existRecord = Redis::get($key);
} while ($existRecord);
return [$salt, $hashCode];
}
private function hashCode64($str) {
$str = (string)$str;
$hash = 0;
$len = strlen($str);
if ($len == 0 )
return $hash;
for ($i = 0; $i < $len; $i++) {
$h = $hash << 5;
$h -= $hash;
$h += ord($str[$i]);
$hash = $h;
$hash &= 0x7FFFFFFF;
}
return $hash;
}
}

@ -42,6 +42,16 @@ class GameRebateController extends ThinkController
$this->records('F');
}
public function newRole()
{
$this->records('G');
}
public function dailySign()
{
$this->records('H');
}
public function records($awardType)
{
$params = I('get.');

@ -200,6 +200,8 @@
<th>达成日期</th>
<?php elseif($awardType == 'F'):?>
<th>可领取福利日期</th>
<?php elseif($awardType == 'H'):?>
<th>签到日期</th>
<?php endif;?>
<th>奖励内容</th>
<th>订单生成时间</th>
@ -245,6 +247,8 @@
<td>{$data.award_date}</td>
<?php elseif($awardType == 'F'):?>
<td>{$data.award_date_range}</td>
<?php elseif($awardType == 'H'):?>
<td>{$data.award_date}</td>
<?php endif;?>
<td>{$data.gift_content}</td>

@ -29,6 +29,8 @@ class GameRebateService
'D' => '首充福利发放',
'E' => '单日累充福利发放',
'F' => '周卡福利发放',
'G' => '首次进游福利',
'H' => '签到福利发放',
];
public $typeNames = [
@ -38,6 +40,8 @@ class GameRebateService
'D' => 'firstPay',
'E' => 'dayAccumulative',
'F' => 'weekly',
'G' => 'newRole',
'H' => 'dailySign',
];
public function isGiftItemSend($order, $item)
@ -296,6 +300,8 @@ class GameRebateService
$fields['award_date'] = '达成日期';
} elseif($awardType == 'F') {
$fields['award_date_range'] = '可领取福利日期';
} elseif($awardType == 'H') {
$fields['award_date'] = '签到日期';
}
$fields = array_merge($fields, [

Loading…
Cancel
Save