WalletService.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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\ActionLogModel;
  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 WalletService extends BaseService
  27. {
  28. /**
  29. * 构造函数
  30. * @author laravel开发员
  31. * @since 2020/11/11
  32. */
  33. public function __construct()
  34. {
  35. $this->model = new WalletModel();
  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. // $status = isset($params['status'])? $params['status'] : 0;
  47. // if($status > 0){
  48. // $where['a.status'] = $status;
  49. // }
  50. if (!empty($params['type'])) {
  51. $where['a.type'] = $params['type'];
  52. }
  53. if (isset($params['status']) && $params['status'] != '') {
  54. $where['a.status'] = $params['status'];
  55. }
  56. $list = $this->model
  57. ->from('wallet 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_text'] = $item['create_time']? datetime($item['create_time']):'';
  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. * 添加会编辑会员
  75. * @return array
  76. * @since 2020/11/11
  77. * @author laravel开发员
  78. */
  79. public function edit()
  80. {
  81. // 请求参数
  82. $data = request()->all();
  83. if (!isset($data['address']) || $data['address'] == '') {
  84. return message("地址不能为空", false);
  85. }
  86. if(!empty($data['address'])){
  87. if (!\App\Services\WalletService::make()->checkAddress($data['address'])) {
  88. return message('地址验证失败');
  89. }
  90. }
  91. if (!isset($data['private_key']) || $data['private_key'] == '') {
  92. return message("秘钥不能为空", false);
  93. }
  94. if (!isset($data['name']) || $data['name'] == '') {
  95. return message("钱包名称不能为空", false);
  96. }
  97. if (!isset($data['type']) || $data['type'] == '') {
  98. return message("钱包类型不能为空", false);
  99. }
  100. if (!isset($data['status']) || $data['status'] == '') {
  101. return message("状态不能为空", false);
  102. }
  103. ActionLogModel::setTitle("新增/编辑平台钱包");
  104. ActionLogModel::record();
  105. return parent::edit($data); // TODO: Change the autogenerated stub
  106. }
  107. }