视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城,service=>客服】
* @return name:first_id type:int default:-- desc:详情id(视频、图文、资料为系列id)
* @return name:second_id type:second_id default:-- desc:系列某详情id(视频、图文、资料)
* @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
*/
public function getBanner()
{
$num = input('get.num',100);
$is_pc = input('get.is_pc',0);
$list = StoreBanner::field('id,cover,place,first_id,second_id')
->where(['is_deleted'=>0,'is_pc'=>$is_pc])
->limit(0,$num)
->order('sort desc ,id desc')->select()->toArray();
foreach ($list as &$v){
$v['is_normal'] = CheckPower::checkModulesPower($v['first_id'],$v['second_id'],$v['place']);
}
$this->success('ok',['list'=>$list]);
}
/**
* @title 添加极光推送记录
* @desc 添加极光推送记录
* @author qc
* @url /api/Expedite/clientLog
* @method POST
* @tag 编辑信息
* @header name:Authorization require:1 desc:Token
* @param name:type type:string default:1 desc:类型
* @param name:log type:int default:-- desc:记录内容
*/
public function clientLog()
{
$data = input();
if($this->user_id){
$data['user_id'] = $this->user_id;
}
$data['create_at'] = date('Y-m-d H:i:s');
$client_log = Db::name('client_log')->insert($data);
$this->success('添加成功',['detail'=>$client_log]);
}
/**
* @title 推送查询
* @desc 推送查询
* @author qc
* @url /api/Expedite/aliases
* @method GET
* @tag 环信
* @param name:filename type:string default:-- desc:语音文件的名称
* @param name:from type:string default:-- desc:发送方用户id
* @param name:to type:string default:-- desc:接收方用户id
* @param name:url type:string default:-- desc:语音文件的url地址
* @return name:url type:string default:-- desc:语音文件的url地址
*/
public function aliases(){
$data = input();
// if(!$data['url'] || !$data['from'] || !$data['to'] || !$data['url']){
//
// }
$arr = [
'url'=>'https://device.jpush.cn/v3/aliases/479?new_format=true',
'AppKey'=>config('app.jiguang')['AppKey'],
'MasterSecret'=>config('app.jiguang')['MasterSecret'],
];
// $hx_voice = hx_voice(24);
// $url= $arr['url'].$arr['org_name'].'/'.$arr['app_name'].'/'.'messages/users';
// $body['from'] = $data['form']; //'member2200'
// $body['to'] = $data['to']; //worker1000
// $body['type'] = 'audio';
// $body['body'] = [
// 'filename' => $data['filename'], //'testaudio.amr', //语音文件的名称
// 'url' => $data['url'] //'http://tmp/bQo7Udv1FETr01c4bb0ecee3a2edb86b00a393176fcc.durationTime=2790.aac', //语音文件的url地址
// ];
$body = [
// "registration_ids"=>[
// "remove"=> ["100d85590840f4bd5b8"]
// ]
];
$options['type']="audio";
$options['msg']='发送';
$b=json_encode($body);
// return $b;
$str = $arr['AppKey'].':'.$arr['MasterSecret'];
//$str = '7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1';
$base64 = base64_encode($str);
//$header=['Authorization' => ];
$header = array("Authorization: Basic ".$base64);
// return json($header);
$result=$this->postCurl($arr['url'],$b,$header,'GET');
// $result=$this->postCurl($url,$body,$header);
//dump($result);
return json($result);
// return $hx_voice;
}
public function postCurl($url,$body,$header,$type="POST"){
//1.创建一个curl资源
$ch = curl_init();
//2.设置URL和相应的选项
curl_setopt($ch,CURLOPT_URL,$url);//设置url
//1)设置请求头
// array_push($header, 'Accept:application/json');
// array_push($header,'Content-Type:application/json');
// array_push($header, 'http:multipart/form-data');
//设置为false,只会获得响应的正文(true的话会连响应头一并获取到)
curl_setopt($ch,CURLOPT_HEADER,0);
// curl_setopt ( $ch, CURLOPT_TIMEOUT,5); // 设置超时限制防止死循环
//设置发起连接前的等待时间,如果设置为0,则无限等待。
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
//将curl_exec()获取的信息以文件流的形式返回,而不是直接输出。
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//2)设备请求体
if (strlen($body)>0) {
//$b=json_encode($body,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);//全部数据使用HTTP协议中的"POST"操作来发送。
}
//设置请求头
// if(count($header)>0){
// curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
// }
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
//上传文件相关设置
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);// 对认证证书来源的检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);// 从证书中检查SSL加密算
//3)设置提交方式
switch($type){
case "GET":
curl_setopt($ch,CURLOPT_HTTPGET,true);
break;
case "POST":
curl_setopt($ch,CURLOPT_POST,true);
break;
case "PUT"://使用一个自定义的请求信息来代替"GET"或"HEAD"作为HTTP请求。这对于执行"DELETE" 或者其他更隐蔽的HTT
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"PUT");
break;
case "DELETE":
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"DELETE");
break;
}
//4)在HTTP请求中包含一个"User-Agent: "头的字符串。-----必设
// curl_setopt($ch, CURLOPT_USERAGENT, 'SSTS Browser/1.0');
// curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
//curl_setopt ( $ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)' ); // 模拟用户使用的浏览器
//5)
//3.抓取URL并把它传递给浏览器
$res=curl_exec($ch);
$result=json_decode($res,true);
//4.关闭curl资源,并且释放系统资源
curl_close($ch);
if(empty($result))
return $res;
else
return $result;
}
/**
* @title 获取会员等级设置
* @desc 获取会员等级设置
* @author qc
* @url /api/Expedite/getUserLevelSet
* @method GET
* @header name:Authorization require:1 desc:Token
* @return name:id type:int default:-- desc:等级id
* @return name:name type:string default:-- desc:等级名称
* @return name:logo type:string default:-- desc:图片
* @return name:price type:array default:-- desc:价格设置【为空,,不能购买】
* @return name:price.title type:string default:-- desc:标题
* @return name:price.time type:string default:-- desc:时间(单位月)
* @return name:price.price type:float default:-- desc:价格
* @return name:price.renew type:int default:-- desc:续费价格
* @return name:is_renew type:int default:-- desc:是否是续费会员【1是0否】
*/
public function getUserLevelSet()
{
$list = UserLevel::field('id,logo,name,price')->where("price is not null and price != ''")->where('id',1)->select()->toArray();
foreach ($list as &$v) {
$v['price_arr'] = json_decode($v['price'],true);
}
$is_renew = \app\common\model\LevelOrder::where('user_id',$this->user_id)->where('status',1)->where('pay_state',1)->count();
$this->success('ok',['list'=>$list,'is_renew'=>$is_renew ? 1:0]);
}
/**
* @title 会员等级开关【IOS用】
* @desc 会员等级开关
* @author qc
* @url /api/Expedite/levelSwitch
* @method GET
* @header name:Authorization require:1 desc:Token
* @return name:value type:int default:-- desc:0关闭1开启
*/
public function levelSwitch(){
$this->success('ok',['value'=>sysconf('level_switch')]);
}
/**
* @title 注销开关
* @desc 注销开关
* @author qc
* @url /api/Expedite/logoutSwitch
* @method GET
* @header name:Authorization require:1 desc:Token
* @return name:value type:int default:-- desc:0关闭1开启
*/
public function logoutSwitch(){
$this->success('ok',['value'=>sysconf('logout_switch')]);
}
/**
* @title 获取热搜列表
* @desc 获取热搜列表
* @author qc
* @url /api/Expedite/getTopSearch
* @method GET
* @param name:page type:int default:-- desc:页数
* @param name:page_num type:int default:-- desc:每页数量
* @param name:module type:string default:-- desc:模块,不传查全部的[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
* @return name:title type:string default:-- desc:标题
* @return name:hot_num type:int default:-- desc:热搜量
* @return name:rel_id type:int default:-- desc:相关详情id【不是系列id】
* @return name:series_id type:int default:-- desc:系列id【图文、视频、资料用】
* @return name:module type:string default:-- desc:[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
*/
public function getTopSearch()
{
$module = input('module');
$data = input();
if(isset($data['module'])){
$most_num = 30;
}else{
$most_num = 60;
}
if(!isset($data['page_num'])){
$data['page_num'] = 20;
}
if(!isset($data['page'])){
$data['page'] = 1;
}
$total_num = (int)$data['page_num'] * (int)$data['page'];
// return $total_num.'-'.$most_num;
$page_num = $this->page_num;
if($total_num > $most_num){
$t_num = $total_num - $most_num;
$l_num = $data['page_num'] - $t_num;
//$this->page_num = $l_num;
$page_num = $l_num;
//$this->off_set = $l_num;
// return $l_num;
}
$sel = [];
$sel['is_deleted'] = 0;
$sel['status'] = 1;
if($module) $sel['module'] =$module;
if($page_num <= 0){
$list = [];
}else{
// if(){
//$video_list = VideoUrl::field('a.id url_id,a.create_at,a.video_id,a.cover,a.title,a.is_vip,a.ali_vid,a.label,a.read_num,a.transmit_num,a.user_id,a.duration')->alias('a')
// ->when($search_name,function ($query)use ($search_name,$search_time){
// if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
// if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
// })->leftJoin('video_intro b','b.id = a.video_id')
// ->where('a.status',1)->where('release_time','< time',date('Y-m-d H:i:s'))->where('a.is_deleted',0)
// ->where('b.status',1)->where('b.is_deleted',0)->limit($this->off_set,$this->page_num)->order($order)
// ->select()->toArray();
// }
$list = TopSearch::field('id,title,rel_id,module,hot_num,series_id')
->where($sel)
->order('hot_num desc')
->limit($this->off_set,$page_num)
->select()->toArray();
}
$total_num =TopSearch::where($sel)->count();
if($total_num > $most_num){
$total_num = $most_num;
}
$this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
}
/**
* @title 全局搜索【登录状态需要header需要传Authorization】
* @desc 全局搜索
* @author qc
* @url /api/Expedite/globalSearch
* @method GET
* @param name:page type:int default:-- desc:页数
* @param name:page_num type:int default:-- desc:每页数量
* @param name:type type:string default:-- desc:搜索类型(不传查全部)[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
* @param name:search_name type:string default:-- desc:搜索名称
* @param name:search_time type:int default:-- desc:0不限,182半年,365一年
* @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序 *
* @return name:video_list type:array default:-- desc:视频列表【单个】
* @return name:video_list.url_id type:int default:-- desc:url_id
* @return name:video_list.video_id type:int default:-- desc:video_id
* @return name:video_list.cover type:string default:-- desc:封面
* @return name:video_list.title type:string default:-- desc:标题
* @return name:video_list.is_vip type:int default:-- desc:是否是vip【0否1是】
* @return name:video_list.ali_vid type:string default:-- desc:云点播视频id
* @return name:video_list.read_num type:int default:-- desc:播放量
* @return name:video_list.duration type:int default:-- desc:时长(单位:秒)
* @return name:video_list.app_name type:string default:-- desc:平台名称
* @return name:video_list.app_logo type:string default:-- desc:平台头像
* @return name:video_list.create_at type:string default:-- desc:时间
* @return name:article_list type:array default:-- desc:图文列表【单个】
* @return name:article_list.title type:string default:-- desc:图文标题
* @return name:article_list.is_vip type:int default:-- desc:是否是vip
* @return name:article_list.desc type:int default:-- desc:简介【文本】
* @return name:article_list.cover type:string default:-- desc:封面
* @return name:article_list.images type:int default:-- desc:图片【多张|隔开】
* @return name:article_list.images_arr type:array default:-- desc:图片
* @return name:article_list.read_num type:int default:-- desc:阅读量
* @return name:article_list.app_name type:string default:-- desc:平台名称
* @return name:article_list.app_logo type:string default:-- desc:平台头像
* @return name:article_list.create_at type:string default:-- desc:时间
*
* @return name:datum_list type:array default:-- desc:资料列表【单个】
* @return name:datum_list.id type:int default:-- desc:资料的url_id
* @return name:datum_list.title type:string default:-- desc:标题
* @return name:datum_list.is_vip type:int default:-- desc:是否是vip
*
* @return name:press_list type:array default:-- desc:新闻列表
* @return name:press_list.id type:int default:-- desc:新闻id
* @return name:press_list.title type:string default:-- desc:标题
* @return name:press_list.cover type:string default:-- desc:封面
* @return name:press_list.images_arr type:array default:-- desc:图片
* @return name:press_list.read_num type:int default:-- desc:阅读量
* @return name:press_list.is_collect type:int default:-- desc:是否收藏(0否1是)
* @return name:press_list.transmit_num type:int default:-- desc:转发量
* @return name:press_list.collect_num type:int default:-- desc:收藏量
* @return name:press_list.praise_num type:int default:-- desc:点赞量
* @return name:press_list.is_praise type:int default:-- desc:是否点赞(0否1是)
* @return name:press_list.comment_num type:int default:-- desc:评论量
*
*
*
*
* @return name:recruit_list type:array default:-- desc:招聘列表
* @return name:recruit_list.title type:string default:-- desc:标题
* @return name:recruit_list.company type:string default:-- desc:公司名
* @return name:recruit_list.cover type:string default:-- desc:公司logo
* @return name:recruit_list.label_name type:array default:-- desc:标签
* @return name:recruit_list.welfare_arr type:array default:-- desc:岗位福利
* @return name:recruit_list.education type:string default:-- desc:学历
* @return name:recruit_list.experience_min type:int default:0 desc:最低工作年限
* @return name:recruit_list.experience_max type:int default:0 desc:最高工作年限
* @return name:recruit_list.price_min type:int default:-- desc:最低薪资
* @return name:recruit_list.price_max type:int default:-- desc:最高薪资
* @return name:recruit_list.province type:string default:-- desc:省名
* @return name:recruit_list.city type:string default:-- desc:市名
* @return name:recruit_list.address type:string default:-- desc:地址
* @return name:recruit_list.app_name type:string default:-- desc:发布人名称
* @return name:recruit_list.app_logo type:string default:-- desc:发布人头像
*
* @return name:goods_list type:array default:-- desc:商城商品
* @return name:goods_list.id type:int default:-- desc:d
* @return name:goods_list.name type:string default:-- desc:商品名称
* @return name:goods_list.cover type:string default:-- desc:封面
* @return name:goods_list.low_price type:float default:-- desc:价格
*
* @return name:supplier_goods_list type:array default:-- desc:供应商商品
* @return name:supplier_goods_list.id type:int default:-- desc:供应商商品d
* @return name:supplier_goods_list.name type:string default:-- desc:商品名称
* @return name:supplier_goods_list.cover_arr type:array default:-- desc:封面
* @return name:supplier_goods_list.label_name type:array default:-- desc:标签
* @return name:supplier_goods_list.label type:string default:-- desc:标签
* @return name:supplier_goods_list.read_num type:int default:-- desc:浏览量
* @return name:supplier_goods_list.supplier_name type:float default:-- desc:供应商名称
*
* @return name:demand_list type:array default:-- desc:需求
* @return name:demand_list.title type:string default:-- desc:标题
* @return name:demand_list.content type:string default:-- desc:内容
* @return name:demand_list.cover type:array default:-- desc:封面
* @return name:demand_list.money type:float default:-- desc:价格
* @return name:demand_list.app_name type:string default:-- desc:发布方名称
* @return name:demand_list.app_logo type:string default:-- desc:发布方头像
* @return name:demand_list.is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
* @return name:demand_list.company type:string default:-- desc:公司名
* @return name:demand_list.company_logo type:string default:-- desc:公司logo
*
*
* @return name:forum_list type:array default:-- desc:问答
* @return name:forum_list.id type:int default:-- desc:id
* @return name:forum_list.title type:string default:-- desc:标题
* @return name:forum_list.content type:string default:0 desc:内容
* @return name:forum_list.level type:int default:-- desc:vip等级id
* @return name:forum_list.label type:string default:-- desc:标签
* @return name:forum_list.name type:string default:-- desc:发布用户
* @return name:forum_list.headimg type:string default:-- desc:发布用户头像
* @return name:forum_list.browse_num type:int default:-- desc:浏览量
* @return name:forum_list.reply_num type:int default:-- desc:回答量
*
* @return name:activity_list type:array default:-- desc:活动
* @return name:activity_list.id type:int default:-- desc:id
* @return name:activity_list.address type:string default:-- desc:地址
* @return name:activity_list.cover type:string default:-- desc:封面
* @return name:activity_list.label_name type:array default:-- desc:标签
* @return name:activity_list.start_time type:string default:-- desc:开始时间
* @return name:activity_list.end_time type:string default:-- desc:结束时候
* @return name:activity_list.end_time type:string default:-- desc:结束时间
* @return name:activity_list.price type:string default:-- desc:价格
*/
public function globalSearch()
{
$type = input('get.type');
$search_name = input('get.search_name');
$search_time = input('get.search_time');
$sort_type = input('get.sort_type');
$app_name = sysconf('app_name');
$app_logo = sysconf('app_logo');
$user_id = $this->user_id;
switch ($sort_type) {
case 1:
$order = ['a.sort'=>'desc','a.id'=>'asc'];
break;
case 2:
$order = ['a.id'=>'asc','a.sort'=>'desc'];
break;
case 3:
$order = ['a.id'=>'desc','a.sort'=>'desc'];
break;
}
if($this->user_id && $search_name) UserSearch::saveSearchTitle($this->user_id,$search_name,0);
// 视频
$video_list = VideoUrl::field('a.id url_id,a.create_at,a.video_id,a.cover,a.title,a.is_vip,a.ali_vid,a.label,a.read_num,a.transmit_num,a.user_id,a.duration')->alias('a')
->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('video_intro b','b.id = a.video_id')
->where('a.status',1)->where('release_time','< time',date('Y-m-d H:i:s'))->where('a.is_deleted',0)
->where('b.status',1)->where('b.is_deleted',0)->limit($this->off_set,$this->page_num)->order($order)
->select()->toArray();
array_walk($video_list,function (&$v,$k)use ($app_name,$app_logo){
$v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')) : null;
$video_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
$v['app_name'] = $video_auth['app_name'];
$v['app_logo'] = $video_auth['app_logo'];
});
$video_num = VideoUrl::when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->alias('a')->leftJoin('video_intro b','b.id = a.video_id')->where('release_time','< time',date('Y-m-d H:i:s'))
->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)->where('b.is_deleted',0)->count();
// 图文
$article_list = ArticleItem::field('a.id item_id,a.user_id,a.create_at,a.article_id,a.cover,a.title,a.is_vip,a.images,a.read_num,a.desc')->alias('a')
->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('article_intro b','a.article_id = b.id')
->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)->where('b.is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->order($order)
->limit($this->off_set,$this->page_num)->select()->toArray();
array_walk($article_list,function (&$v,$k)use ($app_name,$app_logo){
$article_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
$v['app_name'] = $article_auth['app_name'];
$v['app_logo'] = $article_auth['app_logo'];
});
$article_num = ArticleItem::when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('article_intro b','a.article_id = b.id')->alias('a') ->where('release_time','< time',date('Y-m-d H:i:s'))
->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)->where('b.is_deleted',0)->count();
// 资料
$datum_list = DatumUrl::field('a.id,a.url,a.datum_id,a.title,a.is_vip,a.create_at')->alias('a')
->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('datum_intro b','b.id = a.datum_id') ->where('release_time','< time',date('Y-m-d H:i:s'))
->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)->where('b.is_deleted',0) ->order($order)
->limit($this->off_set,$this->page_num)->select()->toArray();
$datum_num = DatumUrl::alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('datum_intro b','b.id = a.datum_id')->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)
->where('release_time','< time',date('Y-m-d H:i:s'))->where('b.is_deleted',0)->count();
//新闻
$press_list = \app\common\model\Press::field('id,title,cover,images,read_num')->alias('a')
->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->order($order)
->limit($this->off_set,$this->page_num)->select()->toArray();
array_walk($press_list,function (&$v,$k){
$v['comment_num'] = PressComment::where(['first_id'=>$v['id'],'type'=>1,'is_deleted'=>0])->count();
$v['is_collect'] = UserCollect::checkCollectByType($this->user_id,4,$v['id']);
$v['collect_num'] = UserCollect::getCollectNum(4,$v['id']);
$v['is_praise'] = PlatformLike::checkTags($this->user_id,$v['id'],1);
$v['praise_num'] = PlatformLike::getPraiseNum($v['id'],1);
$v['images_arr'] = $v['images'] ? explode('|',$v['images']) : null;
});
$press_num = \app\common\model\Press::when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
//招聘
$recruit_list = \app\common\model\Recruit::field('id,title,label,address,price_min,price_max,company,education,experience_min,experience_max,welfare,province,city,salary,user_id')
->alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->order($order)
->limit($this->off_set,$this->page_num)->select()->toArray();
array_walk($recruit_list,function (&$v,$k)use ($app_logo,$app_name){
$v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
$v['welfare_arr'] = explode(',',trim($v['welfare'],','));
if(!$v['user_id']){
$v['app_name'] = $app_name;
$v['app_logo'] = $app_logo;
}else{
$user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
$v['app_name'] = $user_info ? $user_info->name : '';
$v['app_logo'] = $user_info ? $user_info->headimg : '';
}
});
$recruit_num = \app\common\model\Recruit::when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
// 商品
$goods_list = StoreGoods::field('id,name,cover,low_price')->alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('name','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('is_deleted',0)->where('status',1)->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
$goods_num =StoreGoods::when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('name','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('is_deleted',0)->where('status',1) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
// 供应商
$supplier_goods_list =SupplierGoods::field('a.id,a.supplier_id,a.name,a.read_num,a.label,a.cover,s.title supplier_name,a.create_at')
->alias('a')->when($search_name,function ($query)use($search_name,$search_time){
if($search_name) $query->where('a.name','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('Supplier s','a.supplier_id = s.id')->where('a.status','=',1)->where('a.is_deleted','=',0)->where('s.status','=',1)->where('s.is_deleted','=',0)
->where('release_time','< time',date('Y-m-d H:i:s'))->limit($this->off_set,$this->page_num) ->order($order)->select()->toArray();
array_walk($supplier_goods_list,function (&$v,$k){
$v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
$v['cover_arr'] = explode('|',trim($v['cover'],'|'));
});
$supplier_goods_num = SupplierGoods::when($search_name,function ($query)use($search_name,$search_time){
if($search_name) $query->where('g.name','like','%'.$search_name.'%');
if($search_time) $query->where('g.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->alias('g')->leftJoin('Supplier s','g.supplier_id = s.id')->where('g.status','=',1) ->where('g.release_time','< time',date('Y-m-d H:i:s'))
->where('g.is_deleted','=',0)->where('s.status','=',1)->where('s.is_deleted','=',0)->count();
// 需求
$demand_list = PlatformDemand::field('id,cover,money,user_id,label,title,cover,is_over,content,company,company_logo,a.create_at')->alias('a')
->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))
->limit($this->off_set,$this->page_num)->order($order)->select()->toArray();
array_walk($demand_list,function (&$v,$k)use ($app_logo,$app_name){
if(!$v['user_id']){
$v['app_name'] = $app_name;
$v['app_logo'] = $app_logo;
}else{
$user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
$v['app_name'] = $user_info ? $user_info->name : '';
$v['app_logo'] = $user_info ? $user_info->headimg : '';
}
$v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
$v['cover_arr'] = explode('|',trim($v['cover'],'|'));
});
$demand_num = PlatformDemand::when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
// 问答
$forum_list = UserForum::field('a.id,a.title,a.content,a.label,a.level,a.browse_num,a.sort,a.create_at,u.name,u.headimg, IFNULL( (SELECT count(DISTINCT r.user_id) FROM dd_forum_reply as r WHERE a.id=r.forum_id),0 ) as reply_num')->alias('a')
->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('store_member u','u.id = a.user_id') ->where('release_time','< time',date('Y-m-d H:i:s'))
->where('a.status',1)->where('a.is_deleted',0)->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
$forum_num = UserForum::field('a.id')->alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->leftJoin('store_member u','u.id = a.user_id')
->where('a.status',1) ->where('release_time','< time',date('Y-m-d H:i:s'))
->where('a.is_deleted',0)->count();
// 活动
$activity_list = \app\common\model\Activity::field('id,cover,title,address,label,start_time,end_time,price,a.create_at')->alias('a')
->when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0)->order($order)->limit($this->off_set,$this->page_num) ->where('release_time','< time',date('Y-m-d H:i:s'))->select()->toArray();
array_walk($activity_list,function (&$v,$k){
$v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
// $v['ladder'] = $v['ladder'] ? json_decode($v['ladder'],true):null;
});
$activity_num = \app\common\model\Activity::when($search_name,function ($query)use ($search_name,$search_time){
if($search_name) $query->where('title|label','like','%'.$search_name.'%');
if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
})->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
if(!$type) {
$total_count = $video_num+$article_num+$datum_num+$demand_num+$press_num+$goods_num+$supplier_goods_num + $activity_num + $forum_num+$recruit_num;
}else{
$total_count = compact($type.'_num')[$type.'_num'];
}
$this->success('ok',$type ? compact([$type.'_list','total_count']): compact(['video_list','article_list','datum_list','goods_list','press_list','supplier_goods_list','demand_list','recruit_list','forum_list','activity_list','total_count']));
}
/**
* @title 发送短信验证码
* @desc 发送短信验证码
* @author qc
* @url /api/Expedite/sendSms
* @method POST
* @tag 短信验证码
* @param name:phone type:int require:1 default:-- desc:要获取验证码的手机号
* @param name:phone_pre type:int require:1 default:86 desc:手机号前缀
* @return name:code type:string default:-- desc:验证码
*/
public function sendSms(){
$phone_pre = input('post.phone_pre',86);
$phone = input('post.phone');
$user_info = User::where('phone',$phone)
->where('phone_pre',$phone_pre)
->where('is_deleted',0)
->field('id,status,is_deleted')->find();
if($user_info && (!$user_info->status || $user_info->is_deleted))$this ->error('用户被禁用,请联系官方');
if(empty($phone)) $this ->error('参数错误');
$code = rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
AlibabaCloud::accessKeyClient('LTAI5tJ5p12drZegeWVG33xZ', '82UWAiY5e5wH8tSkRvMtqVoGO0h8SB')->regionId('cn-hangzhou')->asDefaultClient();
try {
$result = AlibabaCloud::rpc()
->product('Dysmsapi')
->version('2017-05-25')
->action('SendSms')
->method('POST')
->host('dysmsapi.aliyuncs.com')
->options([
'query' => [
'RegionId' => "cn-hangzhou",
'PhoneNumbers' => $phone_pre == '86' ? $phone :$phone_pre.$phone,
'SignName' => "搞一下汽车电子",
'TemplateCode' => $phone_pre == '86' ? "SMS_234397351" :'SMS_269485496',
'TemplateParam' => json_encode(array("code"=>$code)),
],
])->request();
$result = $result->toArray();
if($result['Code'] != "OK") $this->exception('发送失败');
$sms_data = [
'phone'=>$phone,
'code'=>$code,
'phone_pre'=>$phone_pre,
'result'=>$result['Message']
];
Db::name('store_member_sms')->insert($sms_data);
} catch (ClientException $e) {
$this->error($e->getErrorMessage().PHP_EOL);
} catch (ServerException $e) {
$this->error($e->getErrorMessage().PHP_EOL);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('发送成功');
}
/**
* @title 发送邮箱验证码
* @desc 发送邮箱验证码
* @author qc
* @url /api/Expedite/emailSms
* @method POST
* @tag 邮箱验证码
* @param name:email type:int require:1 default:-- desc:邮箱
* @return name:code type:string default:-- desc:验证码
*/
function emailSms(){
$email = input('post.email');
$user_info = User::where('email',$email)->where('is_deleted',0)->field('id,status')->find();
if($user_info && $user_info['status'] == 0)$this ->error('用户被禁用,请联系官方');
$code = rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
require_once env('root_path').'/vendor/aliyunmail/aliyun-php-sdk-core/Config.php';
$iClientProfile = \DefaultProfile::getProfile("cn-hangzhou", "LTAI5tJ5p12drZegeWVG33xZ", "82UWAiY5e5wH8tSkRvMtqVoGO0h8SB");
$client = new \DefaultAcsClient($iClientProfile);
$request = new Dm\SingleSendMailRequest();
$request->setAccountName("gyx@yzm.gyxqcdz.com");
$request->setFromAlias("[验证码]");
$request->setAddressType(1);
$request->setTagName("zonghuzhuche");
$request->setReplyToAddress("true");
$request->setToAddress($email);
$request->setSubject("验证码");
$img= "http://gaoyixia.hdlkeji.com/code/33.png";
$img ="
";
$html_body = '您的验证码'.$code.'有效时间5分钟';
$resd = $request->setHtmlBody($html_body);
try {
$response = $client->getAcsResponse($request);
return json($response);
$sms_data = array(
'phone'=>$email,
'code'=>$code,
'result'=>'OK'
);
Db::name('store_member_sms')->insert($sms_data);
$this->success('发送成功');
} catch (ClientException $e) {
return $e->getErrorCode();
$this->error($e->getErrorMessage());
// print_r($e->getErrorCode());
// print_r($e->getErrorMessage());
} catch (ServerException $e) {
return $e->getErrorCode();
$this->error($e->getErrorMessage());
// print_r($e->getErrorCode());
// print_r($e->getErrorMessage());
}
}
/**
* @title 获取签名
* @desc 获取签名
* @url /api/Expedite/getWeChatSign
* @method POST
* @param name:url type:string default:-- desc:页面地址
* @return name:appid type:string default:-- desc:appid
* @return name:noncestr type:string default:-- desc:随机字符
* @return name:timestamp type:string default:-- desc:时间戳
* @return name:sign type:string default:-- desc:签名
* @return name:ticket type:string default:-- desc:ticket
**/
public function getWeChatSign(){
$urls = input('post.url');
$appid = config('app.official_account')['appid'];
$secret = config('app.official_account')['secret'];
$redis = new Redis();
$access_token = $redis->get('access_token');
if (!$access_token){
$access_token = '';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
$res= http_curl($url);
if (isset($res['access_token'])){
$redis->set('access_token',$res['access_token'],'7000');
$access_token = $res['access_token'];
}
}
$url2 ="https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$access_token."&type=jsapi";
$res2=http_curl($url2);
//var_dump($res2);
if (!isset($res2) || $res2['errcode']!=0) $this->error('获取ticket失败');
$timestamp = time();
$noncestr = get32Str(15);
$string = "jsapi_ticket=".$res2['ticket']."&noncestr=$noncestr×tamp=$timestamp&url=".$urls;
$sign = sha1($string);
$return = [
'appid'=>$appid,
'noncestr'=>$noncestr,
'timestamp'=>$timestamp,
'url'=>$urls,
'sign'=>$sign,
'ticket'=>$res2['ticket']
];
$this->success('成功',$return);
}
/**
* @title 获取分享链接
* @desc 获取分享链接
* @url /api/Expedite/getUrlScheme
* @method POST
* @return name:url type:string default:-- desc:url
**/
public function getUrlScheme()
{
$appid = config('app.mini_program')['app_id'];
$secret = config('app.mini_program')['secret'];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
$res= http_curl($url);
$access_token = $res['access_token'];
$api_url = 'https://api.weixin.qq.com/wxa/generatescheme?access_token='.$access_token;
$url_scheme = curl_post($api_url,[]);
$this->success('ok',['url'=>$url_scheme['openlink']]);
}
/**
* @title getUrlLink
* @desc getUrlLink
* @url /api/Expedite/getUrlLink
* @method POST
* @return name:url type:string default:-- desc:url
**/
public function getUrlLink()
{
$appid = config('app.mini_program')['app_id'];
$secret = config('app.mini_program')['secret'];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
$res= http_curl($url);
$access_token = $res['access_token'];
$api_url = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token='.$access_token;
$url_link = curl_post($api_url,[]);
$this->success('ok',['url'=>$url_link['url_link']]);
}
/**
* @title 获取平台文案设置
* @desc 获取平台文案设置
* @author qc
* @url /api/Expedite/getSysConfig
* @method GET
* @param name:search_name type:string default:-- desc:根据下面名称查(不传查全部的)
* @return name:agreement type:string default:-- desc:用户协议
* @return name:about_us type:string default:-- desc:关于我们
* @return name:privacy type:string default:-- desc:隐私政策
* @return name:user_equity type:string default:-- desc:会员权益
* @return name:customer_service type:string default:-- desc:客服设置
* @return name:original_pact type:string default:-- desc:原创公约
* @return name:app_name type:string default:-- desc:平台名称
* @return name:app_logo type:string default:-- desc:平台logo
* @return name:app_version type:string default:-- desc:版本号
* @return name:trade_image type:string default:-- desc:营业执照
* @return name:resources_image type:string default:-- desc:人力资源服务许可证
*/
public function getSysConfig(){
$search_name = input('get.search_name');
$con_name = $search_name? [$search_name] : ['agreement','about_us','privacy','user_equity','customer_service','original_pact','app_version','trade_image','resources_image'];
$set = Db::name('system_config')->where('name','in',$con_name)->select();
$ret = [];
foreach ($set as $value) {
// if($search_name == 'resources_image'){
// $value['value'] = explode('|',$value['value']);
// }
$ret[$value['name']]=$value['value'];
}
$this->success('获取成功',$ret);
}
/**
* @title 修改版本信息【安卓】
* @desc 修改版本信息
* @author qc
* @method POST
* @url /api/Expedite/changeVersion
* @header name:Authorization require:1 desc:Token
* @param name:app_version type:string default:1 desc:版本号
* @param name:version_name type:string default:-- desc:版本名
* @param name:version_title type:string default:-- desc:更新标题
* @param name:version_content type:string default:-- desc:更新内容
* @param name:version_url type:string default:-- desc:下载地址
* @param name:version_compel type:string default:-- desc:是否强制更新
*/
public function changeVersion()
{
if(input('app_version'))Data::save('system_config',['value'=>input('app_version'),'name'=>'app_version'],'name',['name'=>'app_version']);
if(input('version_name')) Data::save('system_config',['value'=>input('version_name'),'name'=>'version_name'],'name',['name'=>'version_name']);
if(input('version_title')) Data::save('system_config',['value'=>input('version_title'),'name'=>'version_title'],'name',['name'=>'version_title']);
if(input('version_content')) Data::save('system_config',['value'=>input('version_content'),'name'=>'version_content'],'name',['name'=>'version_content']);
if(input('version_url')) Data::save('system_config',['value'=>input('version_url'),'name'=>'version_url'],'name',['name'=>'version_url']);
Data::save('system_config',['value'=>input('version_compel'),'name'=>'version_compel'],'name',['name'=>'version_compel']);
$this->success('修改成功');
}
/**
* @title 获取版本信息【安卓】
* @desc 获取版本信息
* @author qc
* @method GET
* @url /api/Expedite/getVersionInfo
* @header name:Authorization require:1 desc:Token
* @return name:app_version type:string default:1 desc:版本号
* @return name:version_name type:string default:-- desc:版本名
* @return name:version_title type:string default:-- desc:更新标题
* @return name:version_content type:string default:-- desc:更新内容
* @return name:version_url type:string default:-- desc:下载地址
* @return name:version_compel type:string default:-- desc:是否强制更新
*/
public function getVersionInfo()
{
$version_sel = ['app_version','version_name','version_title','version_content','version_url','version_compel'];
$set = Db::name('system_config')->where('name','in',$version_sel)->column('value','name');
$ret = [];
foreach ($version_sel as $v) {
$ret[$v] = isset($set[$v]) ? $set[$v] :null;
if($v == 'app_version') $ret[$v] = intval($set[$v]);
}
$this->success('获取成功',$ret);
}
/**
* @title 修改版本信息【IOS】
* @desc 修改版本信息
* @author qc
* @method POST
* @url /api/Expedite/changeIosVersion
* @header name:Authorization require:1 desc:Token
* @param name:app_version_ios type:string default:1 desc:版本号
* @param name:version_name_ios type:string default:-- desc:版本名
* @param name:version_compel_ios type:string default:-- desc:是否强制更新
*/
public function changeIosVersion()
{
if(input('app_version_ios'))Data::save('system_config',['value'=>input('app_version_ios'),'name'=>'app_version_ios'],'name',['name'=>'app_version_ios']);
if(input('version_name_ios')) Data::save('system_config',['value'=>input('version_name_ios'),'name'=>'version_name_ios'],'name',['name'=>'version_name_ios']);
Data::save('system_config',['value'=>input('version_compel_ios'),'name'=>'version_compel_ios'],'name',['name'=>'version_compel_ios']);
$this->success('修改成功');
}
/**
* @title 获取版本信息【IOS】
* @desc 获取版本信息
* @author qc
* @method GET
* @url /api/Expedite/getIosVersionInfo
* @header name:Authorization require:1 desc:Token
* @return name:app_version_ios type:string default:1 desc:版本号
* @return name:version_name_ios type:string default:-- desc:版本名
* @return name:version_compel_ios type:string default:-- desc:是否强制更新
*/
public function getIosVersionInfo()
{
$version_sel = ['app_version_ios','version_name_ios','version_compel_ios'];
$set = Db::name('system_config')->where('name','in',$version_sel)->column('value','name');
$ret = [];
foreach ($version_sel as $v) {
$ret[$v] = isset($set[$v]) ? $set[$v] :null;
// if($v == 'app_version_ios') $ret[$v] = intval($set[$v]);
}
$this->success('获取成功',$ret);
}
/**
* @title 获取APP启动页信息
* @desc 获取APP启动页信息
* @author qc
* @method GET
* @url /api/Expedite/getAppBootConfig
* @header name:Authorization require:1 desc:Token
* @return name:app_image type:string default:1 desc:启动图
* @return name:app_place type:string default:-- desc:跳转模块【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城】
* @return name:first_id type:int default:-- desc:详情id(视频、图文、资料为系列id)
* @return name:second_id type:second_id default:-- desc:系列某详情id(视频、图文、资料)
* @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
*/
public function getAppBootConfig()
{
$version_sel = ['app_image','app_place','first_id','second_id'];
$set = Db::name('system_config')->where('name','in',$version_sel)->column('value','name');
$ret = [];
foreach ($version_sel as $v) {
$ret[$v] = isset($set[$v]) ? $set[$v] :null;
$set[$v] = $ret[$v];
}
$ret['is_normal'] = CheckPower::checkModulesPower($set['first_id'],$set['second_id'],$set['app_place']);
$this->success('获取成功',$ret);
}
/**
* @title IOS获取链接
* @desc GET方式获取POST修改
* @author qc
* @method GET||POST
* @url /api/Expedite/iosUrl
* @header name:Authorization require:1 desc:Token
* @param name:ios_url type:string default:-- desc:链接地址
* @return name:ios_url type:string default:-- desc:链接地址
*/
public function iosUrl()
{
if($this->request->isPost()) Data::save('system_config',['value'=>input('ios_url'),'name'=>'ios_url'],'name',['name'=>'ios_url']);
$url = Db::name('system_config')->where('name','ios_url')->value('value');
$this->success('获取成功',['ios_url'=>$url ? $url :'']);
}
/**
* @title 获取客服设置【平台的】
* @desc 获取客服设置【平台的】
* @author qc
* @url /api/Expedite/getServiceSet
* @method GET
* @return name:service_qr_code type:string default:-- desc:客服二维码
* @return name:service_phone type:string default:-- desc:客服电话
* @return name:service_email type:string default:-- desc:客服邮箱
*/
public function getServiceSet(){
$con_name = ['service_qr_code','service_phone','service_email'];
$set = Db::name('system_config')->where('name','in',$con_name)->select();
$ret = [];
foreach ($set as $value) {
$ret[$value['name']]=$value['value'];
}
$this->success('获取成功',$ret);
}
/**
* @title 获取联系客服设置【模块的】[所有模块的联系我们都用这个接口]
* @desc 获取联系客服设置
* @author qc
* @url /api/Expedite/getContact
* @method GET
* @param name:tag type:string default:-- desc:标识【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商,recruit=>招聘,mall=>商城】
* @return name:qrcode type:string default:-- desc:客服二维码
* @return name:phone type:string default:-- desc:客服电话
* @return name:email type:string default:-- desc:客服邮箱
* @return name:place type:string default:-- desc:归属模块
* @return name:tag type:string default:-- desc:归属标识【可以按照这个值查询或是区分所属模块】
*/
public function getContact()
{
$tag = input('get.tag');
$sel_tag = $tag ? [$tag] : ['video','article','datum','activity','demand','forum','press','supplier','recruit','mall'];
$list = Db::name('contact')->where('tag','in',$sel_tag)->column('tag,qrcode,phone,email,tag,place','tag');
$this->success('ok',$list);
}
/**
* @title 获取模块封面
* @desc 获取模块封面
* @author qc
* @url /api/Expedite/getModulesCover
* @method GET
* @param name:tag type:string default:-- desc:标识【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商,recruit=>招聘,mall=>商城,'search'=>热搜】
* @return name:cover type:string default:-- desc:封面
* @return name:place type:string default:-- desc:归属模块
* @return name:tag type:string default:-- desc:归属标识【可以按照这个值查询或是区分所属模块】
*/
public function getModulesCover()
{
$tag = input('get.tag');
$sel_tag = $tag ? [$tag] : ['video','article','datum','activity','demand','forum','press','supplier','recruit','mall','search'];
$list = Db::name('cover')->where('tag','in',$sel_tag)->column('tag,cover,tag,place','tag');
$this->success('ok',$list);
}
/**
* @title 推送测试
* @desc 推送测试
* @author qc
* @url /api/Expedite/messagePush
* @method GET
* @param name:user_id type:int default:-- desc:会员id
* @param name:content type:string default:-- desc:推送内容
* @param name:module type:string default:-- desc:模块
* @param name:type type:类型 default:-- desc:推送类型
* @param name:rel_id type:类型 default:-- desc:关联id
*/
public function messagePush()
{
$user_id= input('user_id');
$content= input('content');
$module= input('module');
$type= input('type');
$rel_id= input('rel_id');
$res = UserMessage::Jpush($user_id,$content,$module,$type,$rel_id);
$this->success('',['result'=>$res]);
}
/**
* @title 获取分享地址
* @desc 获取分享地址
* @author qc
* @url /api/Expedite/getShareUrl
* @method GET
* @param name:tag type:string default:-- desc:标识【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城商品】
* @param name:first_id type:int default:-- desc:【视频系列id,图文系列id,资料系列id,活动id,需求id,问答id,新闻id,供应商商品id,招聘记录id,商城商品id】
* @param name:second_id type:string default:-- desc:【视频url_id,图文item_id,资料item_id,其他类型的不传】
* @return name:url type:string default:-- desc:跳转地址
*/
public function getShareUrl()
{
$tag = input('get.tag');
if(!in_array($tag, ['video','article','datum','activity','demand','forum','press','supplier','recruit','mall'])) $this->error('类型标识错误');
$first_id = input('get.first_id');
$second_id = input('get.second_id');
$url_arr= [
'video' =>$this->request->root(true) ."/dist/#/video-details?id=$first_id&videoArrId=$second_id",
'article' =>$this->request->root(true) ."/dist/#/image-text-details?id=$first_id&item_id=$second_id",
'datum' =>$this->request->root(true) ."/dist/#/information-details?id=$first_id&url_id=$second_id",
'activity' =>$this->request->root(true) ."/dist/#/activity-detail?id=$first_id",
'demand' =>$this->request->root(true) ."/dist/#/demand-details?id=$first_id",
'forum' =>$this->request->root(true) ."/dist/#/forum-question-details?forum_id=$first_id",
'press' =>$this->request->root(true) ."/dist/#/news-details?press_id=$first_id",
'supplier' =>$this->request->root(true) ."/dist/#/supplier-details?id=$first_id",
'recruit' =>$this->request->root(true) ."/dist/#/recruit-details?id=$first_id",
'mall' =>$this->request->root(true) ."/dist/#/product-details?id=$first_id",
];
$this->success('ok',['url'=>$url_arr[$tag]]);
}
/**
* @title 获取极光推送类型
* @desc module'=>[type=>['title'=>'视频投稿','is_push'=>0,'msg'=>['视频投稿成功请等待审核']]]
* @author qc
* @url /api/Expedite/getJiGuangPushType
* @method GET
* @return name:is_push type:string default:-- desc:模块类型下的消息是否有极光推送(1推送0不推送)
* @return name:exp type:string default:-- desc:module'=>[type=>['title'=>'视频投稿','is_push'=>0,'msg'=>['视频投稿成功请等待审核']]]
*
*/
public function getJiGuangPushType()
{
$type_desc = [
'video'=>[
3=>['title'=>'视频评论回复【回复我的】','is_push'=>1,'msg'=>['有会员评论了您的回复']],
4=>['title'=>'视频评论【评论我的】','is_push'=>1,'msg'=>['有会员评论了您的视频']],
],// 视频
'article'=>[
3=>['title'=>'图文评论回复【回复我的】','is_push'=>1,'msg'=>['有会员评论了您的回复']],
4=>['title'=>'图文评论【评论我的】','is_push'=>1,'msg'=>['有会员评论了您的图文']],
],//图文
'forum'=>[
3=>['title'=>'回复的评论【评论我的】','is_push'=>1,'msg'=>['有会员评论了您的回复']],
4=>['title'=>'评论的回复【回复我的】','is_push'=>1,'msg'=>['有会员回复了您的评论']],
5=>['title'=>'问答回复【回答我的】','is_push'=>1,'msg'=>['有会员回复了您的问题']],
],// 问答
'press'=>[
1=>['title'=>'评论回复【回复我的】','is_push'=>1,'msg'=>['有会员回复了您的评论']],
],// 新闻
'feedback'=>[
1=>['title'=>'反馈内容回复','is_push'=>1,'msg'=>['平台回复了您的反馈']],
],// 反馈
];
$this->success('ok',$type_desc);
}
/**
* @title 获取模块总角标数量
* @desc 获取模块总角标数量
* @author qc
* @method GET
* @url /api/Expedite/getTotalMarkNum
* @header name:Authorization require:1 desc:Token
* @return name:video_num type:int default:-- desc:视频
* @return name:article_num type:int default:-- desc:图文
* @return name:press_num type:int default:-- desc:新闻
* @return name:demand_num type:int default:-- desc:需求
* @return name:forum_num type:int default:-- desc:问答
* @return name:sys_num type:int default:-- desc:系统消息
* @return name:datum_num type:int default:-- desc:资料
* @return name:supplier_num type:int default:-- desc:供应商
* @return name:activity_num type:int default:-- desc:活动
* @return name:mark_num type:int default:-- desc:商品
* @return name:recruit_num type:int default:-- desc:招聘
* @return name:total_num type:int default:-- desc:总计
*/
public function getTotalMarkNum()
{
if(!$this->user_id) $this->success('ok',['video_num'=>0,'article_num'=>0,'press_num'=>0,'demand_num'=>0,'forum_num'=>0,'sys_num'=>0,'datum_num'=>0,'total_num'=>0]);
$video_all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
// 回复我的
$video_reply_num = VideoComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$video_all_comment)]])->alias('t')->count();
// 评论我的
$video_comment_num = VideoComment::where([['t.is_deleted','=',0],['i.user_id','=',$this->user_id],['t.user_id','<>',$this->user_id],['t.is_read','=',0],['t.pid','=',0]])
->leftJoin('VideoUrl i','t.url_id = i.id')
->alias('t')->count();
// 追更
$video_follow_num = UserMessage::getUnreadNum($this->user_id,'video',5);
// 点赞我的
$all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
$video_praise_num = 0;//VideoCommentLike::where([['type','=',2],['is_read','=',0],['like_id','in',$all_video]])->count();
$comment_praise_num = 0 ;// VideoCommentLike::where([['type','=',1],['is_read','=',0],['like_id','in',$video_all_comment]])->count();
$video_num = $video_reply_num + $video_comment_num + $video_follow_num + $video_praise_num + $comment_praise_num;
// 回复我的
$article_all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
$article_reply_num = ArticleComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$article_all_comment)]])->alias('t')->count();
// 评论我的
$article_comment_num = ArticleComment::where([['t.is_deleted','=',0],['i.user_id','=',$this->user_id],['t.user_id','<>',$this->user_id],['t.is_read','=',0],['t.pid','=',0]])
->leftJoin('ArticleItem i','t.item_id = i.id')
->alias('t')->count();
// 追更
$article_follow_num = UserMessage::getUnreadNum($this->user_id,'article',5);
// 点赞我的
$all_article = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
$article_praise_num = 0;//ArticleCommentLike::where([['is_read','=',0],['like_id','in',$all_article]])->count();
$comment_praise_num = 0;//ArticleLike::where([['is_read','=',0],['item_id','in',$article_all_comment]])->count();
$article_num = $article_reply_num + $article_comment_num + $article_follow_num + $article_praise_num + $comment_praise_num;
// 评论我的
$datum_comment_num = DatumComment::where([['t.is_deleted','=',0],['i.user_id','=',$this->user_id],['t.user_id','<>',$this->user_id],['is_read','=',0],['t.pid','=',0]])
->leftJoin('DatumUrl i','t.url_id = i.id')
->alias('t')->count();
// 回复我的
$datum_all_comment = DatumComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
$datum_reply_num = $datum_all_comment ? DatumComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$datum_all_comment)]])->alias('t')->count() : 0;
// 点赞我的
$all_datum = DatumUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
$datum_praise_num = DatumCommentLike::where([['is_read','=',0],['like_id','in',$datum_all_comment],['user_id','<>',$this->user_id]])->count();
$comment_praise_num = DatumLike::where([['is_read','=',0],['url_id','in',$all_datum],['user_id','<>',$this->user_id]])->count();
$praise_num = $datum_praise_num + $comment_praise_num;
$follow_num = UserMessage::getUnreadNum($this->user_id,'datum',5);
$datum_num =$datum_comment_num + $datum_reply_num +$datum_praise_num + $comment_praise_num +$follow_num;
// 回复我的
$press_all_comment = PressComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
$press_reply_num = PressComment::where([['t.is_deleted','=',0],['t.lev','>=',2],['t.user_id','<>',$this->user_id],['is_read','=',0],['t.pid','in',implode(',',$press_all_comment)]])->alias('t')->count();
// 评论我的
$press_comment_num = PressComment::where([['t.is_deleted','=',0],['t.pid','=',0],['i.user_id','=',$this->user_id],['t.is_read','=',0],['t.user_id','<>',$this->user_id]])
->leftJoin('Press i','t.first_id = i.id')
->alias('t')->count();
$press_num = $press_reply_num + $press_comment_num;
$demand_num = DemandComment::where([['t.is_deleted','=',0],['i.user_id','=',$this->user_id],['t.is_read','=',0],['t.user_id','<>',$this->user_id],['t.pid','=',0]])
->leftJoin('PlatformDemand i','t.first_id = i.id')
->alias('t')->count();
$all_comment = DemandComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
$reply_num = DemandComment::where([['t.is_deleted','=',0],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count();
$demand_num = $demand_num + $reply_num;
//问答模块
//回答我的
// $answer_num = ForumReply::where([['r.issue_user','=',$this->user_id],['r.is_deleted','=',0],['r.is_read','=',0]])
// ->alias('r')->leftJoin('user_forum a','r.forum_id = a.id')->count();
$answer_num = ForumReply::where([['r.issue_user', '=', $this->user_id], ['r.is_deleted', '=', 0], ['r.is_read', '=', 0]])
->alias('r')->leftJoin('user_forum f', 'r.forum_id = f.id')->count();
// 回复我的
// $forum_all_comment = ForumReplyComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
// $forum_reply_num = ForumReplyComment::where([['t.is_deleted','=',0],['t.user_id', '<>', $this->user_id],['t.is_read','=',0],['t.pid','in',implode(',',$forum_all_comment)]])->alias('t')->count();
// 回复我的
$forum_all_comment = ForumReplyComment::where(['user_id' => $this->user_id, 'is_deleted' => 0])->column('id');
if(count($forum_all_comment) < 1){
$forum_reply_num = 0;
$reply_answer = 0;
}else{
$forum_reply_num = ForumReplyComment::where([['t.is_deleted', '=', 0], ['t.user_id', '<>', $this->user_id], ['t.reply_id', '=', 0], ['t.is_read', '=', 0], ['t.pid', 'in', implode(',', $forum_all_comment)]])->alias('t')->count();
$reply_answer = ForumReplyComment::where([['t.is_deleted', '=', 0], ['t.user_id', '<>', $this->user_id], ['t.reply_id', '>', 0], ['t.is_read', '=', 0], ['t.pid', 'in', implode(',', $forum_all_comment)]])->alias('t')->count();
}
$forum_reply_num = $forum_reply_num +$reply_answer;
// 评论我的问题
$forum_comment = ForumReplyComment::alias('c')
->where(['r.user_id' => $this->user_id, 'r.is_deleted' => 0, 'c.is_read' => 0,'c.reply_id'=>0,'c.pid'=>0,'c.to_deleted'=>0])
->where('c.user_id','<>',$this->user_id)
->leftJoin('UserForum r', 'c.forum_id = r.id')
->count();
// 评论我的回答
$reply_comment = ForumReplyComment::alias('c')
->where(['r.user_id' => $this->user_id, 'r.is_deleted' => 0, 'c.is_read' => 0,'c.pid'=>0,])
->leftJoin('forum_reply r', 'c.reply_id = r.id')
->count();
$forum_follow_num = UserMessage::getUnreadNum($this->user_id,'forum',6);
$forum_num = $answer_num+$forum_reply_num+$forum_comment+$reply_comment+ $forum_follow_num;
//问答模块end
$sys_num = 0;//UserMessage::where(['user_id'=>$this->user_id,'is_deleted'=>0])->where('is_read',0)->count();
// 供应商
$supplier_comment_num = SupplierComment::where([['g.user_id', '=', $this->user_id],['c.is_deleted', '=', 0],['c.to_deleted', '=', 0],['c.is_read','=',0],['c.pid','=',0]])
->alias('c') ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')->count();
//回复我的
$supplier_all_comment = SupplierComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
$supplier_reply_num = $supplier_all_comment ? SupplierComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.is_read','=',0],['t.pid','in',implode(',',$supplier_all_comment)]])->alias('t')->count() :0;
//订阅
$supplier_follow_num = UserMessage::getUnreadNum($this->user_id,'supplier',5);
$supplier_num = $supplier_comment_num + $supplier_reply_num + $supplier_follow_num;
// 活动
$activity_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'is_read'=>0])->where('m.module','in','activity,apply')->alias('m')->count();
// 商品
$trolley_num = ShoppingTrolley::where(['user_id'=>$this->user_id])->sum('num');
$no_pay_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>0,'cancel_state'=>0,'status'=>0])->count();
$no_express_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>1,'express_state'=>0,'cancel_state'=>0])
->where('status',1)
->where('refund_state','in','0')
->count();
$express_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>1,'express_state'=>1,'cancel_state'=>0])
->where('refund_state','in','0,1,2')
->count();
// $finish_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>1,'express_state'=>2,'cancel_state'=>0])
// ->where('refund_state','in','0,1,2')
// ->count();
$finish_num = 0;
$refund_num = GoodsOrder::where(['o.user_id'=>$this->user_id,'o.is_deleted'=>0,'o.pay_state'=>1,'o.cancel_state'=>0])->alias('o')
->leftJoin('StoreOrderRefund r','r.order_id = o.id')
->where('o.refund_state','in','1,2,3')
->where('r.status','in','0,1,2,4')
->count();
$mark_num = $trolley_num + $no_pay_num + $no_express_num + $express_num + $finish_num + $finish_num + $refund_num;
//招聘
$praise_num = PlatformLike::where([['p.type', '=', 5],['f.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0]])->alias('p') ->leftJoin('Recruit f', 'f.id = p.like_id')->count();
// $follow_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'recruit','m.type_id'=>5,'is_read'=>0])->alias('m')->count();
$follow_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'recruit','is_read'=>0])->where('m.type_id','in','4,5')->alias('m')->count();
$recruits = \app\common\model\Recruit::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
$resume_num = RecruitResume::where('recruit_id','in',$recruits)->where('is_deleted',0)->where('to_deleted',0)->where('is_read',0)->count();
$recruit_num = $praise_num + $follow_num + $resume_num;
$total_num = $video_num + $article_num + $datum_num + $press_num + $demand_num + $forum_num + $supplier_num + $activity_num + $mark_num + $recruit_num;
$this->success('ok',compact(['video_num','article_num','press_num','demand_num','forum_num','sys_num','datum_num','activity_num','supplier_num','mark_num','recruit_num','total_num']));
}
/**
* @title 以下接口为二期需求
* @desc 以下接口为二期需求
* @author qc
* @url /api/Expedite/secondPhase
* @method
* @return name:1 type:string default:-- desc:以下接口为二期需求
*/
public function secondPhase(){}
/**
* @title 获取平台页面链接
* @desc 参数自定义!参数自定义!!参数自定义!!!
* @author qc
* @url /api/Expedite/getPlatformUrl
* @method GET
* @param name:module type:string default:-- desc:模块【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城商品】
* @param name:tag type:string default:-- desc:页面标识【detail=>详情,list=>列表】
* @param name:from type:string default:-- desc:请求接口来源1:h5,2:ios,3:android
* @return name:url type:array default:-- desc:链接
* @return name:desc type:string default:-- desc:页面描述
* @return name:param type:string default:-- desc:页面参数拼接
*/
public function getPlatformUrl()
{
$request_param = input('get.');
$module = input('module','activity');
$tag = input('tag','detail');
unset($request_param[$module]);
unset($request_param[$tag]);
$url = config('platform_url.'.$module)[$tag];
$this->success('ok',['url'=>$url,'params'=>http_build_query($request_param)]);
}
/**
* @title 获取手机号前缀
* @desc 获取手机号前缀
* @author qc
* @method GET
* @url /api/Expedite/getPhonePrefix
* @header name:Authorization require:1 desc:Token
* @return name:name type:string default:-- desc:名称
* @return name:code type:string default:-- desc:前缀
*/
public function getPhonePrefix()
{
/*$prefix = [
['name' => '中国大陆','code'=>'86'],
['name' => '中国香港','code'=>'852'],
['name' => '中国澳门','code'=>'853'],
['name' => '中国台湾','code'=>'886'],
['name' => '韩国','code'=>'82'],
['name' => '日本','code'=>'81'],
['name' => '美国','code'=>'1'],
['name' => '加拿大','code'=>'1'],
['name' => '新加坡','code'=>'65'],
['name' => '马来西亚','code'=>'62'],
['name' => '俄罗斯','code'=>'7'],
['name' => '新西兰','code'=>'64'],
['name' => '法国','code'=>'33'],
['name' => '德国','code'=>'49'],
];*/
$prefix = Db::name('phone_pre')->field('name,code')->where('is_deleted',0)->select();
$this->success('ok',$prefix);
}
/**
* @title ElasticSearch【登录状态需要header需要传Authorization】
* @desc ElasticSearch返回参数文档:https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html
* @author qc
* @url /api/Expedite/ElasticSearch
* @method GET
* @param name:page type:int default:-- desc:页数
* @param name:page_num type:int default:-- desc:每页数量
* @param name:search type:string default:-- desc:搜索关键词
* @param name:sort_type type:int default:1 desc:1默认2发布时间正序3发布时间倒序
* @param name:is_over type:int default:-1 desc:-1全部0未解决1已解决2开源【需求模块用】
* @param name:city type:string default:-- desc:城市搜索【招聘模块用】
* @param name:module type:string default:-- desc:搜索类型(不传查全部)[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
* @return name:highlight type:array default:-- desc:高亮【目前设置三个字段:title、label、desc】
*
* @return name:module type:string default:-- desc:模块名
* @return name:release_time type:string default:-- desc:上架时间
* @return name:series_id type:int default:-- desc:系列id【视频、图文、资料用】
* @return name:id type:int default:-- desc:某个模块的详情id【不是系列id】
* @return name:title type:string default:-- desc:标题或名称
* @return name:label type:string default:-- desc:标签
* @return name:label_arr type:array default:-- desc:标签【数组】
* @return name:desc type:string default:-- desc:描述
* @return name:desc_text type:string default:-- desc:描述文本【搜索用的,页面展示忽略】
* @return name:content type:string default:-- desc:内容【富文本】
* @return name:detail type:string default:-- desc:详情【富文本】
* @return name:create_at type:string default:-- desc:时间
* @return name:app_name type:string default:-- desc:发布者
* @return name:app_logo type:string default:-- desc:发布者头像
* @return name:read_num type:int default:-- desc:阅读量||播放量【若模块用不到忽略】
* @return name:comment_num type:int default:-- desc:评论量【若模块用不到忽略】
* @return name:like_num type:int default:-- desc:点赞量【若模块用不到忽略】
* @return name:transmit_num type:int default:-- desc:转发量【若模块用不到忽略】
* @return name:collect_num type:int default:-- desc:收藏量【若模块用不到忽略】
* @return name:down_num type:int default:-- desc:下载量【若模块用不到忽略】
* @return name:cover type:string default:-- desc:封面【单张】
* @return name:is_vip type:int default:-- desc:是否是vip
*
* @return name:duration type:string default:-- desc:时长【视频模块】
* @return name:ali_vid type:int default:-- desc:云点播ID【视频模块】
*
* @return name:images_arr type:array default:-- desc:图片【图文】
* @return name:content_type type:int default:1 desc:1富文本2pdf【图文】
* @return name:content type:string default:-- desc:内容富文本【图文】
*
* @return name:url type:string default:-- desc:资料路径【资料】
* @return name:is_down type:int default:-- desc:是否允许下载【资料】
*
* @return name:browse_num type:string default:-- desc:浏览量【问答】
* @return name:reply_num type:string default:-- desc:回答量【问答】
* @return name:level type:string default:-- desc:vip等级id【问答】
*
* @return name:start_time type:string default:-- desc:开始时间【活动】
* @return name:end_time type:string default:-- desc:结束时间【活动】
*
* @return name:is_over type:int default:-- desc:0未解决1已解决2开源【需求模块用】
* @return name:money type:string default:-- desc:金额【需求模块用】
*
* @return name:company type:string default:-- desc:公司名称【招聘】
* @return name:company_intro type:string default:-- desc:公司简介【招聘】
* @return name:is_ss type:string default:-- desc:是否上市,1上市【招聘】
* @return name:scale type:string default:-- desc:公司规模(人数)【招聘】
* @return name:principal type:string default:-- desc:联系人【招聘】
* @return name:province type:string default:-- desc:省【招聘】
* @return name:city type:string default:-- desc:市【招聘】
* @return name:salary type:string default:-- desc:薪资【招聘】
* @return name:hr_headimg type:string default:-- desc:联系人头像【招聘】
*
*
* @return name:item_list type:array default:-- desc:商品规格详情【商城商品】
* @return name:min_price type:float default:-- desc:最低价格【商城商品】
* @return name:max_price type:float default:-- desc:最高价格【商城商品】
* @return name:sale_num type:int default:-- desc:销量【商城商品】
*
*/
public function elasticSearch()
{
$index = input('index',config('text.es_index'));
$search = input('search','');
$module = input('module','');
$is_over = intval(input('is_over',-1));
$sort_type = input('sort_type',1);
$city = input('city');
//"全部",1=>'视频',2=>'资料',3=>'图文',4=>'新闻',5=>'问答',6=>'商品',7=>'活动',8=>'招聘',9=>'供应商',10=>'供应商商品',11=>'需求'
// video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
$search_type = [
'video'=>"1",
'datum'=>"2",
'article'=>"3",
'press'=>"4",
'forum'=>"5",
'goods'=>"6",
'activity'=>"7",
'recruit'=>"8",
'supplier'=>"9",
'supplier_goods'=>"10",
'demand'=>"11",
];
if($search && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$search,isset($search_type[$module]) ?$search_type[$module] :0 );
switch ($sort_type) {
case 1:
$order = $module ? [['_score'=>['order'=>'desc']],['id'=>['order'=>'desc']]] : [['_score'=>['order'=>'desc']], ['create_at'=>['order'=>'desc']]];
break;
case 2:
// $order = $module ? [['id'=>['order'=>'asc']]] : ['create_at'=>['order'=>'asc']];
$order = $module ? ['create_at'=>['order'=>'asc']] : ['create_at'=>['order'=>'asc']];
break;
case 3:
// $order = $module ? [['id'=>['order'=>'desc']]] : ['create_at'=>['order'=>'desc']];
$order = $module ? ['create_at'=>['order'=>'desc']] : ['create_at'=>['order'=>'desc']];
break;
}
$user_level = UserLevelRank::getUserVip($this->user_id);
$sel_level = $user_level ? $user_level : 1;
$where = [
'index'=>$index,
'from' => $this->off_set,
'size' => $this->page_num,
'body'=>[
'sort' => $order,
'query'=>[
'bool'=>[
'must'=> [
// ['match' => ['module'=> $module]],// module = module
['match' => ['status'=>1]], // status !=0
['match' => ['is_deleted'=> 0]],// is_deleted !=1
['range' => ['release_time'=> ['lte'=>time()]]],//
// ['range' => ['level'=> ['lte'=>$sel_level]]],//
/* ['bool'=>[
'should'=> [
'multi_match' => [
'fields'=> ['title','label','desc','content','detail'],
'query'=> $search,
"fuzziness"=>"AUTO",
'type'=> 'best_fields',
]],
]]*/
],
],
],
'highlight'=>[
"fields"=>[
'title'=>[
'pre_tags'=>[""],
'post_tags'=>[""]
],
'label'=>[
'pre_tags'=>[""],
'post_tags'=>[""]
],
'desc'=>[
'pre_tags'=>[""],
'post_tags'=>[""]
],
'content'=>[
'pre_tags'=>[""],
'post_tags'=>[""]
],
'detail'=>[
'pre_tags'=>[""],
'post_tags'=>[""]
],
'desc_text'=>[
'pre_tags'=>[""],
'post_tags'=>[""]
],
]
]
]
];
// if($module) $where['body']['query']['bool']['must'][] = ['match' =>['module'=> $module]];
if($module){
if($module == 'datum'){
$where['body']['query']['bool']['must'][] = ['bool' => ['should' => [
['match' => ['module' => $module]],
['match' => ['module' => 'datumIntro']],
]]];
}else{
$where['body']['query']['bool']['must'][] = ['match' =>['module'=> $module]];
}
// $where['body']['query']['bool']['must'][] = ['match' =>['module'=> $module]];
}else{
// $where['body']['query']['bool']['must'][] = ['bool' => ['should' => [
// ['match' => ['module' => 'video']],
// ['match' => ['module' => 'datum']],
// ['match' => ['module' => 'article']],
// ['match' => ['module' => 'press']],
// ['match' => ['module' => 'forum']],
// ['match' => ['module' => 'goods']],
// ['match' => ['module' => 'activity']],
// ['match' => ['module' => 'recruit']],
// ['match' => ['module' => 'supplier']],
// ['match' => ['module' => 'supplier_goods']],
// ['match' => ['module' => 'demand']],
// ]]];
}
if($module == 'demand' && $is_over != -1 ) $where['body']['query']['bool']['must'][] = ['match' =>['is_over'=> $is_over]];
if($module == 'recruit' && $city ) $where['body']['query']['bool']['must'][] = ['match' =>['city'=> $city]];
// if($search) $where['body']['query']['bool']['must'][] = ['bool' =>[
// 'should'=> [
// 'multi_match' => [
// 'fields'=> ['title','label','desc','content','detail'],
// 'query'=> $search,
// //"lenient"=> true,
// //"fuzziness"=>"1",
// 'operator' => 'and',
// 'type'=> 'best_fields',
// //"tie_breaker" => 0.1,
// //"minimum_should_match" => 1
// ]
// ]
// ]
// ];
//原版
if($search) $where['body']['query']['bool']['must'][] = ['bool' =>[
'should'=> [
'multi_match' => [
'fields'=> ['title','label','desc','content','detail'],
'query'=> $search,
"fuzziness"=>"AUTO",
'type'=> 'best_fields',
]]]];
//原版end
// if($search) $where['body']['query']['bool']['must'][] = [
// 'bool' =>[
// 'should'=> [
// 'match_phrase'=>[
// 'title' => [
// 'query' => $search,
// 'slop' => 1
// ],
// ],
//
// ]
// ]
// ];
// return json($where);
$list = Elastic::select($index,$where);
$w_list = [];
$speak_list= $list['hits']['hits'];
// return json($speak_list);
foreach ($list['hits']['hits'] as $k => &$v)
{
$v['_source']['label_arr'] = $v['_source']['label'] ? explode(',',$v['_source']['label']):null;
$v['_source']['create_at'] = date("Y-m-d",$v['_source']['create_at']);
$v['_source']['release_time'] = date("Y-m-d",$v['_source']['release_time']);
$v['_source']['is_over'] = isset($v['_source']['is_over']) ? intval($v['_source']['is_over']) : 0;
switch ($v['_source']['module']) {
case "video":
$info = VideoUrl::field('is_vip,cover,duration,ali_vid,read_num,video_id')->where('id',$v['_source']['id'])->find()->toArray();
$url = VideoIntro::where('id',$info['video_id'])->find();
// $v = $url;
// unset($list['hits']['hits'][$k]);
if($url == null){
unset($list['hits']['hits'][$k]);
}else{
if($url['status'] == 1 && $url['is_deleted'] == 0){
$v['_source']['series_id'] = $info['video_id'];
$v['_source']['cover'] = $info['cover'];
$v['_source']['is_vip'] = $info['is_vip'];
$v['_source']['duration'] = $info['duration'];
$v['_source']['ali_vid'] = $info['ali_vid'];
$v['_source']['read_num'] = numTransform($info['read_num']);
$info_auth = VideoUrl::getVideoAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $info_auth['app_name'];
$v['_source']['app_logo'] = $info_auth['app_logo'];
$w_list[] = $v;
}
}
break;
case "article":
// var_dump($v['_source']['id']);
// var_dump($v);
$info = ArticleItem::field('images,is_vip,cover,read_num,article_id,pdf,content_type')
->where('id',$v['_source']['id'])->find();
$info = $info->toArray();
$v['_source']['series_id'] = $info['article_id'];
$v['_source']['cover'] = $info['cover'];
$v['_source']['is_vip'] = $info['is_vip'];
$v['_source']['pdf'] = $info['pdf'];
$v['_source']['content_type'] = $info['content_type'];
$v['_source']['read_num'] = numTransform($info['read_num']);
$v['_source']['images_arr'] = $info['images']?explode('|',$info['images']):null;
$info_auth = ArticleItem::getArticleAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $info_auth['app_name'];
$v['_source']['app_logo'] = $info_auth['app_logo'];
unset($v['_source']['content']);
$w_list[] = $v;
break;
case "datum":
$info = DatumUrl::field('is_vip,read_num,down_num,url,is_down,datum_id')->where('id',$v['_source']['id'])->find()->toArray();
$v['_source']['series_id'] = $info['datum_id'];
$v['_source']['is_vip'] = $info['is_vip'];
$v['_source']['read_num'] = numTransform($info['read_num']);
$v['_source']['down_num'] = numTransform($info['down_num']);
$v['_source']['url'] = $info['url'];
$v['_source']['is_down'] = $info['is_down'];
$info_auth = DatumUrl::getDatumAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $info_auth['app_name'];
$v['_source']['app_logo'] = $info_auth['app_logo'];
$w_list[] = $v;
break;
case 'forum':
$info_auth = UserForum::getAuthInfo($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $info_auth['app_name'];
$v['_source']['app_logo'] = $info_auth['app_logo'];
$reply_num = ForumReply::where('forum_id', $v['_source']['id'])->where('is_deleted', 0)->count();
$v['_source']['reply_num'] = numTransform( $reply_num);
$forum_info = UserForum::where('id',$v['_source']['id'])->find()->toArray();
$v['_source']['browse_num'] = numTransform( $forum_info['browse_num']);
$w_list[] = $v;
break;
case 'activity':
$auth_info = \app\common\model\Activity::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $auth_info['app_name'];
$v['_source']['app_logo'] = $auth_info['app_logo'];
$info = \app\common\model\Activity::where('id',$v['_source']['id'])->find()->toArray();
$v['_source']['start_time'] = $info['start_time'];
$v['_source']['end_time'] = $info['end_time'];
$v['_source']['cover'] = $info['cover'];
$v['_source']['read_num'] = numTransform($info['read_num']);
$w_list[] = $v;
break;
case 'supplier_goods':
$info = SupplierGoods::where('id',$v['_source']['id'])->find()->toArray();
// return json($info['supplier_id']);
$auth_info = SupplierGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$auth_info = \app\common\model\Supplier::where('id',$info['supplier_id'])->find();
if(!$auth_info){
$app_name = '';
$app_logo = '';
}else{
$app_name = $auth_info['title'];
$app_logo = $auth_info['logo'];
}
$v['_source']['app_name'] = $app_name;
$v['_source']['app_logo'] = $app_logo;
$v['_source']['read_num'] = numTransform($info['read_num']);
$v['_source']['cover'] = $info['cover'];
unset($v['_source']['content']);
$w_list[] = $v;
break;
case 'press':
$info = \app\common\model\Press::where('id',$v['_source']['id'])->find()->toArray();
$auth_info = SupplierGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $auth_info['app_name'];
$v['_source']['app_logo'] = $auth_info['app_logo'];
$v['_source']['read_num'] = numTransform($info['read_num']);
$images_arr = $info['images'] ? explode('|',$info['images']) : null;
$v['_source']['cover'] = $images_arr ? $images_arr[0] : null;
unset($v['_source']['content']);
$w_list[] = $v;
break;
case 'demand':
$info = PlatformDemand::where('id',$v['_source']['id'])->find()->toArray();
$auth_info = PlatformDemand::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $auth_info['app_name'];
$v['_source']['app_logo'] = $auth_info['app_logo'];
$v['_source']['read_num'] = numTransform($info['read_num']);
$images_arr = $info['images'] ? explode('|',$info['images']) : null;
$v['_source']['cover'] = $info['cover'];
$v['_source']['money'] = $info['money'];
unset($v['_source']['content']);
$w_list[] = $v;
break;
case 'recruit':
$info = \app\common\model\Recruit::where('id',$v['_source']['id'])->find()->toArray();
$auth_info = \app\common\model\Recruit::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $auth_info['app_name'];
$v['_source']['app_logo'] = $auth_info['app_logo'];
$v['_source']['scale'] = $info['scale'];
$v['_source']['is_ss'] = $info['is_ss'];
$v['_source']['company'] = $info['company'];
$v['_source']['company_intro'] = $info['company_intro'];
$v['_source']['province'] = $info['province'];
$v['_source']['salary'] = $info['salary'];
$v['_source']['city'] = $info['city'];
$v['_source']['principal'] = $info['principal'];
$v['_source']['hr_headimg'] = $info['hr_headimg'];
unset($v['_source']['content']);
$w_list[] = $v;
break;
case 'goods':
$info = \app\common\model\StoreGoods::where('id',$v['_source']['id'])->find()->toArray();
$auth_info = \app\common\model\StoreGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $auth_info['app_name'];
$v['_source']['app_logo'] = $auth_info['app_logo'];
$v['_source']['cover'] = $info['cover'];
$v['_source']['sale_num'] = $info['sale_num'];
$v['_source']['specs'] = json_decode($info['specs'],true);
$v['_source']['item_list'] = StoreGoodsItem::getGoodsSpec($info['id']);
$v['_source']['min_price'] = empty($v['_source']['item_list']) ? 0 : min(array_column($v['_source']['item_list'],'sell_price'));
$v['_source']['max_price'] = empty($v['_source']['item_list']) ? 0 : max(array_column($v['_source']['item_list'],'sell_price'));
unset($v['_source']['content']);
$w_list[] = $v;
break;
case 'datumIntro':
$auth_info = \app\common\model\StoreGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
$v['_source']['app_name'] = $auth_info['app_name'];
$v['_source']['app_logo'] = $auth_info['app_logo'];
$v['_source']['min_price'] = empty($v['_source']['item_list']) ? 0 : min(array_column($v['_source']['item_list'],'sell_price'));
$v['_source']['max_price'] = empty($v['_source']['item_list']) ? 0 : max(array_column($v['_source']['item_list'],'sell_price'));
unset($v['_source']['content']);
$w_list[] = $v;
break;
}
}
$list['hits']['hits'] = $w_list;
$this->success('ok',['list'=>$list,'total_count'=>$list['hits']['total']['value'],'page_num'=>$this->page_num]);
}
/**
* @title 获取DRM无法播放机型
* @desc 获取DRM无法播放机型
* @author qc
* @url /api/Expedite/getBanPhoneModel
* @method GET
*/
public function getBanPhoneModel()
{
$list = Db::name('ban_phone_model')->where('is_deleted',0)->column('name');
$this->success('ok',$list);
}
/**
* @title 获取各个模分享图片
* @desc 获取各个模分享图片
* @author qc
* @url /api/Expedite/getModuleBgImages
* @method GET
* @return name:activity type:string default:-- desc:活动
* @return name:video type:string default:-- desc:视频
* @return name:datum type:string default:-- desc:资料
* @return name:forum type:string default:-- desc:问答
* @return name:article type:string default:-- desc:图文
* @return name:supplier type:string default:-- desc:供应商
* @return name:press type:string default:-- desc:新闻
* @return name:demand type:string default:-- desc:需求
* @return name:recruit type:string default:-- desc:招聘
* @return name:goods type:string default:-- desc:商品
*/
public function getModuleBgImages()
{
$list = [
'activity' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/activity.png',// 活动
'video' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/video.png',// 视频
'datum' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/datum.png',//资料
'forum' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/forum.png',// 问答
'article' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/article.png',// 图文
'supplier' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/supplier.png',// 供应商
'press' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/press.png',//新闻
'demand' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/demand.png',// 需求
'recruit' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/recruit.png',// 招聘
'goods' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/goods.png',// 商品
];
$this->success('ok',$list);
}
}