| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Common;
- use App\Models\ActionLogModel;
- use App\Models\WalletModel;
- use App\Services\BaseService;
- use Illuminate\Support\Facades\Auth;
- /**
- * 承兑商管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Common
- */
- class WalletService extends BaseService
- {
- /**
- * 构造函数
- * @author laravel开发员
- * @since 2020/11/11
- */
- public function __construct()
- {
- $this->model = new WalletModel();
- }
- /**
- * 获取列表
- * @param $params 参数
- * @param int $pageSize 分页大小:默认 15
- * @return array
- */
- public function getDataList($params, $pageSize = 10, $field = [])
- {
- $where = ['a.mark' => 1];
- if (!empty($params['type'])) {
- $where['a.type'] = $params['type'];
- }
- if (isset($params['status']) && $params['status'] != '') {
- $where['a.status'] = $params['status'];
- }
- $list = $this->model
- ->from('wallet 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['balance'] = \App\Services\WalletService::make()->getBalance($item['address']);
- $usdtData = \App\Services\WalletService::make()->getUsdtBalance($item['address']);
- $item['usdt'] = isset($usdtData['amount'])? $usdtData['amount'] : '0.00';
- }
- }
- return [
- 'pageSize' => $pageSize,
- 'total' => isset($list['total']) ? $list['total'] : 0,
- 'list' => isset($list['data']) ? $list['data'] : []
- ];
- }
- /**
- * 添加会编辑会员
- * @return array
- * @since 2020/11/11
- * @author laravel开发员
- */
- public function edit()
- {
- // 请求参数
- $data = request()->all();
- if (!isset($data['address']) || $data['address'] == '') {
- return message("地址不能为空", false);
- }
- if(!empty($data['address'])){
- if (!\App\Services\WalletService::make()->checkAddress($data['address'])) {
- return message('地址验证失败');
- }
- }
- if (!isset($data['type']) || $data['type'] == '') {
- return message("钱包类型不能为空", false);
- }
- if (intval($data['type']) ==2 && (!isset($data['private_key']) || $data['private_key'] == '')) {
- return message("秘钥不能为空", false);
- }
- if (!isset($data['name']) || $data['name'] == '') {
- return message("钱包名称不能为空", false);
- }
- if (!isset($data['status']) || $data['status'] == '') {
- return message("状态不能为空", false);
- }
- ActionLogModel::setTitle("新增/修改平台钱包");
- ActionLogModel::record();
- return parent::edit($data); // TODO: Change the autogenerated stub
- }
- }
|