MoneyDetailsController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Http\Controllers\MoneyDetail\Front;
  3. use App\Http\Controllers\FrontController;
  4. use App\Models\MoneyDetail;
  5. use App\Models\MoneyDetails;
  6. use App\Servers\MoneyDetailServer;
  7. use Carbon\Carbon;
  8. use Illuminate\Support\Facades\Auth;
  9. class MoneyDetailsController extends FrontController
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. /**
  16. * @param int $size
  17. * @return \Illuminate\Http\JsonResponse
  18. *
  19. * 货币
  20. */
  21. public function index($size = 20)
  22. {
  23. $status=request()->input('status','0');
  24. $type = request()->input('coin_id', 1);
  25. if($status==2 && $type==3){
  26. $status=[5,6,7,11,12,13,21];
  27. }else{
  28. $status=['1',2,3,4,8,9,10,14,15,20,22];
  29. }
  30. $details = MoneyDetails::where('type', $type)
  31. ->whereIn('status', $status)
  32. ->where('member_id', $this->member->{'id'})
  33. ->orderBy('id', 'desc')
  34. ->paginate($size);
  35. $data = array();
  36. foreach ($details as $key => $detail) {
  37. if ($detail->add_reduce == 2) {
  38. $data[$key]['price'] = -$detail->price; // 转出数目
  39. } else {
  40. $data[$key]['price'] = $detail->price; // 转出数目
  41. }
  42. $data[$key]['remainder'] = $detail->remainder; // 余
  43. $data[$key]['id'] = $detail->id; // 余
  44. if (request()->input('lang', 'zh') == 'zh') {
  45. $data[$key]['mark'] = $detail->mark; // 明细
  46. $data[$key]['status_str'] = MoneyDetailServer::$status_map[$detail->status];
  47. } else {
  48. $data[$key]['mark'] = $detail->mark_en; // 明细
  49. $data[$key]['status_str'] = MoneyDetailServer::$status_map_en[$detail->status];
  50. }
  51. $data[$key]['created_at'] = Carbon::parse($detail->created_at, config('app.timezone'))->format('Y/m/d H:i'); // 时间
  52. }
  53. return $this->apiResponseSuccess($data, 'member.yes');
  54. }
  55. /**
  56. * 获取明细详情
  57. * @return \Illuminate\Http\JsonResponse
  58. */
  59. function info()
  60. {
  61. $id = request()->input('id',1);
  62. // withdraw_config
  63. $details = MoneyDetails::where('id', $id)->first()->toArray();
  64. $details['coin_name'] = MoneyDetailServer::$type_map[$details['type']];
  65. if (request()->input('lang', 'zh') == 'zh') {
  66. $details['status_str'] = MoneyDetailServer::$status_map[$details['status']];
  67. } else {
  68. $details['mark'] = $details['mark_en'] ; // 明细
  69. $details['status_str'] = MoneyDetailServer::$status_map_en[$details['status']];
  70. }
  71. return $this->apiResponseSuccess($details, 'member.yes');
  72. }
  73. }