'SMH拨币', 2 => 'Qubic拨币', 3 => '团队算力分红', 4 => '团队算力平级奖', 5 => '市场分红', 6 => '加权分红', 7 => '公司推荐奖', 8 => '保持等级', 9 => 'ETC拨币', 10 => 'SMH拨币', 11 => 'Aleo拨币', ]; /** * 拨币 * 向会员发放SMH * 每一万算力每天收益9-10个币 */ public function AllocateSmh() { $type_id = 1; $date = $this->getExeDate($type_id); if(empty($date)){ (new Output())->writeln("本次没有可用时间:" . $date); return ; } //创建定时任务执行日志 $log_id = (new TimedTaskLogModel())->insertGetId([ 'type_id' => $type_id, 'type_name' => $this->rewards_type[$type_id], 'date_time' => $date, 'create_time' => date('Y-m-d H:i:s'), ]); //查找会员资产列表 $info_list = DB::table('ledger_wallet') ->alias('w') ->join('user u','u.id = w.user_id') ->field('user_id,power') ->where('power', '>', 0) ->where('effective_time', '>', 0) //报单有收益 ->select(); if(empty($info_list)){ (new Output())->writeln("本次没有可用会员数据:" . $date); return $log_id; } $num =rand(3000,4000); $power_smh_price = $num/10000/1000;//每算力每日获得SMH的数量,算法为每一万算力每日产10个SMH foreach ($info_list as $info) { $amount = ($info['power']) * $power_smh_price; $check = (new LedgerSmhChangeModel()) ->where('user_id', $info['user_id']) ->where('action', LedgerSmhChangeModel::SysSend) ->where('from_id', strtotime($date)) ->count(); if($check){ dump('用户ID:' . $info['user_id'] . '已拨过,拨币量为:' . $amount); }else{ dump(['用户ID:' . $info['user_id'],'拨币量为:' . $amount]); //发放 (new LedgerWalletModel)->changeWalletAccount($info['user_id'], Asset::SMH, $amount, LedgerSmhChangeModel::SysSend); } } return $log_id; } /** * 拨币 * 向会员发放qubic * 每一万算力每天收益14-15万个币 */ public function AllocateQubic() { $type_id = 2; $date = $this->getExeDate($type_id); if(empty($date)){ (new Output())->writeln("本次没有可用时间:" . $date); return ; } //创建定时任务执行日志 $log_id = (new TimedTaskLogModel())->insertGetId([ 'type_id' => $type_id, 'type_name' => $this->rewards_type[$type_id], 'date_time' => $date, 'create_time' => date('Y-m-d H:i:s'), ]); //查找会员资产列表 $info_list = DB::table('ledger_wallet') ->alias('w') ->join('user u','u.id = w.user_id') ->field('user_id,power') ->where('power', '>', 0) ->where('effective_time', '>', 0) //报单有收益 ->select(); if(empty($info_list)){ (new Output())->writeln("本次没有可用会员数据:" . $date); return $log_id; } $num =rand(120000,130000); $power_price = $num/10000;//每算力每日获得SMH的数量,算法为每一万算力每日产15万个Qubic foreach ($info_list as $info) { $amount = ($info['power']) * $power_price; $check = (new LedgerQubicChangeModel()) ->where('user_id', $info['user_id']) ->where('action', LedgerQubicChangeModel::SysSend) ->where('from_id', strtotime($date)) ->count(); if($check){ dump('用户ID:' . $info['user_id'] . '已拨过,拨币量为:' . $amount); }else{ dump(['用户ID:' . $info['user_id'],'拨币量为:' . $amount]); //发放 (new LedgerWalletModel)->changeWalletAccount($info['user_id'], Asset::QUBIC, $amount, LedgerQubicChangeModel::SysSend); } } return $log_id; } /** * 拨币 * 向会员发放qubic * 每一万算力每天收益14-15万个币 */ public function AllocateAleo() { $type_id = 11; $date = $this->getExeDate($type_id); if(empty($date)){ (new Output())->writeln("本次没有可用时间:" . $date); return ; } //创建定时任务执行日志 $log_id = (new TimedTaskLogModel())->insertGetId([ 'type_id' => $type_id, 'type_name' => $this->rewards_type[$type_id], 'date_time' => $date, 'create_time' => date('Y-m-d H:i:s'), ]); //查找会员资产列表 $info_list = DB::table('ledger_wallet') ->alias('w') ->join('user u','u.id = w.user_id') ->field('user_id,power') ->where('power', '>', 0) ->where('effective_time', '>', 0) //报单有收益 ->select(); if(empty($info_list)){ (new Output())->writeln("本次没有可用会员数据:" . $date); return $log_id; } $num = mt_rand(4030,4080) / 1000;//每一万算力每日获得Aleo的数量,算法为每一万算力每日产6.5个币,并从2024-9-20开始,每天递减5% // $date1 = '2024-9-26'; // $date2 = date('Y-m-d'); // $diff = strtotime($date2) - strtotime($date1); // // 将时间戳差转换为天数 // $days = floor($diff / (60 * 60 * 24)); // if($days > 0){ // //每日递减3% // $num = $num * pow((1-0.03), $days); // } // if($num < 4){ // $num = $num = mt_rand(3500,4500) / 1000;//每一万算力保底3个币 // } $power_price = $num/10000;//每算力每日获得Aleo的数量,算法为每一万算力每日产6.5个币,并从2024-9-20开始,每天递减5% foreach ($info_list as $info) { $amount = ($info['power']) * $power_price; $check = (new LedgerQubicChangeModel()) ->where('user_id', $info['user_id']) ->where('action', LedgerTokenChangeModel::SysSend) ->where('from_id', strtotime($date)) ->count(); if($check){ dump('用户ID:' . $info['user_id'] . '已拨过,拨币量为:' . $amount); }else{ dump(['用户ID:' . $info['user_id'],'拨币量为:' . $amount]); //发放 (new LedgerWalletModel)->changeWalletAccount($info['user_id'], Asset::TOKEN, $amount, LedgerTokenChangeModel::SysSend); } } return $log_id; } /** * 获取可用日期 * @var array */ protected function getExeDate($type_id = 1) { $today = date('Y-m-d',strtotime("-1day"));//当前时间减一天为最后一次可用时间 $dateInfo = DB::table('timed_task_log') ->where('type_id' ,$type_id) ->where('status', 1) ->order('date_time', 'desc') ->find(); if(empty($dateInfo)){//首次 return $today; } $new_date = date('Y-m-d',strtotime("+1day",strtotime($dateInfo['date_time'])));//最后一次发放日期+1天为本次执行时间 if($new_date > $today){//超过今天 return ""; } return $new_date; } }