WithdrawController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. namespace app\admin\controller;
  3. use think\exception\ValidateException;
  4. use app\model\Withdraw;
  5. use app\model\Message;
  6. use app\model\Agent;
  7. use app\model\Technical;
  8. use app\model\Store;
  9. use app\model\Tuanzhang;
  10. use app\model\MemberBankcard;
  11. class WithdrawController extends Base
  12. {
  13. function getPath()
  14. {
  15. $path = input('post.path', '', 'serach_in');
  16. if (!empty($path)) {
  17. $tmppath = explode('/', $path);
  18. }
  19. return $tmppath;
  20. }
  21. function index()
  22. {
  23. $weid = weid();
  24. $path = input('post.path', '', 'serach_in');
  25. //$mo = input('post.mo', '', 'serach_in');
  26. $page = input('post.page', 1, 'intval');
  27. $keyword = input('post.keyword', '', 'serach_in');
  28. $query = Withdraw::where(['weid' => $weid]);
  29. $mo = $this->getPath()[2];
  30. if (!empty($mo)) {
  31. $query->where('mo', $mo);
  32. }
  33. if (!empty($this->sid)) {
  34. $query->where('sid', $this->sid);
  35. }
  36. if (!empty($this->ocid)) {
  37. $query->where('ocid', $this->ocid);
  38. }
  39. if (!empty($mo)) {
  40. $query->where('mo', $mo);
  41. }
  42. $res = $query->order('id desc')
  43. ->paginate(getpage())
  44. ->toArray();
  45. foreach ($res['data'] as &$vo) {
  46. $vo['sid'] = Store::getTitle($vo['sid']);
  47. $vo['MemberBankcard'] = MemberBankcard::getbankcard($vo['bid']);
  48. if ($vo['mo'] == 'agent') {
  49. $vo['username'] = Agent::getTitle($vo['uid']);
  50. } elseif ($vo['mo'] == 'technical') {
  51. $vo['username'] = Technical::getTitlebyuid($vo['uid']);
  52. } elseif ($vo['mo'] == 'store') {
  53. $vo['username'] = Store::getTitlebyuid($vo['uid']);
  54. } elseif ($vo['mo'] == 'tuanzhang') {
  55. $vo['username'] = Tuanzhang::getTitlebyuid($vo['uid']);
  56. }
  57. }
  58. $data['data'] = $res;
  59. return $this->json($data);
  60. }
  61. function listUpdate()
  62. {
  63. $data = only('id,status,sort');
  64. if (!$data['id']) throw new ValidateException('参数错误');
  65. if ($data['status'] == 1) {
  66. $res = Withdraw::audit($data['id']);
  67. if (!empty($res['code'])) {
  68. return $this->json(['msg' => '审核成功']);
  69. } else {
  70. throw new ValidateException($res['return_msg'] . $res['err_code_des']);
  71. }
  72. }
  73. Withdraw::update($data);
  74. return $this->json(['msg' => '操作成功']);
  75. }
  76. function getInfo()
  77. {
  78. $id = $this->request->post('id', '', 'serach_in');
  79. if (!$id) throw new ValidateException('参数错误');
  80. $data = Withdraw::find($id);
  81. if (!empty($data)) {
  82. $data = $data->toArray();
  83. if ($data['mo'] == 'agent') {
  84. $data['username'] = Agent::getTitle($data['uid']);
  85. } elseif ($data['mo'] == 'technical') {
  86. $data['username'] = Technical::getTitle($data['uid']);
  87. } elseif ($data['mo'] == 'store') {
  88. $data['username'] = Store::getTitlebyuid($data['uid']);
  89. } elseif ($data['mo'] == 'tuanzhang') {
  90. $data['username'] = Tuanzhang::getTitlebyuid($data['uid']);
  91. }
  92. $data['MemberBankcard'] = MemberBankcard::getbankcard($data['bid']);
  93. }
  94. return $this->json(['data' => $data]);
  95. }
  96. public function audit()
  97. {
  98. $id = $this->request->post('id');
  99. $res = Withdraw::audit($id);
  100. if (!empty($res['code'])) {
  101. return $this->json(['msg' => '审核成功']);
  102. } else {
  103. return $this->json(['msg' => $res['return_msg'] . $res['err_code_des']]);
  104. }
  105. }
  106. function delete()
  107. {
  108. return $this->del(new Withdraw());
  109. }
  110. }