helloworld

第 365 位会员

会员
个人信息
  • 加入于 2018-02-28 22:54:16
  • 最后登录时间 5年前
个人成就
  • 发表文章次数 1
  • 发布回复次数 5
  • 个人主页浏览次数 0
优惠券次数限制bug5年前

@Fecshop #2楼 第一次 addCoupon是 $cu_model->times_used = 1;为1的

/**
     * @property $type | String     add or cancel
     * @return bool
     *              增加或者减少优惠券使用的次数
     */
    protected function updateCouponUse($type)
    {
        if ($this->_customer_id) {
            $c_model = $this->getCouponModel();
            if ($c_model) {
                if ($type == 'add') {
                    $cu_model = $this->getCouponUsageModel();
                    if (!$cu_model) {
                        $cu_model = new $this->_couponUsageModelName;
                        $cu_model->times_used = 1;
                        $cu_model->customer_id = $this->_customer_id;
                        $cu_model->coupon_id = $c_model['coupon_id'];
                        $cu_model->save();
                    } else {
                        Yii::info('是否新增优惠券使用次数!1','fecshop_debug');
                        // 通过update函数 将times_used +1
                        $sql = 'update '.$this->_couponUsageModel->tableName().' set times_used = times_used + 1 where id = :id';
                        $data = [
                            'id'  => $cu_model['id'],
                        ];
                        Yii::info('sql:'.$sql,'fecshop_debug');
                        Yii::info('$cu_model[\'id\']:'.$cu_model['id'],'fecshop_debug');
                        $result = $this->_couponUsageModel->getDb()->createCommand($sql,$data)->execute();
                        Yii::info('是否新增优惠券使用次数!2','fecshop_debug');
                    }
                    // coupon的总使用次数+1
                    $sql = 'update '.$this->_couponModel->tableName().' set times_used = times_used + 1 where coupon_id  = :coupon_id ';
                    $data = [
                        'coupon_id' => $c_model['coupon_id'],
                    ];
                    $result = $this->_couponModel->getDb()->createCommand($sql,$data)->execute();
                    return true;
                } elseif ($type == 'cancel') {
                    $couponModel = $this->getCouponModel();
                    $cu_model = $this->getCouponUsageModel();
                    if ($cu_model) {
                        // $this->_couponUsageModel 使用次数-1
                        $sql = 'update '.$this->_couponUsageModel->tableName().' set times_used = times_used - 1 where id = :id';
                        $data = [
                            'id'  => $cu_model['id'],
                        ];
                        $result = $this->_couponUsageModel->getDb()->createCommand($sql,$data)->execute();
                        // $this->_couponModel 使用次数-1
                        $sql = 'update '.$this->_couponModel->tableName().' set times_used = times_used - 1 where coupon_id  = :coupon_id ';
                        $data = [
                            'coupon_id' => $c_model['coupon_id'],
                        ];
                        $result = $this->_couponModel->getDb()->createCommand($sql,$data)->execute();
                        
                        return true;
                    }
                }
            }
        }
    }
新版本1.4.0.0产品管理加载分类提示错误6年前

还有一处,就是appfront购物车增减产品数量的接口

新版本1.4.0.0产品管理加载分类提示错误6年前

docker下全新安装fecshop,,,echo之后,加个exit就可以了。

新版本1.4.0.0产品管理加载分类提示错误6年前

@Fecshop #4楼 比如:获取产品分类的接口 D:\wwwroot\yii2\app\fecshop\vendor\fancyecommerce\fecshop\app\appadmin\modules\Catalog\block\productinfo\Getproductcategory.php

public function getProductCategory()
    {
        $product_id = CRequest::param('product_id');

        $menuStr = $this->getMenuStr($product_id);
        Yii::info($menuStr,'fecshop_debug');
        echo json_encode([
            'menu'=>$menuStr,
            'return_status'=>'success',
        ]);
    }

echo返回数据后,还会去触发yii框架的 Yii::$app->response 导致的报错!我的是docker-composer安装的

{"status":"success"}<pre>An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /www/web/fecshop/vendor/fancyecommerce/fecshop/app/appfront/modules/Checkout/controllers/CartController.php on line 210. in /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response-&gt;sendHeaders()
#1 /www/web/fecshop/vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response-&gt;send()
#2 /www/web/fecshop/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler-&gt;renderException(Object(yii\web\HeadersAlreadySentException))
#3 [internal function]: yii\base\ErrorHandler-&gt;handleException(Object(yii\web\HeadersAlreadySentException))
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /www/web/fecshop/vendor/fancyecommerce/fecshop/app/appfront/modules/Checkout/controllers/CartController.php on line 210. in /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response-&gt;sendHeaders()
#1 /www/web/fecshop/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Response-&gt;send()
#2 /www/web/fecshop/appfront/web/index.php(90): yii\base\Application-&gt;run()
#3 {main}</pre>
新版本1.4.0.0产品管理加载分类提示错误6年前

好像yii框架的错误,所有each返回数据的接口都报错:yii\web\HeadersAlreadySentException: Headers already sent

Your Site Analytics