1.搞不明白你为什么这么改,改的有点无厘头,结果也无厘头
2.对于init()
方法,这个相当于对象的构造函数,是yii2框架里面的,只要这个类继承了 yii/base/BaseObject,那么 init()
是会在类实例化对象的时候执行的,因此
public function actionStart()
{
$this->init();
在这里调用是多此一举,根本不需要调用,默认就会执行
3.你这个改名有什么意义?看不明白,更看不明白的是你改后的结果,居然还跑起来了?
你是不是改了啥代码?
附一下默认的文件内容
@fecbbc\app\apphtml5\modules\Payment\controllers\WxpayjsapiController.php
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecbbc\app\apphtml5\modules\Payment\controllers;
use fecshop\app\apphtml5\modules\Payment\PaymentController;
use Yii;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class WxpayjsapiController extends \fecshop\app\apphtml5\modules\Payment\controllers\WxpayjsapiController
{
public $enableCsrfValidation = false;
protected $_trade_no;
protected $_order_models;
public function initFunc()
{
$homeUrl = Yii::$service->url->homeUrl();
$this->_trade_no = Yii::$service->order->getSessionTradeNo();
if (!$this->_trade_no) {
Yii::$service->url->redirect($homeUrl);
exit;
}
$this->_order_models = Yii::$service->order->getOrderModelsByTradeNo($this->_trade_no);
if (!is_array($this->_order_models) || empty($this->_order_models)) {
Yii::$service->url->redirect($homeUrl);
exit;
}
}
/**
* 支付开始页面.
*/
public function actionStart()
{
$this->initFunc();
//Yii::$service->page->theme->layoutFile = 'wxpay_jsapi.php';
$data = Yii::$service->payment->wxpayJsApi->getScanCodeStart();
$data['success_url'] = Yii::$service->payment->getStandardSuccessRedirectUrl();
return $this->render($this->action->id, $data);
}
/**
* IPN消息推送地址
* IPN过来后,不清除session中的 increment_id ,也不清除购物车
* 仅仅是更改订单支付状态。
*/
public function actionIpn()
{
Yii::$service->payment->wxpay->ipn();
}
}
2.@fecshop\app\apphtml5\modules\Payment\controllers\WxpayjsapiController
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\apphtml5\modules\Payment\controllers;
use fecshop\app\apphtml5\modules\Payment\PaymentController;
use Yii;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class WxpayjsapiController extends PaymentController
{
public $enableCsrfValidation = false;
public function init()
{
parent::init();
}
/**
* 支付开始页面.
*/
public function actionStart()
{
Yii::$service->page->theme->layoutFile = 'wxpay_jsapi.php';
$data = Yii::$service->payment->wxpayJsApi->getScanCodeStart();
$data['success_url'] = Yii::$service->payment->getStandardSuccessRedirectUrl();
return $this->render($this->action->id, $data);
}
/**
* IPN消息推送地址
* IPN过来后,不清除session中的 increment_id ,也不清除购物车
* 仅仅是更改订单支付状态。
*/
public function actionIpn()
{
Yii::$service->payment->wxpay->ipn();
}
/** 废弃
* 成功支付页面.
*/
public function actionSuccess()
{
$data = [
'increment_id' => $this->_increment_id,
];
// 清理购物车中的产品。(游客用户的购物车在成功页面清空)
if (Yii::$app->user->isGuest) {
Yii::$service->cart->clearCartProductAndCoupon();
}
// 清理session中的当前的increment_id
Yii::$service->order->removeSessionIncrementId();
return $this->render('../../payment/checkmoney/success', $data);
}
}