common\local\local_services\Coupon 代码如下:
<?php
namespace common\local\local_services;
use fecshop\services\Service;
use Yii;
class Coupon extends Service
{
/**
* $storagePrex , $storage , $storagePath 为找到当前的storage而设置的配置参数
* 可以在配置中更改,更改后,就会通过容器注入的方式修改相应的配置值
*/
public $storage; // 当前的storage,在config中配置,在初始化的时候会被注入修改
/**
* 设置storage的path路径,
* 如果不设置,则系统使用默认路径
* 如果设置了路径,则使用自定义的路径
*/
public $storagePath;
protected $_coupon;
public function init()
{
parent::init();
$currentService = $this->getStorageService($this);
$this->_coupon = new $currentService();
}
/**
* get artile's primary key.
*/
protected function actionGetPrimaryKey()
{
return $this->_coupon->getPrimaryKey();
}
/**
* get artile model by primary key.
*/
protected function actionGetByPrimaryKey($primaryKey)
{
return $this->_coupon->getByPrimaryKey($primaryKey);
}
/**
* 得到category model的全名.
*/
protected function actionGetModelName()
{
return get_class($this->_coupon);
}
/**
* @property $filter|array
* get artile collection by $filter
* example filter:
* [
* 'numPerPage' => 20,
* 'pageNum' => 1,
* 'orderBy' => ['_id' => SORT_DESC, 'sku' => SORT_ASC ],
'where' => [
['>','price',1],
['<=','price',10]
* ['sku' => 'uk10001'],
* ],
* 'asArray' => true,
* ]
*/
protected function actionColl($filter = '')
{
return $this->_coupon->coll($filter);
}
/**
* @property $one|array , save one data .
* @property $originUrlKey|string , article origin url key.
* save $data to cms model,then,add url rewrite info to system service urlrewrite.
*/
protected function actionSave($one, $originUrlKey)
{
return $this->_coupon->save($one, $originUrlKey);
}
protected function actionRemove($ids)
{
return $this->_coupon->remove($ids);
}
}