浏览代码

充值提现

dyjh 6 年之前
父节点
当前提交
32a455ae1c

+ 139 - 0
app/Http/Controllers/Admin/Wechat/AppController.php

xqd
@@ -0,0 +1,139 @@
+<?php
+/**
+ *  11
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-07-26 01:43:25
+ *
+ */
+namespace App\Http\Controllers\Admin\Wechat;
+use App\Http\Controllers\Admin\Controller;
+use Illuminate\Http\Request;
+use App\Repositories\Base\Criteria\OrderBy;
+use App\Repositories\Wechat\Criteria\MultiWhere;
+use App\Repositories\Wechat\AppRepository;
+
+class AppController extends Controller
+{
+    private $repository;
+
+    public function __construct(AppRepository $repository) {
+        if(!$this->repository) $this->repository = $repository;
+    }
+
+    function index(Request $request) {
+        $search['keyword'] = $request->input('keyword');
+        $query = $this->repository->pushCriteria(new MultiWhere($search));
+
+        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']));
+        }else{
+            $query = $query->pushCriteria(new OrderBy('id','DESC'));
+        }
+        $list = $query->paginate();
+        return view('admin.wechat.app.index',compact('list'));
+    }
+
+
+    function check(Request $request) {
+        $request = $request->all();
+        $search['keyword'] = $request->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.wechat.app.check',compact('list'));
+    }
+
+
+    /**
+     * 添加
+     * 
+     */
+    public function create(Request $request)
+    {
+        if($request->method() == 'POST') {
+            return $this->_createSave();
+        }
+        return view('admin.wechat.app.edit');
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _createSave(){
+        $data = (array) request('data');
+        $id = $this->repository->create($data);
+        if($id) {
+            $url[] = array('url'=>U( 'Wechat/App/index'),'title'=>'返回列表');
+            $url[] = array('url'=>U( 'Wechat/App/create'),'title'=>'继续添加');
+            $this->showMessage('添加成功',$url);
+        }else{
+            $url[] = array('url'=>U( 'Wechat/App/index'),'title'=>'返回列表');
+            return $this->showWarning('添加失败',$url);
+        }
+    }
+    
+    /**
+     * 
+     * 修改
+     * 
+     * 
+     */
+    public function update(Request $request) {
+        if($request->method() == 'POST') {
+            return $this->_updateSave();
+        }
+        $data = $this->repository->find($request->get('id'));
+        //($request->get('id'));
+        return view('admin.wechat.app.edit',compact('data'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _updateSave() {
+        $data = (array) request('data');
+        $ok = $this->repository->update(request('id'),$data);
+        if($ok) {
+            $url[] = array('url'=>U( 'Wechat/App/index'),'title'=>'返回列表');
+            return $this->showMessage('操作成功',urldecode(request('_referer')));
+        }else{
+            $url[] = array('url'=>U( 'Wechat/App/index'),'title'=>'返回列表');
+            return $this->showWarning('操作失败',$url);
+        }
+    }
+
+    public function view(Request $request) {
+        $data = $this->repository->find(request('id'));
+        return view('admin.wechat.app.view',compact('data'));
+    }
+
+
+    /**
+     *
+     * 状态改变
+     *
+     */
+    public function status(Request $request) {
+        $ok = $this->repository->updateStatus(request('id'),request('status'));
+        if($ok) {
+            return $this->showMessage('操作成功');
+        }else{
+            return $this->showWarning('操作失败');
+        }
+    }
+    
+    /**
+     * 删除
+     */
+    public function destroy(Request $request) {
+        $bool = $this->repository->destroy($request->get('id'));
+        if($bool) {
+            return  $this->showMessage('操作成功');
+        }else{
+            return  $this->showWarning("操作失败");
+        }
+    }
+}

+ 4 - 5
app/Http/Controllers/Api/V1/PayController.php

xqd xqd xqd
@@ -14,12 +14,14 @@ use App\Models\WechatAppModel;
 use EasyWeChat\Factory;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Log;
+use Auth;
 
 class PayController extends Controller
 {
     private $config;
     public function __construct()
     {
+        parent::__construct();
         $wechat = WechatAppModel::find(1);
         $this->config = [
             // 必要配置
@@ -48,14 +50,11 @@ class PayController extends Controller
 
             ]
         );
-
-
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
+        $userAuth = Auth('api')->user();
         $money = $request->input('price');
-        $user = UserInfoModel::find($this->getUserId());
-
         $trade_no = 'Pay'.date('YmdHis').rand(1000,9999);
 
         $app = Factory::payment($this->config);
@@ -66,7 +65,7 @@ class PayController extends Controller
             'total_fee' => $money * 100,
             'trade_type' => 'JSAPI',
             'notify_url' => url('/api/home/notify'),
-            'openid' => $user->openid
+            'openid' => $userAuth->openid
         ]);
 
 

+ 15 - 15
app/Models/WechatAppModel.php

xqd xqd xqd
@@ -1,14 +1,13 @@
 <?php
+namespace App\Models;
+use App\Models\BaseModel;
 /**
- * Created by PhpStorm.
- * User: 思维定制
- * Date: 2018/7/13
- * Time: 10:45
+ *  @description 11
+ *  @author  system;
+ *  @version    1.0
+ *  @date 2018-07-26 01:43:25
+ *
  */
-
-namespace App\Models;
-
-
 class WechatAppModel extends BaseModel
 {
     /**
@@ -19,7 +18,7 @@ class WechatAppModel extends BaseModel
      */
     protected $table = 'wechat_app';
     /**
-     * 主键
+    主键
      */
     protected $primaryKey = 'id';
 
@@ -32,10 +31,11 @@ class WechatAppModel extends BaseModel
      * @var string
      */
     protected $fillable = [
-        'appId',
-        'appSecret',
-        'mchId',
-        'key',
-        'poundage'
-    ];
+                           'appId',
+                           'appSecret',
+                           'mchId',
+                           'key',
+                           'poundage'
+                          ];
+
 }

+ 21 - 0
app/Repositories/Wechat/AppRepository.php

xqd
@@ -0,0 +1,21 @@
+<?php
+/**
+ *   11
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-07-26 01:43:25
+ *
+ */
+namespace App\Repositories\Wechat;
+
+use App\Repositories\Base\Repository;
+
+
+class AppRepository extends Repository {
+
+    public function model() {
+        return \App\Models\WechatAppModel::class;
+    }
+
+    
+}

+ 45 - 0
app/Repositories/Wechat/Criteria/MultiWhere.php

xqd
@@ -0,0 +1,45 @@
+<?php
+/**
+ * User: Mike
+ * Email: m@9026.com
+ * Date: 2017/1/12
+ * Time: 17:52
+ */
+
+namespace App\Repositories\Wechat\Criteria;
+
+
+
+
+use App\Repositories\Base\Criteria;
+use App\Repositories\Contracts\RepositoryInterface as Repository;
+
+class MultiWhere extends Criteria {
+
+    private $search = [];
+
+    /**
+     * MultiWhere constructor.
+     * @param array $search
+     *
+     */
+    public function __construct(array $search)
+    {
+        $this->search = $search;
+    }
+
+    /**
+    * @param $model
+    * @param RepositoryInterface $repository
+    * @return mixed
+    */
+    public function apply($model, Repository $repository)
+    {
+          if(isset($this->search['poundage']) && $this->search['poundage']) {
+                                    $model = $model->where('poundage',$this->search['poundage']);
+                                 }
+
+         return $model;
+    }
+
+}

+ 90 - 0
resources/views/admin/wechat/app/check.blade.php

xqd
@@ -0,0 +1,90 @@
+@extends('admin.layout')
+
+@section('content')
+		<div class="row">
+			<div class="col-sm-12">
+				<div class="ibox float-e-margins">
+					<div class="ibox-title">
+						<h5>11</h5>
+						<div class="ibox-tools">
+							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+							</a>
+						</div>
+					</div>
+					<div class="ibox-content">
+						<div class="row">
+							<form method="GET" action="" accept-charset="UTF-8">
+
+								<div class="col-sm-4">
+									<div class="input-group">
+										<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control">
+								<span class="input-group-btn">
+									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
+								</span>
+									</div>
+								</div>
+							</form>
+							@if(role('Wechat/App/create'))
+								<div class="col-sm-3 pull-right">
+									<a href="{{ U('Wechat/App/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
+								</div>
+							@endif
+						</div>
+
+						<table class="table table-striped table-bordered table-hover dataTables-example dataTable dataCheckTable">
+							<thead>
+							<tr>
+								<th><input class="btSelectAll" name="btSelectAll" type="checkbox"></th>
+								
+            <th class="sorting" data-sort="id"> ID </th>
+            <th class="sorting" data-sort="appId"> appid </th>
+            <th class="sorting" data-sort="appSecret"> appsecret </th>
+            <th class="sorting" data-sort="mchId"> 商户id </th>
+            <th class="sorting" data-sort="key"> 商户key </th>
+            <th class="sorting" data-sort="created_at"> 创建时间 </th>
+            <th class="sorting" data-sort="updated_at"> 更新时间 </th>
+								<th width="22%">相关操作</th>
+							</tr>
+							</thead>
+							<tbody>
+							@if(isset($list))
+								@foreach($list as $key => $item)
+									<tr>
+									<td><input data-json='{!! json_encode($item) !!}'  name="btSelectItem" class="data_key" type="checkbox" value="{{ $item->id or 0 }}" /></td>
+									
+            <td>{{ $item->id }}</td>
+            <td>{{ $item->appId }}</td>
+            <td>{{ $item->appSecret }}</td>
+            <td>{{ $item->mchId }}</td>
+            <td>{{ $item->key }}</td>
+            <td>{{ $item->created_at }}</td>
+            <td>{{ $item->updated_at }}</td>
+									<td>
+										@if(role('Wechat/App/view'))
+											<button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Wechat/App/view',['id'=>$item->id])}}'});"  class="btn btn-primary ">查看</button>
+										@endif
+									</td>
+								</tr>
+								@endforeach
+							@endif
+
+							</tbody>
+						</table>
+						<div class="row">
+							<div class="col-sm-6">
+								<div class="dataTables_info" id="DataTables_Table_0_info"
+									 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。</div>
+							</div>
+							<div class="col-sm-6">
+								<div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+									{!! $list->setPath('')->appends(Request::all())->render() !!}
+								</div>
+							</div>
+						</div>
+					</div>
+				</div>
+			</div>
+		</div>
+	@include('admin.tools.check_script');
+
+@endsection

+ 98 - 0
resources/views/admin/wechat/app/edit.blade.php

xqd
@@ -0,0 +1,98 @@
+@extends('admin.layout')
+
+@section('content')
+
+<?php
+    if(!isset($data)) $data = array();
+    if(!$data && session("data")){
+        $data = session("data");
+    }
+    if(!$data && session('_old_input')){
+        $data = session("_old_input");
+    }
+?>
+	<div class="row">
+		<div class="col-sm-12">
+			<div class="ibox float-e-margins">
+				<div class="ibox-title">
+					<h5>系统配置</h5>
+					<div class="ibox-tools">
+						<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+						</a>
+					</div>
+				</div>
+				<div class="ibox-content">
+
+
+		            <div class="row">
+                        <div class="col-lg-10">
+                            <form name="form_product" id="form-validation" action="" class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
+
+                                    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">appid</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_appId" name="data[appId]" class="form-control" value="{{ $data['appId'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">appsecret</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_appSecret" name="data[appSecret]" class="form-control" value="{{ $data['appSecret'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">商户id</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_mchId" name="data[mchId]" class="form-control" value="{{ $data['mchId'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">商户key</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_key" name="data[key]" class="form-control" value="{{ $data['key'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">手续费</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_poundage" name="data[poundage]" class="form-control" value="{{ $data['poundage'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>
+                                
+                                <div class="form-group">
+                                    <label class="control-label col-sm-3">&nbsp;</label>
+                                    <div class="col-sm-9">
+                                        <input type="hidden" name="_referer" value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
+                                        <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
+                                        <input type="submit" class="btn btn-success" style="margin-right:20px;">
+                                        <input type="reset" class="btn btn-default" >
+                                    </div>
+                                </div>
+        
+                            </form>
+                        </div>
+                        <!-- /.col-lg-10 -->
+                    </div>
+                    <!-- /.row -->
+				</div>
+			</div>
+		</div>
+	</div>
+
+@endsection

+ 105 - 0
resources/views/admin/wechat/app/index.blade.php

xqd
@@ -0,0 +1,105 @@
+@extends('admin.layout') 
+
+@section('content')
+	<div class="row">
+		<div class="col-sm-12">
+			<div class="ibox float-e-margins">
+				<div class="ibox-title">
+					<h5>11</h5>
+					<div class="ibox-tools">
+						<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+						</a>
+					</div>
+				</div>
+				<div class="ibox-content">
+				    <div class="row">
+				        <form method="GET" action="" accept-charset="UTF-8">
+
+				        <div class="col-sm-4">
+				            <div class="input-group">
+								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control"> 
+								<span class="input-group-btn">
+									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
+								</span>
+    						</div>
+				        </div>
+				        </form>
+						@if(role('Wechat/App/create'))
+    					<div class="col-sm-3 pull-right">
+    					   <a href="{{ U('Wechat/App/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
+    					</div>
+						@endif
+					</div>
+					
+					<table class="table table-striped table-bordered table-hover dataTables-example dataTable">
+						<thead>
+    						<tr>
+								
+            <th class="sorting" data-sort="id"> ID </th>
+            <th class="sorting" data-sort="appId"> appid </th>
+            <th class="sorting" data-sort="appSecret"> appsecret </th>
+            <th class="sorting" data-sort="mchId"> 商户id </th>
+            <th class="sorting" data-sort="key"> 商户key </th>
+            <th class="sorting" data-sort="created_at"> 创建时间 </th>
+            <th class="sorting" data-sort="updated_at"> 更新时间 </th>
+        						<th width="22%">相关操作</th>
+        					</tr>
+						</thead>
+						<tbody>
+						@if(isset($list))
+							@foreach($list as $key => $item)							<tr>
+								
+            <td>{{ $item->id }}</td>
+            <td>{{ $item->appId }}</td>
+            <td>{{ $item->appSecret }}</td>
+            <td>{{ $item->mchId }}</td>
+            <td>{{ $item->key }}</td>
+            <td>{{ $item->created_at }}</td>
+            <td>{{ $item->updated_at }}</td>
+								<td>
+									<div class="btn-group">
+										<button data-toggle="dropdown"
+											class="btn btn-warning btn-sm dropdown-toggle"
+											aria-expanded="false">
+											操作 <span class="caret"></span>
+										</button>
+										<ul class="dropdown-menu">
+
+
+											@if(role('Wechat/App/update'))
+											<li><a href="{{ U('Wechat/App/update',['id'=>$item->id])}}" class="font-bold">修改</a></li>
+											@endif
+
+											@if(role('Wechat/App/destroy'))
+											<li class="divider"></li>
+											<li><a href="{{ U('Wechat/App/destroy',['id'=>$item->id])}}" onclick="return confirm('你确定执行删除操作?');">删除</a></li>
+											@endif
+
+										</ul>
+									</div>
+								@if(role('Wechat/App/view'))
+										<button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Wechat/App/view',['id'=>$item->id])}}'});"  class="btn btn-primary ">查看</button>
+									@endif
+								</td>
+							</tr>
+							@endforeach
+							@endif
+
+						</tbody>
+					</table>
+					<div class="row">
+						<div class="col-sm-6">
+							<div class="dataTables_info" id="DataTables_Table_0_info"
+								role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。</div>
+						</div>
+						<div class="col-sm-6">
+						<div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+						{!! $list->setPath('')->appends(Request::all())->render() !!}
+						</div>
+						</div>
+					</div>
+				</div>
+			</div>
+		</div>
+	</div>
+@endsection

+ 67 - 0
resources/views/admin/wechat/app/view.blade.php

xqd
@@ -0,0 +1,67 @@
+@extends('admin.layout')
+
+@section('content')
+<div class="row">
+    <div class="ibox-content">
+        <div class="list-group">
+                                 
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">ID</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['id'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">appid</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['appId'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">appsecret</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['appSecret'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">商户id</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['mchId'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">商户key</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['key'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">创建时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['created_at'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">更新时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['updated_at'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">手续费</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['poundage'] or ''}}</p>
+                                                 
+               </div>
+        </div>
+    </div>
+</div>
+@endsection