Withdraw.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * 提现
  4. */
  5. namespace app\admin\controller\withdraw;
  6. use alipay\AopCertClient;
  7. use alipay\request\AlipayFundTransUniTransferRequest;
  8. use app\admin\logic\UserLogic;
  9. use app\admin\logic\WithdrawLogLogic;
  10. use app\admin\model\dao\WithdrawLog;
  11. use app\admin\traits\Curd;
  12. use app\api\services\AliPayServices;
  13. use app\api\services\ThirdPayServices;
  14. use app\validate\admin\withdraw\withdraw\ReturnServiceMoney;
  15. use EasyAdmin\annotation\ControllerAnnotation;
  16. use EasyAdmin\annotation\NodeAnotation;
  17. use app\common\controller\AdminController;
  18. use app\common\model\WithDrawLogModel;
  19. use jianyan\excel\Excel;
  20. use think\App;
  21. use think\Exception;
  22. use think\exception\ValidateException;
  23. use think\facade\Cache;
  24. use think\facade\Db;
  25. /**
  26. * Class Admin
  27. * @package app\admin\controller\withdraw
  28. * @ControllerAnnotation(title="提现管理处理")
  29. */
  30. class Withdraw extends AdminController
  31. {
  32. public function __construct(App $app, WithDrawLogModel $model)
  33. {
  34. parent::__construct($app);
  35. $this->model = $model;
  36. }
  37. use Curd;
  38. /**
  39. * @NodeAnotation(title="列表")
  40. */
  41. public function index()
  42. {
  43. if ($this->request->isAjax()) {
  44. if (input('selectFields')) {
  45. return $this->selectList();
  46. }
  47. list($page, $limit, $where) = $this->buildTableParames();
  48. Cache::set("WITHDRAW_EXPORT", ['page' => $page, 'limit' => $limit, 'where' => $where]);
  49. list($count, $list) = WithdrawLogLogic::getList($page, $limit, $where, $this->user_map, $this->sort);
  50. $data = [
  51. 'code' => 0,
  52. 'msg' => '',
  53. 'count' => $count,
  54. 'data' => $list,
  55. ];
  56. return json($data);
  57. }
  58. $this->assign('limits',[10, 15, 20, 25, 50, 100]);
  59. return $this->fetch();
  60. }
  61. /**
  62. * @NodeAnotation(title="提现失败")
  63. */
  64. public function withdrawerror($id)
  65. {
  66. if ($this->request->isPost()) {
  67. $post = $this->request->post();
  68. list($return, $msg) = WithdrawLogLogic::withdrawError($id, $post);
  69. $return === true ? $this->success($msg) : $this->error($msg);
  70. }
  71. return $this->fetch();
  72. }
  73. /**
  74. * @NodeAnotation(title="执行提现")
  75. */
  76. public function tx($id)
  77. {
  78. list($return, $msg) = WithdrawLogLogic::tx($id);
  79. $return === true ? $this->success($msg) : $this->error($msg);
  80. }
  81. /**
  82. * @NodeAnotation(title="导出")
  83. */
  84. public function export()
  85. {
  86. list($page, $limit, $where) = $this->buildTableParames();
  87. if (empty($where)) {
  88. $search = Cache::get("WITHDRAW_EXPORT");
  89. $page = $search['page'];
  90. $limit = $search['limit'];
  91. $where = $search['where'];
  92. }
  93. $header = getExportHeader($this->model->getName(), $this->noExportFields);
  94. $list = WithdrawLogLogic::getExportList($where, $page, $limit);
  95. $fileName = time();
  96. return Excel::exportData($list, $header, $fileName, 'xlsx');
  97. }
  98. /**
  99. * @NodeAnotation(title="提现数据")
  100. */
  101. public function withdrawdata()
  102. {
  103. $tx_success = WithdrawLog::SumPracticalMoneyByStatus(1);
  104. $this->assign('tx_success', $tx_success);
  105. $tx = WithdrawLog::SumPracticalMoneyByStatus(0);
  106. $this->assign('tx', $tx);
  107. return $this->fetch();
  108. }
  109. /**
  110. * 退还手续费
  111. * @return mixed
  112. */
  113. public function returnservicemoney()
  114. {
  115. $id = $this->request['id'];
  116. $withdrawLog = new WithdrawLogLogic();
  117. if ($this->request->isPost()) {
  118. $post = $this->request->post();
  119. try {
  120. validate(ReturnServiceMoney::class)->check($post);
  121. } catch (ValidateException $e) {
  122. $this->error($e->getMessage());
  123. }
  124. $result = $withdrawLog->returnServiceMoney($post);
  125. if ($result !== true) {
  126. $this->error($result);
  127. }
  128. $this->success('成功');
  129. }
  130. $withdrawLog->getWithdrawLog($id);
  131. $this->assign('info', $withdrawLog);
  132. return $this->fetch();
  133. }
  134. }