Bill.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace WY\app\model;
  3. use WY\app\libs\Model;
  4. if (!defined('WY_ROOT')) {
  5. exit;
  6. }
  7. class Bill extends Model
  8. {
  9. function __construct()
  10. {
  11. parent::__construct();
  12. $this->config = $this->model()->select()->from('config')->fetchRow();
  13. }
  14. public function fee($money = 0)
  15. {
  16. $fee = 0;
  17. if ($money > 0 && $this->config['tx_fee'] > 0) {
  18. $fee = number_format($this->config['tx_fee'] / 100 * $money, 2, '.', '');
  19. $fee = $fee < 1 ? 1 : $fee;
  20. $fee = $this->config['tx_limit'] > 0 && $fee >= $this->config['tx_limit'] ? $this->config['tx_limit'] : $fee;
  21. }
  22. return $fee;
  23. }
  24. public function todayUserIncome($userid, $is_ship = 0)
  25. {
  26. $where = array('fields' => 'userid=? and is_state=? and is_ship=? and addtime>=?', 'values' => array($userid, 1, $is_ship, strtotime(date('Y-m-d'))));
  27. $order_income = $this->model()->select(array('income' => 'realmoney*uprice'))->from('orders')->where($where)->sum();
  28. return $order_income['income'];
  29. }
  30. public function beforeUserIncome($userid, $is_ship = 0)
  31. {
  32. $where = array('fields' => 'userid=? and is_state=? and is_ship=? and addtime<?', 'values' => array($userid, 1, $is_ship, strtotime(date('Y-m-d'))));
  33. $order_income = $this->model()->select(array('income' => 'realmoney*uprice'))->from('orders')->where($where)->sum();
  34. return $order_income['income'];
  35. }
  36. public function getUserIncome($userid, $fromTime)
  37. {
  38. $where = array('fields' => 'userid=? and is_state=? and is_ship=? and addtime<=?', 'values' => array($userid, 1, 0, $fromTime));
  39. $order_income = $this->model()->select(array('income' => 'realmoney*uprice'))->from('orders')->where($where)->sum();
  40. return $order_income['income'];
  41. }
  42. public function todayAgentIncome($userid, $is_ship = 0)
  43. {
  44. $where = array('fields' => 'agentid=? and is_state=? and is_ship_agent=? and addtime>=?', 'values' => array($userid, 1, $is_ship, strtotime(date('Y-m-d'))));
  45. $order_income = $this->model()->select(array('income' => 'realmoney*(gprice-uprice)'))->from('orders')->where($where)->sum();
  46. return $order_income['income'];
  47. }
  48. public function beforeAgentIncome($userid, $is_ship = 0)
  49. {
  50. $where = array('fields' => 'agentid=? and is_state=? and is_ship_agent=? and addtime<? and gprice>?', 'values' => array($userid, 1, $is_ship, strtotime(date('Y-m-d')), 0));
  51. $order_income = $this->model()->select(array('income' => 'realmoney*(gprice-uprice)'))->from('orders')->where($where)->sum();
  52. return $order_income['income'];
  53. }
  54. }
  55. ?>