GmMemLogic.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * GmMemLogic.php UTF-8
  4. *
  5. *
  6. * @date : 2018/6/6 10:45
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\finance;
  13. use huo\logic\member\MemberLogic;
  14. use huo\model\common\CommonModel;
  15. use huo\model\finance\GmMemModel;
  16. use huolib\constant\CommonConst;
  17. class GmMemLogic extends CommonModel {
  18. /**
  19. * @param array $param
  20. *
  21. * @return array
  22. */
  23. protected function getWhere($param = []) {
  24. $_map = [];
  25. if (!empty($param['start_time']) && !empty($param['end_time'])) {
  26. $_map['gm_mem_model.create_time'] = ['between', [strtotime($param['start_time']),
  27. CommonConst::CONST_DAY_SECONDS + strtotime(
  28. $param['end_time']
  29. )]];
  30. } else if (!empty($param['start_time'])) {
  31. $_map['gm_mem_model.create_time'] = ['gt', strtotime($param['start_time'])];
  32. } else if (!empty($param['end_time'])) {
  33. $_map['gm_mem_model.create_time'] = ['lt', CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])];
  34. }
  35. if (!empty($param['mem_id'])) {
  36. $_map['mem_id'] = $param['mem_id'];
  37. }
  38. if (!empty($param['username'])) {
  39. $_mem_ids = (new MemberLogic())->getIdsByUsername($param['username']);
  40. $_map['mem_id'] = ['in', $_mem_ids];
  41. }
  42. if (!empty($param['app_id'])) {
  43. $_map['app_id'] = $param['app_id'];
  44. }
  45. return $_map;
  46. }
  47. public function getField($agent_id) {
  48. return [];
  49. }
  50. /**
  51. * 获取记录
  52. *
  53. * @param $param
  54. * @param string $page
  55. * @param string $order
  56. *
  57. * @return array
  58. */
  59. public function getMemList($param = [], $page = '1,10', $order = '-create_time') {
  60. $_map = $this->getWhere($param);
  61. $_field = [
  62. 'mem_id',
  63. 'app_id',
  64. 'sum_money',
  65. 'total',
  66. 'remain',
  67. ];
  68. return $this->getList($_field, $_map, $page, $order);
  69. }
  70. /**
  71. * 获取列表
  72. *
  73. * @param array $field
  74. * @param array $where
  75. * @param string $page
  76. * @param string $order
  77. *
  78. * @return array
  79. */
  80. public function getList($field = [], $where, $page = '1,10', $order = '-create_time') {
  81. $_map = $where;
  82. $_model = new GmMemModel();
  83. $_count = $_model->alias('gm_mem_model')->where($_map)->count();
  84. if (empty($_count)) {
  85. return [
  86. 'count' => 0,
  87. 'list' => []
  88. ];
  89. }
  90. $_field = $field;
  91. if (empty($field)) {
  92. $_field = [];
  93. }
  94. $_order = $_model->orderFilter($order);
  95. $_datas = $_model
  96. ->alias('gm_mem_model')
  97. ->with('mem')
  98. ->with('game')
  99. ->where($where)
  100. ->field($_field)
  101. ->order($_order)
  102. ->page($page)
  103. ->select();
  104. if (is_object($_datas)) {
  105. $_datas = $_datas->toArray();
  106. }
  107. if (empty($_datas)) {
  108. return [
  109. 'count' => $_count,
  110. 'list' => []
  111. ];
  112. }
  113. return [
  114. 'count' => $_count,
  115. 'list' => $_datas
  116. ];
  117. }
  118. }