1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php namespace Place\Lib;
- use Dever;
- class Agent
- {
-
- public function getList($state = true)
- {
- $data = array();
- if ($state) {
- $data = array
- (
- 0 => 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;
- }
- }
|