4,'on_resale'=>2])->sum('endnums'); $config = Config::getConfigByGroup('trade'); $awardBase = isset($config['award_base'])? floatval($config['award_base']['value']) : 0; $award = round($total + $awardBase, 2); $counts = [ 'total'=> CoinRate::transfer($award), 'total_usdt'=> $award, 'award'=> $total, 'award_base'=> $awardBase, ]; return $counts; } /** * 释放统计 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getReleaseTotal($userId) { $total = Trade::where(['status'=> 4,'on_resale'=>1,'relevant_userid'=> $userId])->sum('endnums'); $releaseTotal = Trade::where(['status'=> 4,'on_resale'=>1,'relevant_userid'=> $userId])->sum('release_usdt'); $counts = [ 'total'=> $total, 'release_usdt'=> $releaseTotal, 'surplus_usdt'=> $total-$releaseTotal, ]; return $counts; } /** * 获取用户释放加速值 * @param $userId * @return array|false * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getSpeedTotalByUser($userId) { $uids = User::getLowerIds($userId); if(empty($uids)){ return false; } // 下线销售额,包括自己 $total = Trade::where(['status'=> 4,'on_resale'=>2])->whereIn('userid', $uids)->sum('endnums'); // 加速参数 $config = Config::getConfigByGroup('trade'); $speedRate = isset($config['speed_rate'])? floatval($config['speed_rate']['value']) : 0; $speedUsdt = round($total * $speedRate/100, 2); $counts = [ 'total'=> $total, 'speed_rate'=> $speedRate, 'speed_usdt'=> $speedUsdt, 'speed_total'=> CoinRate::transfer($speedUsdt), 'rate'=> $speedRate, ]; return $counts; } }