From 901da36493f715852c511cb335b1afc72206d45c Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Thu, 9 Nov 2017 17:31:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/UserMoneyController.php | 1 + .../Controllers/Weixin/UserController.php | 50 +++++++++- app/Http/Model/UserRecharge.php | 6 +- .../views/weixin/user/userRecharge.blade.php | 3 +- .../weixin/user/userRechargeOrder.blade.php | 96 +++++++++++++++++++ .../user/userRechargeOrderDetail.blade.php | 2 +- routes/web.php | 4 +- 7 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 resources/views/weixin/user/userRechargeOrder.blade.php diff --git a/app/Http/Controllers/Api/UserMoneyController.php b/app/Http/Controllers/Api/UserMoneyController.php index f02aa96..8f30958 100644 --- a/app/Http/Controllers/Api/UserMoneyController.php +++ b/app/Http/Controllers/Api/UserMoneyController.php @@ -14,6 +14,7 @@ class UserMoneyController extends CommonController parent::__construct(); } + //余额明细列表 public function userMoneyList(Request $request) { //参数 diff --git a/app/Http/Controllers/Weixin/UserController.php b/app/Http/Controllers/Weixin/UserController.php index bc111ce..2c423a9 100644 --- a/app/Http/Controllers/Weixin/UserController.php +++ b/app/Http/Controllers/Weixin/UserController.php @@ -62,9 +62,53 @@ class UserController extends CommonController return view('weixin.user.userRecharge'); } + //充值明细 + public function userRechargeOrder(Request $request) + { + $pagesize = 10; + $offset = 0; + if(isset($_REQUEST['page'])){$offset = ($_REQUEST['page']-1)*$pagesize;} + + $postdata = array( + 'limit' => $pagesize, + 'offset' => $offset, + 'status' => 1, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/user_recharge_list"; + $res = curl_request($url,$postdata,'GET'); + $data['list'] = $res['data']['list']; + + $data['totalpage'] = ceil($res['data']['count']/$pagesize); + + if(isset($_REQUEST['page_ajax']) && $_REQUEST['page_ajax']==1) + { + $html = ''; + + if($res['data']['list']) + { + foreach($res['data']['list'] as $k => $v) + { + $html .= '
  • '; + $html .= '+ '.$v['money'].''; + $html .= '

    充值

    '; + $html .= '

    '.$v['created_at'].'

    '; + $html .= '
  • '; + } + } + + exit(json_encode($html)); + } + + return view('weixin.user.userRechargeOrder', $data); + } + //用户充值第二步,支付 - public function userRechargeOrderDetail($id) + public function userRechargeOrderDetail(Request $request) { + $id = $request->input('id',''); + if($id == ''){$this->error_jump(ReturnData::PARAMS_ERROR);} + //获取充值记录详情 $postdata = array( 'id' => $id, @@ -102,7 +146,7 @@ class UserController extends CommonController $unifiedOrder->setParameter("body","$body");//商品描述 $unifiedOrder->setParameter("out_trade_no","$out_trade_no");//商户订单号 $unifiedOrder->setParameter("total_fee","$total_fee");//总金额 - //$unifiedOrder->setParameter("attach","$attach"); //附加数据,选填,在查询API和支付通知中原样返回,可作为自定义参数使用,示例:a=1&b=2 + $unifiedOrder->setParameter("attach","$attach"); //附加数据,选填,在查询API和支付通知中原样返回,可作为自定义参数使用,示例:a=1&b=2 $unifiedOrder->setParameter("notify_url","$notify_url");//通知地址 $unifiedOrder->setParameter("trade_type","JSAPI");//交易类型 $prepay_id = $unifiedOrder->getPrepayId(); @@ -111,7 +155,7 @@ class UserController extends CommonController $jsApiParameters = $jsApi->getParameters(); $data['jsApiParameters'] = $jsApiParameters; - $data['returnUrl'] = route('weixin_user'); //支付完成要跳转的url + $data['returnUrl'] = route('weixin_user_recharge_order'); //支付完成要跳转的url return view('weixin.user.userRechargeOrderDetail', $data); } diff --git a/app/Http/Model/UserRecharge.php b/app/Http/Model/UserRecharge.php index 3337033..8d5af6e 100644 --- a/app/Http/Model/UserRecharge.php +++ b/app/Http/Model/UserRecharge.php @@ -28,7 +28,7 @@ class UserRecharge extends BaseModel $limit = isset($limit) ? $limit : 10; $offset = isset($offset) ? $offset : 0; - $model = new UserRecharge; + $model = new self(); if(isset($status) && $status!=-1){$where['status'] = $status;} //-1表示获取所有 @@ -41,10 +41,6 @@ class UserRecharge extends BaseModel { $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get(); } - else - { - return false; - } return $res; } diff --git a/resources/views/weixin/user/userRecharge.blade.php b/resources/views/weixin/user/userRecharge.blade.php index 3348a8a..8e590ce 100644 --- a/resources/views/weixin/user/userRecharge.blade.php +++ b/resources/views/weixin/user/userRecharge.blade.php @@ -7,6 +7,7 @@
    返回
    充值
    +
    +
    + + + +
    暂无记录
    + +
    + + +@include('weixin.common.footer') + \ No newline at end of file diff --git a/resources/views/weixin/user/userRechargeOrderDetail.blade.php b/resources/views/weixin/user/userRechargeOrderDetail.blade.php index 0b808e4..1db5da2 100644 --- a/resources/views/weixin/user/userRechargeOrderDetail.blade.php +++ b/resources/views/weixin/user/userRechargeOrderDetail.blade.php @@ -23,7 +23,7 @@ function jsApiCall() alert('支付失败!'); } - //setTimeout("location.href = ''",2000); + setTimeout("location.href = ''",2000); } ); } diff --git a/routes/web.php b/routes/web.php index 36020c4..b7fc2a2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -87,7 +87,6 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin', 'middleware' => ['w //用户充值 Route::get('/user_recharge', 'UserController@userRecharge')->name('weixin_user_recharge'); Route::get('/user_recharge_order', 'UserController@userRechargeOrder')->name('weixin_user_recharge_order'); - Route::get('/user_recharge_order_detail/{id}', 'UserController@userRechargeOrderDetail')->name('weixin_user_recharge_order_detail'); //优惠券、红包 Route::get('/user_bonus_list', 'UserController@userBonusList')->name('weixin_user_bonus_list'); //浏览记录 @@ -105,12 +104,12 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin', 'middleware' => ['w Route::get('/user_address', 'AddressController@index')->name('weixin_user_address_list'); Route::get('/user_address_add', 'AddressController@userAddressAdd')->name('weixin_user_address_add'); Route::get('/user_address_update', 'AddressController@userAddressUpdate')->name('weixin_user_address_update'); - }); //无需token验证,全局 Route::group(['middleware' => ['web']], function () { + Route::get('/weixin_user_recharge_order_detail', 'Weixin\UserController@userRechargeOrderDetail')->name('weixin_user_recharge_order_detail'); //微信充值支付,为了配合公众号支付授权目录 Route::post('/dataapi/listarc', 'Api\IndexController@listarc')->name('api_listarc'); Route::post('/dataapi/customer_login', 'Api\WechatAuthController@customerLogin'); Route::post('/dataapi/', 'Api\UserController@signin'); //签到 @@ -149,6 +148,7 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web //用户充值 Route::post('/user_recharge_add', 'UserRechargeController@userRechargeAdd'); Route::get('/user_recharge_detail', 'UserRechargeController@userRechargeDetail'); + Route::get('/user_recharge_list', 'UserRechargeController@userRechargeList'); //用户余额(钱包) Route::get('/user_money_list', 'UserMoneyController@userMoneyList'); Route::post('/user_money_add', 'UserMoneyController@userMoneyAdd');