123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <?php
- namespace Journal\Lib;
- use Dever;
- class Manage
- {
- /**
- * 显示用户信息
- *
- * @return mixed
- */
- public function showUserInfo($uid, $ldate = false)
- {
- if ($uid) {
- $user = Dever::db('passport/user')->one($uid);
- if ($user) {
- $table = array();
- $table['用户名'] = $user['username'];
- $table['手机号'] = $user['mobile'];
- $table['领取时间'] = date('Y-m-d H:i:s', $ldate);
- return Dever::table($table);
- }
- } else {
- return '';
- }
- }
- /**
- * 创建兑换码
- *
- * @return mixed
- */
- public function create($id, $name, $data)
- {
- $code = Dever::param('code', $data);
- $type = Dever::param('type', $data);
- $product_id = Dever::param('product_id', $data);
- //$product_id = $id;
- if (!in_array(2, $type)) {
- return;
- }
- $total = Dever::db('journal/code')->total(array('product_id' => $product_id,'product_price_id' => $id, 'type' => 1));
- if ($code > 0 && $code > $total) {
- $num = $code - $total;
- for ($i = 0; $i < $num; $i++) {
- $this->createCode($product_id, $id);
- }
- }
- }
- private function createCode($product_id, $id)
- {
- $code = Dever::rand(8, 0);
- $data['product_id'] = $product_id;
- $data['product_price_id'] = $id;
- $data['code'] = $code;
- $total = Dever::db('journal/code')->total($data);
- if ($total > 0) {
- return $this->createCode($product_id, $id);
- }
- $data['type'] = 1;
- Dever::db('code/info')->insert($data);
- return $code;
- }
- /**
- * 资料审核
- *
- * @return mixed
- */
- public function info_audit($id, $name, $data)
- {
- $info = Dever::db('task/user_info')->one($id);
- $status = Dever::param('status', $data);
- $desc = Dever::param('status_desc', $data);
- if ($info && $status == 3) {
- $uid = $info['uid'];
- $name = '用户认证未通过';
- $content = '原因:' . $desc;
- Dever::load('message/lib/data.push', -1, $uid, $name, $content, 11);
- }
- }
- private function search($table = 'content/article')
- {
- $keyword = Dever::input('keyword');
- $yes = Dever::input('yes');
- $where = array();
- 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());
- }
- return $data;
- }
- # 搜索文章
- public function search_article_api()
- {
- return $this->search('content/article');
- }
- # 搜索视频
- public function search_vod_api()
- {
- return $this->search('video/vod');
- }
- # 搜索直播
- public function search_live_api()
- {
- return $this->search('video/live');
- }
- # 显示杂志内页
- public function journalContent()
- {
- $where['info_id'] = Dever::input('search_option_info_id');
- $where['state'] = Dever::input('search_option_state');
- $data = Dever::db('journal/content')->all($where);
- $database = Dever::load('manage/database');
- if ($data) {
- foreach ($data as $k => $v) {
- if ($v['type'] <= 2) {
- $data[$k]['name'] = '';
- } elseif ($v['type'] == 3) {
- $data[$k]['pic'] = $v['focus'];
- }
- if ($v['type'] == 2) {
- $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
- } else {
- $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]['delete'] = $database->url('delete', $v['id']);
- }
- }
- return $data;
- }
- public function text($database, $content_id, $info_id)
- {
- $id = 1;
- $link = $database->url('edit') . '&search_option_info_id=' . $info_id . '&search_option_content_id=' . $content_id . '&table=content_text&where_id=' . $id;
- $edit =
- $html = '<table class="layui-table">
- <tbody>
- <tr>
- <td><a href="javascript:;" onclick="fastEdit($(this), \''.$link . '&search_option_location=1'.'\', \'编辑上左文字\', \'\')">上左</a></td>
- <td>上中</td>
- <td>上右</td>
- </tr>
- <tr>
- <td>中左</td>
- <td>正中</td>
- <td>中右</td>
- </tr>
- <tr>
- <td>下左</td>
- <td>下中</td>
- <td>下右</td>
- </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('journal/content')->update($where);
- }
- }
- return $data;
- }
- }
|