Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
0bf9d363
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0bf9d363
编写于
8月 08, 2017
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
appserver的接口部分
上级
da6cc041
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
348 addition
and
31 deletion
+348
-31
app/appapi/modules/V1/controllers/ArticleController.php
app/appapi/modules/V1/controllers/ArticleController.php
+1
-1
app/appserver/config/modules/Cms.php
app/appserver/config/modules/Cms.php
+15
-0
app/appserver/config/modules/General.php
app/appserver/config/modules/General.php
+15
-0
app/appserver/modules/AppserverController.php
app/appserver/modules/AppserverController.php
+30
-18
app/appserver/modules/Cms/Module.php
app/appserver/modules/Cms/Module.php
+44
-0
app/appserver/modules/Cms/controllers/HomeController.php
app/appserver/modules/Cms/controllers/HomeController.php
+98
-0
app/appserver/modules/General/Module.php
app/appserver/modules/General/Module.php
+44
-0
app/appserver/modules/General/controllers/BaseController.php
app/appserver/modules/General/controllers/BaseController.php
+56
-0
services/Category.php
services/Category.php
+2
-2
services/Store.php
services/Store.php
+29
-1
services/category/CategoryMongodb.php
services/category/CategoryMongodb.php
+5
-2
services/category/Product.php
services/category/Product.php
+6
-5
yii/filters/auth/QueryParamAuth.php
yii/filters/auth/QueryParamAuth.php
+3
-2
未找到文件。
app/appapi/modules/V1/controllers/ArticleController.php
浏览文件 @
0bf9d363
...
...
@@ -18,7 +18,7 @@ class ArticleController extends AppapiController
public
function
actionTest
()
{
//
echo 11;exit;
echo
11
;
exit
;
//var_dump(get_class(Yii::$service->cms->article->getByPrimaryKey('')));
}
}
app/appserver/config/modules/Cms.php
0 → 100644
浏览文件 @
0bf9d363
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
return
[
'cms'
=>
[
'class'
=>
'\fecshop\app\appserver\modules\Cms\Module'
,
'params'
=>
[
],
]
];
\ No newline at end of file
app/appserver/config/modules/General.php
0 → 100644
浏览文件 @
0bf9d363
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
return
[
'general'
=>
[
'class'
=>
'\fecshop\app\appserver\modules\General\Module'
,
'params'
=>
[
],
]
];
\ No newline at end of file
app/appserver/modules/AppserverController.php
浏览文件 @
0bf9d363
...
...
@@ -9,45 +9,57 @@
namespace
fecshop\app\appserver\modules
;
use
fec\controllers\Fec
Controller
;
use
yii\rest\
Controller
;
use
fec\helpers\CConfig
;
use
Yii
;
use
yii\web\Response
;
use
yii\filters\auth\CompositeAuth
;
use
yii\filters\auth\HttpBasicAuth
;
use
yii\filters\auth\HttpBearerAuth
;
use
yii\filters\auth\QueryParamAuth
;
use
yii\base\InvalidValueException
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
AppserverController
extends
Fec
Controller
class
AppserverController
extends
Controller
{
public
$blockNamespace
;
/**
* init theme component property : $fecshopThemeDir and $layoutFile
* $fecshopThemeDir is appfront base theme directory.
* layoutFile is current layout relative path.
*/
public
function
init
()
{
parent
::
init
();
Yii
::
$app
->
user
->
enableSession
=
false
;
//if (!Yii::$service->page->theme->fecshopThemeDir) {
// Yii::$service->page->theme->fecshopThemeDir = Yii::getAlias(CConfig::param('appfrontBaseTheme'));
//}
//if (!Yii::$service->page->theme->layoutFile) {
// Yii::$service->page->theme->layoutFile = CConfig::param('appfrontBaseLayoutName');
//}
//Yii::$service->page->translate->category = 'appfront';
}
public
function
behaviors
()
{
$behaviors
=
parent
::
behaviors
();
$behaviors
[
'contentNegotiator'
][
'formats'
][
'text/html'
]
=
Response
::
FORMAT_JSON
;
$behaviors
[
"corsFilter"
]
=
[
'class'
=>
\
yii\filters\Cors
::
className
(),
'cors'
=>
[
// restrict access to
'Origin'
=>
[
'*'
],
'Access-Control-Request-Method'
=>
[
'GET'
,
'POST'
,
'PUT'
,
'PATCH'
,
'DELETE'
,
'HEAD'
,
'OPTIONS'
],
// Allow only POST and PUT methods
'Access-Control-Request-Headers'
=>
[
'*'
],
// Allow only headers 'X-Wsse'
'Access-Control-Allow-Credentials'
=>
null
,
// Allow OPTIONS caching
'Access-Control-Max-Age'
=>
86400
,
// Allow the X-Pagination-Current-Page header to be exposed to the browser.
'Access-Control-Expose-Headers'
=>
[
'fecshop_uuid'
],
],
];
return
$behaviors
;
}
/**
* get current block
* you can change $this->blockNamespace.
*/
public
function
getBlock
(
$blockName
=
''
)
{
if
(
!
$blockName
)
{
...
...
app/appserver/modules/Cms/Module.php
0 → 100644
浏览文件 @
0bf9d363
<?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\Cms
;
use
fecshop\app\appserver\modules\AppserverModule
;
use
Yii
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
Module
extends
AppserverModule
{
public
$blockNamespace
;
public
function
init
()
{
// 以下代码必须指定
$nameSpace
=
__NAMESPACE__
;
// web controller
if
(
Yii
::
$app
instanceof
\
yii\web\Application
)
{
$this
->
controllerNamespace
=
$nameSpace
.
'\\controllers'
;
$this
->
blockNamespace
=
$nameSpace
.
'\\block'
;
// console controller
//} elseif (Yii::$app instanceof \yii\console\Application) {
// $this->controllerNamespace = $nameSpace . '\\console\\controllers';
// $this->blockNamespace = $nameSpace . '\\console\\block';
}
//$this->_currentDir = __DIR__ ;
//$this->_currentNameSpace = __NAMESPACE__;
// 指定默认的man文件
//$this->layout = "home.php";
//Yii::$service->page->theme->layoutFile = 'main.php';
parent
::
init
();
}
}
app/appserver/modules/Cms/controllers/HomeController.php
0 → 100644
浏览文件 @
0bf9d363
<?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\Cms\controllers
;
use
fecshop\app\appserver\modules\AppserverController
;
use
Yii
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
HomeController
extends
AppserverController
{
public
function
actionAdvertise
(){
$bigImg1
=
Yii
::
$service
->
image
->
getImgUrl
(
'custom/home_img_1.jpg'
,
'apphtml5'
);
$bigImg2
=
Yii
::
$service
->
image
->
getImgUrl
(
'custom/home_img_2.jpg'
,
'apphtml5'
);
$bigImg3
=
Yii
::
$service
->
image
->
getImgUrl
(
'custom/home_img_3.jpg'
,
'apphtml5'
);
$smallImg1
=
Yii
::
$service
->
image
->
getImgUrl
(
'custom/home_small_1.jpg'
,
'apphtml5'
);
$smallImg2
=
Yii
::
$service
->
image
->
getImgUrl
(
'custom/home_small_2.jpg'
,
'apphtml5'
);
return
[
'bigImgList'
=>
[
[
'imgUrl'
=>
$bigImg1
],
[
'imgUrl'
=>
$bigImg2
],
[
'imgUrl'
=>
$bigImg3
],
],
'smallImgList'
=>
[
[
'imgUrl'
=>
$smallImg1
],
[
'imgUrl'
=>
$smallImg2
],
],
];
}
public
function
actionProduct
(){
$featured_skus
=
Yii
::
$app
->
controller
->
module
->
params
[
'homeFeaturedSku'
];
Yii
::
$service
->
session
->
getUUID
();
return
$this
->
getProductBySkus
(
$featured_skus
);
}
//public function getBestSellerProduct(){
// $best_skus = Yii::$app->controller->module->params['homeBestSellerSku'];
// return $this->getProductBySkus($best_skus);
//}
public
function
getProductBySkus
(
$skus
)
{
if
(
is_array
(
$skus
)
&&
!
empty
(
$skus
))
{
$filter
[
'select'
]
=
[
'sku'
,
'spu'
,
'name'
,
'image'
,
'price'
,
'special_price'
,
'special_from'
,
'special_to'
,
'url_key'
,
'score'
,
];
$filter
[
'where'
]
=
[
'in'
,
'sku'
,
$skus
];
$products
=
Yii
::
$service
->
product
->
getProducts
(
$filter
);
//var_dump($products);
$products
=
Yii
::
$service
->
category
->
product
->
convertToCategoryInfo
(
$products
);
$i
=
1
;
$product_return
=
[];
if
(
is_array
(
$products
)
&&
!
empty
(
$products
)){
foreach
(
$products
as
$k
=>
$v
){
$i
++
;
$products
[
$k
][
'url'
]
=
'/catalog/product/'
.
$v
[
'product_id'
];
$products
[
$k
][
'image'
]
=
Yii
::
$service
->
product
->
image
->
getUrl
(
$v
[
'image'
]
);
if
(
$i
%
2
===
0
){
$arr
=
$products
[
$k
];
}
else
{
$product_return
[]
=
[
'one'
=>
$arr
,
'two'
=>
$products
[
$k
],
];
}
}
if
(
$i
%
2
===
0
){
$product_return
[]
=
[
'one'
=>
$arr
,
'two'
=>
[],
];
}
}
return
$product_return
;
}
}
}
\ No newline at end of file
app/appserver/modules/General/Module.php
0 → 100644
浏览文件 @
0bf9d363
<?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\General
;
use
fecshop\app\appserver\modules\AppserverModule
;
use
Yii
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
Module
extends
AppserverModule
{
public
$blockNamespace
;
public
function
init
()
{
// 以下代码必须指定
$nameSpace
=
__NAMESPACE__
;
// web controller
if
(
Yii
::
$app
instanceof
\
yii\web\Application
)
{
$this
->
controllerNamespace
=
$nameSpace
.
'\\controllers'
;
$this
->
blockNamespace
=
$nameSpace
.
'\\block'
;
// console controller
//} elseif (Yii::$app instanceof \yii\console\Application) {
// $this->controllerNamespace = $nameSpace . '\\console\\controllers';
// $this->blockNamespace = $nameSpace . '\\console\\block';
}
//$this->_currentDir = __DIR__ ;
//$this->_currentNameSpace = __NAMESPACE__;
// 指定默认的man文件
//$this->layout = "home.php";
//Yii::$service->page->theme->layoutFile = 'main.php';
parent
::
init
();
}
}
app/appserver/modules/General/controllers/BaseController.php
0 → 100644
浏览文件 @
0bf9d363
<?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\General\controllers
;
use
fecshop\app\appserver\modules\AppserverController
;
use
Yii
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
BaseController
extends
AppserverController
{
public
function
actionMenu
(){
$arr
=
Yii
::
$service
->
category
->
getTreeArr
(
''
,
''
,
true
);
return
$arr
;
}
// 语言
public
function
actionLang
(){
$langs
=
Yii
::
$service
->
store
->
serverLangs
;
$currentLangCode
=
Yii
::
$service
->
store
->
currentLangCode
;
foreach
(
$langs
as
$k
=>
$one
){
$code
=
$one
[
'code'
];
if
(
$currentLangCode
==
$code
){
$langs
[
$k
][
'selected'
]
=
true
;
}
else
{
$langs
[
$k
][
'selected'
]
=
false
;
}
}
return
$langs
;
}
public
function
actionCurrency
(){
$currencys
=
Yii
::
$service
->
page
->
currency
->
getCurrencys
();
$currentCurrencyCode
=
Yii
::
$service
->
page
->
currency
->
getCurrentCurrency
();
foreach
(
$currencys
as
$k
=>
$one
){
$code
=
$one
[
'code'
];
if
(
$currentCurrencyCode
==
$code
){
$currencys
[
$k
][
'selected'
]
=
true
;
}
else
{
$currencys
[
$k
][
'selected'
]
=
false
;
}
}
return
$currencys
;
}
}
\ No newline at end of file
services/Category.php
浏览文件 @
0bf9d363
...
...
@@ -105,9 +105,9 @@ class Category extends Service
* 数组中只有 id name(default language), child(子分类) 等数据。
* 目前此函数仅仅用于后台对分类的编辑使用。 appadmin.
*/
protected
function
actionGetTreeArr
(
$rootCategoryId
=
0
)
protected
function
actionGetTreeArr
(
$rootCategoryId
=
0
,
$lang
=
''
,
$appserver
=
false
)
{
return
$this
->
_category
->
getTreeArr
(
$rootCategoryId
);
return
$this
->
_category
->
getTreeArr
(
$rootCategoryId
,
$lang
,
$appserver
);
}
/**
...
...
services/Store.php
浏览文件 @
0bf9d363
...
...
@@ -53,7 +53,8 @@ class Store extends Service
public
$thirdLogin
;
//public $https;
public
$serverLangs
;
/**
* Bootstrap:init website, class property $currentLang ,$currentTheme and $currentStore.
* if you not config this ,default class property will be set.
...
...
@@ -108,6 +109,33 @@ class Store extends Service
*/
$init_compelte
=
1
;
$this
->
thirdLogin
=
$store
[
'thirdLogin'
];
/**
* appserver 部分
*/
if
(
isset
(
$store
[
'serverLangs'
])
&&
!
empty
(
$store
[
'serverLangs'
])){
$this
->
serverLangs
=
$store
[
'serverLangs'
];
}
$headers
=
Yii
::
$app
->
request
->
getHeaders
();
if
(
isset
(
$headers
[
'language'
])
&&
$headers
[
'language'
]){
$h_lang
=
$headers
[
'language'
];
if
(
is_array
(
$this
->
serverLangs
)){
foreach
(
$this
->
serverLangs
as
$one
){
if
(
$one
[
'code'
]
==
$h_lang
){
Yii
::
$service
->
store
->
currentLangCode
=
$h_lang
;
}
}
}
}
if
(
isset
(
$headers
[
'currency'
])
&&
$headers
[
'currency'
]){
$currentC
=
Yii
::
$service
->
page
->
currency
->
getCurrentCurrency
();
if
(
$currentC
!=
$headers
[
'currency'
]){
Yii
::
$service
->
page
->
currency
->
setCurrentCurrency
(
$currentC
);
}
}
break
;
}
}
...
...
services/category/CategoryMongodb.php
浏览文件 @
0bf9d363
...
...
@@ -196,7 +196,7 @@ class CategoryMongodb implements CategoryInterface
* 数组中只有 id name(default language), child(子分类) 等数据。
* 目前此函数仅仅用于后台对分类的编辑使用。 appadmin.
*/
public
function
getTreeArr
(
$rootCategoryId
=
''
,
$lang
=
''
)
public
function
getTreeArr
(
$rootCategoryId
=
''
,
$lang
=
''
,
$appserver
=
false
)
{
$arr
=
[];
if
(
!
$lang
)
{
...
...
@@ -217,10 +217,13 @@ class CategoryMongodb implements CategoryInterface
$idKey
=>
$idVal
,
'name'
=>
Yii
::
$service
->
fecshoplang
->
getLangAttrVal
(
$cate
[
'name'
],
'name'
,
$lang
),
];
if
(
$appserver
){
$arr
[
$idVal
][
'url'
]
=
Yii
::
$service
->
url
->
getUrl
(
'catalog/category/'
.
$idVal
);
}
//echo $arr[$idVal]['name'];
if
(
$this
->
hasChildCategory
(
$idVal
))
{
$arr
[
$idVal
][
'child'
]
=
$this
->
getTreeArr
(
$idVal
,
$lang
);
$arr
[
$idVal
][
'child'
]
=
$this
->
getTreeArr
(
$idVal
,
$lang
,
$appserver
);
}
}
}
...
...
services/category/Product.php
浏览文件 @
0bf9d363
...
...
@@ -106,12 +106,13 @@ class Product extends Service
}
list
(
$price
,
$special_price
)
=
$this
->
getPrices
(
$one
[
'price'
],
$one
[
'special_price'
],
$one
[
'special_from'
],
$one
[
'special_to'
]);
$arr
[]
=
[
'name'
=>
$name
,
'sku'
=>
$one
[
'sku'
],
'image'
=>
$image
,
'price'
=>
$price
,
'name'
=>
$name
,
'sku'
=>
$one
[
'sku'
],
'image'
=>
$image
,
'price'
=>
$price
,
'special_price'
=>
$special_price
,
'url'
=>
Yii
::
$service
->
url
->
getUrl
(
$url_key
),
'url'
=>
Yii
::
$service
->
url
->
getUrl
(
$url_key
),
'product_id'
=>
(
string
)
$one
[
'_id'
],
];
}
}
...
...
yii/filters/auth/QueryParamAuth.php
浏览文件 @
0bf9d363
...
...
@@ -29,8 +29,9 @@ class QueryParamAuth extends YiiQueryParamAuth
return
$identity
;
}
else
{
$result
=
[
'status'
=>
'ERROR'
,
'code'
=>
401
,
'message'
=>
'token is time out'
];
echo
json_encode
(
$result
);
exit
;
Yii
::
$app
->
response
->
data
=
json_encode
(
$result
);
Yii
::
$app
->
response
->
send
();
Yii
::
$app
->
end
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录