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['money'].''; $html .= '

    充值

    '; - $html .= '

    '.$v['created_at'].'

    '; + $html .= '

    '.date('Y-m-d H:i:s', $v['created_at']).'

    '; $html .= '
  • '; } } @@ -236,7 +236,7 @@ class UserController extends CommonController $body = '充值';//订单详情 $out_trade_no = $user_recharge['recharge_sn'];//订单号 $total_fee = floatval($user_recharge['money']*100);//价格0.01 - $attach = 'pay_type=1'; //pay_type=1充值支付 + $attach = 'pay_type=1'; //附加数据,pay_type=1充值支付,示例:xxx=1&yyy=2 $notify_url = route('weixin_wxpay_notify');//通知地址 $wxconfig= \WxPayConfig::wxconfig(); diff --git a/app/Http/Controllers/Weixin/WxPayController.php b/app/Http/Controllers/Weixin/WxPayController.php index f67f9b1..2feca89 100644 --- a/app/Http/Controllers/Weixin/WxPayController.php +++ b/app/Http/Controllers/Weixin/WxPayController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Weixin; use App\Http\Controllers\Weixin\CommonController; use Illuminate\Http\Request; use DB; +use Log; class WxPayController extends CommonController { @@ -12,77 +13,91 @@ class WxPayController extends CommonController parent::__construct(); } - //微信支付回调 + /** + * 微信支付回调 + */ public function wxpayNotify(Request $request) { - file_put_contents("1.txt",$GLOBALS['HTTP_RAW_POST_DATA']); + $res = "SUCCESS"; //支付成功返回SUCCESS,失败返回FAILE + + //file_put_contents("1.txt",$GLOBALS['HTTP_RAW_POST_DATA']); + Log::info('微信支付回调数据:'.$GLOBALS['HTTP_RAW_POST_DATA']); + //获取通知的数据 $xml = $GLOBALS['HTTP_RAW_POST_DATA']; //将XML转为array //禁止引用外部xml实体 libxml_disable_entity_loader(true); $post_data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); - $get_arr = explode('&',$post_data['attach']); - foreach($get_arr as $value) + + if(isset($post_data['attach']) && !empty($post_data['attach'])) { - $tmp_arr = explode('=',$value); - $post_data[$tmp_arr[0]] = $tmp_arr[1]; - } + $get_arr = explode('&',$post_data['attach']); + foreach($get_arr as $value) + { + $tmp_arr = explode('=',$value); + $post_data[$tmp_arr[0]] = $tmp_arr[1]; + } + } if($post_data['result_code'] == 'SUCCESS') { - $pay_money = $post_data['total_fee']/100; - $pay_time_timestamp = strtotime(date_format(date_create($post_data['time_end']),"Y-m-d H:i:s")); - //$post_data['out_trade_no'] - //$post_data['transaction_id'] + $pay_money = $post_data['total_fee']/100; //支付金额 + $pay_time_timestamp = strtotime(date_format(date_create($post_data['time_end']),"Y-m-d H:i:s")); //支付完成时间,时间戳格式 + $pay_time_date = date_format(date_create($post_data['time_end']),"Y-m-d H:i:s"); //支付完成时间,date格式Y-m-d H:i:s + //$post_data['out_trade_no'] //商户订单号 + //$post_data['transaction_id'] //微信支付订单号 //附加参数pay_type:1充值支付,2订单支付 if($post_data['pay_type'] == 1) { //获取充值支付记录 $user_recharge = DB::table('user_recharge')->where(array('recharge_sn'=>$post_data['out_trade_no'],'status'=>0))->first(); - if(!$user_recharge){exit;} - if($pay_money < $user_recharge->money){exit;} //如果支付金额小于要充值的金额 + if(!$user_recharge){Log::info('充值记录不存在');echo "FAILE";exit;} + if($pay_money < $user_recharge->money){Log::info('充值金额不匹配');echo "FAILE";exit;} //如果支付金额小于要充值的金额 //更新充值支付记录状态 - DB::table('user_recharge')->where(array('recharge_sn'=>$post_data['out_trade_no'],'status'=>0))->update(array('pay_time'=>$pay_time_timestamp,'pay_type'=>1,'status'=>1,'trade_no'=>$post_data['transaction_id'],'pay_money'=>$pay_money)); + DB::table('user_recharge')->where(array('recharge_sn'=>$post_data['out_trade_no'],'status'=>0))->update(array('pay_time'=>$pay_time_timestamp,'updated_at'=>time(),'pay_type'=>1,'status'=>1,'trade_no'=>$post_data['transaction_id'],'pay_money'=>$pay_money)); //增加用户余额 DB::table('user')->where(array('id'=>$user_recharge->user_id))->increment('money', $pay_money); //添加用户余额记录 DB::table('user_money')->insert(array('user_id'=>$user_recharge->user_id,'type'=>0,'money'=>$pay_money,'des'=>'充值','user_money'=>DB::table('user')->where(array('id'=>$user_recharge->user_id))->value('money'),'add_time'=>time())); } - if($post_data['pay_type'] == 2) + elseif($post_data['pay_type'] == 2) { //获取订单记录 $order = DB::table('order')->where(array('order_sn'=>$post_data['out_trade_no'],'order_status'=>0,'pay_status'=>0))->first(); - if(!$order){exit;} - if($pay_money < $order->order_amount){exit;} //如果支付金额小于订单金额 + if(!$order){Log::info('订单不存在');echo "FAILE";exit;} + if($pay_money < $order->order_amount){Log::info('订单金额不匹配');exit;} //如果支付金额小于订单金额 //修改订单状态 $order_update_data['pay_status'] = 1; $order_update_data['pay_money'] = $pay_money; //支付金额 $order_update_data['pay_id'] = 2; $order_update_data['pay_time'] = $pay_time_timestamp; - $order_update_data['pay_name'] = '微信'; + $order_update_data['pay_name'] = 'wxpay_jsapi'; $order_update_data['out_trade_no'] = $post_data['transaction_id']; + $order_update_data['updated_at'] = time(); + DB::table('order')->where(array('order_sn'=>$post_data['out_trade_no'],'order_status'=>0,'pay_status'=>0))->update($order_update_data); } - if($post_data['pay_type'] == 3) + elseif($post_data['pay_type'] == 3) { - + $res = "FAILE"; } - if($post_data['pay_type'] == 4) + elseif($post_data['pay_type'] == 4) { - + $res = "FAILE"; + } + else + { + $res = "FAILE"; } - file_put_contents("2.txt",$post_data['total_fee'].'--'.$post_data['out_trade_no'].'--'.$post_data['attach'].'--'.$post_data['pay_type']); - echo "SUCCESS"; - } - else - { - echo "FAILE"; + //file_put_contents("2.txt",$post_data['total_fee'].'--'.$post_data['out_trade_no'].'--'.$post_data['attach'].'--'.$post_data['pay_type']); } + + echo $res; } /** diff --git a/app/Http/Model/User.php b/app/Http/Model/User.php index cb0ce3b..cd8ff7e 100644 --- a/app/Http/Model/User.php +++ b/app/Http/Model/User.php @@ -188,6 +188,7 @@ class User extends BaseModel if(isset($sex)){$data['sex'] = $sex;} if(isset($head_img)){$data['head_img'] = $head_img;} if(isset($nickname)){$data['nickname'] = $nickname;} + $data['add_time'] = time(); if (isset($data) && $id = self::add($data)) { diff --git a/resources/org/wxpay/WxPayConfig.php b/resources/org/wxpay/WxPayConfig.php index 5d19268..f9ba7d6 100644 --- a/resources/org/wxpay/WxPayConfig.php +++ b/resources/org/wxpay/WxPayConfig.php @@ -25,7 +25,7 @@ class WxPayConfig const APPID = 'wx3d216119fe23ef10'; const MCHID = '1503321381'; const KEY = '7357733e71993a94ce392b9b5523c1ae'; - const APPSECRET = '7357733e71993a94ce392b9b5523c1ae'; + const APPSECRET = 'dc8a69f061f595ea4db0d7f0e52fc971'; //=======【证书路径设置】===================================== /** diff --git a/resources/org/wxpay/cert/apiclient_cert.p12 b/resources/org/wxpay/cert/apiclient_cert.p12 new file mode 100644 index 0000000..261b766 Binary files /dev/null and b/resources/org/wxpay/cert/apiclient_cert.p12 differ diff --git a/resources/org/wxpay/cert/apiclient_cert.pem b/resources/org/wxpay/cert/apiclient_cert.pem index e1d82b0..8b62f4a 100644 --- a/resources/org/wxpay/cert/apiclient_cert.pem +++ b/resources/org/wxpay/cert/apiclient_cert.pem @@ -1,26 +1,26 @@ -----BEGIN CERTIFICATE----- -MIIEXzCCA8igAwIBAgIDEN9AMA0GCSqGSIb3DQEBBQUAMIGKMQswCQYDVQQGEwJD -TjESMBAGA1UECBMJR3Vhbmdkb25nMREwDwYDVQQHEwhTaGVuemhlbjEQMA4GA1UE -ChMHVGVuY2VudDEMMAoGA1UECxMDV1hHMRMwEQYDVQQDEwpNbXBheW1jaENBMR8w -HQYJKoZIhvcNAQkBFhBtbXBheW1jaEB0ZW5jZW50MB4XDTE2MDIwMzExNDg1OVoX -DTI2MDEzMTExNDg1OVowgY8xCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ2Rv -bmcxETAPBgNVBAcTCFNoZW56aGVuMRAwDgYDVQQKEwdUZW5jZW50MQ4wDAYDVQQL -EwVNTVBheTEkMCIGA1UEAxQb6Ieq5Yqo5YyW5rWL6K+V5ZWG5oi35ZCN56ewMREw -DwYDVQQEEwgxMTM4NDEzMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -ALQ/qiPEwzmDLkWQhwA1Td6YQh1BxhgxH244rdp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Y2VudDEMMAoGA1UECxMDV1hHMRMwEQYDVQQDEwpNbXBheW1jaENBMR8wHQYJKoZI +hvcNAQkBFhBtbXBheW1jaEB0ZW5jZW50ggkAu1SXK7wA6FcwDgYDVR0PAQH/BAQD +AgbAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4GBAIMU +LvKa9SLWNWjjyywghkaksF7K8gkkP97pjH5xc9aM317OhNNsxC2mmgA7Yf/nh9lM +TqADKoTh6JWtA5xBRoMjdR0iJVTp+6St+x9yEOGhPEbDeg01zIAtMLwLZ+AK/E+4 +NgQsZKiUGg/WfKfRKokQMzLwGsXfmwmoAH1R0HkZ -----END CERTIFICATE----- diff --git a/resources/org/wxpay/cert/apiclient_key.pem b/resources/org/wxpay/cert/apiclient_key.pem index 46687e0..a408b6e 100644 --- a/resources/org/wxpay/cert/apiclient_key.pem +++ b/resources/org/wxpay/cert/apiclient_key.pem @@ -1,28 +1,28 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC0P6ojxMM5gy5F -kIcANU3emEIdQcYYMR9uOK3acn4ol7/5v0G2Bn5CduxGYjTpEbWYNJDoeFxn6PfW -0MImvkksT7Go7Z08GxjmDykT+F3OOEpRUfZ/b9zeV8yyUl2a75Sp89wn+z3R0U18 -bNMNILLmzE7tj9DAAi31MNdSD7RorMfkhjJYIxmdtKurLmBfkcnVE17x3paPUfxx -X8ld0T0ma8jhz9QrSjIfh9QzsHcBfnf2SGNp5HUvRwXt0NkA9fz6Os9YQ+iwJwHY -IBjsl4yzbEoJEMIs0HX+V3OscSIC3xGZcxzjOZ3S2yz6L5vsj3Ipb5taruwHirP6 -qHY+RVPXAgMBAAECggEAb+iLCLQUBTQV2WjW+GEf3JCpk6KPi9uLyRH1loe5HhjB -PxzofkvfvgI5xaUZdo7hMQOJ6Fs5++WfYkawE//WTGWaRuhn07Z7KfLFrTlpfCxk -r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SUUkYsOzXm +PZyyAWJF8iXUgEzYRLfG0ZGzR5pHlX6EpYqkjplo1AYLhiTA5WP0avkExAvvtTwx +fJv1rTeofY0CgYBthRMac4fRHCx4zpYq8C/dZ/oXzyjpkel7OCXpvjWKHEKrmaPf +0GkdBhtroq0v8Qgx3ONerOtrZDGNBl4rmAnuZpM9/98brGe7Xb/Qqx9jPF6WIj3Z +HYniWLMYPOHKn5ORssV/A6z9mrOoQJ3vUr25yibqMwvpayWU8E4RIpMERQKBgDtc +hAxa7fyZu+e+mUy1uWKtH/cOLldpjnx15Hlg9REn5Ejz2l0pTJtwiLdgyOVlPvc8 +8y1LyA/u9p6XF6OgTHLCRcEIG5Izeo+c9wumpeVILqNVa47uIcfuRsP66SlkU7ch +APNd3dVeltg+nJA8DODX8iJEOt6PFLVsHy1FmLvRAoGAZKsYMzugvM28Bdj2TqGp +nQu3hRXtTLU5/x5zRKzxeftxFCK9ewcM0x6ciNCwAWszJS+HuDJ7CzWw7DVe8Y8K +HZm4cOnAAtaS9NlxWMXGKGo5sI/mvuY6rAuU/Xy9g3C3172NMojwC52Zsg+qKZEj +5aMeDZic+rHd0/jztOsxMX8= -----END PRIVATE KEY----- diff --git a/resources/org/wxpay/cert/证书使用说明.txt b/resources/org/wxpay/cert/证书使用说明.txt new file mode 100644 index 0000000..a775010 --- /dev/null +++ b/resources/org/wxpay/cert/证书使用说明.txt @@ -0,0 +1,18 @@ +欢迎使用微信支付! +附件中的三份文件(证书pkcs12格式、证书pem格式、证书密钥pem格式),为接口中强制要求时需携带的证书文件。 +证书属于敏感信息,请妥善保管不要泄露和被他人复制。 +不同开发语言下的证书格式不同,以下为说明指引: + 证书pkcs12格式(apiclient_cert.p12) + 包含了私钥信息的证书文件,为p12(pfx)格式,由微信支付签发给您用来标识和界定您的身份 + 部分安全性要求较高的API需要使用该证书来确认您的调用身份 + windows上可以直接双击导入系统,导入过程中会提示输入证书密码,证书密码默认为您的商户ID(如:10010000) + 证书pem格式(apiclient_cert.pem) + 从apiclient_cert.p12中导出证书部分的文件,为pem格式,请妥善保管不要泄漏和被他人复制 + 部分开发语言和环境,不能直接使用p12文件,而需要使用pem,所以为了方便您使用,已为您直接提供 + 您也可以使用openssl命令来自己导出:openssl pkcs12 -clcerts -nokeys -in apiclient_cert.p12 -out apiclient_cert.pem + 证书密钥pem格式(apiclient_key.pem) + 从apiclient_cert.p12中导出密钥部分的文件,为pem格式 + 部分开发语言和环境,不能直接使用p12文件,而需要使用pem,所以为了方便您使用,已为您直接提供 + 您也可以使用openssl命令来自己导出:openssl pkcs12 -nocerts -in apiclient_cert.p12 -out apiclient_key.pem +备注说明: + 由于绝大部分操作系统已内置了微信支付服务器证书的根CA证书, 2018年3月6日后, 不再提供CA证书文件(rootca.pem)下载 \ No newline at end of file diff --git a/resources/views/weixin/order/orderWxpay.blade.php b/resources/views/weixin/order/orderWxpay.blade.php index e111a42..e6f6cd2 100644 --- a/resources/views/weixin/order/orderWxpay.blade.php +++ b/resources/views/weixin/order/orderWxpay.blade.php @@ -16,14 +16,14 @@ function jsApiCall() if(res.err_msg=='get_brand_wcpay_request:ok') { - alert('支付成功!'); + alert('支付成功'); } else { - alert('支付失败!'); + alert('支付失败'); } - setTimeout("location.href = ''",2000); + setTimeout("location.href = ''",1000); } ); } @@ -54,7 +54,7 @@ function callpay()
    -

    订单已于 提交成功,请您尽快付款!

    +

    订单已于 提交成功,请您尽快付款!

    订单号:
    应付金额:
    diff --git a/resources/views/weixin/user/index.blade.php b/resources/views/weixin/user/index.blade.php index cd36047..cf926a4 100644 --- a/resources/views/weixin/user/index.blade.php +++ b/resources/views/weixin/user/index.blade.php @@ -193,7 +193,7 @@
    -
    +
    - +
    diff --git a/resources/views/weixin/user/userRechargeOrderDetail.blade.php b/resources/views/weixin/user/userRechargeOrderDetail.blade.php index 1db5da2..ae823db 100644 --- a/resources/views/weixin/user/userRechargeOrderDetail.blade.php +++ b/resources/views/weixin/user/userRechargeOrderDetail.blade.php @@ -16,14 +16,14 @@ function jsApiCall() if(res.err_msg=='get_brand_wcpay_request:ok') { - alert('支付成功!'); + alert('支付成功'); } else { - alert('支付失败!'); + alert('支付失败'); } - setTimeout("location.href = ''",2000); + setTimeout("location.href = ''",1000); } ); } @@ -54,7 +54,7 @@ function callpay()
    -

    订单已于 提交成功,请您尽快付款!

    +

    充值订单已于 提交成功,请您尽快付款!

    订单号:
    应付金额:

    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 () { //轮播图