123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- /**
- * 提现列表
- * @author system
- * @version 1.0
- * @date 2017-06-30 18:18:37
- *
- */
- namespace App\Http\Controllers\Admin\User\Cash;
- use App\Http\Controllers\Admin\Controller;
- use App\Models\AccountLog;
- use App\Models\SystemInfoModel;
- use App\Models\UserCashOut;
- use App\Models\UserInfoModel;
- use Illuminate\Http\Request;
- use App\Repositories\Base\Criteria\OrderBy;
- use App\Repositories\User\Cash\Criteria\MultiWhere;
- use App\Repositories\User\Cash\OutRepository;
- use App\Helper\JpushHelper;
- class OutController extends Controller
- {
- private $repository;
- use JpushHelper;
- public function __construct(OutRepository $repository) {
- if(!$this->repository) $this->repository = $repository;
- }
- function index(Request $reqeust) {
- $search['keyword'] = $reqeust->input('keyword');
- $query = $this->repository->pushCriteria(new MultiWhere($search));
- $request = $reqeust->all();
- if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
- $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
- }
- $list = $query->paginate();
- return view('admin.user.cash.out.index',compact('list'));
- }
- function check(Request $reqeust) {
- $request = $reqeust->all();
- $search['keyword'] = $reqeust->input('keyword');
- $orderby = array();
- if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
- $orderby[$request['sort_field']] = $request['sort_field_by'];
- }
- $list = $this->repository->search($search,$orderby);
- return view('admin.user.cash.out.check',compact('list'));
- }
- /**
- * 添加
- *
- */
- public function create(Request $reqeust)
- {
- if($reqeust->method() == 'POST') {
- return $this->_createSave();
- }
- return view('admin.user.cash.out.edit');
- }
- /**
- * 保存修改
- */
- private function _createSave(){
- $data = (array) request('data');
- $id = $this->repository->create($data);
- if($id) {
- $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
- $url[] = array('url'=>U( 'User/Cash/Out/create'),'title'=>'继续添加');
- $this->showMessage('添加成功',$url);
- }else{
- $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
- return $this->showWarning('添加失败',$url);
- }
- }
-
- /**
- *
- * 修改
- *
- *
- */
- public function update(Request $reqeust) {
- if($reqeust->method() == 'POST') {
- return $this->_updateSave();
- }
- $data = $this->repository->find($reqeust->get('id'));
- return view('admin.user.cash.out.edit',compact('data'));
- }
- /**
- * 保存修改
- */
- private function _updateSave() {
- $data = (array) request('data');
- $info = UserCashOut::find(request('id'));
- if ($data['status'] != 1) { //审核不过已打款发送梦想消息
- if ($data['status'] == 3) {
- $message = '你的提现被拒绝了。客服会在短时间内联系你。';
- }elseif($data['status'] == 4){
- $message = '亲,你的提现我们已经审批通过,你的梦想基金很快就到账了哦!';
- }else{
- // 已打款 记录提现日志 并且用户的账号梦想币减少
- if ($info['status']!=2) { //避免重复操作
- $user = UserInfoModel::find($data['user_id']);
- $user->coin -=$data['cash'];
- $user->save();
- if (!empty($user)) {
- $arr = [
- 'from_type'=>'梦想币',
- 'from_id'=>$data['user_id'],
- 'from_name'=>$user->nickname,
- 'op'=>'提现',
- 'from_amount'=>$data['cash'],
- 'to_type'=>'现金',
- 'to_id'=>$data['user_id'],
- 'to_name'=>$user->nickname,
- 'to_amount'=>$data['cash'],
- 'channel'=>'平台内',
- 'transaction_id'=>$info->number,
- 'avatar'=>env('APP_URL').'/base/img/jianhao.png',
- ];
- AccountLog::create($arr);
- }
- }
- $message = '你提现的¥'.$data['cash'].'已经到账啦,去实现梦想吧!喵~';
- // $this->jPush($message,'',$data['user_id']);
- }
- $arr = [
- 'type_id'=>1,
- 'attr_id'=>4,
- 'to_user_id'=>$data['user_id'],
- 'message'=>$message,
- ];
- SystemInfoModel::firstOrCreate($arr);
- }
- $ok = $this->repository->update(request('id'),$data);
- if($ok) {
- $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
- return $this->showMessage('操作成功',urldecode(request('_referer')));
- }else{
- $url[] = array('url'=>U( 'User/Cash/Out/index'),'title'=>'返回列表');
- return $this->showWarning('操作失败',$url);
- }
- }
- public function view(Request $reqeust) {
- $data = $this->repository->find(request('id'));
- return view('admin.user.cash.out.view',compact('data'));
- }
- /**
- *
- * 状态改变
- *
- */
- public function status(Request $reqeust) {
- $ok = $this->repository->updateStatus(request('id'),request('status'));
- if($ok) {
- return $this->showMessage('操作成功');
- }else{
- return $this->showWarning('操作失败');
- }
- }
-
- /**
- * 删除
- */
- public function destroy(Request $reqeust) {
- $bool = $this->repository->destroy($reqeust->get('id'));
- if($bool) {
- return $this->showMessage('操作成功');
- }else{
- return $this->showWarning("操作失败");
- }
- }
- }
|