DrawLogsService.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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\DrawLogModel;
  14. use App\Models\LiveGiftModel;
  15. use App\Models\TaskModel;
  16. use App\Models\TradeModel;
  17. use App\Models\WalletModel;
  18. use App\Services\BaseService;
  19. use Illuminate\Support\Facades\DB;
  20. /**
  21. * 承兑商管理-服务类
  22. * @author laravel开发员
  23. * @since 2020/11/11
  24. * @package App\Services\Common
  25. */
  26. class DrawLogsService extends BaseService
  27. {
  28. /**
  29. * 构造函数
  30. * @author laravel开发员
  31. * @since 2020/11/11
  32. */
  33. public function __construct()
  34. {
  35. $this->model = new DrawLogModel();
  36. }
  37. /**
  38. * 获取列表
  39. * @param $params 参数
  40. * @param int $pageSize 分页大小:默认 15
  41. * @return array
  42. */
  43. public function getDataList($params, $pageSize = 10, $field=[])
  44. {
  45. $where = ['a.mark' => 1];
  46. $query = $this->model->with(['member','machine'])
  47. ->from('draw_logs as a')
  48. ->leftJoin('machine as b','b.id','a.machine_id')
  49. ->leftJoin('member as c','c.id','a.user_id')
  50. ->where($where)
  51. ->select($field ? $field : ['a.*']);
  52. if (isset($params['keyword']) && $params['keyword'] != '') {
  53. $query->where(function($query) use($params){
  54. $query->where('c.nickname','like',"%{$params['keyword']}%")->orWhere('c.realname','like',"%{$params['keyword']}%")->orWhere('c.username','like',"%{$params['keyword']}%");
  55. });
  56. }
  57. if (isset($params['machine']) && $params['machine'] != '') {
  58. $query->where(function($query) use($params){
  59. $kw = isset($params['machine'])? trim($params['machine']) : '';
  60. if($kw){
  61. $query->where('b.name','like',"%{$params['machine']}%");
  62. }
  63. });
  64. }
  65. if (isset($params['order_no']) && $params['order_no'] != '') {
  66. $query->where('a.order_no','like',"%{$params['order_no']}%");
  67. }
  68. if (isset($params['status'])) {
  69. if(is_array($params['status'])){
  70. $query->whereIn('a.status',$params['status']);
  71. }else{
  72. if($params['status'] != ''){
  73. $query->where('a.status',$params['status']);
  74. }
  75. }
  76. }
  77. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  78. $list = $list? $list->toArray() :[];
  79. if($list){
  80. // foreach($list['data'] as &$item){
  81. //// $item['create_time_text'] = $item['create_time']? datetime($item['create_time']):'';
  82. // }
  83. }
  84. return [
  85. 'pageSize'=> $pageSize,
  86. 'total'=>isset($list['total'])? $list['total'] : 0,
  87. 'list'=> isset($list['data'])? $list['data'] : []
  88. ];
  89. }
  90. /**
  91. * 添加会编辑会员
  92. * @return array
  93. * @since 2020/11/11
  94. * @author laravel开发员
  95. */
  96. public function edit()
  97. {
  98. // 请求参数
  99. $data = request()->all();
  100. return parent::edit($data); // TODO: Change the autogenerated stub
  101. }
  102. }