-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
67 lines (57 loc) · 1.58 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require_once "reward.php";
function createUuid($num)
{
$str = md5(uniqid(mt_rand(), true));
$uuid = substr($str, 0, $num) . "-";
return $uuid;
}
function num()
{
return mt_rand(10, 1000);
}
function redPocketInfo()
{
$url_pre = "http://www.";
$url_end = ".com";
$body = createUuid(8);
$url = $url_pre . $body . $url_end;
$array["user_id"] = createUuid(4);
$array["nick_name"] = createUuid(5);
$array["create_time"] = time();
$array["url"] = $url;
$array["reward_id"] = createUuid(6);
$array["money"] = num();
$array["total_num"] = (int)round($array['money'] * 1.5);
$array["rest_num"] = mt_rand(0, $array['money']);
$array["lose_num"] = $array['total_num'] - $array['rest_num'];
return $array;
}
$reward = new Reward("voice");
//添加一条数据
$data = redPocketInfo();
$reward->createReward($data["user_id"], $data);
//$array = $reward->getRewardSquare(0, -1);
//添加数据
$user_id = createUuid(4);
$data = redPocketInfo();
echo "开始时间" . date("Y-m-d H:i:s");
for($i = 0; $i <= 1000000; $i++){
$data = redPocketInfo();
$reward->createReward($data["user_id"], $data);
$reward->log("$i","--------");
}
echo "结束时间" . date("Y-m-d H:i:s");
//$reward->getRewardSquare(0, -1);
//抢红包
/*for ($i = 1; $i< 900; $i++ ) {
$user_id = createUuid(4);
$reward_id = "c50ea9-";
$reward->gainReward($user_id, $reward_id);
$reward->log('^^^^^^^^^^^^^^^^^^^^^^', $i);
}*/
/*for ($i = 0; $i < 1000000; $i++){
$res = $reward->redis->get($data['user_id']);
echo $i ."***" . $res . "\n";
}*/
?>