| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 | 
							- <?php
 
- namespace Journal\Lib;
 
- use Dever;
 
- class Manage
 
- {
 
-     public function showOrderUser($id)
 
-     {
 
-         $info = Dever::db('journal/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'];
 
-         }
 
-         //$table['购买数量'] = $info['num'];
 
-         
 
-         if ($info['source_uid'] && $info['source_uid'] != $info['uid']) {
 
-             $user = Dever::db('passport/user')->one($info['source_uid']);
 
-             $table['邀请人'] = $user['username'];
 
-         }
 
-         return Dever::table($table);
 
-     }
 
-     # 获取订阅本数
 
-     public function ding($id)
 
-     {
 
-         $data = Dever::db('journal/info')->one($id);
 
-         $data = Dever::load('journal/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'];
 
-         $num_comment = $data['num_comment'];
 
-         $buy_num = $data['buy_num'];
 
-         //$html = '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding.'<br />阅读数:'.$num_view.'+'.$num_add_view.'<br />评论数:'.$num_comment.'<br />';
 
-         $html = '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding.'<br />评论数:'.$num_comment.'<br />';
 
-         return $html;
 
-     }
 
-     public function showOrderStatus($id)
 
-     {
 
-         $info = Dever::db('journal/order')->one($id);
 
-         if ($info) {
 
-             if ($info['status'] == 1) {
 
-                 #return '*已支付';
 
-                 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['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']);
 
-                 $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_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 search_journal_api()
 
-     {
 
-         return $this->search('journal/info');
 
-     }
 
-     # 搜索专题
 
-     public function search_feature_api()
 
-     {
 
-         return $this->search('feature/info');
 
-     }
 
-     # 搜索小程序
 
-     public function search_applet_api()
 
-     {
 
-         return $this->search('content/applet');
 
-     }
 
-     # 按照分类搜索小刊
 
-     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('journal/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('journal/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('journal/content')->all($where);
 
-         $database = Dever::load('manage/database');
 
-         $type = Dever::db('journal/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'] == 4 || $v['type'] == 5 || $v['type'] == 6) {
 
-                     $data[$k]['name'] = '';
 
-                     $data[$k]['pic'] = $v['cover'];
 
-                 }
 
-                 if ($v['type'] == 11) {
 
-                     # 图文
 
-                     $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'] == 12) {
 
-                     # 视频
 
-                     $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'] == 13) {
 
-                     # 直播
 
-                     $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'] == 10) {
 
-                     $palaces = Dever::array_decode($v['palaces']);
 
-                     if (isset($palaces[0])) {
 
-                         $data[$k]['pic'] = $palaces[0]['pic'];
 
-                     }
 
-                 }
 
-                 if ($v['type'] == 21) {
 
-                     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('journal/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('journal/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('journal/content')->update($where);
 
-             }
 
-         }
 
-         return $data;
 
-     }
 
-     public function addContent($id, $name, $data)
 
-     {
 
-         # 获取最新的reorder
 
-         $info_id = Dever::param('info_id', $data);
 
-         $data = Dever::db('journal/content')->getAllByReorder(array('info_id' => $info_id));
 
-         if ($data) {
 
-             $update['where_id'] = $id;
 
-             $update['reorder'] = $data['reorder'] + 1;
 
-             Dever::db('journal/content')->update($update);
 
-         }
 
-     }
 
-     public function getName($id)
 
-     {
 
-         $info = Dever::db('journal/buy_num')->one($id);
 
-         if ($info && $info['name']) {
 
-             return $info['name'];
 
-         } else {
 
-             return '购买' . $info['num'] . '本';
 
-         }
 
-     }
 
-     public function getPrice($id)
 
-     {
 
-         $info = Dever::db('journal/buy_num')->one($id);
 
-         $journal = Dever::db('journal/info')->one($info['info_id']);
 
-         if ($info && $info['price']) {
 
-             return $info['price'];
 
-         } else {
 
-             return $info['num'] * $journal['cash'] . '元';
 
-         }
 
-     }
 
-     public function mobileTemplate_api()
 
-     {
 
-         $host = 'http://' . $_SERVER['HTTP_HOST'] . '/wonderful/';
 
-         $file = $host . 'doc/mobile.xlsx';
 
-         Dever::location($file);
 
-     }
 
-     /**
 
-      * 导入用户
 
-      *
 
-      * @return mixed
 
-      */
 
-     public function mobileImport($id, $name, $param)
 
-     {
 
-         $file = Dever::param('file', $param);
 
-         if ($file) {
 
-             $file = str_replace('wonderful', 'upload', Dever::local($file));
 
-             $file = str_replace('https://api.huoxingkandiqiu.com/', '/www/', $file);
 
-             //$file = '/www/upload/data/upload/4/2019/04/11/f730437f0b5764790baed3c96c5264b2.xlsx';
 
-             $data = Dever::excelImport($file);
 
-             if ($data) {
 
-                 foreach ($data as $k => $v) {
 
-                     if ($k > 1) {
 
-                         if (isset($v['A']) && isset($v['B'])) {
 
-                             if ($v['A']) {
 
-                                 $name = $v['A'];
 
-                             }
 
-                             
 
-                             $journal = Dever::db('journal/info')->one(array('name' => $name));
 
-                             if ($journal) {
 
-                                 $info = Dever::db('journal/mobile')->one(array('product_id' => $journal['id'], 'mobile' => $v['B']));
 
-                                 if (!$info) {
 
-                                     Dever::db('journal/mobile')->insert(array('product_id' => $journal['id'], 'mobile' => $v['B']));
 
-                                 }
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |