1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864 |
- <?php
- namespace app\api\controller;
- use AlibabaCloud\Client\AlibabaCloud;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Exception\ServerException;
- use app\common\model\ArticleComment;
- use app\common\model\ArticleCommentLike;
- use app\common\model\ArticleIntro;
- use app\common\model\ArticleItem;
- use app\common\model\ArticleLike;
- use app\common\model\DatumComment;
- use app\common\model\DatumCommentLike;
- use app\common\model\DatumLike;
- use app\common\model\DatumUrl;
- use app\common\model\DemandComment;
- use app\common\model\ForumReply;
- use app\common\model\ForumReplyComment;
- use app\common\model\GoodsOrder;
- use app\common\model\PlatformDemand;
- use app\common\model\PlatformLike;
- use app\common\model\PressComment;
- use app\common\model\RecruitResume;
- use app\common\model\ShoppingTrolley;
- use app\common\model\StoreBanner;
- use app\common\model\StoreGoods;
- use app\common\model\StoreGoodsItem;
- use app\common\model\SupplierComment;
- use app\common\model\SupplierGoods;
- use app\common\model\TopSearch;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserForum;
- use app\common\model\UserLevel;
- use app\common\model\UserLevelRank;
- use app\common\model\UserMessage;
- use app\common\model\UserSearch;
- use app\common\model\VideoCommentLike;
- use app\common\model\VideoIntro;
- use app\common\model\VideoUrl;
- use app\common\service\CheckPower;
- use app\common\service\Elastic;
- use app\common\service\UserSynth;
- use Dm\Request\V20151123 as Dm;
- use library\tools\Data;
- use think\cache\driver\Redis;
- use think\Db;
- use app\common\model\VideoComment;
- class Expedite extends Base
- {
- public function initialize(){
- parent::initialize();
- parent::setUid();
- }
-
- 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]);
- }
-
- 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]);
- }
-
- public function voice(){
- $data = input();
- if(!$data['url'] || !$data['from'] || !$data['to'] || !$data['url']){
- }
- $arr = [
- 'url'=>'https://device.jpush.cn/v3/aliases/66',
- 'AppKey'=>config('app.jiguang')['AppKey'],
- 'MasterSecret'=>config('app.jiguang')['MasterSecret'],
- ];
- $body = [];
- $options['type']="audio";
- $options['msg']='发送';
- $b=json_encode($body);
- $str = 'Basic '.$arr['AppKey'].':'.$arr['MasterSecret'];
- $base64 = base64_encode($str);
- $header=array('Authorization' => $str);
- $result=$this->postCurl($arr['url'],$b,$header);
-
- return json($result);
- }
- public function postCurl($url,$body,$header,$type="POST"){
-
- $ch = curl_init();
-
- curl_setopt($ch,CURLOPT_URL,$url);
-
-
-
-
-
- curl_setopt($ch,CURLOPT_HEADER,0);
-
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- if (strlen($body)>0) {
-
- curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
- }
-
- if(count($header)>0){
- 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);
-
- switch($type){
- case "GET":
- curl_setopt($ch,CURLOPT_HTTPGET,true);
- break;
- case "POST":
- curl_setopt($ch,CURLOPT_POST,true);
- break;
- case "PUT":
- curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"PUT");
- break;
- case "DELETE":
- curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"DELETE");
- break;
- }
-
- curl_setopt ( $ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)' );
-
-
- $res=curl_exec($ch);
- $result=json_decode($res,true);
-
- curl_close($ch);
- if(empty($result))
- return $res;
- else
- return $result;
- }
-
- 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]);
- }
-
- public function levelSwitch(){
- $this->success('ok',['value'=>sysconf('level_switch')]);
- }
-
- public function logoutSwitch(){
- $this->success('ok',['value'=>sysconf('logout_switch')]);
- }
-
- 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'];
- $page_num = $this->page_num;
- if($total_num > $most_num){
- $t_num = $total_num - $most_num;
- $l_num = $data['page_num'] - $t_num;
-
- $page_num = $l_num;
-
- }
- $sel = [];
- $sel['is_deleted'] = 0;
- $sel['status'] = 1;
- if($module) $sel['module'] =$module;
- if($page_num <= 0){
- $list = [];
- }else{
- $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]);
- }
-
- 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,ladder,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']));
- }
-
- 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('发送成功');
- }
-
- 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 ="<img src='$img'/>";
- $html_body = '您的验证码'.$code.'有效时间5分钟';
- $request->setHtmlBody($html_body);
- try {
- $send_res = $client->getAcsResponse($request);
- $sms_data = array(
- 'phone'=>$email,
- 'code'=>$code,
- 'result'=>'OK'
- );
- Db::name('store_member_sms')->insert($sms_data);
- $this->success('发送成功');
- } catch (ClientException $e) {
- $this->error($e->getErrorMessage());
-
-
- } catch (ServerException $e) {
- $this->error($e->getErrorMessage());
-
-
- }
- }
-
- 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);
-
- 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);
- }
-
- 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']]);
- }
-
- 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']]);
- }
-
- 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'];
- $set = Db::name('system_config')->where('name','in',$con_name)->select();
- $ret = [];
- foreach ($set as $value) {
- $ret[$value['name']]=$value['value'];
- }
- $this->success('获取成功',$ret);
- }
-
- 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('修改成功');
- }
-
- 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);
- }
-
- 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('修改成功');
- }
-
- 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;
-
- }
- $this->success('获取成功',$ret);
- }
-
- 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);
- }
-
- 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 :'']);
- }
-
- 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);
- }
-
- 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);
- }
-
- 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);
- }
-
- 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]);
- }
-
- 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-sign-up?activity_id=$first_id",
- 'demand' =>$this->request->root(true) ."/dist/#/demand-details?demand_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?recruit_id=$first_id",
- 'mall' =>$this->request->root(true) ."/dist/#/product-details?product_id=$first_id",
- ];
- $this->success('ok',['url'=>$url_arr[$tag]]);
- }
-
- 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);
- }
-
- 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;
- $comment_praise_num = 0 ;
- $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;
- $comment_praise_num = 0;
- $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],['t.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 = DatumComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.lev','>=',2],['t.is_read','=',0],['t.pid','in',implode(',',$datum_all_comment)]])->alias('t')->count();
-
- $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',$all_datum]])->count();
- $comment_praise_num = DatumLike::where([['is_read','=',0],['url_id','in',$datum_all_comment]])->count();
- $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();
-
- $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_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;
- $sys_num = 0;
-
- $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 = 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','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']));
- }
-
- public function secondPhase(){}
-
- 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)]);
- }
-
- public function getPhonePrefix()
- {
-
- $prefix = Db::name('phone_pre')->field('name,code')->where('is_deleted',0)->select();
- $this->success('ok',$prefix);
- }
-
- 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');
-
-
- $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 ? ['create_at'=>['order'=>'asc']] : ['create_at'=>['order'=>'asc']];
- break;
- case 3:
-
- $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' => ['status'=>1]],
- ['match' => ['is_deleted'=> 0]],
- ['range' => ['release_time'=> ['lte'=>time()]]],
-
-
- ],
- ],
- ],
- 'highlight'=>[
- "fields"=>[
- 'title'=>[
- 'pre_tags'=>["<span style='color:#FF6700'>"],
- 'post_tags'=>["</span>"]
- ],
- 'label'=>[
- 'pre_tags'=>["<span style='color:#FF6700'>"],
- 'post_tags'=>["</span>"]
- ],
- 'desc'=>[
- 'pre_tags'=>["<span style='color:#FF6700'>"],
- 'post_tags'=>["</span>"]
- ],
- 'content'=>[
- 'pre_tags'=>["<span style='color:#FF6700'>"],
- 'post_tags'=>["</span>"]
- ],
- 'detail'=>[
- 'pre_tags'=>["<span style='color:#FF6700'>"],
- 'post_tags'=>["</span>"]
- ],
- 'desc_text'=>[
- 'pre_tags'=>["<span style='color:#FF6700'>"],
- 'post_tags'=>["</span>"]
- ],
- ]
- ]
- ]
- ];
- if($module) $where['body']['query']['bool']['must'][] = ['match' =>['module'=> $module]];
- 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,
- "fuzziness"=>"AUTO",
- 'type'=> 'best_fields',
- ]]]];
- $list = Elastic::select($index,$where);
- $w_list = [];
- $speak_list= $list['hits']['hits'];
- 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();
- 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":
-
-
- $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();
- $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']);
- $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;
- }
- }
- $list['hits']['hits'] = $w_list;
- $this->success('ok',['list'=>$list,'total_count'=>$list['hits']['total']['value'],'page_num'=>$this->page_num]);
- }
-
- public function getBanPhoneModel()
- {
- $list = Db::name('ban_phone_model')->where('is_deleted',0)->column('name');
- $this->success('ok',$list);
- }
-
- 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);
- }
- }
|