|
|
@@ -177,6 +177,11 @@ class Robots
|
|
|
self::build();
|
|
|
}
|
|
|
|
|
|
+ if (count(self::$robots) <= 0) {
|
|
|
+ errlog('build robots failed?');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
foreach (self::$robots as $robot) {
|
|
|
(new RobotsInfoRds)->hset(false, $robot['uid'], $robot);
|
|
|
}
|
|
|
@@ -201,9 +206,14 @@ class Robots
|
|
|
*/
|
|
|
public static function order()
|
|
|
{
|
|
|
- if (!self::$robots) {
|
|
|
+ if (count(self::$robots) <= 0) {
|
|
|
self::from_redis();
|
|
|
}
|
|
|
+
|
|
|
+ if (count(self::$robots) <= 0) {
|
|
|
+ errlog("load robots from redis failed.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 下单人数
|
|
|
$robot_num = tw_rand(0, count(self::$robots) / 2);
|
|
|
|
|
|
@@ -214,6 +224,8 @@ class Robots
|
|
|
$min = $max;
|
|
|
$max = $t;
|
|
|
}
|
|
|
+ debuglog("there will be $robot_num robot making order. will earn: min=$min,max=$max");
|
|
|
+
|
|
|
for ($i = 0; $i < $robot_num; $i++) {
|
|
|
// 下单人UID
|
|
|
$index = tw_rand(0, count(self::$robots));
|
|
|
@@ -230,6 +242,8 @@ class Robots
|
|
|
$robot['value'] = tw_addf($robot['value'], $value, 2);
|
|
|
|
|
|
(new RobotsInfoRds)->hset(false, $uid, $robot);
|
|
|
+
|
|
|
+ debuglog("robot $uid order win $value");
|
|
|
}
|
|
|
}
|
|
|
|