|
@@ -0,0 +1,421 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Magazine\Lib;
|
|
|
+
|
|
|
+use Dever;
|
|
|
+
|
|
|
+class Manage
|
|
|
+{
|
|
|
+ public function getManageData()
|
|
|
+ {
|
|
|
+ $data = array();
|
|
|
+
|
|
|
+ $data = Dever::db('magazine/cate')->state();
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $data[$k]['child'] = Dever::db('magazine/info')->state(array('cate_id' => $v['id']));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function showOrderUserV1($id)
|
|
|
+ {
|
|
|
+ $info = Dever::db('act/order')->one($id);
|
|
|
+
|
|
|
+ $table = array();
|
|
|
+
|
|
|
+ $user = Dever::db('passport/user')->one($info['uid']);
|
|
|
+
|
|
|
+ $table['用户名'] = $user['username'] . '('.$info['uid'].')';
|
|
|
+ $table['手机号'] = $user['mobile'];
|
|
|
+ $table['产品名'] = $info['name'];
|
|
|
+ if ($info['type'] == 1) {
|
|
|
+ $table['支付方式'] = '购买小刊';
|
|
|
+ $table['支付金额'] = $info['cash'];
|
|
|
+ } elseif ($info['type'] == 3) {
|
|
|
+ $table['支付方式'] = '购买小刊兑换码';
|
|
|
+ $table['兑换码'] = $info['code'];
|
|
|
+ $table['支付金额'] = $info['cash'];
|
|
|
+ } elseif ($info['type'] == 2) {
|
|
|
+ $table['支付方式'] = '兑换小刊';
|
|
|
+ $table['兑换码'] = $info['code'];
|
|
|
+ } elseif ($info['type'] == 4) {
|
|
|
+ $table['支付方式'] = '使用通用兑换码';
|
|
|
+ $table['兑换码'] = $info['code'];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($info['source_uid'] && $info['source_uid'] != $info['uid']) {
|
|
|
+ $user = Dever::db('passport/user')->one($info['source_uid']);
|
|
|
+ $table['邀请人'] = $user['username'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($info['star_id']) {
|
|
|
+ $star = Dever::db('magazine/star')->one($info['star_id']);
|
|
|
+ $table['明星'] = $star['name'];
|
|
|
+ }
|
|
|
+
|
|
|
+ return Dever::table($table);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function num($id)
|
|
|
+ {
|
|
|
+ $data = Dever::db('magazine/info')->one($id);
|
|
|
+ $data = Dever::load('magazine/api')->ding($data);
|
|
|
+
|
|
|
+ $num_ding = $data['num_ding'];
|
|
|
+ $num_add_ding = $data['num_add_ding'];
|
|
|
+ $num_ratio_ding = $data['num_ratio_ding'];
|
|
|
+
|
|
|
+ $num_view = $data['num_view'];
|
|
|
+ $num_add_view = $data['num_add_view'];
|
|
|
+
|
|
|
+ $buy_num = $data['buy_num'];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $cate = Dever::db('magazine/cate')->one($data['cate_id']);
|
|
|
+ $html = '《' . $cate['name'] . '》<br />';
|
|
|
+
|
|
|
+ if ($data['buy'] == 1) {
|
|
|
+ $html .= '<font style="color:red">收费电子刊</font><br />';
|
|
|
+ $html .= '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding;
|
|
|
+ } else {
|
|
|
+ $html .= '<font style="color:blue">免费电子刊</font><br />';
|
|
|
+ $html .= '订阅数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function showOrderStatusV1($id)
|
|
|
+ {
|
|
|
+ $info = Dever::db('act/order')->one($id);
|
|
|
+ if ($info) {
|
|
|
+ if ($info['status'] == 1) {
|
|
|
+
|
|
|
+ return '待支付';
|
|
|
+ } elseif ($info['status'] == 2) {
|
|
|
+ return '已支付';
|
|
|
+ } elseif ($info['status'] == 3) {
|
|
|
+ return '支付失败';
|
|
|
+ } elseif ($info['status'] == 5) {
|
|
|
+ $table['状态'] = '已退款';
|
|
|
+ $manage = Dever::db('manage/admin')->one($info['tk_admin']);
|
|
|
+ $table['备注'] = $info['tk_desc'];
|
|
|
+ $table['截图'] = '<a><img src="'.$info['tk_pic'].'" style="width:150px" /></a>';
|
|
|
+
|
|
|
+ $table['操作人'] = $manage['username'];
|
|
|
+ return Dever::table($table);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function search($table = 'content/article')
|
|
|
+ {
|
|
|
+ $keyword = Dever::input('keyword');
|
|
|
+
|
|
|
+ $yes = Dever::input('yes');
|
|
|
+
|
|
|
+ $where = array();
|
|
|
+
|
|
|
+ $cate = Dever::input('cate');
|
|
|
+ if ($cate) {
|
|
|
+ $where['cate_id'] = $cate;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($yes) {
|
|
|
+ $yes = Dever::db($table)->search(array('ids' => $yes));
|
|
|
+ }
|
|
|
+ if (!$keyword) {
|
|
|
+ $where['limit'] = '0,50';
|
|
|
+ $data = Dever::db($table)->search($where);
|
|
|
+ } else {
|
|
|
+ $where['name'] = $keyword;
|
|
|
+ $data = Dever::db($table)->search($where);
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = array();
|
|
|
+ if ($yes) {
|
|
|
+ foreach ($yes as $k => $v) {
|
|
|
+ if (isset($data[$k])) {
|
|
|
+ unset($data[$k]);
|
|
|
+ }
|
|
|
+ $yes[$k]['selected'] = 'selected';
|
|
|
+ }
|
|
|
+ $data = $yes + $data;
|
|
|
+
|
|
|
+ $data = array_merge($data, array());
|
|
|
+ } else {
|
|
|
+ $data = array_merge($data, array());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$data) {
|
|
|
+ Dever::alert('暂无数据');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function search_journal_api()
|
|
|
+ {
|
|
|
+ return $this->search('magazine/info');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function search_cate_journal_api()
|
|
|
+ {
|
|
|
+ $level_num = Dever::input('level_num');
|
|
|
+ $level_id = Dever::input('level_id');
|
|
|
+
|
|
|
+ $auth = Dever::tops();
|
|
|
+ $where = array();
|
|
|
+ if ($level_num == 1) {
|
|
|
+ $default = array
|
|
|
+ (
|
|
|
+ 'value' => -1,
|
|
|
+ 'name' => '选择分类',
|
|
|
+ );
|
|
|
+ if ($auth) {
|
|
|
+ $where['ids'] = $auth;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = Dever::db('magazine/cate')->getIds($where);
|
|
|
+ } elseif ($level_num == 2 && $level_id > 0) {
|
|
|
+ $default = array
|
|
|
+ (
|
|
|
+ 'value' => -1,
|
|
|
+ 'name' => '选择电子刊',
|
|
|
+ );
|
|
|
+ if ($level_id > 0) {
|
|
|
+ $where['cate_id'] = $level_id;
|
|
|
+ } elseif ($auth) {
|
|
|
+ $where['cate_id'] = $auth;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = Dever::db('magazine/info')->getIds($where);
|
|
|
+ } else {
|
|
|
+ return array();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ array_unshift($data, $default);
|
|
|
+ $result['level_total'] = 2;
|
|
|
+ $result['list'] = $data;
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function journalContent()
|
|
|
+ {
|
|
|
+ $where['info_id'] = Dever::input('search_option_info_id');
|
|
|
+ $where['state'] = Dever::input('search_option_state');
|
|
|
+ $data = Dever::db('magazine/content')->all($where);
|
|
|
+
|
|
|
+ $database = Dever::load('manage/database');
|
|
|
+ $type = Dever::db('magazine/content')->config['gettype'];
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+
|
|
|
+ $data[$k]['height'] = 'height: 154px;';
|
|
|
+ $data[$k]['info_height'] = 'height: auto;';
|
|
|
+ if ($v['type'] > 2) {
|
|
|
+ $data[$k]['height'] = 'height: 104px;';
|
|
|
+ $data[$k]['info_height'] = 'height: 47px;';
|
|
|
+ }
|
|
|
+ if ($v['type'] <= 2) {
|
|
|
+ $data[$k]['name'] = '';
|
|
|
+ } elseif ($v['type'] == 3) {
|
|
|
+ $data[$k]['pic'] = $v['focus'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($v['type'] == 21 || $v['type'] == 22 || $v['type'] == 23) {
|
|
|
+ $data[$k]['name'] = '';
|
|
|
+ $data[$k]['pic'] = $v['cover'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($v['type'] == 61) {
|
|
|
+
|
|
|
+ $info = Dever::load('content/lib/article')->get($v['article_id']);
|
|
|
+ if ($info) {
|
|
|
+ $data[$k]['pic'] = $info['pic_cover'];
|
|
|
+ $data[$k]['name'] = $info['name'];
|
|
|
+ }
|
|
|
+ } elseif ($v['type'] == 62) {
|
|
|
+
|
|
|
+ $info = Dever::load('video/lib/vod')->get($v['vod_id']);
|
|
|
+ if ($info) {
|
|
|
+ $data[$k]['pic'] = $info['pic_cover'];
|
|
|
+ $data[$k]['name'] = $info['name'];
|
|
|
+ }
|
|
|
+ } elseif ($v['type'] == 63) {
|
|
|
+
|
|
|
+ $info = Dever::load('video/lib/live')->get($v['live_id']);
|
|
|
+ if ($info) {
|
|
|
+ $data[$k]['pic'] = $info['pic_cover'];
|
|
|
+ $data[$k]['name'] = $info['name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($v['type'] == 13) {
|
|
|
+ $palaces = Dever::array_decode($v['palaces']);
|
|
|
+ if (isset($palaces[0])) {
|
|
|
+ $data[$k]['pic'] = $palaces[0]['pic'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($v['type'] == 41) {
|
|
|
+ if ($data[$k]['talk_pic']) {
|
|
|
+ $data[$k]['pic'] = $data[$k]['talk_pic'];
|
|
|
+ } else {
|
|
|
+ $talk = Dever::array_decode($v['talk']);
|
|
|
+ if ($talk) {
|
|
|
+ foreach ($talk as $tk => $tv) {
|
|
|
+ if ($tv['pic']) {
|
|
|
+ $data[$k]['pic'] = $tv['pic'];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $data[$k]['typename'] = $type[$v['type']];
|
|
|
+
|
|
|
+
|
|
|
+ if ($v['type'] == 1) {
|
|
|
+ $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
|
|
|
+ } else {
|
|
|
+ $data[$k]['text'] = '';
|
|
|
+ }
|
|
|
+ */
|
|
|
+ $data[$k]['text'] = '';
|
|
|
+
|
|
|
+ $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
|
|
|
+
|
|
|
+ $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
|
|
|
+
|
|
|
+ $data[$k]['editurl'] = $link;
|
|
|
+
|
|
|
+ $data[$k]['delete'] = $database->url('delete', $v['id']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function text_name($link, $content_id, $info_id, $location, $name)
|
|
|
+ {
|
|
|
+ $where['info_id'] = $info_id;
|
|
|
+ $where['content_id'] = $content_id;
|
|
|
+ $where['location'] = $location;
|
|
|
+ $info = Dever::db('magazine/content_text')->one($where);
|
|
|
+
|
|
|
+ $link .= '&search_option_info_id=' . $info_id. '&search_option_content_id=' . $content_id.'&table=content_text&search_option_location='.$location;
|
|
|
+
|
|
|
+ if ($info) {
|
|
|
+ $link .= '&where_id=' . $info['id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $html = '<a style="cursor:pointer;" href="javascript:;" onclick="fastEdit($(this), \''.$link.'\', \'编辑'.$name.'文字\', \'\')">'.$name.'</a>';
|
|
|
+
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function text($database, $content_id, $info_id)
|
|
|
+ {
|
|
|
+ $link = $database->url('edit');
|
|
|
+
|
|
|
+ $location = Dever::db('magazine/content_text')->config['location'];
|
|
|
+
|
|
|
+ $html = '<table class="layui-table"><tbody><tr>';
|
|
|
+ $i = 0;
|
|
|
+ foreach ($location as $k => $v) {
|
|
|
+ $name = $this->text_name($link, $content_id, $info_id, $k, $v);
|
|
|
+ $html .= '<td>'.$name.'</td>';
|
|
|
+
|
|
|
+ if ($i == 2 || $i == 5) {
|
|
|
+ $html .= '</tr><tr>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ $html .= '</tr></tbody></table>';
|
|
|
+
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function updateJournalContent_api()
|
|
|
+ {
|
|
|
+ $data = Dever::input('data');
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ $data = explode(',', str_replace('data-', '', $data));
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $k = $k + 1;
|
|
|
+ $where['where_id'] = $v;
|
|
|
+ $where['reorder'] = $k;
|
|
|
+ Dever::db('magazine/content')->update($where);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addContent($id, $name, $data)
|
|
|
+ {
|
|
|
+
|
|
|
+ $info_id = Dever::param('info_id', $data);
|
|
|
+ $data = Dever::db('magazine/content')->getAllByReorder(array('info_id' => $info_id));
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ $update['where_id'] = $id;
|
|
|
+ $update['reorder'] = $data['reorder'] + 1;
|
|
|
+ Dever::db('magazine/content')->update($update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getName($id)
|
|
|
+ {
|
|
|
+ $info = Dever::db('magazine/buy')->one($id);
|
|
|
+ if ($info && $info['name']) {
|
|
|
+ return $info['name'];
|
|
|
+ } else {
|
|
|
+ return '购买' . $info['num'] . '张';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPrice($id)
|
|
|
+ {
|
|
|
+ $info = Dever::db('magazine/buy')->one($id);
|
|
|
+
|
|
|
+ $magazine = Dever::db('magazine/info')->one($info['info_id']);
|
|
|
+ if ($info && $info['price']) {
|
|
|
+ return $info['price'];
|
|
|
+ } else {
|
|
|
+ return $info['num'] * $magazine['cash'] . '元';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setJournalCache($id, $name, $param)
|
|
|
+ {
|
|
|
+ Dever::load('act/order')->setCache($id, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setBuyCache($id, $name, $param)
|
|
|
+ {
|
|
|
+ Dever::load('act/order')->setCache($id, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setRankingCache($id, $name, $param)
|
|
|
+ {
|
|
|
+ Dever::load('act/order')->setCache($id, 3);
|
|
|
+ }
|
|
|
+}
|