Skip to content

Commit

Permalink
php5和php7的升级兼容问题
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Jul 26, 2017
1 parent 455363b commit f7839d1
Show file tree
Hide file tree
Showing 36 changed files with 301 additions and 272 deletions.
5 changes: 3 additions & 2 deletions app/appfront/modules/Catalog/block/product/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ public function __construct()

public function getLastData()
{
$reviewHelper = $this->_reviewHelper;
$productImgSize = Yii::$app->controller->module->params['productImgSize'];
$productImgMagnifier = Yii::$app->controller->module->params['productImgMagnifier'];
if(!$this->initProduct()){
Yii::$service->url->redirect404();
return;
}
$this->_reviewHelper::initReviewConfig();
$ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($this->_product);
$reviewHelper::initReviewConfig();
$ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($this->_product);
list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount;
$this->filterProductImg($this->_product['image']);
$groupAttr = Yii::$service->product->getGroupAttr($this->_product['attr_group']);
Expand Down
4 changes: 2 additions & 2 deletions app/appfront/modules/Catalog/block/product/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function __construct()
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName);

$reviewHelper = $this->_reviewHelper;
// 初始化当前appfront的设置,覆盖service的初始设置。
$this->_reviewHelper::initReviewConfig();
$reviewHelper::initReviewConfig();
}
/**
* 得到当前spu下面的所有评论信息。
Expand Down
4 changes: 2 additions & 2 deletions app/appfront/modules/Catalog/block/reviewproduct/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct()
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName);

$this->_reviewHelper::initReviewConfig();
$reviewHelper = $this->_reviewHelper;
$reviewHelper::initReviewConfig();
}
/**
* @return boolean , review页面是否开启验证码验证。
Expand Down
7 changes: 4 additions & 3 deletions app/appfront/modules/Catalog/block/reviewproduct/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function __construct()
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName);

$this->_reviewHelper::initReviewConfig();
$reviewHelper = $this->_reviewHelper;
$reviewHelper::initReviewConfig();
}
/**
* @property $countTotal | Int
Expand Down Expand Up @@ -97,7 +97,8 @@ public function getLastData()

$pageToolBar = $this->getProductPage($count);
$coll = $data['coll'];
$ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($product);
$reviewHelper = $this->_reviewHelper;
$ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($product);
list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount;

return [
Expand Down
5 changes: 3 additions & 2 deletions app/apphtml5/modules/Catalog/block/product/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function getLastData()
Yii::$service->url->redirect404();
return;
}
$this->_reviewHelper::initReviewConfig();
$ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($this->_product);
$reviewHelper = $this->_reviewHelper;
$reviewHelper::initReviewConfig();
$ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($this->_product);
list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount;
$this->filterProductImg($this->_product['image']);
$groupAttr = Yii::$service->product->getGroupAttr($this->_product['attr_group']);
Expand Down
3 changes: 2 additions & 1 deletion app/apphtml5/modules/Catalog/block/product/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public function __construct()
*/
list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName);
// 初始化当前apphtml5的设置,覆盖service的初始设置。
$this->_reviewHelper::initReviewConfig();
$reviewHelper = $this->_reviewHelper;
$reviewHelper::initReviewConfig();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/apphtml5/modules/Catalog/block/reviewproduct/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function __construct()
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName);
$this->_reviewHelper::initReviewConfig();
$reviewHelper = $this->_reviewHelper;
$reviewHelper::initReviewConfig();
}

/**
Expand Down
6 changes: 4 additions & 2 deletions app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function __construct()
*/
list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName);
// 初始化服务
$this->_reviewHelper::initReviewConfig();
$reviewHelper = $this->_reviewHelper;
$reviewHelper::initReviewConfig();
}
/**
* @property $countTotal | Int
Expand Down Expand Up @@ -97,7 +98,8 @@ public function getLastData()

$pageToolBar = $this->getProductPage($count);
$coll = $data['coll'];
$ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($product);
$reviewHelper = $this->_reviewHelper;
$ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($product);
list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount;

return [
Expand Down
26 changes: 14 additions & 12 deletions services/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function actionRegister($param)
*/
protected function actionIsRegistered($email)
{
$customer = $this->_customerModel::findOne(['email' => $email]);
$customer = $this->_customerModel->findOne(['email' => $email]);
if ($customer['email']) {
return true;
} else {
Expand Down Expand Up @@ -190,10 +190,10 @@ protected function actionChangePassword($password, $identity)
{
if (is_int($identity)) {
$customer_id = $identity;
$customerModel = $this->_customerModel::findIdentity($customer_id);
$customerModel = $this->_customerModel->findIdentity($customer_id);
} elseif (is_string($identity)) {
$email = $identity;
$customerModel = $this->_customerModel::findByEmail($email);
$customerModel = $this->_customerModel->findByEmail($email);
} elseif (is_object($identity)) {
$customerModel = $identity;
}
Expand Down Expand Up @@ -222,7 +222,7 @@ protected function actionGetModelName()
protected function actionGetByPrimaryKey($val)
{
if ($val) {
$one = $this->_customerModel::findOne($val);
$one = $this->_customerModel->findOne($val);
$primaryKey = $this->getPrimaryKey();
if ($one[$primaryKey]) {
return $one;
Expand All @@ -242,10 +242,10 @@ protected function actionChangePasswordAndClearToken($password, $identity)
{
if (is_int($identity)) {
$customer_id = $identity;
$customerModel = $this->_customerModel::findIdentity($customer_id);
$customerModel = $this->_customerModel->findIdentity($customer_id);
} elseif (is_string($identity)) {
$email = $identity;
$customerModel = $this->_customerModel::findByEmail($email);
$customerModel = $this->_customerModel->findByEmail($email);
} elseif (is_object($identity)) {
$customerModel = $identity;
} else {
Expand Down Expand Up @@ -286,7 +286,7 @@ protected function actionGetCurrentAccount()
*/
protected function actionGetUserIdentityByEmail($email)
{
$one = $this->_customerModel::findByEmail($email);
$one = $this->_customerModel->findByEmail($email);
if ($one['email']) {
return $one;
} else {
Expand Down Expand Up @@ -324,7 +324,7 @@ protected function actionGeneratePasswordResetToken($identify)
*/
protected function actionFindByPasswordResetToken($token)
{
return $this->_customerModel::findByPasswordResetToken($token);
return $this->_customerModel->findByPasswordResetToken($token);
}

/**
Expand Down Expand Up @@ -379,15 +379,17 @@ protected function actionLoginSuccessRedirect($urlKey = '')
*/
protected function actionGetStatusDeleted()
{
return $this->_customerModel::STATUS_DELETED;
$model = $this->_customerModel;
return $model::STATUS_DELETED;
}

/**
* 得到status为激活状态的值
*/
protected function actionGetStatusActive()
{
return $this->_customerModel::STATUS_ACTIVE;
$model = $this->_customerModel;
return $model::STATUS_ACTIVE;
}
/**
* 得到customer 表的主键(mysql表)
Expand Down Expand Up @@ -415,7 +417,7 @@ protected function actionGetPrimaryKey()
*/
protected function actionColl($filter = '')
{
$query = $this->_customerModel::find();
$query = $this->_customerModel->find();
$query = Yii::$service->helper->ar->getCollByFilter($query, $filter);
//var_dump($query->all());exit;
return [
Expand All @@ -433,7 +435,7 @@ protected function actionGetEmailByIds($user_ids)
{
$arr = [];
if (is_array($user_ids) && !empty($user_ids)) {
$data = $this->_customerModel::find()->where([
$data = $this->_customerModel->find()->where([
'in', 'id', $user_ids,
])->all();
if (is_array($data) && !empty($data)) {
Expand Down
22 changes: 11 additions & 11 deletions services/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function actionGetPrimaryKey()
*/
protected function actionGetByPrimaryKey($primaryKey)
{
$one = $this->_orderModel::findOne($primaryKey);
$one = $this->_orderModel->findOne($primaryKey);
$primaryKey = $this->getPrimaryKey();
if ($one[$primaryKey]) {
return $one;
Expand All @@ -154,7 +154,7 @@ protected function actionGetByPrimaryKey($primaryKey)
*/
protected function actionGetByIncrementId($increment_id)
{
$one = $this->_orderModel::findOne(['increment_id' => $increment_id]);
$one = $this->_orderModel->findOne(['increment_id' => $increment_id]);
$primaryKey = $this->getPrimaryKey();
if ($one[$primaryKey]) {
return $one;
Expand Down Expand Up @@ -219,7 +219,7 @@ protected function actionGetOrderInfoById($order_id)
if (!$order_id) {
return;
}
$one = $this->_orderModel::findOne($order_id);
$one = $this->_orderModel->findOne($order_id);
$primaryKey = $this->getPrimaryKey();
if (!isset($one[$primaryKey]) || empty($one[$primaryKey])) {
return;
Expand Down Expand Up @@ -256,7 +256,7 @@ protected function actionGetOrderInfoById($order_id)
*/
protected function actionColl($filter = '')
{
$query = $this->_orderModel::find();
$query = $this->_orderModel->find();
$query = Yii::$service->helper->ar->getCollByFilter($query, $filter);
$coll = $query->all();

Expand All @@ -276,7 +276,7 @@ protected function actionSave($one)
$primaryKey = $this->getPrimaryKey();
$primaryVal = isset($one[$primaryKey]) ? $one[$primaryKey] : '';
if ($primaryVal) {
$model = $this->_orderModel::findOne($primaryVal);
$model = $this->_orderModel->findOne($primaryVal);
if (!$model) {
Yii::$service->helper->errors->add('order '.$this->getPrimaryKey().' is not exist');

Expand Down Expand Up @@ -308,7 +308,7 @@ protected function actionRemove($ids)
}
if (is_array($ids) && !empty($ids)) {
foreach ($ids as $id) {
$model = $this->_orderModel::findOne($id);
$model = $this->_orderModel->findOne($id);
if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) {
$model->delete();
} else {
Expand All @@ -319,7 +319,7 @@ protected function actionRemove($ids)
}
} else {
$id = $ids;
$model = $this->_orderModel::findOne($id);
$model = $this->_orderModel->findOne($id);
if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) {
$model->delete();
} else {
Expand Down Expand Up @@ -380,7 +380,7 @@ protected function actionGeneratePPExpressOrder($token){
* 通过token 得到订单 Object
*/
protected function actionGetByPaymentToken($token){
$one = $this->_orderModel::find()->where(['payment_token' => $token])
$one = $this->_orderModel->find()->where(['payment_token' => $token])
->one();
if(isset($one['order_id']) && $one['order_id']){
return $one;
Expand Down Expand Up @@ -547,12 +547,12 @@ protected function actionGenerateOrderByCart($address, $shipping_method, $paymen
*/
protected function checkOrderVersion($increment_id){
# 更新订单版本号,防止被多次执行。
$sql = 'update '.$this->_orderModel::tableName().' set version = version + 1 where increment_id = :increment_id';
$sql = 'update '.$this->_orderModel->tableName().' set version = version + 1 where increment_id = :increment_id';
$data = [
'increment_id' => $increment_id,
];
$result = $this->_orderModel::getDb()->createCommand($sql,$data)->execute();
$myOrder = $this->_orderModel::find()->where([
$result = $this->_orderModel->getDb()->createCommand($sql,$data)->execute();
$myOrder = $this->_orderModel->find()->where([
'increment_id' => $increment_id,
])->one();
# 如果版本号不等于1,则回滚
Expand Down
2 changes: 1 addition & 1 deletion services/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function setRequestParam($originUrlPath)
*/
protected function getOriginUrl($urlKey)
{
$UrlData = $this->_urlRewriteModel::find()->where([
$UrlData = $this->_urlRewriteModel->find()->where([
'custom_url_key' => $urlKey,
])->asArray()->one();
if ($UrlData['custom_url_key']) {
Expand Down
Loading

0 comments on commit f7839d1

Please sign in to comment.