| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919 |
- <?php
- /**
- *------Create thems Controller------
- *------SCWPHP Version 1.0.0------
- *------Dev Model Jions------
- *------Create Time 2017-06-23 15:06:45------
- */
- namespace App\Api\Controller;
- use Illuminate\Support\Facades\DB;
- // ini_set('display_errors', 1);
- // error_reporting(E_ALL);
- class Other extends BaseController {
- /**
- * 轮播图
- */
- public function Banner() {
- $where = array();
- $type = $_REQUEST['type'] ? $_REQUEST['type'] : "1";
- $where['type'] = $type;
- $cachekey = md5( 'Banner'. implode($where));
- $cache= C()->get('cache')->get($cachekey);
- if(!empty($cache)){
- Render($cache, '1', lang()->get('success'));
- }
- $res = lm('banner', 'Commons')->getBanner($where);
- if ($res){
- $i=0;
- foreach ($res as $k=>$v){
- $res[$k]['num']=$i;
- $i++;
- }
- }
- C()->get('cache')->set($cachekey,$res,600);
- Render($res, '1', lang()->get('success'));
- }
- /**
- * 公告
- */
- public function Notice() {
- $res = lm('setinfo', 'Commons')->where('id', '19')->first();
- if(isset($res->infocontent)){
- $res->infocontent = str_replace('white-space:normal;', 'white-space:nowrap;', $res->infocontent);
- $res->infocontent = str_replace('white-space: normal;', 'white-space: nowrap;', $res->infocontent);
- }
- Render($res, '1', lang()->get('success'));
- }
- /**
- * 轮播图
- */
- public function BannerType() {
- $res = lm('advert', 'Commons')->getBanner();
- Render($res, '1', lang()->get('success'));
- }
- /**
- * pc帮助中心
- */
- public function Help()
- {
- $res = lm("game_type", 'commons')->where('close_status',1)->where('type','<','3')->orderBy('hot','desc')->select('play_desc as content', 'name as title','table_name','identity')
- ->get();
- if ($res){
- $res=$res->toArray();
- }else{
- $res=[];
- }
- $dat = lm('article', 'api')->orderBy('sort','desc')->where('type', 11)->oRwhere('type', 9)
- ->get();
- if ($dat){
- $dat=$dat->toArray();
- }else{
- $dat=[];
- }
- $da = lm('article', 'api')->orderBy('sort','desc')->where('type', 10)
- ->get();
- if ($da){
- $da=$da->toArray();
- }else{
- $da=[];
- }
- $data = [
- 'opencai' => $res,
- 'recharge' => $dat,
- 'quert' => $da,
- ];
- Render($data, '1', lang()->get('success'));
- }
- public function HelpData()
- {
- $identity = $_GET['identity'] ? $_GET['identity'] : '';
- $name = $_GET['name'] ? $_GET['name'] : '';
- if (empty($identity)) {
- Render('', '-10009', 'no game');
- return;
- }
- $arr = [ //向数据库追加数组 然后循环出来
- 'title' => $name,
- 'identity' => $identity,
- ];
- $where = '1 = 1';
- foreach ($arr as $key => $value) {
- //循环数组
- if ($value != '' && $key != 'a.id' && $key != 'b.id') { //判断条件
- $where .= " AND {$key}='{$value}'"; //获取值
- }
- }
- $data = lm('article', 'api')->whereRaw($where)
- ->first();
- if ($data){
- $data=$data->toArray();
- }else{
- $data=[];
- }
- Render($data, '1', lang()->get('success'));
- }
- /**
- * 联系我们客服信息
- */
- public function GetNewNoticeinfo() {
- $info = lm('setinfo', 'commons')->where('infotype', 33)->get();
- if (!$info) {
- Render('', '-5006', lang('error')->get('-5006'));
- }
- $data = array();
- foreach ($info as $k => $v) {
- $data[$v['remarks']] = $v['infocontent'];
- }
- Render($data, 1);
- }
- public function GameExplan()
- {
- $game = isset($_GET['game']) ? trim($_GET['game']) : '';
- if (empty($game)) {
- Render('', '-10009', 'no game');
- return;
- }
- $data = lm("game_type", 'commons')->where("table_name", $game)->select('play_desc as content', 'name as title')->first();
- if (!$data) {
- Render('', '-10009', 'no game');
- return;
- }
- if ($data){
- $data = $data->toArray();
- }else{
- $data =[];
- }
- Render($data, '1', lang()->get('success'));
- }
- /**
- * 手机主页弹框内容
- */
- public function Mobile_tan()
- {
- $content = lm('setinfo', 'Commons')->where(['status' => 1, 'infotype' => 6])->first();
- if ($content) {
- $con = $content->toArray();
- } else {
- Render('', '-5001', lang()->get('fail'));
- }
- Render($con, '1', lang()->get('success'));
- }
- /**
- * 获得用户银行卡
- */
- public function GetBank()
- {
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- if (empty($user_id)) {
- Render('', '-4010', lang()->get('user not login'));
- }
- $res = array();
- $res = lm('account_bank', 'Commons')->where('account_identity', $user_id)->first();
- if ($res) {
- $res = $res->toArray();
- }
- if (!empty($res)) {
- Render($res, 1, lang()->get('success'));
- }
- Render('', '-2004', lang()->get('Please bind the bank card'));
- }
- /**
- * 检测试玩用户
- */
- public function CheckUser()
- {
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- if (empty($user_id)) {
- Render('', -4001, lang('error')->get('-4001'));
- }
- $res = lm('account', 'commons')->where('identity', $user_id)->first();
- if ($res) {
- Render($res, 1);
- }
- Render('', '-5001', lang('error')->get('-5001'));
- }
- //意见反馈
- public function FeedBack()
- {
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $name = isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
- $type = isset($_POST['type']) ? strip_tags($_POST['type']) : "";
- $content = isset($_POST['content']) ? strip_tags($_POST['content']) : "";
- $tel = isset($_POST['tel']) ? strip_tags($_POST['tel']) : "";
- $qq = isset($_POST['qq']) ? strip_tags($_POST['qq']) : "";
- $weixin = isset($_POST['weixin']) ? strip_tags($_POST['weixin']) : "";
- $dat = [
- 'account_identity' => $user_id,
- 'type' => $type,
- 'account_name' => $name,
- 'content' => $content,
- 'submit_time' => date('Y-m-d H:i:s',time()),
- ];
- if(!empty($tel))$dat['account_tel']=$tel;
- if(!empty($qq))$dat['account_qq']=$qq;
- if(!empty($weixin))$dat['account_weixin']=$weixin;
- $data = lm('feedback', 'Commons')->insert($dat);
- if ($data) {
- Render($data, 1, lang()->get('success'));
- } else {
- Render('', '-5001', lang('error')->get('-5001'));
- }
- }
- //意见反馈
- public function FeedBackList()
- {
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $page = isset($_POST['page']) ? $_POST['page'] : "1";
- $lists = isset($_POST['lists']) ? $_POST['lists'] : "10";
- $list = $lists;
- //获取总页数
- $count_list = lm('feedback', 'Commons')->where('account_identity', $user_id)->count();
- $count_page = ceil($count_list / $list);
- $first = ($page - 1) * $list;
- $data = lm('feedback', 'Commons')->where('account_identity', $user_id)->orderBy('submit_time', 'desc')->offset($first)->limit($list)
- ->get();
- $dat = [
- 'see_status' => '1',
- ];
- $da = lm('feedback', 'Commons')->where('account_identity', $user_id)
- ->where('see_status', '0')
- ->where('status', '1')
- ->update($dat);
- if ($data) {
- $data = $data->toArray();
- $Iteas = [
- 'data' => $data,
- 'count_page' => $count_page,
- 'page' => $page,
- ];
- Render($Iteas, 1, lang()->get('success'));
- } else {
- Render('', '-5001', lang('error')->get('-5001'));
- }
- }
- //移动意见反馈
- public function FeedBackLists()
- {
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $data = lm('feedback', 'Commons')->where('account_identity', $user_id)->orderBy('submit_time', 'desc')
- ->get();
- $dat = [
- 'see_status' => '1',
- ];
- $da = lm('feedback', 'Commons')->where('account_identity', $user_id)
- ->where('see_status', '0')
- ->where('status', '1')
- ->update($dat);
- if ($data) {
- $data = $data->toArray();
- $Iteas = [
- 'data' => $data,
- ];
- Render($Iteas, 1, lang()->get('success'));
- } else {
- Render('', '-5001', lang('error')->get('-5001'));
- }
- }
- //意见反馈
- public function FeedBackNum()
- {
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $data = lm('feedback', 'Commons')->where('account_identity', $user_id)
- ->where('status', '1')
- ->where('see_status', '0')
- ->count();
- Render($data, 1, lang()->get('success'));
- }
- //我的消息
- public function Message()
- {
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $user_name = isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
- $timed=lm('account_detailed','Commons')->where('account_identity',$user_id)->first();
- $group_codes=$timed['group_code'];
- $group_codes_arr=explode(',',$group_codes);
- array_pop($group_codes_arr);
- $len=count($group_codes_arr);
- $register_time=$timed['register_time'];
- $sql = "SELECT count(*) as num FROM message WHERE message.type = 3 and ((add_time > '$register_time' AND message.add_type = '2') or add_type='1')";
- if(is_array($group_codes_arr)&&$len>0){
- $sql.=" and (";
- foreach ($group_codes_arr as $v){
- $sql.=" group_code like '%,".$v.",%' or";
- }
- $sql .= " toname = 'all') ";
- }
- $sql.="and id not in( SELECT message_id from message_read WHERE account_identity = '" . $user_id . "' GROUP BY message_id)";
- $sqls="SELECT count(*) as num FROM message WHERE type = 1 and toname = '$user_name' and id not in( SELECT message_id from message_read WHERE account_identity = '" . $user_id . "' GROUP BY message_id)";
- $num1=S('DB')->select($sql);
- $num2=S('DB')->select($sqls);
- $num=$num1[0]->num + $num2[0]->num;
- // return $num[0]->num;
- // $num=1;
- // $num=1;
- Render($num,1);
- }
- //新增:2018-12-06 Anton liu
- public function getHomeMsg(){
- $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- //获取最新首页弹出消息
- $msg = lm('message','Commons')
- ->where('type','=',3)
- ->where('is_show','=',1)
- ->orderBy('add_time','desc')
- ->first();
- if($msg){
- //查看是否已读
- $read = lm('message_read','Commons')
- ->where('message_id','=',$msg->id)
- ->where('account_identity','=',$user_id)
- ->first();
- if($read){
- Render('',-1);
- }else{
- Render($msg->toArray(),1);
- }
- }else{
- Render('',-1);
- }
- }
- function AllMessageOne(){
- $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
- $group_code=isset($_SESSION['uinfo']['group_code'])?$_SESSION['uinfo']['group_code']:0;
- $timed=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
- $group_code_arr=explode(',',$group_code);
- array_pop($group_code_arr);//删除最后一个空元素
- $lenth=count($group_code_arr);
- $time=$timed['last_time'];
- $register_time=$timed['register_time'];
- $sql="SELECT * FROM message where message.type = 3 and ((add_time > '$register_time' AND message.add_type
- = '2') or add_type='1' ) ";
- if(is_array($group_code_arr)&&$lenth>0){
- $sql.=" and (";
- foreach ($group_code_arr as $k=> $v){
- $sql.= " group_code LIKE '%,".$v.",%' or";
- }
- $sql.=" toname = 'all')";
- }
- $sql.=" and id not in ( SELECT message_id from message_read WHERE account_identity = '$admin_id' GROUP BY message_id) order by add_time desc";
- $sqlone="SELECT * FROM message WHERE type = 1 and toname = '$admin_name' and id not in (SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "' GROUP BY message_id) order by add_time desc ";
- $sqltwo="SELECT * FROM message WHERE add_time > '$time' and type = 2 and toname = '$admin_name' and id not in( SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "' GROUP BY message_id) order by add_time desc ";
- $datas=S('DB')->select($sql);
- $dataone=S('DB')->select($sqlone);
- $datatwo=S('DB')->select($sqltwo);
- if(empty($datas)){
- $data= array_merge($dataone,$datas);
- }
- if(empty($dataone)){
- $data= array_merge($datas,$dataone);
- }
- if(empty($dataone) && empty($datas)){
- $datadd= [];
- }
- if(!empty($dataone) && !empty($datas)){
- $data= array_merge($datas,$dataone);
- }
- if (!empty($data)){
- $i=0;
- foreach ($data as $v){
- $dataddd[$v->id]=$v;
- }
- krsort($dataddd);
- foreach ($dataddd as $vv){
- $datadd[$i]=$vv;
- $i++;
- }
- }
- $sql = "SELECT count(*) as num FROM message WHERE message.type = 3 and ((add_time > '$register_time' AND message.add_type = '2') or add_type='1' )";
- if(is_array($group_code_arr)&&$lenth>0){
- $sql.=" and (";
- foreach ($group_code_arr as $k=> $v){
- $sql.= " group_code LIKE '%,".$v.",%' or";
- }
- $sql.=" toname = 'all')";
- }
- $sql.=" and id not in( SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "' GROUP BY message_id)";
- $sqls = "SELECT count(*) as num FROM message WHERE type = 1 and toname = '$admin_name' and id not in( SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "' GROUP BY message_id)";
- $num1=S('DB')->select($sql);
- $num2=S('DB')->select($sqls);
- $num=$num1[0]->num + $num2[0]->num;
- $datas=[
- 'dataone'=>$datadd,
- 'datatwo'=>$datatwo,
- 'data'=>$num,
- ];
- return $datas;
- }
- function AllMessagetwo(){
- $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $time=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
- $time=$time['last_time'];
- $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
- $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread from message where add_time > '$time' and type = 2 and toname = '$admin_name' order by add_time desc ";
- $data=S('DB')->select($sql);
- // $pagedata=$pagedata[0]['num']/$num;
- // dump();
- return array('data'=>$data);
- }
- function AllMessage(){
- $page=isset($_POST['page'])?intval($_POST['page']):'';
- $type=isset($_POST['type'])?intval($_POST['type']):"";
- $num=20;
- $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
- $account_group=isset($_SESSION['uinfo']['group_code'])?$_SESSION['uinfo']['group_code']:'';
- $group_code_arr=explode(',',$account_group);
- array_pop($group_code_arr);//删除最后一个空元素
- $lenth=count($group_code_arr);
- $timed=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
- $register_time=$timed['register_time'];
- if (!empty($type)){
- $pagedata=lm('message','Commons')->where('type',3)->count();
- $nums=ceil($pagedata/$num);
- if ($page > $nums){
- $page= $nums;
- }elseif ($page == 0){
- $page=1;
- }
- $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread from message where type = {$type} and message.type = 3 and message.id in (select message_id from message_read where status=1)";
- if(is_array($group_code_arr)&&$lenth>0){
- $sql.=" and (";
- foreach ($group_code_arr as $v){
- $sql.=" group_code like '%,".$v.",%' or";
- }
- $sql.=" toname ='all' )";
- }
- $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type = '2') or add_type='1') order by add_time desc limit {$num} offset ".(($page-1)*$num);
- }else{
- // $pagedata=lm('message','Commons')->where('type',1)->where('toname',$admin_name)->count();
- $sqls="select count(*) as num from message where (type = 3 or (type = 1 and toname = '$admin_name')) and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') ";
- $pagedata=S('DB')->select($sqls);
- $nums=ceil($pagedata[0]->num/$num);
- if ($page > $nums){
- $page= $nums;
- }elseif ($page == 0){
- $page=1;
- }
- $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread from message where message.type = 3";
- if(is_array($group_code_arr)&&$lenth>0){
- $sql.=" and (";
- foreach ($group_code_arr as $v){
- $sql.=" group_code like '%,".$v.",%' or ";
- }
- $sql.=" toname = 'all')";
- }
- $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type
- = '2') or add_type='1') or (type = 1 and toname = '$admin_name') order by add_time desc limit {$num} offset ".(($page-1)*$num);
- }
- $data=S('DB')->select($sql);
- $data = json_decode(json_encode($data),1);
- $new = $data;
- return array('data'=>$new,'cont'=>$pagedata,'page'=>$page);
- }
- function AllMessageModel(){
- $page=isset($_POST['page'])?intval($_POST['page']):1;
- $type=isset($_POST['type'])?intval($_POST['type']):"";
- $num=10;
- $pagedata=lm('message','Commons')->count();
- $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
- $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $timed=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
- $group_codes=$timed['group_code'];
- $group_codes_arr=explode(',',$group_codes);
- array_pop($group_codes_arr);
- $len=count($group_codes_arr);
- $register_time=$timed['register_time'];
- if (!empty($type)){
- $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread from message where type = {$type} and message.type = 3 ";
- if(is_array($group_codes_arr)&&$len>0){
- $sql.=" and (";
- foreach ($group_codes_arr as $v){
- $sql.=" group_code like '%,".$v.",%' or ";
- }
- $sql.=" toname = 'all')";
- }
- $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type= '2') or add_type='1') order by add_time desc limit {$num} offset ".(($page-1)*$num);
- }else{
- $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread from message where (type = 3 or (type = 1 and toname = '$admin_name')) and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}')";
- if(is_array($group_codes_arr)&&$len>0){
- $sql.=" and (";
- foreach ($group_codes_arr as $v){
- $sql.=" group_code like '%,".$v.",%' or ";
- }
- $sql.=" toname = 'all')";
- }
- $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type
- = '2') or add_type='1') or (type = 1 and toname = '$admin_name') order by add_time desc limit {$num} offset ".(($page-1)*$num);
- }
- $data=S('DB')->select($sql);
- // if($data){
- // foreach ($data as $k=>$v){
- // $data_t[$k]['title']=$v->title;
- // $data_t[$k]['content']=$v->content;
- // $data_t[$k]['type']=$v->type;
- // $data_t[$k]['formname']=$v->formname;
- // $data_t[$k]['toname']=$v->toname;
- // $data_t[$k]['add_time']=$v->add_time;
- // $data_t[$k]['id']=$v->id;
- // $data_t[$k]['status']=$v->status;
- // $data_t[$k]['message_type']=$v->message_type;
- // $data_t[$k]['hasread']=$v->hasread;
- //// $data_t[$k]['desc']=substr(strip_tags($data_t[$k]['content']),0,100);
- // }
- // }
- // $pagedata=$pagedata[0]['num']/$num;
- // dump();
- //return array('data'=>$data_t,'cont'=>$pagedata,'page'=>$page);exit;
- // return Render(array('data'=>$data_t,'cont'=>$pagedata,'page'=>$page),1);
- return Render($data);
- }
- //消息列表
- public function MessageList()
- {
- $limit = isset($_GET['limit']) ? $_GET['limit'] : '10';
- $title =isset($_GET['title']) ? $_GET['title'] : '';
- $message_type = isset($_GET['message_type']) ? $_GET['message_type'] : '';
- $type = isset($_GET['type']) ? $_GET['type'] : '';
- $user_name = isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
- $where = array();
- $wheres = array();
- if (!empty($title)) {
- $where[] = array('title', 'like', '%' . $title . '%');
- $wheres[] = array('title', 'like', '%' . $title . '%');
- }
- if (empty($type)) {
- $where[] = array('type', '!=', '4');
- $where[] = array('type', '!=', '2');
- $wheres[] = array('type', 'in', '2');
- $wheres[] = array('toname', '=', $user_name);
- }
- if (empty($message_type)) {
- $where[] = array('message_type', '=', '2');
- $wheres[] = array('message_type', '=', '2');
- }
- $data1 = $this->getlist($limit, $where);
- $data2 = $this->getlist($limit, $wheres);
- if (!empty($data1) || !empty($data2)){
- $data=array_merge($data1,$data2);
- }elseif (empty($data1)){
- $data=$data2;
- }elseif (empty($data2)){
- $data=$data1;
- }else{
- $data ="";
- }
- $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $datas=$this->getlistd($admin_id);
- if (!empty($datas)){
- foreach ($data as $k=>$v){
- foreach ($datas as $vv){
- if($vv['type'] == '1' && $v['id'] == $vv['message_id']){
- $data[$k]['message_type']='1';
- }
- }
- }
- foreach ($data as $k=>$v){
- if($v['message_type'] == '2'){
- $dat[$k]=$v;
- }
- }
- if (!empty($dat)){
- $data= $dat;
- }else{
- $data="";
- }
- }
- if (!empty($data)) {
- foreach ($data as $k=>$v){
- foreach ($datas as $val){
- if ($v['id'] == $val['message_id'] && $val['type'] == '3'){
- $data[$k]['status']='3';
- }elseif ($v['id'] == $val['message_id']){
- $data[$k]['status']='1';
- }
- }
- }
- }
- return $data;
- }
- //已读消息
- public function Tmessage()
- {
- $id = isset($_POST['id']) ? $_POST['id'] : '';
- $admin_id=isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $dataWhwew=[
- 'type'=>'2',
- ];
- $data= $this->MessageUp($id,$admin_id,$dataWhwew);
- return $data;
- }
- //是否弹出消息
- public function MessageRed()
- {
- $id = isset($_POST['id']) ? $_POST['id'] : '';
- $admin_id=isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $dataWhwew=[
- 'message_id'=>$id,
- 'account_identity'=>$admin_id,
- 'add_time'=>date("Y-m-d H:i",time())
- ];
- $dataRead = $this->Messagelista($id,$admin_id);
- if ($dataRead < 0){
- $dataRead = $this->addMessage($dataWhwew);
- }
- return $dataRead;
- }
- //消息详情
- public function MessageL()
- {
- $id = isset($_POST['id']) ? $_POST['id'] : '';
- $dataRead = $this->MessagelistaL($id);
- if ($dataRead < 0){
- return -6030001222;
- }
- return $dataRead;
- }
- //添加消息数据
- function addMessage($data)
- {
- $res = lm('message_read','Commons')->insert($data);
- if (!$res) {
- return -6030001222;
- }
- return 1;
- }
- //查询一条数据
- function MessagelistaL($id)
- {
- $res = lm('message','Commons')->where('id',$id)->first();
- if (!$res) {
- return -6030001222;
- }
- return $res;
- }
- //查询一条数据
- function MessageUp($id,$admin_id,$data)
- {
- $res = lm('message_read','Commons')->where('message_id', $id)->where('account_identity', $admin_id)->update($data);
- if (!$res) {
- return -6030001222;
- }
- return $res;
- }
- function getlist($list = 10, $where = '') {
- $data = lm('message', 'Commons')->orderBy('add_time', 'desc');
- if (!empty($where) && is_array($where)) {
- $data = $data->where($where)->get();
- }
- if (!$data) {
- return -4010010022; //没有数据
- }
- return $data->toArray();
- }
- //查询消息
- function Messagelista($id, $admin_id)
- {
- $data = lm('message_read', 'Commons')->where('message_id', $id)->where('account_identity', $admin_id)->first();
- if (!$data) {
- return -4010010022; //没有数据
- }
- return 1;
- }
- function getlistd($id)
- {
- $data = lm('message_read', 'Commons')->where('account_identity', $id)->get();
- if (!$data) {
- return -4010010022; //没有数据
- }
- return $data->toArray();
- }
- //代理开关
- public function AgentList() {
-
- $data = lm('setinfo', 'Commons')->where('infotype', 13)->first();
- if ($data) {
- $data = $data->toArray();
- Render($data, 1, lang()->get('success'));
- } else {
- Render('', '-5001', lang('error')->get('-5001'));
- }
- }
- /**
- * 客服qq链接
- */
- public function GetQQ() {
- $info = lm('setinfo', 'commons')->where('infotype', 16)->first();
- if (!$info) {
- Render('', '-5006', lang('error')->get('-5006'));
- }
- $data['url'] = 'http://wpa.qq.com/msgrd?v=3&uin=' . $info->infocontent . '&site=qq&menu=yes';
- $data['wapurl'] = 'mqqwpa://im/chat?chat_type=wpa&uin=' . $info->infocontent . '&version=1';
- $data['iosurl'] = 'mqq://im/chat?chat_type=wpa&uin=' . $info->infocontent . '&version=1&src_type=web';
- $data['qq'] = $info->infocontent;
- Render($data, 1);
- }
- /**
- * 联系我们客服信息
- */
- public function GetConinfo() {
- $info = lm('setinfo', 'commons')->where('infotype', 1017)->get();
- if (!$info) {
- Render('', '-5006', lang('error')->get('-5006'));
- }
- $data = array();
- foreach ($info as $k => $v) {
- $data[$v['remarks']] = $v['infocontent'];
- }
- //新增图片服务器地址
- $img = lm('setinfo', 'commons')->where('infotype', 2004)->first();
- $data['imgserver'] = $img['infocontent'];
- Render($data, 1);
- }
- /**
- * 银行列表
- */
- public function BankList() {
- $bank = lm('band_bank', 'commons')->select('bank_name')->get();
- if (!$bank) {
- Render('', -5001, lang('error')->get('-5001'));
- }
- Render($bank->toArray(), 1);
- }
- public function DelMessageRed(){
- $id = isset($_POST['id']) ? $_POST['id'] : '';
- $admin_id=isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
- $dataWhwew=[
- 'status'=>'-1',
- ];
- $ids = explode(',', $id);
- if (!is_array($ids) && intval($ids) < 0) {
- return -2002;
- }
- if (is_array($ids) && count($ids) > 0) {
- foreach ($ids as $k => $v) {
- if (intval($v) < 1) {
- unset($ids[$k]);
- }
- }
- }
- $res = lm('message','Commons')->whereIn('id',$ids)->first();
- if ($res['type'] == 1 ) {
- $data = lm('message','Commons')->whereIn('id',$ids)->delete();
- }else{
- $data= $this->DelMessageUp($ids,$admin_id,$dataWhwew);
- }
- return $data;
- }
- function DelMessageUp($id,$admin_id,$data)
- {
- $res = lm('message_read','Commons')->whereIn('message_id', $id)->where('account_identity', $admin_id)->update($data);
- if (!$res) {
- return -6030001222;
- }
- return $res;
- }
- function GetPageSet(){
- $data = lm('setinfo', 'commons')->where('infotype', 1024)->first();
- if (!$data) {
- Render('', '-5006', lang('error')->get('-5006'));
- }
- $data = $data->toArray();
- Render($data, 1,'获取信息成功');
- }
- }
|