Expedite.php 104 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961
  1. <?php
  2. namespace app\api\controller;
  3. use AlibabaCloud\Client\AlibabaCloud;
  4. use AlibabaCloud\Client\Exception\ClientException;
  5. use AlibabaCloud\Client\Exception\ServerException;
  6. use app\common\model\ArticleComment;
  7. use app\common\model\ArticleCommentLike;
  8. use app\common\model\ArticleIntro;
  9. use app\common\model\ArticleItem;
  10. use app\common\model\ArticleLike;
  11. use app\common\model\DatumComment;
  12. use app\common\model\DatumCommentLike;
  13. use app\common\model\DatumLike;
  14. use app\common\model\DatumUrl;
  15. use app\common\model\DemandComment;
  16. use app\common\model\ForumReply;
  17. use app\common\model\ForumReplyComment;
  18. use app\common\model\GoodsOrder;
  19. use app\common\model\PlatformDemand;
  20. use app\common\model\PlatformLike;
  21. use app\common\model\PressComment;
  22. use app\common\model\RecruitResume;
  23. use app\common\model\ShoppingTrolley;
  24. use app\common\model\StoreBanner;
  25. use app\common\model\StoreGoods;
  26. use app\common\model\StoreGoodsItem;
  27. use app\common\model\SupplierComment;
  28. use app\common\model\SupplierGoods;
  29. use app\common\model\TopSearch;
  30. use app\common\model\User;
  31. use app\common\model\UserCollect;
  32. use app\common\model\UserForum;
  33. use app\common\model\UserLevel;
  34. use app\common\model\UserLevelRank;
  35. use app\common\model\UserMessage;
  36. use app\common\model\UserSearch;
  37. use app\common\model\VideoCommentLike;
  38. use app\common\model\VideoIntro;
  39. use app\common\model\VideoUrl;
  40. use app\common\service\CheckPower;
  41. use app\common\service\Elastic;
  42. use app\common\service\UserSynth;
  43. use Dm\Request\V20151123 as Dm;
  44. use library\tools\Data;
  45. use think\cache\driver\Redis;
  46. use think\Db;
  47. use app\common\model\VideoComment;
  48. /**
  49. * @title 其他接口(不需要登录状态)【多模块共用】
  50. * @controller Expedite
  51. * @package app\api\controller
  52. */
  53. class Expedite extends Base
  54. {
  55. public function initialize(){
  56. parent::initialize();
  57. parent::setUid();
  58. }
  59. /**
  60. * @title 获取首页轮播图
  61. * @desc 获取首页轮播图
  62. * @author qc
  63. * @url /api/Expedite/getBanner
  64. * @method GET
  65. * @header name:Authorization require:1 desc:Token
  66. * @param name:num type:int default:5 desc:查询数量
  67. * @param name:is_pc type:int default:0 desc:是否是pc端用(0否1是)
  68. * @return name:cover type:string default:-- desc:图片路径
  69. * @return name:place type:string default:-- desc:跳转模块【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城,service=>客服】
  70. * @return name:first_id type:int default:-- desc:详情id(视频、图文、资料为系列id)
  71. * @return name:second_id type:second_id default:-- desc:系列某详情id(视频、图文、资料)
  72. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  73. */
  74. public function getBanner()
  75. {
  76. $num = input('get.num',100);
  77. $is_pc = input('get.is_pc',0);
  78. $list = StoreBanner::field('id,cover,place,first_id,second_id')
  79. ->where(['is_deleted'=>0,'is_pc'=>$is_pc])
  80. ->limit(0,$num)
  81. ->order('sort desc ,id desc')->select()->toArray();
  82. foreach ($list as &$v){
  83. $v['is_normal'] = CheckPower::checkModulesPower($v['first_id'],$v['second_id'],$v['place']);
  84. }
  85. $this->success('ok',['list'=>$list]);
  86. }
  87. /**
  88. * @title 添加极光推送记录
  89. * @desc 添加极光推送记录
  90. * @author qc
  91. * @url /api/Expedite/clientLog
  92. * @method POST
  93. * @tag 编辑信息
  94. * @header name:Authorization require:1 desc:Token
  95. * @param name:type type:string default:1 desc:类型
  96. * @param name:log type:int default:-- desc:记录内容
  97. */
  98. public function clientLog()
  99. {
  100. $data = input();
  101. if($this->user_id){
  102. $data['user_id'] = $this->user_id;
  103. }
  104. $data['create_at'] = date('Y-m-d H:i:s');
  105. $client_log = Db::name('client_log')->insert($data);
  106. $this->success('添加成功',['detail'=>$client_log]);
  107. }
  108. /**
  109. * @title 推送查询
  110. * @desc 推送查询
  111. * @author qc
  112. * @url /api/Expedite/aliases
  113. * @method GET
  114. * @tag 环信
  115. * @param name:filename type:string default:-- desc:语音文件的名称
  116. * @param name:from type:string default:-- desc:发送方用户id
  117. * @param name:to type:string default:-- desc:接收方用户id
  118. * @param name:url type:string default:-- desc:语音文件的url地址
  119. * @return name:url type:string default:-- desc:语音文件的url地址
  120. */
  121. public function aliases(){
  122. $data = input();
  123. // if(!$data['url'] || !$data['from'] || !$data['to'] || !$data['url']){
  124. //
  125. // }
  126. $arr = [
  127. 'url'=>'https://device.jpush.cn/v3/aliases/479?new_format=true',
  128. 'AppKey'=>config('app.jiguang')['AppKey'],
  129. 'MasterSecret'=>config('app.jiguang')['MasterSecret'],
  130. ];
  131. // $hx_voice = hx_voice(24);
  132. // $url= $arr['url'].$arr['org_name'].'/'.$arr['app_name'].'/'.'messages/users';
  133. // $body['from'] = $data['form']; //'member2200'
  134. // $body['to'] = $data['to']; //worker1000
  135. // $body['type'] = 'audio';
  136. // $body['body'] = [
  137. // 'filename' => $data['filename'], //'testaudio.amr', //语音文件的名称
  138. // 'url' => $data['url'] //'http://tmp/bQo7Udv1FETr01c4bb0ecee3a2edb86b00a393176fcc.durationTime=2790.aac', //语音文件的url地址
  139. // ];
  140. $body = [
  141. // "registration_ids"=>[
  142. // "remove"=> ["100d85590840f4bd5b8"]
  143. // ]
  144. ];
  145. $options['type']="audio";
  146. $options['msg']='发送';
  147. $b=json_encode($body);
  148. // return $b;
  149. $str = $arr['AppKey'].':'.$arr['MasterSecret'];
  150. //$str = '7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1';
  151. $base64 = base64_encode($str);
  152. //$header=['Authorization' => ];
  153. $header = array("Authorization: Basic ".$base64);
  154. // return json($header);
  155. $result=$this->postCurl($arr['url'],$b,$header,'GET');
  156. // $result=$this->postCurl($url,$body,$header);
  157. //dump($result);
  158. return json($result);
  159. // return $hx_voice;
  160. }
  161. public function postCurl($url,$body,$header,$type="POST"){
  162. //1.创建一个curl资源
  163. $ch = curl_init();
  164. //2.设置URL和相应的选项
  165. curl_setopt($ch,CURLOPT_URL,$url);//设置url
  166. //1)设置请求头
  167. // array_push($header, 'Accept:application/json');
  168. // array_push($header,'Content-Type:application/json');
  169. // array_push($header, 'http:multipart/form-data');
  170. //设置为false,只会获得响应的正文(true的话会连响应头一并获取到)
  171. curl_setopt($ch,CURLOPT_HEADER,0);
  172. // curl_setopt ( $ch, CURLOPT_TIMEOUT,5); // 设置超时限制防止死循环
  173. //设置发起连接前的等待时间,如果设置为0,则无限等待。
  174. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
  175. //将curl_exec()获取的信息以文件流的形式返回,而不是直接输出。
  176. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  177. //2)设备请求体
  178. if (strlen($body)>0) {
  179. //$b=json_encode($body,true);
  180. curl_setopt($ch, CURLOPT_POSTFIELDS, $body);//全部数据使用HTTP协议中的"POST"操作来发送。
  181. }
  182. //设置请求头
  183. // if(count($header)>0){
  184. // curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
  185. // }
  186. curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
  187. //上传文件相关设置
  188. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  189. curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
  190. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);// 对认证证书来源的检查
  191. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);// 从证书中检查SSL加密算
  192. //3)设置提交方式
  193. switch($type){
  194. case "GET":
  195. curl_setopt($ch,CURLOPT_HTTPGET,true);
  196. break;
  197. case "POST":
  198. curl_setopt($ch,CURLOPT_POST,true);
  199. break;
  200. case "PUT"://使用一个自定义的请求信息来代替"GET"或"HEAD"作为HTTP请求。这对于执行"DELETE" 或者其他更隐蔽的HTT
  201. curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"PUT");
  202. break;
  203. case "DELETE":
  204. curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"DELETE");
  205. break;
  206. }
  207. //4)在HTTP请求中包含一个"User-Agent: "头的字符串。-----必设
  208. // curl_setopt($ch, CURLOPT_USERAGENT, 'SSTS Browser/1.0');
  209. // curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  210. //curl_setopt ( $ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)' ); // 模拟用户使用的浏览器
  211. //5)
  212. //3.抓取URL并把它传递给浏览器
  213. $res=curl_exec($ch);
  214. $result=json_decode($res,true);
  215. //4.关闭curl资源,并且释放系统资源
  216. curl_close($ch);
  217. if(empty($result))
  218. return $res;
  219. else
  220. return $result;
  221. }
  222. /**
  223. * @title 获取会员等级设置
  224. * @desc 获取会员等级设置
  225. * @author qc
  226. * @url /api/Expedite/getUserLevelSet
  227. * @method GET
  228. * @header name:Authorization require:1 desc:Token
  229. * @return name:id type:int default:-- desc:等级id
  230. * @return name:name type:string default:-- desc:等级名称
  231. * @return name:logo type:string default:-- desc:图片
  232. * @return name:price type:array default:-- desc:价格设置【为空,,不能购买】
  233. * @return name:price.title type:string default:-- desc:标题
  234. * @return name:price.time type:string default:-- desc:时间(单位月)
  235. * @return name:price.price type:float default:-- desc:价格
  236. * @return name:price.renew type:int default:-- desc:续费价格
  237. * @return name:is_renew type:int default:-- desc:是否是续费会员【1是0否】
  238. */
  239. public function getUserLevelSet()
  240. {
  241. $list = UserLevel::field('id,logo,name,price')->where("price is not null and price != ''")->where('id',1)->select()->toArray();
  242. foreach ($list as &$v) {
  243. $v['price_arr'] = json_decode($v['price'],true);
  244. }
  245. $is_renew = \app\common\model\LevelOrder::where('user_id',$this->user_id)->where('status',1)->where('pay_state',1)->count();
  246. $this->success('ok',['list'=>$list,'is_renew'=>$is_renew ? 1:0]);
  247. }
  248. /**
  249. * @title 会员等级开关【IOS用】
  250. * @desc 会员等级开关
  251. * @author qc
  252. * @url /api/Expedite/levelSwitch
  253. * @method GET
  254. * @header name:Authorization require:1 desc:Token
  255. * @return name:value type:int default:-- desc:0关闭1开启
  256. */
  257. public function levelSwitch(){
  258. $this->success('ok',['value'=>sysconf('level_switch')]);
  259. }
  260. /**
  261. * @title 注销开关
  262. * @desc 注销开关
  263. * @author qc
  264. * @url /api/Expedite/logoutSwitch
  265. * @method GET
  266. * @header name:Authorization require:1 desc:Token
  267. * @return name:value type:int default:-- desc:0关闭1开启
  268. */
  269. public function logoutSwitch(){
  270. $this->success('ok',['value'=>sysconf('logout_switch')]);
  271. }
  272. /**
  273. * @title 获取热搜列表
  274. * @desc 获取热搜列表
  275. * @author qc
  276. * @url /api/Expedite/getTopSearch
  277. * @method GET
  278. * @param name:page type:int default:-- desc:页数
  279. * @param name:page_num type:int default:-- desc:每页数量
  280. * @param name:module type:string default:-- desc:模块,不传查全部的[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
  281. * @return name:title type:string default:-- desc:标题
  282. * @return name:hot_num type:int default:-- desc:热搜量
  283. * @return name:rel_id type:int default:-- desc:相关详情id【不是系列id】
  284. * @return name:series_id type:int default:-- desc:系列id【图文、视频、资料用】
  285. * @return name:module type:string default:-- desc:[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
  286. */
  287. public function getTopSearch()
  288. {
  289. $module = input('module');
  290. $data = input();
  291. if(isset($data['module'])){
  292. $most_num = 30;
  293. }else{
  294. $most_num = 60;
  295. }
  296. if(!isset($data['page_num'])){
  297. $data['page_num'] = 20;
  298. }
  299. if(!isset($data['page'])){
  300. $data['page'] = 1;
  301. }
  302. $total_num = (int)$data['page_num'] * (int)$data['page'];
  303. // return $total_num.'-'.$most_num;
  304. $page_num = $this->page_num;
  305. if($total_num > $most_num){
  306. $t_num = $total_num - $most_num;
  307. $l_num = $data['page_num'] - $t_num;
  308. //$this->page_num = $l_num;
  309. $page_num = $l_num;
  310. //$this->off_set = $l_num;
  311. // return $l_num;
  312. }
  313. $sel = [];
  314. $sel['is_deleted'] = 0;
  315. $sel['status'] = 1;
  316. if($module) $sel['module'] =$module;
  317. if($page_num <= 0){
  318. $list = [];
  319. }else{
  320. // if(){
  321. //$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')
  322. // ->when($search_name,function ($query)use ($search_name,$search_time){
  323. // if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  324. // if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  325. // })->leftJoin('video_intro b','b.id = a.video_id')
  326. // ->where('a.status',1)->where('release_time','< time',date('Y-m-d H:i:s'))->where('a.is_deleted',0)
  327. // ->where('b.status',1)->where('b.is_deleted',0)->limit($this->off_set,$this->page_num)->order($order)
  328. // ->select()->toArray();
  329. // }
  330. $list = TopSearch::field('id,title,rel_id,module,hot_num,series_id')
  331. ->where($sel)
  332. ->order('hot_num desc')
  333. ->limit($this->off_set,$page_num)
  334. ->select()->toArray();
  335. }
  336. $total_num =TopSearch::where($sel)->count();
  337. if($total_num > $most_num){
  338. $total_num = $most_num;
  339. }
  340. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  341. }
  342. /**
  343. * @title 全局搜索【登录状态需要header需要传Authorization】
  344. * @desc 全局搜索
  345. * @author qc
  346. * @url /api/Expedite/globalSearch
  347. * @method GET
  348. * @param name:page type:int default:-- desc:页数
  349. * @param name:page_num type:int default:-- desc:每页数量
  350. * @param name:type type:string default:-- desc:搜索类型(不传查全部)[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
  351. * @param name:search_name type:string default:-- desc:搜索名称
  352. * @param name:search_time type:int default:-- desc:0不限,182半年,365一年
  353. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序 *
  354. * @return name:video_list type:array default:-- desc:视频列表【单个】
  355. * @return name:video_list.url_id type:int default:-- desc:url_id
  356. * @return name:video_list.video_id type:int default:-- desc:video_id
  357. * @return name:video_list.cover type:string default:-- desc:封面
  358. * @return name:video_list.title type:string default:-- desc:标题
  359. * @return name:video_list.is_vip type:int default:-- desc:是否是vip【0否1是】
  360. * @return name:video_list.ali_vid type:string default:-- desc:云点播视频id
  361. * @return name:video_list.read_num type:int default:-- desc:播放量
  362. * @return name:video_list.duration type:int default:-- desc:时长(单位:秒)
  363. * @return name:video_list.app_name type:string default:-- desc:平台名称
  364. * @return name:video_list.app_logo type:string default:-- desc:平台头像
  365. * @return name:video_list.create_at type:string default:-- desc:时间
  366. * @return name:article_list type:array default:-- desc:图文列表【单个】
  367. * @return name:article_list.title type:string default:-- desc:图文标题
  368. * @return name:article_list.is_vip type:int default:-- desc:是否是vip
  369. * @return name:article_list.desc type:int default:-- desc:简介【文本】
  370. * @return name:article_list.cover type:string default:-- desc:封面
  371. * @return name:article_list.images type:int default:-- desc:图片【多张|隔开】
  372. * @return name:article_list.images_arr type:array default:-- desc:图片
  373. * @return name:article_list.read_num type:int default:-- desc:阅读量
  374. * @return name:article_list.app_name type:string default:-- desc:平台名称
  375. * @return name:article_list.app_logo type:string default:-- desc:平台头像
  376. * @return name:article_list.create_at type:string default:-- desc:时间
  377. *
  378. * @return name:datum_list type:array default:-- desc:资料列表【单个】
  379. * @return name:datum_list.id type:int default:-- desc:资料的url_id
  380. * @return name:datum_list.title type:string default:-- desc:标题
  381. * @return name:datum_list.is_vip type:int default:-- desc:是否是vip
  382. *
  383. * @return name:press_list type:array default:-- desc:新闻列表
  384. * @return name:press_list.id type:int default:-- desc:新闻id
  385. * @return name:press_list.title type:string default:-- desc:标题
  386. * @return name:press_list.cover type:string default:-- desc:封面
  387. * @return name:press_list.images_arr type:array default:-- desc:图片
  388. * @return name:press_list.read_num type:int default:-- desc:阅读量
  389. * @return name:press_list.is_collect type:int default:-- desc:是否收藏(0否1是)
  390. * @return name:press_list.transmit_num type:int default:-- desc:转发量
  391. * @return name:press_list.collect_num type:int default:-- desc:收藏量
  392. * @return name:press_list.praise_num type:int default:-- desc:点赞量
  393. * @return name:press_list.is_praise type:int default:-- desc:是否点赞(0否1是)
  394. * @return name:press_list.comment_num type:int default:-- desc:评论量
  395. *
  396. *
  397. *
  398. *
  399. * @return name:recruit_list type:array default:-- desc:招聘列表
  400. * @return name:recruit_list.title type:string default:-- desc:标题
  401. * @return name:recruit_list.company type:string default:-- desc:公司名
  402. * @return name:recruit_list.cover type:string default:-- desc:公司logo
  403. * @return name:recruit_list.label_name type:array default:-- desc:标签
  404. * @return name:recruit_list.welfare_arr type:array default:-- desc:岗位福利
  405. * @return name:recruit_list.education type:string default:-- desc:学历
  406. * @return name:recruit_list.experience_min type:int default:0 desc:最低工作年限
  407. * @return name:recruit_list.experience_max type:int default:0 desc:最高工作年限
  408. * @return name:recruit_list.price_min type:int default:-- desc:最低薪资
  409. * @return name:recruit_list.price_max type:int default:-- desc:最高薪资
  410. * @return name:recruit_list.province type:string default:-- desc:省名
  411. * @return name:recruit_list.city type:string default:-- desc:市名
  412. * @return name:recruit_list.address type:string default:-- desc:地址
  413. * @return name:recruit_list.app_name type:string default:-- desc:发布人名称
  414. * @return name:recruit_list.app_logo type:string default:-- desc:发布人头像
  415. *
  416. * @return name:goods_list type:array default:-- desc:商城商品
  417. * @return name:goods_list.id type:int default:-- desc:d
  418. * @return name:goods_list.name type:string default:-- desc:商品名称
  419. * @return name:goods_list.cover type:string default:-- desc:封面
  420. * @return name:goods_list.low_price type:float default:-- desc:价格
  421. *
  422. * @return name:supplier_goods_list type:array default:-- desc:供应商商品
  423. * @return name:supplier_goods_list.id type:int default:-- desc:供应商商品d
  424. * @return name:supplier_goods_list.name type:string default:-- desc:商品名称
  425. * @return name:supplier_goods_list.cover_arr type:array default:-- desc:封面
  426. * @return name:supplier_goods_list.label_name type:array default:-- desc:标签
  427. * @return name:supplier_goods_list.label type:string default:-- desc:标签
  428. * @return name:supplier_goods_list.read_num type:int default:-- desc:浏览量
  429. * @return name:supplier_goods_list.supplier_name type:float default:-- desc:供应商名称
  430. *
  431. * @return name:demand_list type:array default:-- desc:需求
  432. * @return name:demand_list.title type:string default:-- desc:标题
  433. * @return name:demand_list.content type:string default:-- desc:内容
  434. * @return name:demand_list.cover type:array default:-- desc:封面
  435. * @return name:demand_list.money type:float default:-- desc:价格
  436. * @return name:demand_list.app_name type:string default:-- desc:发布方名称
  437. * @return name:demand_list.app_logo type:string default:-- desc:发布方头像
  438. * @return name:demand_list.is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
  439. * @return name:demand_list.company type:string default:-- desc:公司名
  440. * @return name:demand_list.company_logo type:string default:-- desc:公司logo
  441. *
  442. *
  443. * @return name:forum_list type:array default:-- desc:问答
  444. * @return name:forum_list.id type:int default:-- desc:id
  445. * @return name:forum_list.title type:string default:-- desc:标题
  446. * @return name:forum_list.content type:string default:0 desc:内容
  447. * @return name:forum_list.level type:int default:-- desc:vip等级id
  448. * @return name:forum_list.label type:string default:-- desc:标签
  449. * @return name:forum_list.name type:string default:-- desc:发布用户
  450. * @return name:forum_list.headimg type:string default:-- desc:发布用户头像
  451. * @return name:forum_list.browse_num type:int default:-- desc:浏览量
  452. * @return name:forum_list.reply_num type:int default:-- desc:回答量
  453. *
  454. * @return name:activity_list type:array default:-- desc:活动
  455. * @return name:activity_list.id type:int default:-- desc:id
  456. * @return name:activity_list.address type:string default:-- desc:地址
  457. * @return name:activity_list.cover type:string default:-- desc:封面
  458. * @return name:activity_list.label_name type:array default:-- desc:标签
  459. * @return name:activity_list.start_time type:string default:-- desc:开始时间
  460. * @return name:activity_list.end_time type:string default:-- desc:结束时候
  461. * @return name:activity_list.end_time type:string default:-- desc:结束时间
  462. * @return name:activity_list.price type:string default:-- desc:价格
  463. */
  464. public function globalSearch()
  465. {
  466. $type = input('get.type');
  467. $search_name = input('get.search_name');
  468. $search_time = input('get.search_time');
  469. $sort_type = input('get.sort_type');
  470. $app_name = sysconf('app_name');
  471. $app_logo = sysconf('app_logo');
  472. $user_id = $this->user_id;
  473. switch ($sort_type) {
  474. case 1:
  475. $order = ['a.sort'=>'desc','a.id'=>'asc'];
  476. break;
  477. case 2:
  478. $order = ['a.id'=>'asc','a.sort'=>'desc'];
  479. break;
  480. case 3:
  481. $order = ['a.id'=>'desc','a.sort'=>'desc'];
  482. break;
  483. }
  484. if($this->user_id && $search_name) UserSearch::saveSearchTitle($this->user_id,$search_name,0);
  485. // 视频
  486. $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')
  487. ->when($search_name,function ($query)use ($search_name,$search_time){
  488. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  489. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  490. })->leftJoin('video_intro b','b.id = a.video_id')
  491. ->where('a.status',1)->where('release_time','< time',date('Y-m-d H:i:s'))->where('a.is_deleted',0)
  492. ->where('b.status',1)->where('b.is_deleted',0)->limit($this->off_set,$this->page_num)->order($order)
  493. ->select()->toArray();
  494. array_walk($video_list,function (&$v,$k)use ($app_name,$app_logo){
  495. $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')) : null;
  496. $video_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
  497. $v['app_name'] = $video_auth['app_name'];
  498. $v['app_logo'] = $video_auth['app_logo'];
  499. });
  500. $video_num = VideoUrl::when($search_name,function ($query)use ($search_name,$search_time){
  501. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  502. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  503. })->alias('a')->leftJoin('video_intro b','b.id = a.video_id')->where('release_time','< time',date('Y-m-d H:i:s'))
  504. ->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)->where('b.is_deleted',0)->count();
  505. // 图文
  506. $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')
  507. ->when($search_name,function ($query)use ($search_name,$search_time){
  508. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  509. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  510. })->leftJoin('article_intro b','a.article_id = b.id')
  511. ->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)
  512. ->limit($this->off_set,$this->page_num)->select()->toArray();
  513. array_walk($article_list,function (&$v,$k)use ($app_name,$app_logo){
  514. $article_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
  515. $v['app_name'] = $article_auth['app_name'];
  516. $v['app_logo'] = $article_auth['app_logo'];
  517. });
  518. $article_num = ArticleItem::when($search_name,function ($query)use ($search_name,$search_time){
  519. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  520. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  521. })->leftJoin('article_intro b','a.article_id = b.id')->alias('a') ->where('release_time','< time',date('Y-m-d H:i:s'))
  522. ->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)->where('b.is_deleted',0)->count();
  523. // 资料
  524. $datum_list = DatumUrl::field('a.id,a.url,a.datum_id,a.title,a.is_vip,a.create_at')->alias('a')
  525. ->when($search_name,function ($query)use ($search_name,$search_time){
  526. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  527. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  528. })->leftJoin('datum_intro b','b.id = a.datum_id') ->where('release_time','< time',date('Y-m-d H:i:s'))
  529. ->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)->where('b.is_deleted',0) ->order($order)
  530. ->limit($this->off_set,$this->page_num)->select()->toArray();
  531. $datum_num = DatumUrl::alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
  532. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  533. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  534. })->leftJoin('datum_intro b','b.id = a.datum_id')->where('a.status',1)->where('a.is_deleted',0)->where('b.status',1)
  535. ->where('release_time','< time',date('Y-m-d H:i:s'))->where('b.is_deleted',0)->count();
  536. //新闻
  537. $press_list = \app\common\model\Press::field('id,title,cover,images,read_num')->alias('a')
  538. ->when($search_name,function ($query)use ($search_name,$search_time){
  539. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  540. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  541. })->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->order($order)
  542. ->limit($this->off_set,$this->page_num)->select()->toArray();
  543. array_walk($press_list,function (&$v,$k){
  544. $v['comment_num'] = PressComment::where(['first_id'=>$v['id'],'type'=>1,'is_deleted'=>0])->count();
  545. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,4,$v['id']);
  546. $v['collect_num'] = UserCollect::getCollectNum(4,$v['id']);
  547. $v['is_praise'] = PlatformLike::checkTags($this->user_id,$v['id'],1);
  548. $v['praise_num'] = PlatformLike::getPraiseNum($v['id'],1);
  549. $v['images_arr'] = $v['images'] ? explode('|',$v['images']) : null;
  550. });
  551. $press_num = \app\common\model\Press::when($search_name,function ($query)use ($search_name,$search_time){
  552. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  553. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  554. })->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
  555. //招聘
  556. $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')
  557. ->alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
  558. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  559. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  560. })->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->order($order)
  561. ->limit($this->off_set,$this->page_num)->select()->toArray();
  562. array_walk($recruit_list,function (&$v,$k)use ($app_logo,$app_name){
  563. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  564. $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
  565. if(!$v['user_id']){
  566. $v['app_name'] = $app_name;
  567. $v['app_logo'] = $app_logo;
  568. }else{
  569. $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
  570. $v['app_name'] = $user_info ? $user_info->name : '';
  571. $v['app_logo'] = $user_info ? $user_info->headimg : '';
  572. }
  573. });
  574. $recruit_num = \app\common\model\Recruit::when($search_name,function ($query)use ($search_name,$search_time){
  575. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  576. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  577. })->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
  578. // 商品
  579. $goods_list = StoreGoods::field('id,name,cover,low_price')->alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
  580. if($search_name) $query->where('name','like','%'.$search_name.'%');
  581. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  582. })->where('is_deleted',0)->where('status',1)->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  583. $goods_num =StoreGoods::when($search_name,function ($query)use ($search_name,$search_time){
  584. if($search_name) $query->where('name','like','%'.$search_name.'%');
  585. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  586. })->where('is_deleted',0)->where('status',1) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
  587. // 供应商
  588. $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')
  589. ->alias('a')->when($search_name,function ($query)use($search_name,$search_time){
  590. if($search_name) $query->where('a.name','like','%'.$search_name.'%');
  591. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  592. })->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)
  593. ->where('release_time','< time',date('Y-m-d H:i:s'))->limit($this->off_set,$this->page_num) ->order($order)->select()->toArray();
  594. array_walk($supplier_goods_list,function (&$v,$k){
  595. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  596. $v['cover_arr'] = explode('|',trim($v['cover'],'|'));
  597. });
  598. $supplier_goods_num = SupplierGoods::when($search_name,function ($query)use($search_name,$search_time){
  599. if($search_name) $query->where('g.name','like','%'.$search_name.'%');
  600. if($search_time) $query->where('g.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  601. })->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'))
  602. ->where('g.is_deleted','=',0)->where('s.status','=',1)->where('s.is_deleted','=',0)->count();
  603. // 需求
  604. $demand_list = PlatformDemand::field('id,cover,money,user_id,label,title,cover,is_over,content,company,company_logo,a.create_at')->alias('a')
  605. ->when($search_name,function ($query)use ($search_name,$search_time){
  606. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  607. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  608. })->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))
  609. ->limit($this->off_set,$this->page_num)->order($order)->select()->toArray();
  610. array_walk($demand_list,function (&$v,$k)use ($app_logo,$app_name){
  611. if(!$v['user_id']){
  612. $v['app_name'] = $app_name;
  613. $v['app_logo'] = $app_logo;
  614. }else{
  615. $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
  616. $v['app_name'] = $user_info ? $user_info->name : '';
  617. $v['app_logo'] = $user_info ? $user_info->headimg : '';
  618. }
  619. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  620. $v['cover_arr'] = explode('|',trim($v['cover'],'|'));
  621. });
  622. $demand_num = PlatformDemand::when($search_name,function ($query)use ($search_name,$search_time){
  623. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  624. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  625. })->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
  626. // 问答
  627. $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')
  628. ->when($search_name,function ($query)use ($search_name,$search_time){
  629. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  630. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  631. })->leftJoin('store_member u','u.id = a.user_id') ->where('release_time','< time',date('Y-m-d H:i:s'))
  632. ->where('a.status',1)->where('a.is_deleted',0)->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  633. $forum_num = UserForum::field('a.id')->alias('a')->when($search_name,function ($query)use ($search_name,$search_time){
  634. if($search_name) $query->where('a.title|a.label','like','%'.$search_name.'%');
  635. if($search_time) $query->where('a.create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  636. })->leftJoin('store_member u','u.id = a.user_id')
  637. ->where('a.status',1) ->where('release_time','< time',date('Y-m-d H:i:s'))
  638. ->where('a.is_deleted',0)->count();
  639. // 活动
  640. $activity_list = \app\common\model\Activity::field('id,cover,title,address,label,start_time,end_time,price,a.create_at')->alias('a')
  641. ->when($search_name,function ($query)use ($search_name,$search_time){
  642. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  643. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  644. })->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();
  645. array_walk($activity_list,function (&$v,$k){
  646. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  647. // $v['ladder'] = $v['ladder'] ? json_decode($v['ladder'],true):null;
  648. });
  649. $activity_num = \app\common\model\Activity::when($search_name,function ($query)use ($search_name,$search_time){
  650. if($search_name) $query->where('title|label','like','%'.$search_name.'%');
  651. if($search_time) $query->where('create_at','> time',date('Y-m-d H:i:s',strtotime('-'.$search_time.' days')));
  652. })->where('status',1)->where('is_deleted',0) ->where('release_time','< time',date('Y-m-d H:i:s'))->count();
  653. if(!$type) {
  654. $total_count = $video_num+$article_num+$datum_num+$demand_num+$press_num+$goods_num+$supplier_goods_num + $activity_num + $forum_num+$recruit_num;
  655. }else{
  656. $total_count = compact($type.'_num')[$type.'_num'];
  657. }
  658. $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']));
  659. }
  660. /**
  661. * @title 发送短信验证码
  662. * @desc 发送短信验证码
  663. * @author qc
  664. * @url /api/Expedite/sendSms
  665. * @method POST
  666. * @tag 短信验证码
  667. * @param name:phone type:int require:1 default:-- desc:要获取验证码的手机号
  668. * @param name:phone_pre type:int require:1 default:86 desc:手机号前缀
  669. * @return name:code type:string default:-- desc:验证码
  670. */
  671. public function sendSms(){
  672. $phone_pre = input('post.phone_pre',86);
  673. $phone = input('post.phone');
  674. $user_info = User::where('phone',$phone)
  675. ->where('phone_pre',$phone_pre)
  676. ->where('is_deleted',0)
  677. ->field('id,status,is_deleted')->find();
  678. if($user_info && (!$user_info->status || $user_info->is_deleted))$this ->error('用户被禁用,请联系官方');
  679. if(empty($phone)) $this ->error('参数错误');
  680. $code = rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
  681. AlibabaCloud::accessKeyClient('LTAI5tJ5p12drZegeWVG33xZ', '82UWAiY5e5wH8tSkRvMtqVoGO0h8SB')->regionId('cn-hangzhou')->asDefaultClient();
  682. try {
  683. $result = AlibabaCloud::rpc()
  684. ->product('Dysmsapi')
  685. ->version('2017-05-25')
  686. ->action('SendSms')
  687. ->method('POST')
  688. ->host('dysmsapi.aliyuncs.com')
  689. ->options([
  690. 'query' => [
  691. 'RegionId' => "cn-hangzhou",
  692. 'PhoneNumbers' => $phone_pre == '86' ? $phone :$phone_pre.$phone,
  693. 'SignName' => "搞一下汽车电子",
  694. 'TemplateCode' => $phone_pre == '86' ? "SMS_234397351" :'SMS_269485496',
  695. 'TemplateParam' => json_encode(array("code"=>$code)),
  696. ],
  697. ])->request();
  698. $result = $result->toArray();
  699. if($result['Code'] != "OK") $this->exception('发送失败');
  700. $sms_data = [
  701. 'phone'=>$phone,
  702. 'code'=>$code,
  703. 'phone_pre'=>$phone_pre,
  704. 'result'=>$result['Message']
  705. ];
  706. Db::name('store_member_sms')->insert($sms_data);
  707. } catch (ClientException $e) {
  708. $this->error($e->getErrorMessage().PHP_EOL);
  709. } catch (ServerException $e) {
  710. $this->error($e->getErrorMessage().PHP_EOL);
  711. }catch (\Exception $e){
  712. $this->error($e->getMessage());
  713. }
  714. $this->success('发送成功');
  715. }
  716. /**
  717. * @title 发送邮箱验证码
  718. * @desc 发送邮箱验证码
  719. * @author qc
  720. * @url /api/Expedite/emailSms
  721. * @method POST
  722. * @tag 邮箱验证码
  723. * @param name:email type:int require:1 default:-- desc:邮箱
  724. * @return name:code type:string default:-- desc:验证码
  725. */
  726. function emailSms(){
  727. $email = input('post.email');
  728. $user_info = User::where('email',$email)->where('is_deleted',0)->field('id,status')->find();
  729. if($user_info && $user_info['status'] == 0)$this ->error('用户被禁用,请联系官方');
  730. $code = rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
  731. require_once env('root_path').'/vendor/aliyunmail/aliyun-php-sdk-core/Config.php';
  732. $iClientProfile = \DefaultProfile::getProfile("cn-hangzhou", "LTAI5tJ5p12drZegeWVG33xZ", "82UWAiY5e5wH8tSkRvMtqVoGO0h8SB");
  733. $client = new \DefaultAcsClient($iClientProfile);
  734. $request = new Dm\SingleSendMailRequest();
  735. $request->setAccountName("gyx@yzm.gyxqcdz.com");
  736. $request->setFromAlias("[验证码]");
  737. $request->setAddressType(1);
  738. $request->setTagName("zonghuzhuche");
  739. $request->setReplyToAddress("true");
  740. $request->setToAddress($email);
  741. $request->setSubject("验证码");
  742. $img= "http://gaoyixia.hdlkeji.com/code/33.png";
  743. $img ="<img src='$img'/>";
  744. $html_body = '您的验证码'.$code.'有效时间5分钟';
  745. $resd = $request->setHtmlBody($html_body);
  746. try {
  747. $response = $client->getAcsResponse($request);
  748. return json($response);
  749. $sms_data = array(
  750. 'phone'=>$email,
  751. 'code'=>$code,
  752. 'result'=>'OK'
  753. );
  754. Db::name('store_member_sms')->insert($sms_data);
  755. $this->success('发送成功');
  756. } catch (ClientException $e) {
  757. return $e->getErrorCode();
  758. $this->error($e->getErrorMessage());
  759. // print_r($e->getErrorCode());
  760. // print_r($e->getErrorMessage());
  761. } catch (ServerException $e) {
  762. return $e->getErrorCode();
  763. $this->error($e->getErrorMessage());
  764. // print_r($e->getErrorCode());
  765. // print_r($e->getErrorMessage());
  766. }
  767. }
  768. /**
  769. * @title 获取签名
  770. * @desc 获取签名
  771. * @url /api/Expedite/getWeChatSign
  772. * @method POST
  773. * @param name:url type:string default:-- desc:页面地址
  774. * @return name:appid type:string default:-- desc:appid
  775. * @return name:noncestr type:string default:-- desc:随机字符
  776. * @return name:timestamp type:string default:-- desc:时间戳
  777. * @return name:sign type:string default:-- desc:签名
  778. * @return name:ticket type:string default:-- desc:ticket
  779. **/
  780. public function getWeChatSign(){
  781. $urls = input('post.url');
  782. $appid = config('app.official_account')['appid'];
  783. $secret = config('app.official_account')['secret'];
  784. $redis = new Redis();
  785. $access_token = $redis->get('access_token');
  786. if (!$access_token){
  787. $access_token = '';
  788. $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
  789. $res= http_curl($url);
  790. if (isset($res['access_token'])){
  791. $redis->set('access_token',$res['access_token'],'7000');
  792. $access_token = $res['access_token'];
  793. }
  794. }
  795. $url2 ="https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$access_token."&type=jsapi";
  796. $res2=http_curl($url2);
  797. //var_dump($res2);
  798. if (!isset($res2) || $res2['errcode']!=0) $this->error('获取ticket失败');
  799. $timestamp = time();
  800. $noncestr = get32Str(15);
  801. $string = "jsapi_ticket=".$res2['ticket']."&noncestr=$noncestr&timestamp=$timestamp&url=".$urls;
  802. $sign = sha1($string);
  803. $return = [
  804. 'appid'=>$appid,
  805. 'noncestr'=>$noncestr,
  806. 'timestamp'=>$timestamp,
  807. 'url'=>$urls,
  808. 'sign'=>$sign,
  809. 'ticket'=>$res2['ticket']
  810. ];
  811. $this->success('成功',$return);
  812. }
  813. /**
  814. * @title 获取分享链接
  815. * @desc 获取分享链接
  816. * @url /api/Expedite/getUrlScheme
  817. * @method POST
  818. * @return name:url type:string default:-- desc:url
  819. **/
  820. public function getUrlScheme()
  821. {
  822. $appid = config('app.mini_program')['app_id'];
  823. $secret = config('app.mini_program')['secret'];
  824. $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
  825. $res= http_curl($url);
  826. $access_token = $res['access_token'];
  827. $api_url = 'https://api.weixin.qq.com/wxa/generatescheme?access_token='.$access_token;
  828. $url_scheme = curl_post($api_url,[]);
  829. $this->success('ok',['url'=>$url_scheme['openlink']]);
  830. }
  831. /**
  832. * @title getUrlLink
  833. * @desc getUrlLink
  834. * @url /api/Expedite/getUrlLink
  835. * @method POST
  836. * @return name:url type:string default:-- desc:url
  837. **/
  838. public function getUrlLink()
  839. {
  840. $appid = config('app.mini_program')['app_id'];
  841. $secret = config('app.mini_program')['secret'];
  842. $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
  843. $res= http_curl($url);
  844. $access_token = $res['access_token'];
  845. $api_url = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token='.$access_token;
  846. $url_link = curl_post($api_url,[]);
  847. $this->success('ok',['url'=>$url_link['url_link']]);
  848. }
  849. /**
  850. * @title 获取平台文案设置
  851. * @desc 获取平台文案设置
  852. * @author qc
  853. * @url /api/Expedite/getSysConfig
  854. * @method GET
  855. * @param name:search_name type:string default:-- desc:根据下面名称查(不传查全部的)
  856. * @return name:agreement type:string default:-- desc:用户协议
  857. * @return name:about_us type:string default:-- desc:关于我们
  858. * @return name:privacy type:string default:-- desc:隐私政策
  859. * @return name:user_equity type:string default:-- desc:会员权益
  860. * @return name:customer_service type:string default:-- desc:客服设置
  861. * @return name:original_pact type:string default:-- desc:原创公约
  862. * @return name:app_name type:string default:-- desc:平台名称
  863. * @return name:app_logo type:string default:-- desc:平台logo
  864. * @return name:app_version type:string default:-- desc:版本号
  865. * @return name:trade_image type:string default:-- desc:营业执照
  866. * @return name:resources_image type:string default:-- desc:人力资源服务许可证
  867. */
  868. public function getSysConfig(){
  869. $search_name = input('get.search_name');
  870. $con_name = $search_name? [$search_name] : ['agreement','about_us','privacy','user_equity','customer_service','original_pact','app_version','trade_image','resources_image'];
  871. $set = Db::name('system_config')->where('name','in',$con_name)->select();
  872. $ret = [];
  873. foreach ($set as $value) {
  874. // if($search_name == 'resources_image'){
  875. // $value['value'] = explode('|',$value['value']);
  876. // }
  877. $ret[$value['name']]=$value['value'];
  878. }
  879. $this->success('获取成功',$ret);
  880. }
  881. /**
  882. * @title 修改版本信息【安卓】
  883. * @desc 修改版本信息
  884. * @author qc
  885. * @method POST
  886. * @url /api/Expedite/changeVersion
  887. * @header name:Authorization require:1 desc:Token
  888. * @param name:app_version type:string default:1 desc:版本号
  889. * @param name:version_name type:string default:-- desc:版本名
  890. * @param name:version_title type:string default:-- desc:更新标题
  891. * @param name:version_content type:string default:-- desc:更新内容
  892. * @param name:version_url type:string default:-- desc:下载地址
  893. * @param name:version_compel type:string default:-- desc:是否强制更新
  894. */
  895. public function changeVersion()
  896. {
  897. if(input('app_version'))Data::save('system_config',['value'=>input('app_version'),'name'=>'app_version'],'name',['name'=>'app_version']);
  898. if(input('version_name')) Data::save('system_config',['value'=>input('version_name'),'name'=>'version_name'],'name',['name'=>'version_name']);
  899. if(input('version_title')) Data::save('system_config',['value'=>input('version_title'),'name'=>'version_title'],'name',['name'=>'version_title']);
  900. if(input('version_content')) Data::save('system_config',['value'=>input('version_content'),'name'=>'version_content'],'name',['name'=>'version_content']);
  901. if(input('version_url')) Data::save('system_config',['value'=>input('version_url'),'name'=>'version_url'],'name',['name'=>'version_url']);
  902. Data::save('system_config',['value'=>input('version_compel'),'name'=>'version_compel'],'name',['name'=>'version_compel']);
  903. $this->success('修改成功');
  904. }
  905. /**
  906. * @title 获取版本信息【安卓】
  907. * @desc 获取版本信息
  908. * @author qc
  909. * @method GET
  910. * @url /api/Expedite/getVersionInfo
  911. * @header name:Authorization require:1 desc:Token
  912. * @return name:app_version type:string default:1 desc:版本号
  913. * @return name:version_name type:string default:-- desc:版本名
  914. * @return name:version_title type:string default:-- desc:更新标题
  915. * @return name:version_content type:string default:-- desc:更新内容
  916. * @return name:version_url type:string default:-- desc:下载地址
  917. * @return name:version_compel type:string default:-- desc:是否强制更新
  918. */
  919. public function getVersionInfo()
  920. {
  921. $version_sel = ['app_version','version_name','version_title','version_content','version_url','version_compel'];
  922. $set = Db::name('system_config')->where('name','in',$version_sel)->column('value','name');
  923. $ret = [];
  924. foreach ($version_sel as $v) {
  925. $ret[$v] = isset($set[$v]) ? $set[$v] :null;
  926. if($v == 'app_version') $ret[$v] = intval($set[$v]);
  927. }
  928. $this->success('获取成功',$ret);
  929. }
  930. /**
  931. * @title 修改版本信息【IOS】
  932. * @desc 修改版本信息
  933. * @author qc
  934. * @method POST
  935. * @url /api/Expedite/changeIosVersion
  936. * @header name:Authorization require:1 desc:Token
  937. * @param name:app_version_ios type:string default:1 desc:版本号
  938. * @param name:version_name_ios type:string default:-- desc:版本名
  939. * @param name:version_compel_ios type:string default:-- desc:是否强制更新
  940. */
  941. public function changeIosVersion()
  942. {
  943. if(input('app_version_ios'))Data::save('system_config',['value'=>input('app_version_ios'),'name'=>'app_version_ios'],'name',['name'=>'app_version_ios']);
  944. if(input('version_name_ios')) Data::save('system_config',['value'=>input('version_name_ios'),'name'=>'version_name_ios'],'name',['name'=>'version_name_ios']);
  945. Data::save('system_config',['value'=>input('version_compel_ios'),'name'=>'version_compel_ios'],'name',['name'=>'version_compel_ios']);
  946. $this->success('修改成功');
  947. }
  948. /**
  949. * @title 获取版本信息【IOS】
  950. * @desc 获取版本信息
  951. * @author qc
  952. * @method GET
  953. * @url /api/Expedite/getIosVersionInfo
  954. * @header name:Authorization require:1 desc:Token
  955. * @return name:app_version_ios type:string default:1 desc:版本号
  956. * @return name:version_name_ios type:string default:-- desc:版本名
  957. * @return name:version_compel_ios type:string default:-- desc:是否强制更新
  958. */
  959. public function getIosVersionInfo()
  960. {
  961. $version_sel = ['app_version_ios','version_name_ios','version_compel_ios'];
  962. $set = Db::name('system_config')->where('name','in',$version_sel)->column('value','name');
  963. $ret = [];
  964. foreach ($version_sel as $v) {
  965. $ret[$v] = isset($set[$v]) ? $set[$v] :null;
  966. // if($v == 'app_version_ios') $ret[$v] = intval($set[$v]);
  967. }
  968. $this->success('获取成功',$ret);
  969. }
  970. /**
  971. * @title 获取APP启动页信息
  972. * @desc 获取APP启动页信息
  973. * @author qc
  974. * @method GET
  975. * @url /api/Expedite/getAppBootConfig
  976. * @header name:Authorization require:1 desc:Token
  977. * @return name:app_image type:string default:1 desc:启动图
  978. * @return name:app_place type:string default:-- desc:跳转模块【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城】
  979. * @return name:first_id type:int default:-- desc:详情id(视频、图文、资料为系列id)
  980. * @return name:second_id type:second_id default:-- desc:系列某详情id(视频、图文、资料)
  981. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  982. */
  983. public function getAppBootConfig()
  984. {
  985. $version_sel = ['app_image','app_place','first_id','second_id'];
  986. $set = Db::name('system_config')->where('name','in',$version_sel)->column('value','name');
  987. $ret = [];
  988. foreach ($version_sel as $v) {
  989. $ret[$v] = isset($set[$v]) ? $set[$v] :null;
  990. $set[$v] = $ret[$v];
  991. }
  992. $ret['is_normal'] = CheckPower::checkModulesPower($set['first_id'],$set['second_id'],$set['app_place']);
  993. $this->success('获取成功',$ret);
  994. }
  995. /**
  996. * @title IOS获取链接
  997. * @desc GET方式获取POST修改
  998. * @author qc
  999. * @method GET||POST
  1000. * @url /api/Expedite/iosUrl
  1001. * @header name:Authorization require:1 desc:Token
  1002. * @param name:ios_url type:string default:-- desc:链接地址
  1003. * @return name:ios_url type:string default:-- desc:链接地址
  1004. */
  1005. public function iosUrl()
  1006. {
  1007. if($this->request->isPost()) Data::save('system_config',['value'=>input('ios_url'),'name'=>'ios_url'],'name',['name'=>'ios_url']);
  1008. $url = Db::name('system_config')->where('name','ios_url')->value('value');
  1009. $this->success('获取成功',['ios_url'=>$url ? $url :'']);
  1010. }
  1011. /**
  1012. * @title 获取客服设置【平台的】
  1013. * @desc 获取客服设置【平台的】
  1014. * @author qc
  1015. * @url /api/Expedite/getServiceSet
  1016. * @method GET
  1017. * @return name:service_qr_code type:string default:-- desc:客服二维码
  1018. * @return name:service_phone type:string default:-- desc:客服电话
  1019. * @return name:service_email type:string default:-- desc:客服邮箱
  1020. */
  1021. public function getServiceSet(){
  1022. $con_name = ['service_qr_code','service_phone','service_email'];
  1023. $set = Db::name('system_config')->where('name','in',$con_name)->select();
  1024. $ret = [];
  1025. foreach ($set as $value) {
  1026. $ret[$value['name']]=$value['value'];
  1027. }
  1028. $this->success('获取成功',$ret);
  1029. }
  1030. /**
  1031. * @title 获取联系客服设置【模块的】[所有模块的联系我们都用这个接口]
  1032. * @desc 获取联系客服设置
  1033. * @author qc
  1034. * @url /api/Expedite/getContact
  1035. * @method GET
  1036. * @param name:tag type:string default:-- desc:标识【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商,recruit=>招聘,mall=>商城】
  1037. * @return name:qrcode type:string default:-- desc:客服二维码
  1038. * @return name:phone type:string default:-- desc:客服电话
  1039. * @return name:email type:string default:-- desc:客服邮箱
  1040. * @return name:place type:string default:-- desc:归属模块
  1041. * @return name:tag type:string default:-- desc:归属标识【可以按照这个值查询或是区分所属模块】
  1042. */
  1043. public function getContact()
  1044. {
  1045. $tag = input('get.tag');
  1046. $sel_tag = $tag ? [$tag] : ['video','article','datum','activity','demand','forum','press','supplier','recruit','mall'];
  1047. $list = Db::name('contact')->where('tag','in',$sel_tag)->column('tag,qrcode,phone,email,tag,place','tag');
  1048. $this->success('ok',$list);
  1049. }
  1050. /**
  1051. * @title 获取模块封面
  1052. * @desc 获取模块封面
  1053. * @author qc
  1054. * @url /api/Expedite/getModulesCover
  1055. * @method GET
  1056. * @param name:tag type:string default:-- desc:标识【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商,recruit=>招聘,mall=>商城,'search'=>热搜】
  1057. * @return name:cover type:string default:-- desc:封面
  1058. * @return name:place type:string default:-- desc:归属模块
  1059. * @return name:tag type:string default:-- desc:归属标识【可以按照这个值查询或是区分所属模块】
  1060. */
  1061. public function getModulesCover()
  1062. {
  1063. $tag = input('get.tag');
  1064. $sel_tag = $tag ? [$tag] : ['video','article','datum','activity','demand','forum','press','supplier','recruit','mall','search'];
  1065. $list = Db::name('cover')->where('tag','in',$sel_tag)->column('tag,cover,tag,place','tag');
  1066. $this->success('ok',$list);
  1067. }
  1068. /**
  1069. * @title 推送测试
  1070. * @desc 推送测试
  1071. * @author qc
  1072. * @url /api/Expedite/messagePush
  1073. * @method GET
  1074. * @param name:user_id type:int default:-- desc:会员id
  1075. * @param name:content type:string default:-- desc:推送内容
  1076. * @param name:module type:string default:-- desc:模块
  1077. * @param name:type type:类型 default:-- desc:推送类型
  1078. * @param name:rel_id type:类型 default:-- desc:关联id
  1079. */
  1080. public function messagePush()
  1081. {
  1082. $user_id= input('user_id');
  1083. $content= input('content');
  1084. $module= input('module');
  1085. $type= input('type');
  1086. $rel_id= input('rel_id');
  1087. $res = UserMessage::Jpush($user_id,$content,$module,$type,$rel_id);
  1088. $this->success('',['result'=>$res]);
  1089. }
  1090. /**
  1091. * @title 获取分享地址
  1092. * @desc 获取分享地址
  1093. * @author qc
  1094. * @url /api/Expedite/getShareUrl
  1095. * @method GET
  1096. * @param name:tag type:string default:-- desc:标识【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城商品】
  1097. * @param name:first_id type:int default:-- desc:【视频系列id,图文系列id,资料系列id,活动id,需求id,问答id,新闻id,供应商商品id,招聘记录id,商城商品id】
  1098. * @param name:second_id type:string default:-- desc:【视频url_id,图文item_id,资料item_id,其他类型的不传】
  1099. * @return name:url type:string default:-- desc:跳转地址
  1100. */
  1101. public function getShareUrl()
  1102. {
  1103. $tag = input('get.tag');
  1104. if(!in_array($tag, ['video','article','datum','activity','demand','forum','press','supplier','recruit','mall'])) $this->error('类型标识错误');
  1105. $first_id = input('get.first_id');
  1106. $second_id = input('get.second_id');
  1107. $url_arr= [
  1108. 'video' =>$this->request->root(true) ."/dist/#/video-details?id=$first_id&videoArrId=$second_id",
  1109. 'article' =>$this->request->root(true) ."/dist/#/image-text-details?id=$first_id&item_id=$second_id",
  1110. 'datum' =>$this->request->root(true) ."/dist/#/information-details?id=$first_id&url_id=$second_id",
  1111. 'activity' =>$this->request->root(true) ."/dist/#/activity-detail?id=$first_id",
  1112. 'demand' =>$this->request->root(true) ."/dist/#/demand-details?id=$first_id",
  1113. 'forum' =>$this->request->root(true) ."/dist/#/forum-question-details?forum_id=$first_id",
  1114. 'press' =>$this->request->root(true) ."/dist/#/news-details?press_id=$first_id",
  1115. 'supplier' =>$this->request->root(true) ."/dist/#/supplier-details?id=$first_id",
  1116. 'recruit' =>$this->request->root(true) ."/dist/#/recruit-details?id=$first_id",
  1117. 'mall' =>$this->request->root(true) ."/dist/#/product-details?id=$first_id",
  1118. ];
  1119. $this->success('ok',['url'=>$url_arr[$tag]]);
  1120. }
  1121. /**
  1122. * @title 获取极光推送类型
  1123. * @desc module'=>[type=>['title'=>'视频投稿','is_push'=>0,'msg'=>['视频投稿成功请等待审核']]]
  1124. * @author qc
  1125. * @url /api/Expedite/getJiGuangPushType
  1126. * @method GET
  1127. * @return name:is_push type:string default:-- desc:模块类型下的消息是否有极光推送(1推送0不推送)
  1128. * @return name:exp type:string default:-- desc:module'=>[type=>['title'=>'视频投稿','is_push'=>0,'msg'=>['视频投稿成功请等待审核']]]
  1129. *
  1130. */
  1131. public function getJiGuangPushType()
  1132. {
  1133. $type_desc = [
  1134. 'video'=>[
  1135. 3=>['title'=>'视频评论回复【回复我的】','is_push'=>1,'msg'=>['有会员评论了您的回复']],
  1136. 4=>['title'=>'视频评论【评论我的】','is_push'=>1,'msg'=>['有会员评论了您的视频']],
  1137. ],// 视频
  1138. 'article'=>[
  1139. 3=>['title'=>'图文评论回复【回复我的】','is_push'=>1,'msg'=>['有会员评论了您的回复']],
  1140. 4=>['title'=>'图文评论【评论我的】','is_push'=>1,'msg'=>['有会员评论了您的图文']],
  1141. ],//图文
  1142. 'forum'=>[
  1143. 3=>['title'=>'回复的评论【评论我的】','is_push'=>1,'msg'=>['有会员评论了您的回复']],
  1144. 4=>['title'=>'评论的回复【回复我的】','is_push'=>1,'msg'=>['有会员回复了您的评论']],
  1145. 5=>['title'=>'问答回复【回答我的】','is_push'=>1,'msg'=>['有会员回复了您的问题']],
  1146. ],// 问答
  1147. 'press'=>[
  1148. 1=>['title'=>'评论回复【回复我的】','is_push'=>1,'msg'=>['有会员回复了您的评论']],
  1149. ],// 新闻
  1150. 'feedback'=>[
  1151. 1=>['title'=>'反馈内容回复','is_push'=>1,'msg'=>['平台回复了您的反馈']],
  1152. ],// 反馈
  1153. ];
  1154. $this->success('ok',$type_desc);
  1155. }
  1156. /**
  1157. * @title 获取模块总角标数量
  1158. * @desc 获取模块总角标数量
  1159. * @author qc
  1160. * @method GET
  1161. * @url /api/Expedite/getTotalMarkNum
  1162. * @header name:Authorization require:1 desc:Token
  1163. * @return name:video_num type:int default:-- desc:视频
  1164. * @return name:article_num type:int default:-- desc:图文
  1165. * @return name:press_num type:int default:-- desc:新闻
  1166. * @return name:demand_num type:int default:-- desc:需求
  1167. * @return name:forum_num type:int default:-- desc:问答
  1168. * @return name:sys_num type:int default:-- desc:系统消息
  1169. * @return name:datum_num type:int default:-- desc:资料
  1170. * @return name:supplier_num type:int default:-- desc:供应商
  1171. * @return name:activity_num type:int default:-- desc:活动
  1172. * @return name:mark_num type:int default:-- desc:商品
  1173. * @return name:recruit_num type:int default:-- desc:招聘
  1174. * @return name:total_num type:int default:-- desc:总计
  1175. */
  1176. public function getTotalMarkNum()
  1177. {
  1178. 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]);
  1179. $video_all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1180. // 回复我的
  1181. $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();
  1182. // 评论我的
  1183. $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]])
  1184. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1185. ->alias('t')->count();
  1186. // 追更
  1187. $video_follow_num = UserMessage::getUnreadNum($this->user_id,'video',5);
  1188. // 点赞我的
  1189. $all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1190. $video_praise_num = 0;//VideoCommentLike::where([['type','=',2],['is_read','=',0],['like_id','in',$all_video]])->count();
  1191. $comment_praise_num = 0 ;// VideoCommentLike::where([['type','=',1],['is_read','=',0],['like_id','in',$video_all_comment]])->count();
  1192. $video_num = $video_reply_num + $video_comment_num + $video_follow_num + $video_praise_num + $comment_praise_num;
  1193. // 回复我的
  1194. $article_all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1195. $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();
  1196. // 评论我的
  1197. $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]])
  1198. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1199. ->alias('t')->count();
  1200. // 追更
  1201. $article_follow_num = UserMessage::getUnreadNum($this->user_id,'article',5);
  1202. // 点赞我的
  1203. $all_article = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1204. $article_praise_num = 0;//ArticleCommentLike::where([['is_read','=',0],['like_id','in',$all_article]])->count();
  1205. $comment_praise_num = 0;//ArticleLike::where([['is_read','=',0],['item_id','in',$article_all_comment]])->count();
  1206. $article_num = $article_reply_num + $article_comment_num + $article_follow_num + $article_praise_num + $comment_praise_num;
  1207. // 评论我的
  1208. $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]])
  1209. ->leftJoin('DatumUrl i','t.url_id = i.id')
  1210. ->alias('t')->count();
  1211. // 回复我的
  1212. $datum_all_comment = DatumComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1213. $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;
  1214. // 点赞我的
  1215. $all_datum = DatumUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1216. $datum_praise_num = DatumCommentLike::where([['is_read','=',0],['like_id','in',$datum_all_comment],['user_id','<>',$this->user_id]])->count();
  1217. $comment_praise_num = DatumLike::where([['is_read','=',0],['url_id','in',$all_datum],['user_id','<>',$this->user_id]])->count();
  1218. $praise_num = $datum_praise_num + $comment_praise_num;
  1219. $follow_num = UserMessage::getUnreadNum($this->user_id,'datum',5);
  1220. $datum_num =$datum_comment_num + $datum_reply_num +$datum_praise_num + $comment_praise_num +$follow_num;
  1221. // 回复我的
  1222. $press_all_comment = PressComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1223. $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();
  1224. // 评论我的
  1225. $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]])
  1226. ->leftJoin('Press i','t.first_id = i.id')
  1227. ->alias('t')->count();
  1228. $press_num = $press_reply_num + $press_comment_num;
  1229. $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]])
  1230. ->leftJoin('PlatformDemand i','t.first_id = i.id')
  1231. ->alias('t')->count();
  1232. $all_comment = DemandComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1233. $reply_num = DemandComment::where([['t.is_deleted','=',0],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count();
  1234. $demand_num = $demand_num + $reply_num;
  1235. //问答模块
  1236. //回答我的
  1237. // $answer_num = ForumReply::where([['r.issue_user','=',$this->user_id],['r.is_deleted','=',0],['r.is_read','=',0]])
  1238. // ->alias('r')->leftJoin('user_forum a','r.forum_id = a.id')->count();
  1239. $answer_num = ForumReply::where([['r.issue_user', '=', $this->user_id], ['r.is_deleted', '=', 0], ['r.is_read', '=', 0]])
  1240. ->alias('r')->leftJoin('user_forum f', 'r.forum_id = f.id')->count();
  1241. // 回复我的
  1242. // $forum_all_comment = ForumReplyComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1243. // $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();
  1244. // 回复我的
  1245. $forum_all_comment = ForumReplyComment::where(['user_id' => $this->user_id, 'is_deleted' => 0])->column('id');
  1246. if(count($forum_all_comment) < 1){
  1247. $forum_reply_num = 0;
  1248. $reply_answer = 0;
  1249. }else{
  1250. $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();
  1251. $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();
  1252. }
  1253. $forum_reply_num = $forum_reply_num +$reply_answer;
  1254. // 评论我的问题
  1255. $forum_comment = ForumReplyComment::alias('c')
  1256. ->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])
  1257. ->where('c.user_id','<>',$this->user_id)
  1258. ->leftJoin('UserForum r', 'c.forum_id = r.id')
  1259. ->count();
  1260. // 评论我的回答
  1261. $reply_comment = ForumReplyComment::alias('c')
  1262. ->where(['r.user_id' => $this->user_id, 'r.is_deleted' => 0, 'c.is_read' => 0,'c.pid'=>0,])
  1263. ->leftJoin('forum_reply r', 'c.reply_id = r.id')
  1264. ->count();
  1265. $forum_follow_num = UserMessage::getUnreadNum($this->user_id,'forum',6);
  1266. $forum_num = $answer_num+$forum_reply_num+$forum_comment+$reply_comment+ $forum_follow_num;
  1267. //问答模块end
  1268. $sys_num = 0;//UserMessage::where(['user_id'=>$this->user_id,'is_deleted'=>0])->where('is_read',0)->count();
  1269. // 供应商
  1270. $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]])
  1271. ->alias('c') ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')->count();
  1272. //回复我的
  1273. $supplier_all_comment = SupplierComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1274. $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;
  1275. //订阅
  1276. $supplier_follow_num = UserMessage::getUnreadNum($this->user_id,'supplier',5);
  1277. $supplier_num = $supplier_comment_num + $supplier_reply_num + $supplier_follow_num;
  1278. // 活动
  1279. $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();
  1280. // 商品
  1281. $trolley_num = ShoppingTrolley::where(['user_id'=>$this->user_id])->sum('num');
  1282. $no_pay_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>0,'cancel_state'=>0,'status'=>0])->count();
  1283. $no_express_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>1,'express_state'=>0,'cancel_state'=>0])
  1284. ->where('status',1)
  1285. ->where('refund_state','in','0')
  1286. ->count();
  1287. $express_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>1,'express_state'=>1,'cancel_state'=>0])
  1288. ->where('refund_state','in','0,1,2')
  1289. ->count();
  1290. // $finish_num = GoodsOrder::where(['user_id'=>$this->user_id,'is_deleted'=>0,'pay_state'=>1,'express_state'=>2,'cancel_state'=>0])
  1291. // ->where('refund_state','in','0,1,2')
  1292. // ->count();
  1293. $finish_num = 0;
  1294. $refund_num = GoodsOrder::where(['o.user_id'=>$this->user_id,'o.is_deleted'=>0,'o.pay_state'=>1,'o.cancel_state'=>0])->alias('o')
  1295. ->leftJoin('StoreOrderRefund r','r.order_id = o.id')
  1296. ->where('o.refund_state','in','1,2,3')
  1297. ->where('r.status','in','0,1,2,4')
  1298. ->count();
  1299. $mark_num = $trolley_num + $no_pay_num + $no_express_num + $express_num + $finish_num + $finish_num + $refund_num;
  1300. //招聘
  1301. $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();
  1302. // $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();
  1303. $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();
  1304. $recruits = \app\common\model\Recruit::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1305. $resume_num = RecruitResume::where('recruit_id','in',$recruits)->where('is_deleted',0)->where('to_deleted',0)->where('is_read',0)->count();
  1306. $recruit_num = $praise_num + $follow_num + $resume_num;
  1307. $total_num = $video_num + $article_num + $datum_num + $press_num + $demand_num + $forum_num + $supplier_num + $activity_num + $mark_num + $recruit_num;
  1308. $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']));
  1309. }
  1310. /**
  1311. * @title 以下接口为二期需求
  1312. * @desc 以下接口为二期需求
  1313. * @author qc
  1314. * @url /api/Expedite/secondPhase
  1315. * @method
  1316. * @return name:1 type:string default:-- desc:以下接口为二期需求
  1317. */
  1318. public function secondPhase(){}
  1319. /**
  1320. * @title 获取平台页面链接
  1321. * @desc 参数自定义!参数自定义!!参数自定义!!!
  1322. * @author qc
  1323. * @url /api/Expedite/getPlatformUrl
  1324. * @method GET
  1325. * @param name:module type:string default:-- desc:模块【video=>视频,article=>图文,datum=>资料,activity=>活动,demand=>需求,forum=>问答,press=>新闻,supplier=>供应商商品,recruit=>招聘,mall=>商城商品】
  1326. * @param name:tag type:string default:-- desc:页面标识【detail=>详情,list=>列表】
  1327. * @param name:from type:string default:-- desc:请求接口来源1:h5,2:ios,3:android
  1328. * @return name:url type:array default:-- desc:链接
  1329. * @return name:desc type:string default:-- desc:页面描述
  1330. * @return name:param type:string default:-- desc:页面参数拼接
  1331. */
  1332. public function getPlatformUrl()
  1333. {
  1334. $request_param = input('get.');
  1335. $module = input('module','activity');
  1336. $tag = input('tag','detail');
  1337. unset($request_param[$module]);
  1338. unset($request_param[$tag]);
  1339. $url = config('platform_url.'.$module)[$tag];
  1340. $this->success('ok',['url'=>$url,'params'=>http_build_query($request_param)]);
  1341. }
  1342. /**
  1343. * @title 获取手机号前缀
  1344. * @desc 获取手机号前缀
  1345. * @author qc
  1346. * @method GET
  1347. * @url /api/Expedite/getPhonePrefix
  1348. * @header name:Authorization require:1 desc:Token
  1349. * @return name:name type:string default:-- desc:名称
  1350. * @return name:code type:string default:-- desc:前缀
  1351. */
  1352. public function getPhonePrefix()
  1353. {
  1354. /*$prefix = [
  1355. ['name' => '中国大陆','code'=>'86'],
  1356. ['name' => '中国香港','code'=>'852'],
  1357. ['name' => '中国澳门','code'=>'853'],
  1358. ['name' => '中国台湾','code'=>'886'],
  1359. ['name' => '韩国','code'=>'82'],
  1360. ['name' => '日本','code'=>'81'],
  1361. ['name' => '美国','code'=>'1'],
  1362. ['name' => '加拿大','code'=>'1'],
  1363. ['name' => '新加坡','code'=>'65'],
  1364. ['name' => '马来西亚','code'=>'62'],
  1365. ['name' => '俄罗斯','code'=>'7'],
  1366. ['name' => '新西兰','code'=>'64'],
  1367. ['name' => '法国','code'=>'33'],
  1368. ['name' => '德国','code'=>'49'],
  1369. ];*/
  1370. $prefix = Db::name('phone_pre')->field('name,code')->where('is_deleted',0)->select();
  1371. $this->success('ok',$prefix);
  1372. }
  1373. /**
  1374. * @title ElasticSearch【登录状态需要header需要传Authorization】
  1375. * @desc ElasticSearch返回参数文档:https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html
  1376. * @author qc
  1377. * @url /api/Expedite/ElasticSearch
  1378. * @method GET
  1379. * @param name:page type:int default:-- desc:页数
  1380. * @param name:page_num type:int default:-- desc:每页数量
  1381. * @param name:search type:string default:-- desc:搜索关键词
  1382. * @param name:sort_type type:int default:1 desc:1默认2发布时间正序3发布时间倒序
  1383. * @param name:is_over type:int default:-1 desc:-1全部0未解决1已解决2开源【需求模块用】
  1384. * @param name:city type:string default:-- desc:城市搜索【招聘模块用】
  1385. * @param name:module type:string default:-- desc:搜索类型(不传查全部)[video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
  1386. * @return name:highlight type:array default:-- desc:高亮【目前设置三个字段:title、label、desc】
  1387. *
  1388. * @return name:module type:string default:-- desc:模块名
  1389. * @return name:release_time type:string default:-- desc:上架时间
  1390. * @return name:series_id type:int default:-- desc:系列id【视频、图文、资料用】
  1391. * @return name:id type:int default:-- desc:某个模块的详情id【不是系列id】
  1392. * @return name:title type:string default:-- desc:标题或名称
  1393. * @return name:label type:string default:-- desc:标签
  1394. * @return name:label_arr type:array default:-- desc:标签【数组】
  1395. * @return name:desc type:string default:-- desc:描述
  1396. * @return name:desc_text type:string default:-- desc:描述文本【搜索用的,页面展示忽略】
  1397. * @return name:content type:string default:-- desc:内容【富文本】
  1398. * @return name:detail type:string default:-- desc:详情【富文本】
  1399. * @return name:create_at type:string default:-- desc:时间
  1400. * @return name:app_name type:string default:-- desc:发布者
  1401. * @return name:app_logo type:string default:-- desc:发布者头像
  1402. * @return name:read_num type:int default:-- desc:阅读量||播放量【若模块用不到忽略】
  1403. * @return name:comment_num type:int default:-- desc:评论量【若模块用不到忽略】
  1404. * @return name:like_num type:int default:-- desc:点赞量【若模块用不到忽略】
  1405. * @return name:transmit_num type:int default:-- desc:转发量【若模块用不到忽略】
  1406. * @return name:collect_num type:int default:-- desc:收藏量【若模块用不到忽略】
  1407. * @return name:down_num type:int default:-- desc:下载量【若模块用不到忽略】
  1408. * @return name:cover type:string default:-- desc:封面【单张】
  1409. * @return name:is_vip type:int default:-- desc:是否是vip
  1410. *
  1411. * @return name:duration type:string default:-- desc:时长【视频模块】
  1412. * @return name:ali_vid type:int default:-- desc:云点播ID【视频模块】
  1413. *
  1414. * @return name:images_arr type:array default:-- desc:图片【图文】
  1415. * @return name:content_type type:int default:1 desc:1富文本2pdf【图文】
  1416. * @return name:content type:string default:-- desc:内容富文本【图文】
  1417. *
  1418. * @return name:url type:string default:-- desc:资料路径【资料】
  1419. * @return name:is_down type:int default:-- desc:是否允许下载【资料】
  1420. *
  1421. * @return name:browse_num type:string default:-- desc:浏览量【问答】
  1422. * @return name:reply_num type:string default:-- desc:回答量【问答】
  1423. * @return name:level type:string default:-- desc:vip等级id【问答】
  1424. *
  1425. * @return name:start_time type:string default:-- desc:开始时间【活动】
  1426. * @return name:end_time type:string default:-- desc:结束时间【活动】
  1427. *
  1428. * @return name:is_over type:int default:-- desc:0未解决1已解决2开源【需求模块用】
  1429. * @return name:money type:string default:-- desc:金额【需求模块用】
  1430. *
  1431. * @return name:company type:string default:-- desc:公司名称【招聘】
  1432. * @return name:company_intro type:string default:-- desc:公司简介【招聘】
  1433. * @return name:is_ss type:string default:-- desc:是否上市,1上市【招聘】
  1434. * @return name:scale type:string default:-- desc:公司规模(人数)【招聘】
  1435. * @return name:principal type:string default:-- desc:联系人【招聘】
  1436. * @return name:province type:string default:-- desc:省【招聘】
  1437. * @return name:city type:string default:-- desc:市【招聘】
  1438. * @return name:salary type:string default:-- desc:薪资【招聘】
  1439. * @return name:hr_headimg type:string default:-- desc:联系人头像【招聘】
  1440. *
  1441. *
  1442. * @return name:item_list type:array default:-- desc:商品规格详情【商城商品】
  1443. * @return name:min_price type:float default:-- desc:最低价格【商城商品】
  1444. * @return name:max_price type:float default:-- desc:最高价格【商城商品】
  1445. * @return name:sale_num type:int default:-- desc:销量【商城商品】
  1446. *
  1447. */
  1448. public function elasticSearch()
  1449. {
  1450. $index = input('index',config('text.es_index'));
  1451. $search = input('search','');
  1452. $module = input('module','');
  1453. $is_over = intval(input('is_over',-1));
  1454. $sort_type = input('sort_type',1);
  1455. $city = input('city');
  1456. //"全部",1=>'视频',2=>'资料',3=>'图文',4=>'新闻',5=>'问答',6=>'商品',7=>'活动',8=>'招聘',9=>'供应商',10=>'供应商商品',11=>'需求'
  1457. // video=>视频,article=>图文,datum=>资料,goods=>商城商品,press=>新闻,supplier_goods=>供应商商品,demand=>需求,recruit=>招聘,forum=>问答,activity=>活动]
  1458. $search_type = [
  1459. 'video'=>"1",
  1460. 'datum'=>"2",
  1461. 'article'=>"3",
  1462. 'press'=>"4",
  1463. 'forum'=>"5",
  1464. 'goods'=>"6",
  1465. 'activity'=>"7",
  1466. 'recruit'=>"8",
  1467. 'supplier'=>"9",
  1468. 'supplier_goods'=>"10",
  1469. 'demand'=>"11",
  1470. ];
  1471. if($search && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$search,isset($search_type[$module]) ?$search_type[$module] :0 );
  1472. switch ($sort_type) {
  1473. case 1:
  1474. $order = $module ? [['_score'=>['order'=>'desc']],['id'=>['order'=>'desc']]] : [['_score'=>['order'=>'desc']], ['create_at'=>['order'=>'desc']]];
  1475. break;
  1476. case 2:
  1477. // $order = $module ? [['id'=>['order'=>'asc']]] : ['create_at'=>['order'=>'asc']];
  1478. $order = $module ? ['create_at'=>['order'=>'asc']] : ['create_at'=>['order'=>'asc']];
  1479. break;
  1480. case 3:
  1481. // $order = $module ? [['id'=>['order'=>'desc']]] : ['create_at'=>['order'=>'desc']];
  1482. $order = $module ? ['create_at'=>['order'=>'desc']] : ['create_at'=>['order'=>'desc']];
  1483. break;
  1484. }
  1485. $user_level = UserLevelRank::getUserVip($this->user_id);
  1486. $sel_level = $user_level ? $user_level : 1;
  1487. $where = [
  1488. 'index'=>$index,
  1489. 'from' => $this->off_set,
  1490. 'size' => $this->page_num,
  1491. 'body'=>[
  1492. 'sort' => $order,
  1493. 'query'=>[
  1494. 'bool'=>[
  1495. 'must'=> [
  1496. // ['match' => ['module'=> $module]],// module = module
  1497. ['match' => ['status'=>1]], // status !=0
  1498. ['match' => ['is_deleted'=> 0]],// is_deleted !=1
  1499. ['range' => ['release_time'=> ['lte'=>time()]]],//
  1500. // ['range' => ['level'=> ['lte'=>$sel_level]]],//
  1501. /* ['bool'=>[
  1502. 'should'=> [
  1503. 'multi_match' => [
  1504. 'fields'=> ['title','label','desc','content','detail'],
  1505. 'query'=> $search,
  1506. "fuzziness"=>"AUTO",
  1507. 'type'=> 'best_fields',
  1508. ]],
  1509. ]]*/
  1510. ],
  1511. ],
  1512. ],
  1513. 'highlight'=>[
  1514. "fields"=>[
  1515. 'title'=>[
  1516. 'pre_tags'=>["<span style='color:#FF6700'>"],
  1517. 'post_tags'=>["</span>"]
  1518. ],
  1519. 'label'=>[
  1520. 'pre_tags'=>["<span style='color:#FF6700'>"],
  1521. 'post_tags'=>["</span>"]
  1522. ],
  1523. 'desc'=>[
  1524. 'pre_tags'=>["<span style='color:#FF6700'>"],
  1525. 'post_tags'=>["</span>"]
  1526. ],
  1527. 'content'=>[
  1528. 'pre_tags'=>["<span style='color:#FF6700'>"],
  1529. 'post_tags'=>["</span>"]
  1530. ],
  1531. 'detail'=>[
  1532. 'pre_tags'=>["<span style='color:#FF6700'>"],
  1533. 'post_tags'=>["</span>"]
  1534. ],
  1535. 'desc_text'=>[
  1536. 'pre_tags'=>["<span style='color:#FF6700'>"],
  1537. 'post_tags'=>["</span>"]
  1538. ],
  1539. ]
  1540. ]
  1541. ]
  1542. ];
  1543. // if($module) $where['body']['query']['bool']['must'][] = ['match' =>['module'=> $module]];
  1544. if($module){
  1545. if($module == 'datum'){
  1546. $where['body']['query']['bool']['must'][] = ['bool' => ['should' => [
  1547. ['match' => ['module' => $module]],
  1548. ['match' => ['module' => 'datumIntro']],
  1549. ]]];
  1550. }else{
  1551. $where['body']['query']['bool']['must'][] = ['match' =>['module'=> $module]];
  1552. }
  1553. // $where['body']['query']['bool']['must'][] = ['match' =>['module'=> $module]];
  1554. }else{
  1555. // $where['body']['query']['bool']['must'][] = ['bool' => ['should' => [
  1556. // ['match' => ['module' => 'video']],
  1557. // ['match' => ['module' => 'datum']],
  1558. // ['match' => ['module' => 'article']],
  1559. // ['match' => ['module' => 'press']],
  1560. // ['match' => ['module' => 'forum']],
  1561. // ['match' => ['module' => 'goods']],
  1562. // ['match' => ['module' => 'activity']],
  1563. // ['match' => ['module' => 'recruit']],
  1564. // ['match' => ['module' => 'supplier']],
  1565. // ['match' => ['module' => 'supplier_goods']],
  1566. // ['match' => ['module' => 'demand']],
  1567. // ]]];
  1568. }
  1569. if($module == 'demand' && $is_over != -1 ) $where['body']['query']['bool']['must'][] = ['match' =>['is_over'=> $is_over]];
  1570. if($module == 'recruit' && $city ) $where['body']['query']['bool']['must'][] = ['match' =>['city'=> $city]];
  1571. // if($search) $where['body']['query']['bool']['must'][] = ['bool' =>[
  1572. // 'should'=> [
  1573. // 'multi_match' => [
  1574. // 'fields'=> ['title','label','desc','content','detail'],
  1575. // 'query'=> $search,
  1576. // //"lenient"=> true,
  1577. // //"fuzziness"=>"1",
  1578. // 'operator' => 'and',
  1579. // 'type'=> 'best_fields',
  1580. // //"tie_breaker" => 0.1,
  1581. // //"minimum_should_match" => 1
  1582. // ]
  1583. // ]
  1584. // ]
  1585. // ];
  1586. //原版
  1587. if($search) $where['body']['query']['bool']['must'][] = ['bool' =>[
  1588. 'should'=> [
  1589. 'multi_match' => [
  1590. 'fields'=> ['title','label','desc','content','detail'],
  1591. 'query'=> $search,
  1592. "fuzziness"=>"AUTO",
  1593. 'type'=> 'best_fields',
  1594. ]]]];
  1595. //原版end
  1596. // if($search) $where['body']['query']['bool']['must'][] = [
  1597. // 'bool' =>[
  1598. // 'should'=> [
  1599. // 'match_phrase'=>[
  1600. // 'title' => [
  1601. // 'query' => $search,
  1602. // 'slop' => 1
  1603. // ],
  1604. // ],
  1605. //
  1606. // ]
  1607. // ]
  1608. // ];
  1609. // return json($where);
  1610. $list = Elastic::select($index,$where);
  1611. $w_list = [];
  1612. $speak_list= $list['hits']['hits'];
  1613. // return json($speak_list);
  1614. foreach ($list['hits']['hits'] as $k => &$v)
  1615. {
  1616. $v['_source']['label_arr'] = $v['_source']['label'] ? explode(',',$v['_source']['label']):null;
  1617. $v['_source']['create_at'] = date("Y-m-d",$v['_source']['create_at']);
  1618. $v['_source']['release_time'] = date("Y-m-d",$v['_source']['release_time']);
  1619. $v['_source']['is_over'] = isset($v['_source']['is_over']) ? intval($v['_source']['is_over']) : 0;
  1620. switch ($v['_source']['module']) {
  1621. case "video":
  1622. $info = VideoUrl::field('is_vip,cover,duration,ali_vid,read_num,video_id')->where('id',$v['_source']['id'])->find()->toArray();
  1623. $url = VideoIntro::where('id',$info['video_id'])->find();
  1624. // $v = $url;
  1625. // unset($list['hits']['hits'][$k]);
  1626. if($url == null){
  1627. unset($list['hits']['hits'][$k]);
  1628. }else{
  1629. if($url['status'] == 1 && $url['is_deleted'] == 0){
  1630. $v['_source']['series_id'] = $info['video_id'];
  1631. $v['_source']['cover'] = $info['cover'];
  1632. $v['_source']['is_vip'] = $info['is_vip'];
  1633. $v['_source']['duration'] = $info['duration'];
  1634. $v['_source']['ali_vid'] = $info['ali_vid'];
  1635. $v['_source']['read_num'] = numTransform($info['read_num']);
  1636. $info_auth = VideoUrl::getVideoAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1637. $v['_source']['app_name'] = $info_auth['app_name'];
  1638. $v['_source']['app_logo'] = $info_auth['app_logo'];
  1639. $w_list[] = $v;
  1640. }
  1641. }
  1642. break;
  1643. case "article":
  1644. // var_dump($v['_source']['id']);
  1645. // var_dump($v);
  1646. $info = ArticleItem::field('images,is_vip,cover,read_num,article_id,pdf,content_type')
  1647. ->where('id',$v['_source']['id'])->find();
  1648. $info = $info->toArray();
  1649. $v['_source']['series_id'] = $info['article_id'];
  1650. $v['_source']['cover'] = $info['cover'];
  1651. $v['_source']['is_vip'] = $info['is_vip'];
  1652. $v['_source']['pdf'] = $info['pdf'];
  1653. $v['_source']['content_type'] = $info['content_type'];
  1654. $v['_source']['read_num'] = numTransform($info['read_num']);
  1655. $v['_source']['images_arr'] = $info['images']?explode('|',$info['images']):null;
  1656. $info_auth = ArticleItem::getArticleAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1657. $v['_source']['app_name'] = $info_auth['app_name'];
  1658. $v['_source']['app_logo'] = $info_auth['app_logo'];
  1659. unset($v['_source']['content']);
  1660. $w_list[] = $v;
  1661. break;
  1662. case "datum":
  1663. $info = DatumUrl::field('is_vip,read_num,down_num,url,is_down,datum_id')->where('id',$v['_source']['id'])->find()->toArray();
  1664. $v['_source']['series_id'] = $info['datum_id'];
  1665. $v['_source']['is_vip'] = $info['is_vip'];
  1666. $v['_source']['read_num'] = numTransform($info['read_num']);
  1667. $v['_source']['down_num'] = numTransform($info['down_num']);
  1668. $v['_source']['url'] = $info['url'];
  1669. $v['_source']['is_down'] = $info['is_down'];
  1670. $info_auth = DatumUrl::getDatumAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1671. $v['_source']['app_name'] = $info_auth['app_name'];
  1672. $v['_source']['app_logo'] = $info_auth['app_logo'];
  1673. $w_list[] = $v;
  1674. break;
  1675. case 'forum':
  1676. $info_auth = UserForum::getAuthInfo($v['_source']['user_id'],APPNAME,APPLOGO);
  1677. $v['_source']['app_name'] = $info_auth['app_name'];
  1678. $v['_source']['app_logo'] = $info_auth['app_logo'];
  1679. $reply_num = ForumReply::where('forum_id', $v['_source']['id'])->where('is_deleted', 0)->count();
  1680. $v['_source']['reply_num'] = numTransform( $reply_num);
  1681. $forum_info = UserForum::where('id',$v['_source']['id'])->find()->toArray();
  1682. $v['_source']['browse_num'] = numTransform( $forum_info['browse_num']);
  1683. $w_list[] = $v;
  1684. break;
  1685. case 'activity':
  1686. $auth_info = \app\common\model\Activity::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1687. $v['_source']['app_name'] = $auth_info['app_name'];
  1688. $v['_source']['app_logo'] = $auth_info['app_logo'];
  1689. $info = \app\common\model\Activity::where('id',$v['_source']['id'])->find()->toArray();
  1690. $v['_source']['start_time'] = $info['start_time'];
  1691. $v['_source']['end_time'] = $info['end_time'];
  1692. $v['_source']['cover'] = $info['cover'];
  1693. $v['_source']['read_num'] = numTransform($info['read_num']);
  1694. $w_list[] = $v;
  1695. break;
  1696. case 'supplier_goods':
  1697. $info = SupplierGoods::where('id',$v['_source']['id'])->find()->toArray();
  1698. // return json($info['supplier_id']);
  1699. $auth_info = SupplierGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1700. $auth_info = \app\common\model\Supplier::where('id',$info['supplier_id'])->find();
  1701. if(!$auth_info){
  1702. $app_name = '';
  1703. $app_logo = '';
  1704. }else{
  1705. $app_name = $auth_info['title'];
  1706. $app_logo = $auth_info['logo'];
  1707. }
  1708. $v['_source']['app_name'] = $app_name;
  1709. $v['_source']['app_logo'] = $app_logo;
  1710. $v['_source']['read_num'] = numTransform($info['read_num']);
  1711. $v['_source']['cover'] = $info['cover'];
  1712. unset($v['_source']['content']);
  1713. $w_list[] = $v;
  1714. break;
  1715. case 'press':
  1716. $info = \app\common\model\Press::where('id',$v['_source']['id'])->find()->toArray();
  1717. $auth_info = SupplierGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1718. $v['_source']['app_name'] = $auth_info['app_name'];
  1719. $v['_source']['app_logo'] = $auth_info['app_logo'];
  1720. $v['_source']['read_num'] = numTransform($info['read_num']);
  1721. $images_arr = $info['images'] ? explode('|',$info['images']) : null;
  1722. $v['_source']['cover'] = $images_arr ? $images_arr[0] : null;
  1723. unset($v['_source']['content']);
  1724. $w_list[] = $v;
  1725. break;
  1726. case 'demand':
  1727. $info = PlatformDemand::where('id',$v['_source']['id'])->find()->toArray();
  1728. $auth_info = PlatformDemand::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1729. $v['_source']['app_name'] = $auth_info['app_name'];
  1730. $v['_source']['app_logo'] = $auth_info['app_logo'];
  1731. $v['_source']['read_num'] = numTransform($info['read_num']);
  1732. $images_arr = $info['images'] ? explode('|',$info['images']) : null;
  1733. $v['_source']['cover'] = $info['cover'];
  1734. $v['_source']['money'] = $info['money'];
  1735. unset($v['_source']['content']);
  1736. $w_list[] = $v;
  1737. break;
  1738. case 'recruit':
  1739. $info = \app\common\model\Recruit::where('id',$v['_source']['id'])->find()->toArray();
  1740. $auth_info = \app\common\model\Recruit::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1741. $v['_source']['app_name'] = $auth_info['app_name'];
  1742. $v['_source']['app_logo'] = $auth_info['app_logo'];
  1743. $v['_source']['scale'] = $info['scale'];
  1744. $v['_source']['is_ss'] = $info['is_ss'];
  1745. $v['_source']['company'] = $info['company'];
  1746. $v['_source']['company_intro'] = $info['company_intro'];
  1747. $v['_source']['province'] = $info['province'];
  1748. $v['_source']['salary'] = $info['salary'];
  1749. $v['_source']['city'] = $info['city'];
  1750. $v['_source']['principal'] = $info['principal'];
  1751. $v['_source']['hr_headimg'] = $info['hr_headimg'];
  1752. unset($v['_source']['content']);
  1753. $w_list[] = $v;
  1754. break;
  1755. case 'goods':
  1756. $info = \app\common\model\StoreGoods::where('id',$v['_source']['id'])->find()->toArray();
  1757. $auth_info = \app\common\model\StoreGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1758. $v['_source']['app_name'] = $auth_info['app_name'];
  1759. $v['_source']['app_logo'] = $auth_info['app_logo'];
  1760. $v['_source']['cover'] = $info['cover'];
  1761. $v['_source']['sale_num'] = $info['sale_num'];
  1762. $v['_source']['specs'] = json_decode($info['specs'],true);
  1763. $v['_source']['item_list'] = StoreGoodsItem::getGoodsSpec($info['id']);
  1764. $v['_source']['min_price'] = empty($v['_source']['item_list']) ? 0 : min(array_column($v['_source']['item_list'],'sell_price'));
  1765. $v['_source']['max_price'] = empty($v['_source']['item_list']) ? 0 : max(array_column($v['_source']['item_list'],'sell_price'));
  1766. unset($v['_source']['content']);
  1767. $w_list[] = $v;
  1768. break;
  1769. case 'datumIntro':
  1770. $auth_info = \app\common\model\StoreGoods::getAuth($v['_source']['user_id'],APPNAME,APPLOGO);
  1771. $v['_source']['app_name'] = $auth_info['app_name'];
  1772. $v['_source']['app_logo'] = $auth_info['app_logo'];
  1773. $v['_source']['min_price'] = empty($v['_source']['item_list']) ? 0 : min(array_column($v['_source']['item_list'],'sell_price'));
  1774. $v['_source']['max_price'] = empty($v['_source']['item_list']) ? 0 : max(array_column($v['_source']['item_list'],'sell_price'));
  1775. unset($v['_source']['content']);
  1776. $w_list[] = $v;
  1777. break;
  1778. }
  1779. }
  1780. $list['hits']['hits'] = $w_list;
  1781. $this->success('ok',['list'=>$list,'total_count'=>$list['hits']['total']['value'],'page_num'=>$this->page_num]);
  1782. }
  1783. /**
  1784. * @title 获取DRM无法播放机型
  1785. * @desc 获取DRM无法播放机型
  1786. * @author qc
  1787. * @url /api/Expedite/getBanPhoneModel
  1788. * @method GET
  1789. */
  1790. public function getBanPhoneModel()
  1791. {
  1792. $list = Db::name('ban_phone_model')->where('is_deleted',0)->column('name');
  1793. $this->success('ok',$list);
  1794. }
  1795. /**
  1796. * @title 获取各个模分享图片
  1797. * @desc 获取各个模分享图片
  1798. * @author qc
  1799. * @url /api/Expedite/getModuleBgImages
  1800. * @method GET
  1801. * @return name:activity type:string default:-- desc:活动
  1802. * @return name:video type:string default:-- desc:视频
  1803. * @return name:datum type:string default:-- desc:资料
  1804. * @return name:forum type:string default:-- desc:问答
  1805. * @return name:article type:string default:-- desc:图文
  1806. * @return name:supplier type:string default:-- desc:供应商
  1807. * @return name:press type:string default:-- desc:新闻
  1808. * @return name:demand type:string default:-- desc:需求
  1809. * @return name:recruit type:string default:-- desc:招聘
  1810. * @return name:goods type:string default:-- desc:商品
  1811. */
  1812. public function getModuleBgImages()
  1813. {
  1814. $list = [
  1815. 'activity' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/activity.png',// 活动
  1816. 'video' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/video.png',// 视频
  1817. 'datum' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/datum.png',//资料
  1818. 'forum' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/forum.png',// 问答
  1819. 'article' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/article.png',// 图文
  1820. 'supplier' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/supplier.png',// 供应商
  1821. 'press' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/press.png',//新闻
  1822. 'demand' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/demand.png',// 需求
  1823. 'recruit' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/recruit.png',// 招聘
  1824. 'goods' => 'https://gaoyixia.oss-cn-hangzhou.aliyuncs.com/images/goods.png',// 商品
  1825. ];
  1826. $this->success('ok',$list);
  1827. }
  1828. }