Skip to content

Commit

Permalink
appimage
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Sep 27, 2017
1 parent fcac423 commit 32922a7
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/apphtml5/modules/Customer/block/order/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function initParam()
{
if (!Yii::$app->user->isGuest) {
$identity = Yii::$app->user->identity;
$this->customer_id = $identity;
$this->customer_id = $identity['id'];
}
$this->pageNum = (int) Yii::$app->request->get('p');
$this->pageNum = ($this->pageNum >= 1) ? $this->pageNum : 1;
Expand Down
105 changes: 105 additions & 0 deletions app/appserver/modules/Customer/controllers/OrderController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/

namespace fecshop\app\appserver\modules\Customer\controllers;

use fecshop\app\appserver\modules\AppserverTokenController;
use Yii;
use \Firebase\JWT\JWT;

/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class OrderController extends AppserverTokenController
{
public $enableCsrfValidation = false ;
protected $numPerPage = 10;
protected $pageNum;
protected $orderBy;
protected $customer_id;
protected $_page = 'p';

public function actionIndex()
{
$identity = Yii::$app->user->identity;
$this->customer_id = $identity['id'];
$this->pageNum = (int) Yii::$app->request->get('p');
$this->pageNum = ($this->pageNum >= 1) ? $this->pageNum : 1;
$this->orderBy = ['created_at' => SORT_DESC];
$return_arr = [];
if ($this->customer_id) {
$filter = [
'numPerPage' => $this->numPerPage,
'pageNum' => $this->pageNum,
'orderBy' => $this->orderBy,
'where' => [
['customer_id' => $this->customer_id],
],
'asArray' => true,
];

$customer_order_list = Yii::$service->order->coll($filter);
$order_list = $customer_order_list['coll'];
$count = $customer_order_list['count'];
if(is_array($order_list)){
foreach($order_list as $k=>$order){
$created_at = $order_list[$k]['created_at'];
$order_list[$k]['created_at'] = date('Y-m-d H:i:s',$created_at);
}
}
return [
'code' => 200,
'orderList' => $order_list,
'count' => $count,
];
}
}


public function actionView(){
$order_id = Yii::$app->request->get('order_id');
if ($order_id) {
$order_info = Yii::$service->order->getOrderInfoById($order_id);
if (isset($order_info['customer_id']) && !empty($order_info['customer_id'])) {
$identity = Yii::$app->user->identity;
$customer_id = $identity->id;
if ($order_info['customer_id'] == $customer_id) {
$order_info['created_at'] = date('Y-m-d H:i:s',$order_info['created_at']);
$productArr = [];
if(is_array($order_info['products'])){
foreach($order_info['products'] as $product){
$productArr[] = [
'imgUrl' => Yii::$service->product->image->getResize($product['image'],[100,100],false),
'name' => $product['name'],
'sku' => $product['sku'],
'qty' => $product['qty'],
'row_total' => $product['row_total'],
'product_id' => $product['product_id'],
'custom_option_info' => $product['custom_option_info'],
];

}
}
$order_info['products'] = $productArr;
return [
'code' => 200,
'order'=> $order_info,
];

}
}
}


}



}
2 changes: 1 addition & 1 deletion services/cms/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function actionGetByPrimaryKey($primaryKey)
*/
protected function actionGetModelName()
{
return get_class($this->_article->getByPrimaryKey());
return get_class($this->_article);
}

/**
Expand Down
23 changes: 14 additions & 9 deletions services/product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ protected function actionGetResize($imageVal, $imgResize, $isWatered = false)
$waterImgPath = $this->getDir('/'.$this->waterImg);
}
list($newPath, $newUrl) = $this->getProductNewPath($imageVal, $imgResize, $waterImgPath);
if (!file_exists($newPath)) {
\fec\helpers\CImage::saveResizeMiddleWaterImg($originImgPath, $newPath, $imgResize, $waterImgPath);
}
if($newPath && $newUrl){
if (!file_exists($newPath)) {
\fec\helpers\CImage::saveResizeMiddleWaterImg($originImgPath, $newPath, $imgResize, $waterImgPath);
}

return $newUrl;
return $newUrl;
}
}
/**
* @property $imageVal | String ,图片相对路径字符串。
Expand Down Expand Up @@ -163,10 +165,13 @@ protected function getProductNewPath($imageVal, $imgResize, $waterImgPath)
$dirArr[] = $igf;
}
}
\fec\helpers\CDir::createFloder($this->getBaseDir(), $dirArr);
$newPath = $this->getBaseDir().$baseDir .'/'.$width.'/'.$height.$imageVal;
$newUrl = $this->getBaseUrl().$baseDir .'/'.$width.'/'.$height.$imageVal;

return [$newPath, $newUrl];
$createDir = \fec\helpers\CDir::createFloder($this->getBaseDir(), $dirArr);
if($createDir){
$newPath = $this->getBaseDir().$baseDir .'/'.$width.'/'.$height.$imageVal;
$newUrl = $this->getBaseUrl().$baseDir .'/'.$width.'/'.$height.$imageVal;
return [$newPath, $newUrl];
}else{
return [];
}
}
}

0 comments on commit 32922a7

Please sign in to comment.