array ( 'id' => -1, 'name' => '无代理', ), ); } $where['status'] = 1; $data = array_merge($data, Dever::db('agent', 'place')->select($where)); return $data; } # 获取代理购买资源的价格 public function getPrice($price, $agent_id, $info_id, $key = 'price', $app = 'content', $type = 1) { if ($agent_id > 0) { $result = ''; $info = Dever::db('agent_price', $app)->select(array('info_id' => $info_id)); if ($info) { foreach ($info as &$v) { if ($v['agent_id'] == $agent_id) { $result = $v[$key]; break; } elseif (!$v['agent_id']) { $result = $v[$key]; } } if ($key == 'per') { if ($result > 0) { return number_format($price * $result, 2); } } elseif ($result || $result === '0') { return number_format($result, 2); } } $info = Dever::db('agent_price', 'place')->find(array('agent_id' => $agent_id, 'type' => $type)); if ($info && $info['per']) { $result = number_format($price * $info['per'], 2); return $result; } } return null; } # 获取佣金 public function getFee($price, $agent_id, $info_id, $app = 'content', $type = 1) { if ($agent_id > 0) { $result = ''; $info = Dever::db('agent_price', $app)->select(array('info_id' => $info_id)); if ($info) { foreach ($info as &$v) { if ($v['agent_id'] == $agent_id) { $result = $v['fee']; break; } elseif (!$v['agent_id']) { $result = $v['fee']; } } if ($result > 0) { return number_format($price * $result/100, 2); } } $info = Dever::db('agent_price', 'place')->find(array('agent_id' => $agent_id, 'type' => $type)); if ($info && $info['fee'] > 0) { $result = number_format($price * $info['fee']/100, 2); return $result; } } return null; } }