// +---------------------------------------------------------------------- namespace App\Services\Common; use App\Models\ActionLogModel; use App\Models\WalletLogModel; use App\Services\BaseService; /** * 承兑商管理-服务类 * @author laravel开发员 * @since 2020/11/11 * @package App\Services\Common */ class WalletLogService extends BaseService { /** * 构造函数 * @author laravel开发员 * @since 2020/11/11 */ public function __construct() { $this->model = new WalletLogModel(); } /** * 获取列表 * @param $params 参数 * @param int $pageSize 分页大小:默认 15 * @return array */ public function getDataList($params, $pageSize = 10, $field = []) { $where = ['a.mark' => 1]; if (!empty($params['token_type']) && $params['token_type']) { $where['a.token_type'] = intval($params['token_type']); } if (isset($params['status']) && $params['status'] != '') { $where['a.status'] = $params['status']; } if(isset($params['owner_address']) && $params['owner_address']){ $where['owner_address'] = trim($params['owner_address']); } if(isset($params['to_address']) && $params['to_address']){ $where['to_address'] = trim($params['to_address']); } if(isset($params['hash']) && $params['hash']){ $where['hash'] = trim($params['hash']); } $list = $this->model ->from('wallet_log as a') ->where($where) ->select($field ? $field : ['a.*']) ->paginate($pageSize > 0 ? $pageSize : 9999999); $list = $list ? $list->toArray() : []; if ($list) { foreach ($list['data'] as &$item){ $item['create_time'] = $item['create_time']?datetime($item['create_time'],'Y-m-d H:i:s'):''; } } return [ 'pageSize' => $pageSize, 'total' => isset($list['total']) ? $list['total'] : 0, 'list' => isset($list['data']) ? $list['data'] : [] ]; } /** * @return array */ public function delete() { ActionLogModel::setTitle("删除钱包交易记录"); ActionLogModel::record(); $this->model->where('create_time','<=', time() - 7 * 86400)->where(['mark'=>0])->delete(); return parent::delete(); // TODO: Change the autogenerated stub } }