OutController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /**
  3. * 提现列表
  4. * @author system
  5. * @version 1.0
  6. * @date 2017-06-30 18:18:37
  7. *
  8. */
  9. namespace App\Http\Controllers\Admin\User\Cash;
  10. use App\Http\Controllers\Admin\Controller;
  11. use App\Models\SystemInfoModel;
  12. use Illuminate\Http\Request;
  13. use App\Repositories\Base\Criteria\OrderBy;
  14. use App\Repositories\User\Cash\Criteria\MultiWhere;
  15. use App\Repositories\User\Cash\OutRepository;
  16. class OutController extends Controller
  17. {
  18. private $repository;
  19. public function __construct(OutRepository $repository) {
  20. if(!$this->repository) $this->repository = $repository;
  21. }
  22. function index(Request $reqeust) {
  23. $search['keyword'] = $reqeust->input('keyword');
  24. $query = $this->repository->pushCriteria(new MultiWhere($search));
  25. $request = $reqeust->all();
  26. if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
  27. $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
  28. }
  29. $list = $query->paginate();
  30. return view('admin.user.cash.out.index',compact('list'));
  31. }
  32. function check(Request $reqeust) {
  33. $request = $reqeust->all();
  34. $search['keyword'] = $reqeust->input('keyword');
  35. $orderby = array();
  36. if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
  37. $orderby[$request['sort_field']] = $request['sort_field_by'];
  38. }
  39. $list = $this->repository->search($search,$orderby);
  40. return view('admin.user.cash.out.check',compact('list'));
  41. }
  42. /**
  43. * 添加
  44. *
  45. */
  46. public function create(Request $reqeust)
  47. {
  48. if($reqeust->method() == 'POST') {
  49. return $this->_createSave();
  50. }
  51. return view('admin.user.cash.out.edit');
  52. }
  53. /**
  54. * 保存修改
  55. */
  56. private function _createSave(){
  57. $data = (array) request('data');
  58. $id = $this->repository->create($data);
  59. if($id) {
  60. $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
  61. $url[] = array('url'=>U( 'User/Cash/Out/create'),'title'=>'继续添加');
  62. $this->showMessage('添加成功',$url);
  63. }else{
  64. $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
  65. return $this->showWarning('添加失败',$url);
  66. }
  67. }
  68. /**
  69. *
  70. * 修改
  71. *
  72. *
  73. */
  74. public function update(Request $reqeust) {
  75. if($reqeust->method() == 'POST') {
  76. return $this->_updateSave();
  77. }
  78. $data = $this->repository->find($reqeust->get('id'));
  79. return view('admin.user.cash.out.edit',compact('data'));
  80. }
  81. /**
  82. * 保存修改
  83. */
  84. private function _updateSave() {
  85. $data = (array) request('data');
  86. if ($data['status'] == 3|| $data['status'] == 2) { //审核不过已打款发送梦想消息
  87. if ($data['status'] == 3) {
  88. $message = '你的提现被拒绝了。客服会在短时间内联系你。';
  89. }else{
  90. $message = '你提现的¥'.$data['cash'].'已经到账啦,去实现梦想吧!喵~';
  91. }
  92. $arr = [
  93. 'type_id'=>1,
  94. 'attr_id'=>4,
  95. 'to_user_id'=>$data['user_id'],
  96. 'message'=>$message,
  97. ];
  98. SystemInfoModel::firstOrCreate($arr);
  99. }
  100. $ok = $this->repository->update(request('id'),$data);
  101. if($ok) {
  102. $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
  103. return $this->showMessage('操作成功',urldecode(request('_referer')));
  104. }else{
  105. $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
  106. return $this->showWarning('操作失败',$url);
  107. }
  108. }
  109. public function view(Request $reqeust) {
  110. $data = $this->repository->find(request('id'));
  111. return view('admin.user.cash.out.view',compact('data'));
  112. }
  113. /**
  114. *
  115. * 状态改变
  116. *
  117. */
  118. public function status(Request $reqeust) {
  119. $ok = $this->repository->updateStatus(request('id'),request('status'));
  120. if($ok) {
  121. return $this->showMessage('操作成功');
  122. }else{
  123. return $this->showWarning('操作失败');
  124. }
  125. }
  126. /**
  127. * 删除
  128. */
  129. public function destroy(Request $reqeust) {
  130. $bool = $this->repository->destroy($reqeust->get('id'));
  131. if($bool) {
  132. return $this->showMessage('操作成功');
  133. }else{
  134. return $this->showWarning("操作失败");
  135. }
  136. }
  137. }