diff --git a/README.md b/README.md index be2e9e25656d13880654eae0a31dcf18bf2dea5e..726da6495208a8d94a6f5a3da1770a05fd2ef5c4 100644 --- a/README.md +++ b/README.md @@ -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 ------------ diff --git a/composer.json b/composer.json index f1da0b91dd5c8688b585ac1d06ef57580e822613..07e2f82367d465aa1a92e4e4af3f8a7b596405f9 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/models/db/product/ViewLog.php b/models/db/product/ViewLog.php new file mode 100644 index 0000000000000000000000000000000000000000..fbf4d99e57e34b20fba95ec2c67c47991a9e9b0b --- /dev/null +++ b/models/db/product/ViewLog.php @@ -0,0 +1,33 @@ + + * @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; + } + + + + +} diff --git a/models/mongodb/product/ViewLog.php b/models/mongodb/product/ViewLog.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Breadcrumbs.php b/services/Breadcrumbs.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Cart.php b/services/Cart.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Category.php b/services/Category.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Cms.php b/services/Cms.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Coupon.php b/services/Coupon.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Currency.php b/services/Currency.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Customer.php b/services/Customer.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Email.php b/services/Email.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Order.php b/services/Order.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Payment.php b/services/Payment.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Product.php b/services/Product.php new file mode 100644 index 0000000000000000000000000000000000000000..fd72c2489b68754d53c443fea5110eb2e35370b0 --- /dev/null +++ b/services/Product.php @@ -0,0 +1,86 @@ + + * @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; + } + + + + + + +} \ No newline at end of file diff --git a/services/Search.php b/services/Search.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Service.php b/services/Service.php new file mode 100644 index 0000000000000000000000000000000000000000..745b555619f3567e43413ca6d8ce31351f6008ff --- /dev/null +++ b/services/Service.php @@ -0,0 +1,46 @@ + + * @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); + + } + +} \ No newline at end of file diff --git a/services/Shipping.php b/services/Shipping.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Sitemap.php b/services/Sitemap.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Staticblock.php b/services/Staticblock.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Store.php b/services/Store.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/Url.php b/services/Url.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/product/BestSell.php b/services/product/BestSell.php new file mode 100644 index 0000000000000000000000000000000000000000..30fc9118c22d5e3b07e23a12c42936ebe7da927e --- /dev/null +++ b/services/product/BestSell.php @@ -0,0 +1,40 @@ + + * @since 1.0 + */ +class BestSell extends Service +{ + + /** + * õȫƷIJƷ + */ + + public function getCategoryProduct() + { + return 'category best sell product'; + } + + /** + * õȫƷIJƷ + */ + public function getProduct(){ + + + } + + + + +} \ No newline at end of file diff --git a/services/product/Coll.php b/services/product/Coll.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/product/Image.php b/services/product/Image.php new file mode 100644 index 0000000000000000000000000000000000000000..0afad6a710f3ef775119f778c71c44c58d9ebe38 --- /dev/null +++ b/services/product/Image.php @@ -0,0 +1,37 @@ + + * @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'); + } + + + +} \ No newline at end of file diff --git a/services/product/Info.php b/services/product/Info.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/product/Price.php b/services/product/Price.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/product/Review.php b/services/product/Review.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/services/product/ViewLog.php b/services/product/ViewLog.php new file mode 100644 index 0000000000000000000000000000000000000000..ba7869a2592c1dcf7215d3f01839438eaca29087 --- /dev/null +++ b/services/product/ViewLog.php @@ -0,0 +1,111 @@ + + * @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 + } + } + + + + +} \ No newline at end of file diff --git a/services/product/image/Base.php b/services/product/image/Base.php new file mode 100644 index 0000000000000000000000000000000000000000..2eb679a1f35a19a15ea4d2e70004cc3bff0fa04d --- /dev/null +++ b/services/product/image/Base.php @@ -0,0 +1,22 @@ +imagePath; + } + + + + +} \ No newline at end of file