WalletLogService.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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\ActionLogModel;
  13. use App\Models\WalletLogModel;
  14. use App\Services\BaseService;
  15. /**
  16. * 承兑商管理-服务类
  17. * @author laravel开发员
  18. * @since 2020/11/11
  19. * @package App\Services\Common
  20. */
  21. class WalletLogService extends BaseService
  22. {
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. */
  28. public function __construct()
  29. {
  30. $this->model = new WalletLogModel();
  31. }
  32. /**
  33. * 获取列表
  34. * @param $params 参数
  35. * @param int $pageSize 分页大小:默认 15
  36. * @return array
  37. */
  38. public function getDataList($params, $pageSize = 10, $field = [])
  39. {
  40. $where = ['a.mark' => 1];
  41. if (!empty($params['token_type']) && $params['token_type']) {
  42. $where['a.token_type'] = intval($params['token_type']);
  43. }
  44. if (isset($params['status']) && $params['status'] != '') {
  45. $where['a.status'] = $params['status'];
  46. }
  47. if(isset($params['owner_address']) && $params['owner_address']){
  48. $where['owner_address'] = trim($params['owner_address']);
  49. }
  50. if(isset($params['to_address']) && $params['to_address']){
  51. $where['to_address'] = trim($params['to_address']);
  52. }
  53. if(isset($params['hash']) && $params['hash']){
  54. $where['hash'] = trim($params['hash']);
  55. }
  56. $list = $this->model
  57. ->from('wallet_log as a')
  58. ->where($where)
  59. ->select($field ? $field : ['a.*'])
  60. ->paginate($pageSize > 0 ? $pageSize : 9999999);
  61. $list = $list ? $list->toArray() : [];
  62. if ($list) {
  63. foreach ($list['data'] as &$item){
  64. $item['create_time'] = $item['create_time']?datetime($item['create_time'],'Y-m-d H:i:s'):'';
  65. }
  66. }
  67. return [
  68. 'pageSize' => $pageSize,
  69. 'total' => isset($list['total']) ? $list['total'] : 0,
  70. 'list' => isset($list['data']) ? $list['data'] : []
  71. ];
  72. }
  73. /**
  74. * @return array
  75. */
  76. public function delete()
  77. {
  78. ActionLogModel::setTitle("删除钱包交易记录");
  79. ActionLogModel::record();
  80. $this->model->where('create_time','<=', time() - 7 * 86400)->where(['mark'=>0])->delete();
  81. return parent::delete(); // TODO: Change the autogenerated stub
  82. }
  83. }