page((int)$page, (int)$limit)->select()->each(function ($item) { $item['l1'] = $item['l1_money'] . get_money_name($item['l1_money_type']); $item['l2'] = $item['l2_money'] . get_money_name($item['l2_money_type']); $item['l3'] = $item['l3_money'] . get_money_name($item['l3_money_type']); $item['type'] = $item['group_type']?'大公排':'小公排'; }); $count = $model->count(); return compact('data', 'count'); } public static function getDetail($id, $uid = 0) { $model = new self(); $info = $model->where('id', $id)->find()->toArray(); $info['l1_money_type'] = get_money_name($info['l1_money_type']); $info['l2_money_type'] = get_money_name($info['l2_money_type']); $info['l3_money_type'] = get_money_name($info['l3_money_type']); if ($uid) { $info['my_joins'] = ActivityJoin::where('uid', $uid)->where('aid', $id)->order('add_time', 'desc')->select(); $info['my_last_join'] = ActivityJoin::where('uid', $uid)->where('aid', $id)->order('add_time', 'desc')->find(); $info['income'] = ActivityCheck::where('to_uid', $uid)->where('aid', $id)->where('status', 1)->group('money_type')->field('sum(money) as money,money_type')->select(); $info['income_lock'] = UserBill::where('uid', $uid)->where('aid', $id)->where('pm', 1)->where('type', 'activity_income')->where('status', 0)->group('category')->field('sum(number) as money,category as money_type')->select(); $info['expend'] = ActivityCheck::where('uid', $uid)->where('aid', $id)->where('status', 1)->group('money_type')->field('sum(money) as money,money_type')->select(); $info['join_count'] = ActivityJoin::where('uid', $uid)->where('aid', $id)->count(); if ($info['my_last_join']) { if ($info['my_last_join']['status'] >= 3) { $user = User::getUserInfo($uid); $gp_point = ActivityJoin::getUpPoint($user, $id, 1); $info['next_join'] = [ 'group_num' => $gp_point, 'status' => 1, ]; $up_user = intval(ceil(($gp_point - 1) / $info['explode_num'])); $uper_info = ActivityJoin::where('aid', $id)->where('group_num', $up_user)->find(); if (!$uper_info) { $info['next_checker'] = ['nickname' => '系统', 'uid' => 0]; } else { $info['next_checker'] = User::getUserInfo($uper_info['uid']); } } else { $gp_point = $info['my_last_join']['group_num']; for ($i = 0; $i < $info['my_last_join']['status'] + 1; $i++) { $gp_point = intval(ceil(($gp_point - 1) / $info['explode_num'])); } $info['my_last_join']['status'] = $info['my_last_join']['status'] + 1; $info['next_join'] = $info['my_last_join']; // $info['next_join']['status']++; $uper_info = ActivityJoin::where('aid', $id)->where('group_num', $gp_point)->find(); if (!$uper_info) { $info['next_checker'] = ['nickname' => '系统', 'uid' => 0]; } else { $info['next_checker'] = User::getUserInfo($uper_info['uid']); } } } else { $user = User::getUserInfo($uid); $gp_point = ActivityJoin::getUpPoint($user, $id); $info['next_join'] = [ 'group_num' => $gp_point, 'status' => 1, ]; $up_user = intval(ceil(($gp_point - 1) / $info['explode_num'])); $uper_info = ActivityJoin::where('aid', $id)->where('group_num', $up_user)->find(); if (!$uper_info) { $info['next_checker'] = ['nickname' => '系统', 'uid' => 0]; } else { $info['next_checker'] = User::getUserInfo($uper_info['uid']); } } } return $info; } }