AccuntLogService.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\AcceptorModel;
  13. use App\Models\AccountLogModel;
  14. use App\Models\GoodsCategoryModel;
  15. use App\Models\GoodsModel;
  16. use App\Models\TradeModel;
  17. use App\Services\BaseService;
  18. use Illuminate\Support\Facades\DB;
  19. /**
  20. * 承兑商管理-服务类
  21. * @author laravel开发员
  22. * @since 2020/11/11
  23. * @package App\Services\Common
  24. */
  25. class AccuntLogService extends BaseService
  26. {
  27. /**
  28. * 构造函数
  29. * @author laravel开发员
  30. * @since 2020/11/11
  31. */
  32. public function __construct()
  33. {
  34. $this->model = new AccountLogModel();
  35. }
  36. /**
  37. * 获取列表
  38. * @param $params 参数
  39. * @param int $pageSize 分页大小:默认 15
  40. * @return array
  41. */
  42. public function getDataList($params, $pageSize = 10, $field = [])
  43. {
  44. $where = ['a.mark' => 1];
  45. $query = $this->model->with(['member'])
  46. ->from('account_log as a')
  47. ->leftJoin('member as b', 'b.id', 'a.user_id')
  48. ->where($where)
  49. ->select($field ? $field : ['a.*', 'b.username', 'b.realname']);
  50. if (isset($params['keyword']) && $params['keyword'] != '') {
  51. $query->where(function ($query) use ($params) {
  52. $kw = isset($params['keyword']) ? trim($params['keyword']) : '';
  53. if ($kw) {
  54. $query->where('b.nickname', 'like', "%{$params['keyword']}%")->orWhere('b.realname', 'like', "%{$params['keyword']}%")->orWhere('b.username', 'like', "%{$params['keyword']}%");
  55. }
  56. });
  57. }
  58. if (isset($params['source_order_no']) && $params['source_order_no'] != '') {
  59. $query->where('a.source_order_no', 'like', "%{$params['source_order_no']}%");
  60. }
  61. if (isset($params['user_type'])) {
  62. if (is_array($params['user_type'])) {
  63. $query->whereIn('a.user_type', $params['user_type']);
  64. } else {
  65. if ($params['user_type'] != '') {
  66. $query->where('a.user_type', $params['user_type']);
  67. }
  68. }
  69. }
  70. if (isset($params['type'])) {
  71. if (is_array($params['type'])) {
  72. $query->whereIn('a.type', $params['type']);
  73. } else {
  74. if ($params['type'] != '') {
  75. $query->where('a.type', $params['type']);
  76. }
  77. }
  78. }
  79. if (isset($params['coin_type'])) {
  80. if (is_array($params['coin_type'])) {
  81. $query->whereIn('a.coin_type', $params['coin_type']);
  82. } else {
  83. if ($params['coin_type'] != '') {
  84. $query->where('a.coin_type', $params['coin_type']);
  85. }
  86. }
  87. }
  88. if (isset($params['status'])) {
  89. if (is_array($params['status'])) {
  90. $query->whereIn('a.status', $params['status']);
  91. } else {
  92. if ($params['status'] != '') {
  93. $query->where('a.status', $params['status']);
  94. }
  95. }
  96. }
  97. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  98. $list = $list ? $list->toArray() : [];
  99. if ($list) {
  100. // foreach ($list['data'] as &$item) {
  101. // }
  102. }
  103. return [
  104. 'pageSize' => $pageSize,
  105. 'total' => isset($list['total']) ? $list['total'] : 0,
  106. 'list' => isset($list['data']) ? $list['data'] : []
  107. ];
  108. }
  109. /**
  110. * 添加会编辑会员
  111. * @return array
  112. * @since 2020/11/11
  113. * @author laravel开发员
  114. */
  115. public function edit()
  116. {
  117. // 请求参数
  118. $data = request()->all();
  119. return parent::edit($data); // TODO: Change the autogenerated stub
  120. }
  121. public function count()
  122. {
  123. $num = $this->model->where(['mark' => 0, 'status' => 1])->count();
  124. $usdt = $this->model->where(['mark' => 0, 'status' => 1])->sum('money');
  125. return [
  126. 'num' => $num,
  127. 'usdt' => $usdt
  128. ];
  129. }
  130. }