From 2a190a0b78eec8d9c881f5e919c90c0b074d4a91 Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Tue, 22 May 2018 16:44:14 +0800 Subject: [PATCH] order --- app/Common/function.php | 10 +-- app/Http/Controllers/Api/UserController.php | 1 + .../Api/UserRechargeController.php | 3 +- app/Http/Controllers/Home/IndexController.php | 21 ++++++ .../Controllers/Weixin/OrderController.php | 4 +- .../Controllers/Weixin/UserController.php | 4 +- .../Controllers/Weixin/WxPayController.php | 71 +++++++++++------- app/Http/Model/User.php | 1 + resources/org/wxpay/WxPayConfig.php | 2 +- resources/org/wxpay/cert/apiclient_cert.p12 | Bin 0 -> 2876 bytes resources/org/wxpay/cert/apiclient_cert.pem | 48 ++++++------ resources/org/wxpay/cert/apiclient_key.pem | 52 ++++++------- .../org/wxpay/cert/证书使用说明.txt | 18 +++++ .../views/weixin/order/orderWxpay.blade.php | 8 +- resources/views/weixin/user/index.blade.php | 6 +- .../weixin/user/userRechargeOrder.blade.php | 4 +- .../user/userRechargeOrderDetail.blade.php | 8 +- routes/web.php | 7 +- 18 files changed, 164 insertions(+), 104 deletions(-) create mode 100644 resources/org/wxpay/cert/apiclient_cert.p12 create mode 100644 resources/org/wxpay/cert/证书使用说明.txt diff --git a/app/Common/function.php b/app/Common/function.php index d30b44e..d77dcf6 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -33,11 +33,11 @@ if (! function_exists('curl_request')) curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_HEADER, 0); - + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - + $response = curl_exec($curl); - + if ($response === FALSE) { $error = curl_error($curl); @@ -50,9 +50,9 @@ if (! function_exists('curl_request')) $response = trim($response,chr(239).chr(187).chr(191)); $response = json_decode($response, true); } - + curl_close($curl); - + return $response; } } diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 4b86e32..1396f26 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -218,6 +218,7 @@ class UserController extends CommonController return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在'); } + $data['add_time'] = time(); //添加用户 $res = User::wxRegister($data); diff --git a/app/Http/Controllers/Api/UserRechargeController.php b/app/Http/Controllers/Api/UserRechargeController.php index 6c3e71e..8719de1 100644 --- a/app/Http/Controllers/Api/UserRechargeController.php +++ b/app/Http/Controllers/Api/UserRechargeController.php @@ -61,6 +61,7 @@ class UserRechargeController extends CommonController $data['status'] = UserRecharge::UN_PAY; //0未处理,1已完成 $data['pay_type'] = $request->input('pay_type',''); //充值类型:1微信,2支付宝 $data['user_id'] = Token::$uid; + $data['created_at'] = time(); if($data['money']=='' || $data['pay_type']=='') { @@ -84,7 +85,7 @@ class UserRechargeController extends CommonController $data['trade_no'] = $request->input('trade_no',''); $data['pay_time'] = $request->input('pay_time',''); $data['status'] = UserRecharge::COMPLETE_PAY; - $data['updated_at'] = date('Y-m-d H:i:s',time()); + $data['updated_at'] = time(); if($id=='' || $data['trade_no']=='' || $data['pay_time']=='') { diff --git a/app/Http/Controllers/Home/IndexController.php b/app/Http/Controllers/Home/IndexController.php index 03e5a51..46c81b6 100644 --- a/app/Http/Controllers/Home/IndexController.php +++ b/app/Http/Controllers/Home/IndexController.php @@ -457,6 +457,27 @@ class IndexController extends CommonController return view('home.404'); } + //验证消息的确来自微信服务器 + public function checksignature() + { + $signature = $_GET["signature"]; + $timestamp = $_GET["timestamp"]; + $nonce = $_GET["nonce"]; + $echoStr = $_GET["echostr"]; + + $token = 'fanli'; + $tmpArr = array($token, $timestamp, $nonce); + sort($tmpArr, SORT_STRING); + $tmpStr = implode( $tmpArr ); + $tmpStr = sha1( $tmpStr ); + + if( $tmpStr == $signature ){ + exit($echoStr); + }else{ + return false; + } + } + //测试页面 public function test() {return view('home.index.test'); diff --git a/app/Http/Controllers/Weixin/OrderController.php b/app/Http/Controllers/Weixin/OrderController.php index 6c2afb1..6c802a1 100644 --- a/app/Http/Controllers/Weixin/OrderController.php +++ b/app/Http/Controllers/Weixin/OrderController.php @@ -237,7 +237,7 @@ class OrderController extends CommonController $this->success_jump('支付成功',route('weixin_order_list')); } - //订单余额支付 + //订单-微信支付 public function orderWxpay(Request $request) { $order_id = $request->input('order_id',''); @@ -262,7 +262,7 @@ class OrderController extends CommonController $body = '订单支付';//订单详情 $out_trade_no = $data['order_detail']['order_sn'];//订单号 $total_fee = floatval($data['order_detail']['order_amount']*100);//价格0.01 - $attach = 'pay_type=2'; //pay_type=2订单支付 + $attach = 'pay_type=2'; //附加数据,pay_type=2订单支付,示例:xxx=1&yyy=2 $notify_url = route('weixin_wxpay_notify');//通知地址 $wxconfig= \WxPayConfig::wxconfig(); diff --git a/app/Http/Controllers/Weixin/UserController.php b/app/Http/Controllers/Weixin/UserController.php index d49fb9e..ca0184d 100644 --- a/app/Http/Controllers/Weixin/UserController.php +++ b/app/Http/Controllers/Weixin/UserController.php @@ -203,7 +203,7 @@ class UserController extends CommonController $html .= '
充值
'; - $html .= ''.$v['created_at'].'
'.date('Y-m-d H:i:s', $v['created_at']).'
'; $html .= '#W*(-Y79@?NK8A71l?LNXRlx_#
zEJ0vba4g0oSm{I6qd23}G!l!(S}3zU`hZ4D?@g3b19DZSEZ%e%XhSqRBB%~T^7Fcb
z6j{htxbKn|XYO-}hH>f()A<$*dQmk-$DW&TT@^{IT<+m7a{)I6L=+z{H-&hh#oH|;6%E8fmaW8EC>AfTA?yKQgD3??iXrjj8a@3B81$VRD
zKb*JgzF>1LV!4u$@oM3v74D9^&&_%_O5Y}6MXN+JOl4`~S02o9F$p<-k=;79(+W`>
z)pLc)y)kdUB8gkWYGt(6TKE=KF`Hwsz71bZ_d2pKnzj7yO_vYP+TIL%)$498xaEsv
znhm-XMBfS*1rwZ|83e5NgLPmLiFevldX4fSo)RA`GI0hqu&L(EvDl)(g)2n=f$xGP
zbSA%;`q+cOOt)0f=6php@fy?mLcR7mqcD-c@jxx4p ~ie 订单已于 提交成功,请您尽快付款! 订单已于 提交成功,请您尽快付款! 充值 订单已于 提交成功,请您尽快付款! 充值订单已于 提交成功,请您尽快付款!
应付金额:¥ 元
应付金额:¥ 元
diff --git a/routes/web.php b/routes/web.php
index d412c3c..a7218ab 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -44,7 +44,8 @@ Route::group(['namespace' => 'Home'], function () {
Route::get('/goodslist', 'IndexController@goodslist')->name('home_goodslist'); //产品分类页
Route::get('/brandlist', 'IndexController@brandList')->name('home_brandlist'); //品牌列表
Route::get('/sitemap.xml', 'IndexController@sitemap')->name('home_sitemap');//sitemap
-
+ Route::get('/wx_checksignature', 'IndexController@checksignature')->name('home_wx_checksignature');
+
Route::get('/test', 'IndexController@test')->name('home_test'); //测试
Route::get('/aaa', function () {
dd('wap');
@@ -80,6 +81,7 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin'], function () {
Route::get('/test', 'IndexController@test')->name('weixin_test'); //测试
});
+
//微信路由,需登录,全局
Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin', 'middleware' => ['web','wxlogin']], function () {
//个人中心
@@ -112,8 +114,8 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin', 'middleware' => ['w
Route::post('/order_dopay', 'OrderController@dopay')->name('weixin_order_dopay'); //订单支付
Route::get('/order_list', 'OrderController@orderList')->name('weixin_order_list'); //全部订单列表
Route::get('/order_detail', 'OrderController@orderDetail')->name('weixin_order_detail'); //订单详情
- Route::get('/order_wxpay', 'OrderController@orderWxpay')->name('weixin_order_wxpay'); //订单微信支付
Route::get('/order_yuepay', 'OrderController@orderYuepay')->name('weixin_order_yuepay'); //订单余额支付
+ Route::get('/order_wxpay', 'OrderController@orderWxpay')->name('weixin_order_wxpay'); //订单微信支付
Route::any('/order_comment', 'OrderController@orderComment')->name('weixin_order_comment'); //订单评价
//收货地址
Route::get('/user_address', 'AddressController@index')->name('weixin_user_address_list');
@@ -132,6 +134,7 @@ Route::group(['middleware' => ['web']], function () {
Route::post('/dataapi/', 'Api\UserController@signin'); //签到
});
+
//API接口路由,无需token验证
Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web']], function () {
//轮播图