Commit fe11ff22 by haojie

1

parent 904a2075
......@@ -101,10 +101,14 @@ protected function grid()
});
# winner_list-中奖钱包
$grid->column('winner_list', '中奖钱包')->display(function ($item) {
$list = ['12', '234'];
$json = json_encode($list);
$json = json_decode($json);
if (count($json)) {
$json = json_decode($item);
if (!$json) {
return '暂无';
}
return '点击展开';
})->expand(function () {
$json = json_decode($this->winner_list);
if ($json && count($json)) {
# 是数组
$div = '';
foreach ($json as $value) {
......
......@@ -44,11 +44,10 @@ public function handle()
BlindBoxList::query()->where('id', $value->id)->update(['status' => $status]);
}
}
Log::error('结束运行了');
} catch (\Exception $e) {
Log::error($e);
}
sleep(5);
return Command::SUCCESS;
}
}
......@@ -4,10 +4,8 @@
namespace App\Http\Controllers\API\BlindBox;
use App\Models\BlindBoxList;
use App\Models\UserWallet;
use Illuminate\Support\Facades\Log;
class OpenPrizeController
{
/**
......@@ -15,12 +13,11 @@ class OpenPrizeController
*/
public function useOpenPrize($item)
{
Log::error('进入');
# 已购买人数
$purchased = json_decode($item->purchased);
# 可中奖人数
$winner_num = $item->winner_num;
if ($purchased && count($purchased) && count($purchased) > $item->min_participants_num) {
if ($purchased && count($purchased) && count($purchased) >= $item->min_participants_num) {
# 计算购买者应有的中奖几率
#平均值
$average_value = 100 / count($purchased);
......@@ -44,22 +41,19 @@ public function useOpenPrize($item)
$values->rate = $not_invite_rate;
}
}
}
# 开奖 - address-invite_num-rate---$winner_num
$while_status = true;
# 开奖 -
$while_status = 1;
$winner_list = json_decode($item->winner_list);
while ($while_status) {
# 直到抽奖人数达标
if ($winner_list && count($winner_list) >= $winner_num) {
$while_status = false;
$while_status = 0;
continue;
}
$res = self::get_prize($purchased);
Log::error($res);
if ($res) {
if ($winner_list && count($winner_list)) {
# 数组已存在
foreach ($winner_list as $win_item) {
if ($win_item == $res) {
continue;
......@@ -76,16 +70,20 @@ public function useOpenPrize($item)
$winner_list = $list;
}
} else {
Log::error('空地址');
$while_status = false;
$while_status = 0;
Log::error('未取到中奖地址');
}
$while_status += 1;
if ($while_status == 100) {
$while_status = 0;
Log::error('本次开奖已经循环一百次,请查看问题');
}
$while_status = false;
}
Log::error('结束');
# 更新数据
BlindBoxList::query()->where('id', $item->id)->update(['winner_list' => json_encode($winner_list),
'purchased' => json_encode($purchased)]);
}
}
public function get_prize($list)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment