问题描述
我的目标是显示每位用户的总佣金。我已经尝试过了,但我唯一得到的是我自己的佣金,即 503,582.26。我想动态显示佣金。例如:ID 1 = 500,ID 2 = 300,ID = 600。我在下面提供了屏幕截图以供更多解释。任何帮助将不胜感激。谢谢
观看次数:
crsp.comp3 <- structure(list(Permno = c(10026L,10026L,10026L),Observation = 1:10,C.xsgaq = c(45.145,45.145,96.73,145.511,190.986),C.xsgaq.depr = c(44.393,43.653,42.925,92.935,91.386,89.863,136.333,134.061,131.827,174.347)),class = "data.frame",row.names = c(NA,-10L))
> crsp.comp3
Permno Observation C.xsgaq C.xsgaq.depr
1 10026 1 45.145 44.393
2 10026 2 45.145 43.653
3 10026 3 45.145 42.925
4 10026 4 96.730 92.935
5 10026 5 96.730 91.386
6 10026 6 96.730 89.863
7 10026 7 145.511 136.333
8 10026 8 145.511 134.061
9 10026 9 145.511 131.827
10 10026 10 190.986 174.347
控制器:
<?PHP
foreach($result as $rows) { $uuid = $rows->uuid;
$userID = $rows->userID; ?>
<?PHP if($rows->uuid===$_SESSION['uid']): ?>
<tr>
<td><?PHP echo $rows->firstname; ?></td>
<td><?PHP echo $rows->mobile; ?></td>
<td><?PHP echo $rows->account_type; ?></td>
<td><?PHP echo $rows->currentPoints; ?></td>
<td> <?PHP $sum = number_format($commBalance -$commWithdrawn,2); echo ($sum);?></td>
<td>
型号:
public function agents()
{
$data['activeNav'] = "";
$data['subnav'] = "networks";
$this->header($data);
$this->nav();
$data['result'] = $this->networks->getAllData();
$data['commBalance']=$this->load->networks->gettotalcommi();
$data['commWithdrawn']=$this->load->networks->gettotalWithdrawn();
$data['meronResult'] = $this->networks->meronBets();
$data['walaResult'] = $this->networks->walaBets();
$data['tagent']=$this->load->networks->gettotalagent();
$this->load->view('agents',$data);
$this->footer();
}
解决方法
如果我理解正确,您希望通过发布值 USERID 检索数据。并显示个人的“贡献”。
我在您的实施中看到的是,例如,您按 USERID 1 对所有贡献求和,但未按个别贡献者对值进行分组或检索个别贡献者值。
按代理分组示例:
function gettotalcommi(){
return $this->db->select_sum('amount')
->from('agent_commission_history')
->where('commTo',$this->session->userdata('uid'))
->where_in('commType',['commType','in'])
->group_by('commFrom')
->get()->row()->amount;
}
个人获得:
function gettotalcommi(){
return $this->db->select_sum('amount')
->from('agent_commission_history')
->where('commTo',$this->session->userdata('uid'))
// individual
->where('commFrom',$this->input->post('userID'))
->where_in('commType','in'])
->get()->row()->amount;
}
我希望这会有所帮助。如果我误解了你的问题,让我知道。