|
@@ -49,19 +49,51 @@ class Api extends Core
|
|
|
$data['button']['bgcolor'] .= $data['button']['color'];
|
|
|
}
|
|
|
|
|
|
- # 获取最新的章节页id
|
|
|
- $page_where['info_id'] = $data['info']['id'];
|
|
|
- $page_where['year'] = $this->year;
|
|
|
- $data['page'] = Dever::db('collection/page')->child($page_where);
|
|
|
- $data['page_id'] = 0;
|
|
|
- if ($data['page']) {
|
|
|
- $data['page_id'] = $data['page'][0]['id'];
|
|
|
+ # 获取最新的用户记录
|
|
|
+ $where['info_id'] = $this->id;
|
|
|
+ $where['uid'] = $this->uid;
|
|
|
+ $record = Dever::db('collection/user_record')->one($where);
|
|
|
+ if ($record) {
|
|
|
+ $data['page_id'] = $record['page_id'];
|
|
|
+ $data['times'] = $record['times_id'];
|
|
|
+ $data['index'] = $record['index'];
|
|
|
+ } else {
|
|
|
+ # 获取最新的章节页id
|
|
|
+ $page_where['info_id'] = $data['info']['id'];
|
|
|
+ $page_where = $this->getTimes($page_where);
|
|
|
+ $page = Dever::db('collection/page')->child($page_where);
|
|
|
+ $data['page_id'] = 0;
|
|
|
+ if ($page) {
|
|
|
+ $data['page_id'] = $page[0]['id'];
|
|
|
+ }
|
|
|
+ $data['times'] = 0;
|
|
|
+ if ($this->times) {
|
|
|
+ $data['times'] = $this->times;
|
|
|
+ }
|
|
|
+ $data['index'] = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ private function getTimes($where)
|
|
|
+ {
|
|
|
+ # 获取当前年份的最新的时光
|
|
|
+ if (!$this->times) {
|
|
|
+ $where['year'] = date('Y');
|
|
|
+ $times = Dever::db('collection/times')->getNew($where);
|
|
|
+ if ($times) {
|
|
|
+ $this->times = $times['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($this->times) {
|
|
|
+ $where['times_id'] = $this->times;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $where;
|
|
|
+ }
|
|
|
+
|
|
|
# 获取合集下的购买内容
|
|
|
public function getBuy()
|
|
|
{
|
|
@@ -154,8 +186,11 @@ class Api extends Core
|
|
|
$where['info_id'] = $this->id;
|
|
|
$data['cate'] = Dever::db('collection/page')->main($where);
|
|
|
if ($data['cate']) {
|
|
|
- $data['child'] = Dever::db('collection/page')->child($where);
|
|
|
$content = Dever::db('collection/content')->child($where);
|
|
|
+
|
|
|
+ $where = $this->getTimes($where);
|
|
|
+ $data['child'] = Dever::db('collection/page')->child($where);
|
|
|
+
|
|
|
$data['show'] = array();
|
|
|
foreach ($data['cate'] as $k => $v) {
|
|
|
if ($v['id'] == $parent_page_id) {
|
|
@@ -175,6 +210,56 @@ class Api extends Core
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ # 获取合集下的时光
|
|
|
+ public function times()
|
|
|
+ {
|
|
|
+ $parent_page_id = Dever::input('parent_page_id');
|
|
|
+ $page_id = Dever::input('page_id');
|
|
|
+ $where['info_id'] = $this->id;
|
|
|
+ $data['cur'] = $this->times;
|
|
|
+ $data['times'] = Dever::db('collection/times')->main($where);
|
|
|
+ if ($data['times']) {
|
|
|
+ foreach ($data['times'] as $k => $v) {
|
|
|
+ $where['times_id'] = $v['id'];
|
|
|
+ $data['times'][$k]['child'] = Dever::db('collection/times')->child($where);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ # 根据时光id获取pageid
|
|
|
+ public function getPageId()
|
|
|
+ {
|
|
|
+ $where['info_id'] = $this->id;
|
|
|
+ $where = $this->getTimes($where);
|
|
|
+ $page = Dever::db('collection/page')->getOne($where);
|
|
|
+ if ($page) {
|
|
|
+ return $page;
|
|
|
+ }
|
|
|
+ Dever::alert('error');
|
|
|
+ }
|
|
|
+
|
|
|
+ # 记录用户操作
|
|
|
+ public function record()
|
|
|
+ {
|
|
|
+ $where['info_id'] = $this->id;
|
|
|
+ $where['uid'] = $this->uid;
|
|
|
+ $record = Dever::db('collection/user_record')->one($where);
|
|
|
+ $where['page_id'] = Dever::input('page_id');
|
|
|
+ $where['times_id'] = $this->times;
|
|
|
+ $where['content_id'] = Dever::input('content_id');
|
|
|
+ $where['index'] = Dever::input('index');
|
|
|
+ if ($record) {
|
|
|
+ $where['where_id'] = $record['id'];
|
|
|
+ Dever::db('collection/user_record')->update($where);
|
|
|
+ } else {
|
|
|
+ Dever::db('collection/user_record')->insert($where);
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'yes';
|
|
|
+ }
|
|
|
+
|
|
|
public function ding($data)
|
|
|
{
|
|
|
if (isset($data['num_add_buy']) && isset($data['num_ratio_buy'])) {
|
|
@@ -194,6 +279,8 @@ class Api extends Core
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
+ $data['num_up'] = 0;
|
|
|
+ } else {
|
|
|
$data['num_up'] = 0;
|
|
|
}
|
|
|
|