Money_take.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. *------Create thems Model------
  4. *------SCWPHP Version 1.0.0------
  5. *------Dev Model Jions------
  6. *------Create Time 2017-06-12 02:45:54------
  7. */
  8. namespace App\Commons\Model;
  9. use \System\Model;
  10. class Money_take extends Model {
  11. protected $table = 'money_take';
  12. /**
  13. * 提现记录查询
  14. *
  15. * @access public
  16. * @param mixed $select 查询字段
  17. * @param mixed $where 查询条件
  18. * @param mixed $orderBy 排序
  19. * @param mixed $order 顺序
  20. * @return array JsonString
  21. */
  22. public function takeRecord($select, $where, $orderBy = 'apply_time', $order = 'desc') {
  23. $result = $this
  24. -> select($select)
  25. -> where($where)
  26. -> orderBy($orderBy, $order)
  27. -> first();
  28. return $result;
  29. }
  30. /**
  31. * 提现记录查询
  32. *
  33. * @access public
  34. * @param mixed $select 查询字段
  35. * @param mixed $where 查询条件
  36. * @param mixed $between 查询区间 demo: ['apply_time' => [2019-04-19 10:46:35, 2019-04-19 10:46:35],'id'=>[99448,99448]];
  37. * @param mixed $begin 起始位置
  38. * @param mixed $pageSize 分页大小
  39. * @param mixed $orderBy 排序 demo: ['apply_time'=>'desc','id'=>'desc']
  40. * @return array JsonString
  41. */
  42. public function moneyTake($select, $where = '', $between = '', $begin = '', $pageSize = '', $orderBy = '') {
  43. $result = $this -> select($select);
  44. if (!empty($where)) {
  45. $result = $result -> where($where);
  46. }
  47. if (!empty($between)) {
  48. foreach ($between as $key => $value) {
  49. $result = $result -> whereBetween($key, $value);
  50. }
  51. }
  52. if (count($begin) && isset($pageSize)) {
  53. $result = $result -> offset($begin) -> limit($pageSize);
  54. }
  55. if (!empty($orderBy)) {
  56. foreach ($orderBy as $key => $value) {
  57. $result = $result -> orderBy($key, $value);
  58. }
  59. } else {
  60. $result = $result -> orderBy('apply_time', 'desc');
  61. }
  62. $result = $result -> get();
  63. return $result;
  64. }
  65. /**
  66. * 提现记录总数
  67. *
  68. * @access public
  69. * @param mixed $where 查询条件
  70. * @param mixed $between 查询条件区间
  71. * @return array JsonString
  72. */
  73. public function moneyTakeTotal($where, $between) {
  74. $result = $this;
  75. if (!empty($where)) {
  76. $result = $result -> where($where);
  77. }
  78. if (!empty($between)) {
  79. foreach ($between as $key => $value) {
  80. $result = $result -> whereBetween($key, $value);
  81. }
  82. }
  83. $result = $result -> count();
  84. return $result;
  85. }
  86. /**
  87. * 添加提现记录
  88. *
  89. * @access public
  90. * @param mixed $data 添加的字段
  91. * @return array JsonString
  92. */
  93. public function insertTake($data) {
  94. $result = $this -> insert($data);
  95. return $result;
  96. }
  97. }