fecbbc,请问 订单号:$increment_id 是用哪个函数获取的?

问题咨询 · dream · 于 3年前 发布 · 1532 次阅读

路径@/addons/fecmall/fecbbc/services/Order.php里面有这么一段:

/** 废弃
     * @param $increment_id | String ,order订单号
     * 将生成的订单号写入session
     */
    /*
    public function setSessionIncrementId($increment_id)
    {
        Yii::$service->session->set(self::CURRENT_ORDER_INCREAMENT_ID, $increment_id);
    }
    */

    /** 废弃
     * 从session中取出来订单号.
     */
    /*
    public function getSessionIncrementId()
    {
        return Yii::$service->session->get(self::CURRENT_ORDER_INCREAMENT_ID);
    }
    */
    
    /**
     * 从session中销毁订单号.
     */
    /*
    public function removeSessionIncrementId()
    {
        return Yii::$service->session->remove(self::CURRENT_ORDER_INCREAMENT_ID);
    }
    */

但是微信支付方法:

<?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;

use fecshop\app\apphtml5\modules\AppfrontController;
use Yii;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class PaymentController extends AppfrontController
{
    protected $_increment_id;
    protected $_order_model;

    public function init()
    {
        parent::init();
        $homeUrl = Yii::$service->url->homeUrl();
        $this->_increment_id = Yii::$service->order->getSessionIncrementId();
        if (!$this->_increment_id) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }

        $this->_order_model = Yii::$service->order->GetByIncrementId($this->_increment_id);
        if (!isset($this->_order_model['increment_id'])) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }

    }
}

这个地方的初始化函数init(),获取订单号还是用的Yii::$service->order->getSessionIncrementId()

共收到 14 条回复
Fecmall#13年前 0 个赞

看不懂你要表达什么

dream#23年前 0 个赞

@Fecmall #1楼 不好意思,您多担待,$this->_increment_id = Yii::$service->order->getSessionIncrementId();这个getSessionIncrementId()废弃了吗?

Fecmall#33年前 0 个赞

废弃,指的是在fecbbc这个扩展里面废弃了

@fecbbc\app\apphtml5\modules\Payment\controllers\Wxpayh5Controller.php

交易订单号,不是这里读取的吗

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;
        }
    }

$this->_trade_no = Yii::$service->order->getSessionTradeNo();

Fecmall#43年前 0 个赞

我好像清楚你的问题了,稍等我改一下,你测试试试

dream#53年前 0 个赞

@Fecmall #3楼 $this->_increment_id = Yii::$service->order->getSessionIncrementId(); 这个是在init()里面,在执行initFunc() 时,会先执行init()里面的$this->_increment_id = Yii::$service->order->getSessionIncrementId();,理解的不到位的地方,您多指点。

dream#63年前 0 个赞

@Fecmall #4楼 好的,感谢!

Fecmall#73年前 0 个赞

更改下面的两个文件:

@fecshop\app\apphtml5\modules\Payment\controllers\Wxpayh5Controller.php

<?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 Yii;
use fecshop\app\apphtml5\modules\AppfrontController;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class Wxpayh5Controller extends AppfrontController
{
    public $enableCsrfValidation = false;
    protected $_increment_id;
    protected $_order_model;
    
    
    public function initFunc()
    {
        $homeUrl = Yii::$service->url->homeUrl();
        $this->_increment_id = Yii::$service->order->getSessionIncrementId();
        if (!$this->_increment_id) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }

        $this->_order_model = Yii::$service->order->GetByIncrementId($this->_increment_id);
        if (!isset($this->_order_model['increment_id'])) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }
    }
    
    /**
     * 支付开始页面.
     */
    public function actionStart()
    {
        $this->initFunc();
        //Yii::$service->page->theme->layoutFile = 'wxpay_jsapi.php';
        $objectxml = Yii::$service->payment->wxpayH5->getScanCodeStart();
        //var_dump($objectxml);
        $returnUrl =  Yii::$service->payment->getStandardReturnUrl(); 
        $return_Url = urlencode($returnUrl);
        $url = $objectxml['mweb_url'] . '&redirect_url=' . $return_Url;
        
        //echo $url;
        return Yii::$service->url->redirect($url);
        
    }
    
    
    public function actionReview()
    {
        $this->initFunc();
        $out_trade_no = Yii::$service->order->getSessionIncrementId();
        $reviewStatus = Yii::$service->payment->wxpay->scanCodeCheckTradeIsSuccess($out_trade_no);
        if($reviewStatus){
            $successRedirectUrl = Yii::$service->payment->getStandardSuccessRedirectUrl();
            return Yii::$service->url->redirect($successRedirectUrl);
        }else{
            $errors = Yii::$service->helper->errors->get('<br/>');
            $data = [
                'errors' => $errors,
            ];
            return $this->render($this->action->id, $data);
        }
    }
    
    /**
     * IPN消息推送地址
     * IPN过来后,不清除session中的 increment_id ,也不清除购物车
     * 仅仅是更改订单支付状态。
     */
    public function actionIpn()
    {
        Yii::$service->payment->wxpay->ipn();
    }

    /** 废弃
     *  成功支付页面.
     */
    public function actionSuccess()
    {
        $this->initFunc();
        $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);
    }

    
}

@fecshop\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 fecshop\app\apphtml5\modules\Payment\controllers;

use fecshop\app\apphtml5\modules\AppfrontController;
use Yii;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class WxpayjsapiController extends AppfrontController
{
    public $enableCsrfValidation = false;
    protected $_increment_id;
    protected $_order_model;
    
    
    public function initFunc()
    {
        $homeUrl = Yii::$service->url->homeUrl();
        $this->_increment_id = Yii::$service->order->getSessionIncrementId();
        if (!$this->_increment_id) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }

        $this->_order_model = Yii::$service->order->GetByIncrementId($this->_increment_id);
        if (!isset($this->_order_model['increment_id'])) {
            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();
    }

    /** 废弃
     *  成功支付页面.
     */
    public function actionSuccess()
    {
        $this->initFunc();
        $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);
    }

    
}

Fecmall#83年前 0 个赞

这样就不会走 @fecshop\app\apphtml5\modules\Payment\PaymentController.php 里面的init方法了

dream#93年前 1 个赞

@Fecmall #8楼 好的,问题已解决,谢谢!

Fecmall#103年前 0 个赞

@dream #9楼 微信内部h5支付可以了?

dream#113年前 1 个赞

@Fecmall #10楼 是的。

Fecmall#133年前 0 个赞

解决:

1.fecmall更新到版本2.8.5

2.应用扩展更新到最新版本即可

dream#143年前 0 个赞

收到

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics