Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Jun 6, 2016
1 parent 08adf21 commit ecc1d21
Show file tree
Hide file tree
Showing 30 changed files with 377 additions and 7 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ fecshop for ecommerce , online shop open source
> 项目已经开始
> Terry
[![Latest Stable Version](https://poser.pugx.org/fancyecommerce/fecshop/v/stable)](https://packagist.org/packages/fancyecommerce/fecshop)
[![Total Downloads](https://poser.pugx.org/fancyecommerce/fecshop/downloads)](https://packagist.org/packages/fancyecommerce/fecshop)
[![License](https://poser.pugx.org/fancyecommerce/fecshop/license)](https://packagist.org/packages/fancyecommerce/fecshop)


1、安装Yii2
------------

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.6" ,
"fancyecommerce/fec_admin":"~1.3.5.3"

"fancyecommerce/fec_admin":"~1.3.5.3",
"yiisoft/yii2-mongodb": "~2.0.0"
},
"autoload": {
"psr-4": {
Expand Down
33 changes: 33 additions & 0 deletions models/db/product/ViewLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\models\db\product;
use Yii;

/**
* @author Terry Zhao <[email protected]>
* @since 1.0
*/

class ViewLog extends ActiveRecord
{
public static $_tableName;

public static function tableName()
{
return self::$_tableName;
}

public static function setCurrentTableName($tableName){
self::$_tableName = $tableName;
}




}
Empty file.
Empty file added services/Breadcrumbs.php
Empty file.
Empty file added services/Cart.php
Empty file.
Empty file added services/Category.php
Empty file.
Empty file added services/Cms.php
Empty file.
Empty file added services/Coupon.php
Empty file.
Empty file added services/Currency.php
Empty file.
Empty file added services/Customer.php
Empty file.
Empty file added services/Email.php
Empty file.
Empty file added services/Order.php
Empty file.
Empty file added services/Payment.php
Empty file.
86 changes: 86 additions & 0 deletions services/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services;
use Yii;
use yii\base\InvalidValueException;
use yii\base\InvalidConfigException;
/**
* Product Service is the component that you can get product info from it.
* @property Image|\fecshop\services\Product\Image $image ,This property is read-only.
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class Product extends Service
{
public $_productId;
/**
* 1.得到单个产品的详细信息。
* 2.通过当前的语言,名字,描述等都会被转换成当前语言的value
* 3.价格将会被转换成当前货币的价格。
* 4.图片将会被转换成url(根据当前的domain)
* 5.这个功能提供给产品详细页面使用。返回的值比较全面
*/
public function getProductInfo($productId='',$selectAttr=[])
{
if(!$productId)
$productId = $this->getCurrentProductId();
if(!$productId)
throw new InvalidValueException('productId is empty,you must pass a ProductId');


}




/**
* 通过where条件,得到product的数组,
* 您可以在 $selectAttr 中指定返回的字段。
* 如果您选择的属性中有图片,那么图片将会返回url
* 这个功能给分类页面使用
*/
public function getProductCollByWhere($where , $selectAttr){


}

/**
* 得到销量最好的产品,这个给首页等其他地方使用
*/
public function getBestSellProduct(){


}


/**
* 得到某个分类的产品销量最好
*/
public function getCategoryBestSellProduct(){
return Yii::$app->product->bestSell->getCategoryProduct();

}




public function setCurrentProductId($productId){
$this->_productId = $productId;
}

public function getCurrentProductId(){
return $this->_productId;
}






}
Empty file added services/Search.php
Empty file.
46 changes: 46 additions & 0 deletions services/Service.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services;
use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;
/**
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class Service extends Component
{
public $childService;
public $_childService;

/**
* 得到services 里面配置的子服务childService的实例
*/
public function getChildService($childServiceName){
if(!$this->_childService[$childServiceName]){
$childService = $this->childService;
if(isset($childService[$childServiceName])){
$service = $childService[$childServiceName];
$this->_childService[$childServiceName] = Yii::createObject($service);
}else{
throw new InvalidConfigException('Child Service ['.$childServiceName.'] is not find in '.get_called_class().', you must config it! ');
}
}
return $this->_childService[$childServiceName];
}

/**
*
*/
public function __get($attr){
return $this->getChildService($attr);

}

}
Empty file added services/Shipping.php
Empty file.
Empty file added services/Sitemap.php
Empty file.
Empty file added services/Staticblock.php
Empty file.
Empty file added services/Store.php
Empty file.
Empty file added services/Url.php
Empty file.
40 changes: 40 additions & 0 deletions services/product/BestSell.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services\product;
use Yii;
use yii\base\InvalidConfigException;
use fecshop\services\Service;
/**
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class BestSell extends Service
{

/**
* 得到全部产品中热销的产品
*/

public function getCategoryProduct()
{
return 'category best sell product';
}

/**
* 得到全部产品中热销的产品
*/
public function getProduct(){


}




}
Empty file added services/product/Coll.php
Empty file.
37 changes: 37 additions & 0 deletions services/product/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services\product;
use Yii;
use yii\base\InvalidConfigException;
use fecshop\services\Service;
/**
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class Image extends Service
{
public $imagePath;
# get Current Product info
public function getProductImage()
{
return 'product Image info';
}

public function getImageBasePath(){
return Yii::getAlias("@webroot").'/'. $this->imagePath;
}


public function getBase(){
return $this->getChildService('base');
}



}
Empty file added services/product/Info.php
Empty file.
Empty file added services/product/Price.php
Empty file.
Empty file added services/product/Review.php
Empty file.
111 changes: 111 additions & 0 deletions services/product/ViewLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services\product;
use Yii;
use yii\base\InvalidConfigException;
use fecshop\services\Service;
use fecshop\models\db\product\ViewLog as DbViewLog;
use fecshop\models\mongodb\product\ViewLog as MongodbViewLog;
/**
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class ViewLog extends Service
{
public $type;
public $_defaultType = 'session';
public $_defaultViewTable = 'log_product_view';
public $_sessionKey = 'services_product_viewlog_history';
public $_maxProductCount = 10;
public $_currentType;
public $_currentTable;

public $_currentModel;


# 初始化
public function init(){
$configType = $this->type;
if(!$configType){
$configType = $this->_defaultType;
}
$configTypeArr = explode(',',$configType);
$storage = $configTypeArr[0];

if($storage == 'session'){

}else if(($storage == 'mysql') || ($storage == 'mongodb')){
if(isset($configTypeArr[1]) && $configTypeArr[1]){
$this->_currentTable = $configTypeArr[1];
}else{
$this->_currentTable = $this->_defaultViewTable;
}
if($storage == 'mysql'){
DbViewLog::setCurrentTableName($this->_currentTable);
}else if($storage == 'mongodb'){
MongodbViewLog::setCurrentCollectionName($this->_currentTable);
}
}else{

throw new InvalidConfigException('services:product->viewlog,config type is not right, you can
only config type in [session,mysql,mongodb]
,example:(1)session,(2)mysql.'.$this->_defaultViewTable.',(3)mongodb.'.$this->_defaultViewTable.'
if you config mysql or mongodb ,do not config table , default ('.$this->_defaultViewTable.') will use.
current file:'.get_called_class());
}
$this->_currentType = $storage;
}


/**
* 得到产品浏览的历史记录
*/
public function getHistory()
{
return 'category best sell product';
}

/**
* 保存产品的历史记录
*/
public function setHistory($productOb){

$logArr = [
'date_time' => CDate::getCurrentDateTime(),
'product_id'=> $productOb['id'],
'sku' => $productOb['sku'],
'image' => $productOb['image'],
'name' => is_array($productOb['name']) ? serialize($productOb['name']) : $productOb['name'],
];
if($this->_currentType == 'session'){
if(!($session_history = CSession::get($this->_sessionKey))){
$session_history = [];
}else if(($count = count($session_history)) >= $this->_maxProductCount)){
$unsetMaxKey = $count - $this->_maxProductCount ;
for($i=0;$i<=$unsetMaxKey;$i++){
array_shift($session_history);
}
}
$session_history[] = $logArr;
CSession::set($this->_sessionKey,$session_history);
}else if(($this->_currentType == 'mysql'){
$this->_currentModel
$this->_currentTable
$fn_set_exec = $this->_currentModel.'::setCurrentTableName';
\call_user_func_array($fn_set_exec,[$this->_currentTable]);

}else if(($this->_currentType == 'mongodb'){
$this->_currentTable
}
}




}
Loading

0 comments on commit ecc1d21

Please sign in to comment.