Expedite.php 99 KB

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