| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace common\services;
- use Yii;
- use common\components\dict;
- use common\models\xhLuckyDrawAwardCustomer;
- /**
- * 抽奖活动-中奖用户
- * Class xhLuckyDrawAwardCustomerService
- * @package common\services
- */
- class xhLuckyDrawAwardCustomerService {
- public static function add($data)
- {
- $data = xhLuckyDrawAwardCustomer::add($data, true);
- //存入缓存
- baseService::setCacheByData($data, 'xhLuckyDrawAwardCustomer', '', Yii::$app->params['oneDayExpireTime']);
- return $data;
- }
- /**
- * 通过ID获取数据
- * @param $id
- * @return bool
- */
- public static function getById($id)
- {
- $preKey = dict::getCacheKey('xhLuckyDrawAward');
- $cacheKey = $preKey.$id;
- $cacheData = baseService::getCache($cacheKey);
- if(empty($cacheData)){
- $data = baseService::setCacheById($id, 'xhLuckyDrawAwardCustomer', $cacheKey, Yii::$app->params['oneDayExpireTime']);
- if($data === false){
- return false;
- }
- return $data;
- }
- }
- public static function updateById($id, $data)
- {
- $data['id'] = $id;
- $re = xhLuckyDrawAwardCustomer::updateById($id, $data);
- $reData = $re['data'];
- baseService::setCacheByData($reData, 'xhLuckyDrawAwardCustomer');
- return $re;
- }
- }
|