CustomAmount.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php namespace App\Http\Controllers\Api;
  2. use App\Models\CustomAmountRecord as CustomAmountRecord;
  3. use App\Models\CustomAmount as Model;
  4. /**
  5. * 用户余额接口
  6. *
  7. * @author jun
  8. *
  9. * */
  10. class CustomAmount extends Api{
  11. /**
  12. * 获取余额记录 /api/custom_amount/get_record_list
  13. *
  14. * @param string $code 授权码
  15. *
  16. * */
  17. public function get_record_list(Model $Model,CustomAmountRecord $CustomAmountRecord){
  18. // 接口验签
  19. // $this->verify_sign();
  20. // 检查登录
  21. $uid = $this->checkLogin();
  22. // 接收参数
  23. $limit = request('limit',15);
  24. // 查询条件
  25. $map = [['custom_uid','=',$uid],['status','=',1]];
  26. // 查询数据
  27. $Paginator = $CustomAmountRecord->query()->where($map)->orderByDesc('id')
  28. ->paginate($limit,['id','buy_type','pay_type','prefix','description','insert_time','pay_time','status','transfer_bill_no']);
  29. // 重置数据
  30. $list = [];
  31. // 获取数据
  32. $list['total'] = $Paginator->total();
  33. $list['current_page'] = $Paginator->currentPage();
  34. $list['per_page'] = $Paginator->perPage();
  35. $list['last_page'] = $Paginator->lastPage();
  36. $list['data'] = $Paginator->items();
  37. // 循环数据
  38. foreach ($list['data'] as $key => $value) {
  39. // 处理时间
  40. $value['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']);
  41. $value['insert_time'] = date('Y-m-d H:i:s',$value['insert_time']);
  42. // 获取子列表
  43. $value['type_state'] = (string) $CustomAmountRecord->getPayType($value['buy_type'],$value['pay_type'],'name');
  44. if ($value['buy_type'] == 2 && $value['status'] == 1){
  45. $value['state'] = '提现中';
  46. }
  47. // 重组
  48. $list['data'][$key] = $value;
  49. }
  50. // 返回结果
  51. return json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
  52. }
  53. }