MyController.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  1. <?php
  2. namespace App\Http\Controllers\Api\V1;
  3. use App\Models\AccountLog;
  4. use App\Models\BaseDictionaryOptionModel;
  5. use App\Models\BaseSettingsModel;
  6. use App\Models\CommentInfoModel;
  7. use App\Models\DreamInfoModel;
  8. use App\Models\InteractionInfo;
  9. use App\Models\SearchInfoModel;
  10. use App\Models\Suggest;
  11. use App\Models\SystemInfoModel;
  12. use App\Models\UserBank;
  13. use App\Models\UserCareDream;
  14. use App\Models\UserCareUser;
  15. use App\Models\UserCashOut;
  16. use App\Models\UserInfoModel;
  17. use Illuminate\Http\Request;
  18. use App\Services\Base\ErrorCode;
  19. use App\Helper\JpushHelper;
  20. class MyController extends Controller
  21. {
  22. use JpushHelper;
  23. /**
  24. * @api {get} /api/my/show 个人首页
  25. * @apiDescription 个人首页
  26. * @apiGroup My
  27. * @apiPermission Passport
  28. * @apiSuccessExample {json} Success-Response:
  29. * HTTP/1.1 200 O* "status": true,
  30. {
  31. "status": true,
  32. "status_code": 0,
  33. "message": "",
  34. "data": {
  35. "id": 1,
  36. "phone": "13880642880",
  37. "nickname": "name1",
  38. "avatar": "/upload/user/20170629/e77068cc14c82086fb6b16e5bb7c3dd1.jpg",
  39. "birthday": "2000-06-21",
  40. "sign": 0,
  41. "money": 0,
  42. "coin": 308,
  43. "sex": 1,
  44. "signture": "我的个性签名1",
  45. "height": 170,
  46. "work": "网红",
  47. "emotion": 1,
  48. "address": "",
  49. "city": "上海",
  50. "detail_address": "",
  51. "status": 1,
  52. "wechat": "",
  53. "weibo": "",
  54. "remember_token": "",
  55. "created_at": "2017-06-25 10:27:08",
  56. "updated_at": "2017-08-19 13:24:29",
  57. "deleted_at": null,
  58. "care_number": 0, 关注
  59. "fans_number": 0, 粉丝
  60. "dreams_number": 9, 梦想
  61. "collection_number": 0, 收藏
  62. "interaction_number": 0, 发帖
  63. "huitie": 1, 回复
  64. }
  65. }
  66. * @apiErrorExample {json} Error-Response:
  67. * HTTP/1.1 400 Bad Request
  68. *{
  69. * "status": true,
  70. * "status_code": 0,
  71. * "message": "",
  72. * "data": {
  73. * "user": null
  74. * }
  75. *}
  76. */
  77. public function show()
  78. {
  79. $user = $this->getUser();
  80. /*
  81. * 我的关注人数,我的粉丝,收藏
  82. * 点赞?徽章?
  83. * */
  84. $care_num = $user->UserCareUser;
  85. $user->care_number = count($care_num);
  86. $fens = UserCareUser::where('other_user_id',$user->id)->get();
  87. $user->fans_number = count($fens);
  88. $dreams = $user->dreams;
  89. $user->dreams_number = count($dreams);
  90. $collection = $user->collection;
  91. $user->collection_number = count($collection);
  92. $interaction_infos = $user->allInteraction;
  93. $user->interaction_number = count($interaction_infos);
  94. $huitie = CommentInfoModel::where('user_id',$user->id)->orWhere('to_user_id',$user->id)->get()->groupBy('interaction_id');
  95. $user->huitie = count($huitie);
  96. return $this->api($user);
  97. }
  98. /**
  99. * @api {get} /api/my/edit 修改个人信息
  100. * @apiDescription 修改个人信息
  101. * @apiGroup My
  102. * @apiPermission Passport
  103. * @apiVersion 0.1.0
  104. * @apiSuccessExample {json} Success-Response:
  105. * HTTP/1.1 200 OK
  106. *{
  107. * "status": true,
  108. * "status_code": 0,
  109. * "message": "",
  110. "data": {
  111. "emotion": [
  112. {
  113. "value": "1",
  114. "name": "未婚"
  115. },
  116. {
  117. "value": "2",
  118. "name": "已婚"
  119. },
  120. {
  121. "value": "3",
  122. "name": "离异"
  123. }
  124. ],
  125. "sex": [
  126. {
  127. "value": "0",
  128. "name": "男"
  129. },
  130. {
  131. "value": "1",
  132. "name": "女"
  133. }
  134. ]
  135. }
  136. * }
  137. * @apiErrorExample {json} Error-Response:
  138. * HTTP/1.1 400 Bad Request
  139. * {
  140. * "status": false,
  141. * "status_code": 1500,
  142. * "message": "会员不存在",
  143. * "data": null
  144. * }
  145. */
  146. public function edit()
  147. {
  148. $sex = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
  149. where('dictionary_code','sex')->get();
  150. $emotion = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
  151. where('dictionary_code','emotion')->get();
  152. return $this->api(compact('emotion','sex'));
  153. }
  154. /**
  155. * @api {post} /api/my/update 保存个人信息
  156. * @apiDescription 保存个人信息
  157. * @apiParam {string} pic 头像
  158. * @apiParam {int} sex 性别
  159. * @apiParam {string} signture 个性签名
  160. * @apiParam {int} emotion 情感状态
  161. * @apiParam {string} work 职业
  162. * @apiParam {int} height 身高
  163. * @apiGroup My
  164. * @apiPermission Passport
  165. * @apiVersion 0.1.0
  166. * @apiSuccessExample {json} Success-Response:
  167. * HTTP/1.1 200 OK
  168. *{
  169. * "status": true,
  170. * "status_code": 0,
  171. * "message": "",
  172. * "data": ""
  173. *}
  174. * @apiErrorExample {json} Error-Response:
  175. * HTTP/1.1 400 Bad Request
  176. *{
  177. * "status": false,
  178. * "status_code": 600,
  179. * "message": "保存用户数据失败",
  180. * "data": null
  181. * }
  182. */
  183. public function update(Request $request)
  184. {
  185. $user = $this->getUser();
  186. $data = $request->except('_token');
  187. $ok = $user->update($data);
  188. if ($ok == true) {
  189. return $this->api('');
  190. }else{
  191. return $this->error(ErrorCode::SAVE_USER_FAILED);
  192. }
  193. }
  194. /**
  195. * @api {post} /api/my/recharge 充值
  196. * @apiDescription 充值
  197. * @apiGroup My
  198. * @apiParam {int} coin 充值金额
  199. * @apiPermission Passport
  200. * @apiVersion 0.1.0
  201. * @apiSuccessExample {json} Success-Response:
  202. * HTTP/1.1 200 OK
  203. * @apiErrorExample {json} Error-Response:
  204. * HTTP/1.1 400 Bad Request
  205. */
  206. public function recharge(Request $request)
  207. {
  208. $validator = \Validator::make($request->all(),
  209. [
  210. 'coin' => 'required|integer',
  211. ],
  212. [
  213. 'coin.required' => '请填写金额',
  214. 'coin.integer' => '请输入整数',
  215. ]
  216. );
  217. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  218. $user = $this->getUser();
  219. $user->coin += $request->coin;
  220. $user->save();
  221. return $this->api('');
  222. }
  223. /**
  224. * @api {get} /api/my/dream_info 梦想消息
  225. * @apiDescription 梦想消息
  226. * @apiGroup My
  227. * @apiPermission Passport
  228. * @apiVersion 0.1.0
  229. * @apiSuccessExample {json} Success-Response:
  230. * HTTP/1.1 200 OK
  231. *{
  232. * "status": true,
  233. * "status_code": 0,
  234. * "message": "",
  235. * "data": [
  236. * {
  237. * ....
  238. * }
  239. * ]
  240. * @apiErrorExample {json} Error-Response:
  241. * HTTP/1.1 400 Bad Request
  242. */
  243. public function dreamInfo()
  244. {
  245. // 梦想消息分为 1支持 2收藏 3互动 4提现 5梦想暂停 6结束
  246. $user = $this->getUser();
  247. $data1 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',1)->orderBy('id','desc')->get()->toArray();
  248. $new_data1 = [] ;
  249. if (count($data1) > 0) {
  250. if (count($data1) >= 5) {
  251. $data1[0]['message'] = "已经有".count($data1)."个人支持了你的梦想!";
  252. $new_data1[] = $data1[0];
  253. }else{
  254. $new_data1 = $data1;
  255. }
  256. }
  257. $data2 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',2)->orderBy('id','desc')->get()->toArray();
  258. $new_data2 = [] ;
  259. if (count($data2) > 0) {
  260. if (count($data2) >= 5) {
  261. $data2[0]['message'] = "已经有".count($data2)."个人收藏了你的梦想!";
  262. $new_data2[] = $data2[0];
  263. }else{
  264. $new_data2 = $data2;
  265. }
  266. }
  267. $data3 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',3)->orderBy('id','desc')->get()->toArray();
  268. $new_data3 = [] ;
  269. if (count($data3) > 0) {
  270. if (count($data3) >= 5) {
  271. $data3[0]['message'] = "你的互动已经有".count($data3)."个留言啦!快点击看看!";
  272. $new_data3[] = $data3[0];
  273. }else{
  274. $new_data3 = $data3;
  275. }
  276. }
  277. $data456 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)
  278. ->where(function ($query) {
  279. $query->where('attr_id',4)->orWhere('attr_id',5)->orWhere('attr_id',6);
  280. })->orderBy('id','desc')->get()->toArray();
  281. $data = array_merge($new_data1,$new_data2,$new_data3,$data456);
  282. SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->update(['is_read' => 1]);
  283. return $this->api($data);
  284. // foreach ($data as $item){ //访问接口 标记已读
  285. // $item->update(['is_read'=>0]);
  286. // $info = InteractionInfo::find($item->interaction_id);
  287. // $dream_id =empty($info) ? 0 : $info->dream_id;
  288. // $item->dreamid = $dream_id;
  289. // }
  290. }
  291. /**
  292. * @api {get} /api/my/sup_info 支持消息
  293. * @apiDescription 支持消息
  294. * @apiGroup My
  295. * @apiPermission Passport
  296. * @apiVersion 0.1.0
  297. * @apiSuccessExample {json} Success-Response:
  298. * HTTP/1.1 200 OK
  299. *{
  300. * "status": true,
  301. * "status_code": 0,
  302. * "message": "",
  303. * "data": [
  304. * {
  305. * ....
  306. * }
  307. * ]
  308. * @apiErrorExample {json} Error-Response:
  309. * HTTP/1.1 400 Bad Request
  310. */
  311. public function supInfo()
  312. {
  313. // 支持消息有 7私信 8@ 9梦想倒计时 10排名 梦想结束
  314. // XX在互动上已经提起了你999次!你还不去瞧一瞧?你也太大牌啦!
  315. $user = $this->getUser();
  316. $data8 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->where('attr_id',8)->orderBy('id','desc')->get()->toArray();
  317. // 计算interaction_id出现的次数
  318. $count = array_count_values(array_column($data8,"interaction_id"));
  319. if (!empty($count)) {
  320. foreach ($count as $interaction_id => $value) {
  321. if ($value>=5) {
  322. $interaction = InteractionInfo::find($interaction_id);
  323. }
  324. }
  325. }
  326. dd($count);
  327. $new_data8 = [] ;
  328. if (count($data8) > 0) {
  329. if (count($data8) >= 5) {
  330. $data8[0]['message'] = "梦想互动上已经提起了你".count($data8)."次!你还不去瞧一瞧?你也太大牌啦!";
  331. $new_data8[] = $data8[0];
  332. }else{
  333. $new_data8 = $data8;
  334. }
  335. }
  336. $data9 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->where('attr_id','!=',8)->orderBy('id','desc')->get()->toArray();
  337. $data = array_merge($new_data8,$data9);
  338. SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->update(['is_read' => 1]);
  339. return $this->api($data);
  340. }
  341. /**
  342. * @api {get} /api/my/system_info 通知消息
  343. * @apiDescription 通知消息
  344. * @apiGroup My
  345. * @apiPermission Passport
  346. * @apiVersion 0.1.0
  347. * @apiSuccessExample {json} Success-Response:
  348. * HTTP/1.1 200 OK
  349. *{
  350. * "status": true,
  351. * "status_code": 0,
  352. * "message": "",
  353. * "data": [
  354. * {
  355. * ....
  356. * }
  357. * ]
  358. * @apiErrorExample {json} Error-Response:
  359. * HTTP/1.1 400 Bad Request
  360. */
  361. public function systemInfo()
  362. {
  363. $user = $this->getUser();
  364. $data = SystemInfoModel::where('user_id',$user->id)->where('type_id',0)->orderBy('id','desc')->get();
  365. foreach ($data as $item){ //访问接口 标记已读
  366. $item->update(['is_read'=>1]);
  367. }
  368. return $this->api($data);
  369. }
  370. /**
  371. * @api {get} /api/my/info 消息中心
  372. * @apiDescription 消息中心
  373. * @apiGroup My
  374. * @apiPermission Passport
  375. * @apiVersion 0.1.0
  376. * @apiSuccessExample {json} Success-Response:
  377. * HTTP/1.1 200 OK
  378. *{
  379. * "status": true,
  380. * "status_code": 0,
  381. * "message": "",
  382. * "data": {
  383. * "dream_info": {
  384. * "number": 3,
  385. * },
  386. * "sup_info": {
  387. * "number": 0,
  388. * },
  389. * "system_info": {
  390. * "number": 3,
  391. * }
  392. * }
  393. *}
  394. * @apiErrorExample {json} Error-Response:
  395. * HTTP/1.1 400 Bad Request
  396. */
  397. public function info()
  398. {
  399. $user = $this->getUser();
  400. /* $systemInfo1 = SystemInfoModel::where('user_id',$user->id)->whereNull('to_user_id')->orderBy('id','desc')->get();
  401. $systemInfo2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
  402. ->whereNull('to_user_id')->orderBy('id','desc')->get();
  403. $letter1 = SystemInfoModel::where('user_id',$user->id)->whereNotNull('to_user_id')->orderBy('id','desc')->get();
  404. $letter2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
  405. ->whereNotNull('to_user_id')->orderBy('id','desc')->get();
  406. $comments1 = CommentInfoModel::where('to_user_id',$user->id)->orderBy('id','desc')->get();
  407. $comments2 = CommentInfoModel::where('to_user_id',$user->id)->where('is_read','1')->orderBy('id','desc')->get();
  408. $arr = [];
  409. $arr['systemInfo']['number'] = count($systemInfo1) ;
  410. $arr['systemInfo']['is_read'] = count($systemInfo2) ;
  411. $arr['letter']['number'] = count($letter1) ;
  412. $arr['letter']['is_read'] = count($letter2) ;
  413. $arr['reply']['number'] = count($comments1) ;
  414. $arr['reply']['is_read'] = count($comments2) ;*/
  415. // 梦想消息 支持消息 通知消息
  416. $user_id = $user->id;
  417. $dream_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',1)->where('is_read',0)->orderBy('id','desc')->get();
  418. $sup_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',2)->where('is_read',0)->orderBy('id','desc')->get();
  419. $system_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',0)->where('is_read',0)->orderBy('id','desc')->get();
  420. $arr['dream_info']['number'] = count($dream_info) ;
  421. $arr['sup_info']['number'] = count($sup_info) ;
  422. $arr['system_info']['number'] = count($system_info) ;
  423. return $this->api($arr);
  424. }
  425. /**
  426. * @api {get} /api/my/read 设为已读
  427. * @apiDescription 设为已读
  428. * @apiGroup My
  429. * @apiPermission Passport
  430. * @apiVersion 0.1.0
  431. * @apiSuccessExample {json} Success-Response:
  432. * HTTP/1.1 200 OK
  433. *{
  434. * "status": true,
  435. * "status_code": 0,
  436. * "message": "",
  437. * "data": ""
  438. *}
  439. * @apiErrorExample {json} Error-Response:
  440. * HTTP/1.1 400 Bad Request
  441. * {
  442. * "status": false,
  443. * "status_code": 700,
  444. * "message": "操作失败",
  445. * "data": null
  446. *}
  447. */
  448. public function read()
  449. {
  450. $user = $this->getUser();
  451. $id = $user->id;
  452. $system_infos = SystemInfoModel::where(function ($query) use($id){
  453. $query->where('user_id',$id)->where('is_read','0');
  454. })->orWhere(function ($query) use($id){
  455. $query->where('to_user_id',$id)->where('is_read','0');
  456. })->orderBy('id','desc')->get();
  457. $comments = CommentInfoModel::where('user_id',$user->id)->where('is_read','0')->orderBy('id','desc')->get();
  458. foreach ($system_infos as $system_info){
  459. $system_info->update(['is_read'=>1]);
  460. }
  461. foreach ($comments as $comment){
  462. $comment->update(['is_read'=>1]);
  463. }
  464. if (count($system_infos) > 0 || count($comments) > 0) {
  465. return $this->api('');
  466. }else{
  467. return $this->error(ErrorCode::OPERATION_FAILED);
  468. }
  469. }
  470. /**
  471. * @api {get} /api/my/pay/article 支付说明
  472. * @apiDescription 支付说明
  473. * @apiGroup My
  474. * @apiPermission Passport
  475. * @apiVersion 0.1.0
  476. * @apiSuccessExample {json} Success-Response:
  477. * HTTP/1.1 200 OK
  478. *{
  479. * "status": true,
  480. * "status_code": 0,
  481. * "message": "",
  482. *"data": {
  483. * "key": "23453423453", 标题
  484. * "value": "<p><span style=\"color: rgb(255, 0, 0);\">42352345234534是大法官地方<
  485. * img src=\"/ueditor/php/upload/image/20170815/1502779635.jpg\" title=\"1502779635.jpg\" alt=\"a1.jpg\"/>234534</span><
  486. * br/></p>", 内容
  487. *}
  488. * ]
  489. *}
  490. * @apiErrorExample {json} Error-Response:
  491. * HTTP/1.1 400 Bad Request
  492. */
  493. public function payArticle()
  494. {
  495. $data = BaseSettingsModel::where('category','pay_article')->first();
  496. return $this->api($data);
  497. }
  498. /**
  499. * @api {post} /api/my/cash 提现
  500. * @apiDescription 提现
  501. * @apiGroup My
  502. * @apiParam {int} data[bank_id] 银行卡号id
  503. * @apiParam {int} data[cash] 提现金额
  504. * @apiPermission Passport
  505. * @apiVersion 0.1.0
  506. * @apiSuccessExample {json} Success-Response:
  507. * HTTP/1.1 200 OK
  508. *{
  509. * "status": false,
  510. * "status_code": 1413,
  511. * "message": "系统审核中",
  512. * "data": null
  513. *}
  514. * @apiErrorExample {json} Error-Response:
  515. *{
  516. * "status": false,
  517. * "status_code": 700,
  518. * "message": "操作失败",
  519. * "data": null
  520. *}
  521. */
  522. public function cash(Request $request)
  523. {
  524. $data = $request->data;
  525. $user = $this->getUser();
  526. $validator = \Validator::make($request->all(),
  527. [
  528. 'data.bank_id' => 'required|integer',
  529. 'data.cash' => 'required',
  530. ],
  531. [
  532. 'data.bank_id.required' => '请选择提现账号',
  533. 'data.bank_id.integer' => '提现账号不存在',
  534. 'data.cash.required' => '请输入金额',
  535. ]
  536. );
  537. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  538. // $info = [] ;
  539. // $info['from_type'] = '余额';
  540. // $info['from_id'] = $user->id;
  541. // $info['from_name'] = $user->name;
  542. // $info['op'] = '提现';
  543. // $info['from_amount'] = $data['coin'];
  544. // $info['to_type'] = '现金';
  545. // $info['to_id'] = $user->id;
  546. // $info['to_name'] = $data['account']; //账号
  547. // $info['note'] = $data['type'].$data['name'];
  548. // $ok = AccountLog::create($info);
  549. $data['user_id'] = $user->id;
  550. $data['status'] = 1;
  551. $ok = UserCashOut::create($data);
  552. $message = '你提现的¥'.$data["cash"].'已经到账啦,去实现梦想吧!喵~ ';
  553. $info = [
  554. 'user_id' => $user->id,
  555. 'message' => $message,
  556. 'attr_id' => 4,
  557. 'type_id' => 1,
  558. ];
  559. SystemInfoModel::create($info);
  560. // 长连接
  561. $this->jPush($message,'',$user->id);
  562. if ($ok) {
  563. return $this->api(ErrorCode::verify);
  564. }else{
  565. return $this->error(ErrorCode::OPERATION_FAILED);
  566. }
  567. }
  568. // 联系客服
  569. /**
  570. * @api {post} /api/my/suggest 联系客服
  571. * @apiDescription 联系客服
  572. * @apiGroup My
  573. * @apiParam {string} data[content] 内容
  574. * @apiParam {string} data[email] 邮箱
  575. * @apiPermission Passport
  576. * @apiVersion 0.1.0
  577. * @apiSuccessExample {json} Success-Response:
  578. * HTTP/1.1 200 OK
  579. *{
  580. * "status": true,
  581. * "status_code": 0,
  582. * "message": "",
  583. * "data": ""
  584. *}
  585. * @apiErrorExample {json} Error-Response:
  586. *{
  587. * "status": false,
  588. * "status_code": 700,
  589. * "message": "操作失败",
  590. * "data": null
  591. *}
  592. */
  593. public function suggest(Request $request)
  594. {
  595. $data = $request->data;
  596. $user = $this->getUser();
  597. $validator = \Validator::make($request->all(),
  598. [
  599. 'data.content' => 'required',
  600. 'data.email' => 'required|email',
  601. ],
  602. [
  603. 'data.content.required' => '请输入你遇到的问题',
  604. 'data.email.required' => '请输入正确的邮箱地址',
  605. 'data.email.email' => '请输入正确的邮箱地址',
  606. ]
  607. );
  608. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  609. $data['user_id'] = $user->id;
  610. $ok =Suggest::create($data);
  611. if ($ok) {
  612. return $this->api('');
  613. }else{
  614. return $this->error(ErrorCode::OPERATION_FAILED);
  615. }
  616. }
  617. // 回复我的
  618. // public function replyMy()
  619. // {
  620. //
  621. // $user = $this->getUser();
  622. //// 梦想
  623. // $dreams = $user->UserDream;
  624. //
  625. // $data = $user->allInteraction;
  626. // foreach ($data as $item) {
  627. // $item->get_money = $item->dream->get_money;
  628. // $item->money = $item->dream->money;
  629. // }
  630. // dd($data) ;
  631. // if (count($dreams) == 0)
  632. // return $this->error(ErrorCode::DREAM_NOT_EXIST);
  633. // $comments_infos = [];
  634. // foreach ($dreams as $dream){
  635. // $comments_info = $dream->DreamInfo;
  636. // if (count($comments_info) > 0) {
  637. // foreach ($comments_info as $k => $value) {
  638. // $value->dream_name = $dream->dream;
  639. // $value->dream_about = $dream->about;
  640. // $value->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
  641. // $value->progress = $dream->money == 0 ? 0 : floor($dream->get_money/$dream->money);
  642. // $value->reviewer = $value->CommentUser->nickname;
  643. // $value->reviewer_pic = $value->CommentUser->pic;
  644. // }
  645. // $comments_infos[] = $comments_info;
  646. // }
  647. // }
  648. //
  649. // return $this->api(compact('comments_infos'));
  650. // }
  651. /**
  652. * @api {get} /api/my/dream 我的梦想
  653. * @apiDescription 我的梦想
  654. * @apiGroup My
  655. * @apiPermission Passport
  656. * @apiVersion 0.1.0
  657. * @apiSuccessExample {json} Success-Response:
  658. * HTTP/1.1 200 OK
  659. {
  660. "status": true,
  661. "status_code": 0,
  662. "message": "",
  663. "data": {
  664. "current_page": 1,
  665. "data": [
  666. {
  667. "id": 32,
  668. "user_id": 1,
  669. "name": "name",
  670. "about": "13880642880",
  671. "coin": 100,
  672. "end_time": "0000-00-00 00:00:00",
  673. "get_coin": 2017,
  674. "mark": 100,
  675. "status": 127,
  676. "video": "0",
  677. "score": 0,
  678. "sign": "158730",
  679. "code": "http://www.miao.com/qrcodes/WECHATPAY_201708191324294255.png",
  680. "parameter": 0,
  681. "created_at": "2017-08-19 05:22:12",
  682. "updated_at": "2017-08-19 05:24:30",
  683. "img": {
  684. "title": "",
  685. "pic": "http://q8.9026.com/upload/dream/20170629/79c11614cc8a9d37f747e3974d055331.jpg"
  686. }
  687. },
  688. ],
  689. "from": 1,
  690. "last_page": 4,
  691. "next_page_url": "http://www.miao.com/api/my/dream?page=2",
  692. "path": "http://www.miao.com/api/my/dream",
  693. "per_page": 10,
  694. "prev_page_url": null,
  695. "to": 10,
  696. "total": 36
  697. }
  698. }
  699. * @apiErrorExample {json} Error-Response:
  700. * HTTP/1.1 400 Bad Request
  701. */
  702. public function dream()
  703. {
  704. $user = $this->getUser();
  705. $dreams = DreamInfoModel::where('user_id',$user->id)->orderBy('created_at','desc')->with('img')->paginate();
  706. return $this->api($dreams);
  707. }
  708. /**
  709. * @api {get} /api/my/collection 我的收藏
  710. * @apiDescription 我的收藏
  711. * @apiGroup My
  712. * @apiPermission Passport
  713. * @apiParam {string} [keyword] 关键字可选
  714. * @apiVersion 0.1.0
  715. * @apiSuccessExample {json} Success-Response:
  716. * HTTP/1.1 200 OK
  717. *{
  718. * "status": true,
  719. * "status_code": 0,
  720. * "message": "",
  721. * "data": {
  722. * "data": [
  723. * { 梦想详情
  724. * "id": 12,
  725. * "user_id": 2,
  726. * "name": "用户2梦想标题166",
  727. * "about": "用户2梦想介绍666",
  728. * "coin": 2500,
  729. * "time": 21,
  730. * "get_coin": 0,
  731. * "status": 0,
  732. * "video": null,
  733. * "sign": "",
  734. * },
  735. * "img": {
  736. * "title": "",
  737. * "pic": "https://f12f.jpg" 梦想封面图片
  738. * }
  739. * ],
  740. * "users": {
  741. * "2": "https://xxx.jpeg" ID号和头像
  742. * }
  743. * }
  744. *}
  745. * keyword存在
  746. *{
  747. * "status": true,
  748. * "status_code": 0,
  749. * "message": "",
  750. * "data": [
  751. * {
  752. * "id": 2,
  753. * "user_id": 1,
  754. * "dream_id": 12,
  755. * "dream_user_id": 2,
  756. * "interaction_number": 0,
  757. * "created_at": "2017-06-25 13:11:45",
  758. * "updated_at": "2017-06-25 13:11:45",
  759. * "dreams": [ 梦想
  760. * {
  761. * "id": 12,
  762. * "user_id": 2,
  763. * "name": "用户2梦想标题166",
  764. * "about": "用户2梦想介绍666",
  765. * "coin": 2500,
  766. * "end_time": 72000,
  767. * "get_coin": 792,
  768. * "mark": 5484,
  769. * "status": 0,
  770. * "video": "e",
  771. * "score": 158730,
  772. * "sign": "梦想达人",
  773. * "created_at": "2017-06-25 13:10:56",
  774. * "updated_at": "2017-06-28 16:53:39"
  775. * "img": { 图片
  776. * "title": "",
  777. * "pic": "https://timgsa.baidu.com/timg9&di2f.jpg"
  778. * },
  779. * "user": {
  780. *
  781. * }
  782. * }
  783. * ]
  784. * }
  785. * ]
  786. *}
  787. * @apiErrorExample {json} Error-Response:
  788. * HTTP/1.1 400 Bad Request
  789. */
  790. public function collection(Request $request)
  791. {
  792. $user = $this->getUser();
  793. if ($request->keyword) {
  794. $keyword ='%'.$request->keyword.'%';
  795. $data = UserCareDream::where('user_id',$user->id)->
  796. whereHas('dreams',function ($query) use($keyword){
  797. $query->where('end_time','>=',time())->where('name','like',$keyword);
  798. })->with('dreams')->get();
  799. foreach ($data as $item) {
  800. foreach ($item->dreams as $dream) {
  801. $dream->img;
  802. }
  803. }
  804. $this->insertSearchTable($user->id,$request->keyword);
  805. return $this->api($data);
  806. }else{
  807. $dreams = $user->collection;
  808. // $users = [];
  809. foreach ($dreams as $item) {
  810. /* if ($item->pivot->interaction_number > 0) {
  811. $user_info = UserInfoModel::find($item->pivot->dream_user_id);
  812. $avatar = $user_info ? $user_info->avatar : '';
  813. if (!array_key_exists($item->pivot->dream_user_id,$users)) {
  814. $users[$item->pivot->dream_user_id] = $avatar;
  815. }
  816. }*/
  817. $item->img;
  818. $item->user;
  819. }
  820. return $this->api(compact('dreams'));
  821. }
  822. }
  823. /**
  824. * @api {get} /api/my/miao 关于喵喵
  825. * @apiDescription 关于喵喵
  826. * @apiGroup My
  827. * @apiPermission Passport
  828. * @apiVersion 0.1.0
  829. * @apiSuccessExample {json} Success-Response:
  830. * HTTP/1.1 200 OK
  831. *{
  832. * "status": true,
  833. * "status_code": 0,
  834. * "message": "",
  835. * "data": {
  836. * "key": "2511789", 电话
  837. * "value": "关于喵喵介绍" 关于喵喵
  838. * }
  839. *}
  840. * @apiErrorExample {json} Error-Response:
  841. * HTTP/1.1 400 Bad Request
  842. */
  843. public function aboutMiao()
  844. {
  845. $data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
  846. return $this->api($data);
  847. }
  848. /**
  849. * @api {get} /api/my/care 我关注的用户
  850. * @apiDescription 我关注的用户
  851. * @apiGroup My
  852. * @apiPermission Passport
  853. * @apiVersion 0.1.0
  854. * @apiSuccessExample {json} Success-Response:
  855. * HTTP/1.1 200 OK
  856. *{
  857. * "status": true,
  858. * "status_code": 0,
  859. * "message": "",
  860. * "data":[] or
  861. * "data": [
  862. * {
  863. * "id": 2,
  864. * "phone": "13880642881",
  865. * "nickname": "name2",
  866. * "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
  867. * "birthday": "2000-06-21",
  868. * "sign": 0,
  869. * "money": 0,
  870. * "coin": 800,
  871. * "sex": 1,
  872. * "signture": "我的个性签名2",
  873. * "height": 200,
  874. * "work": "兼职",
  875. * "emotion": 2,
  876. * "address": "370105",
  877. * "city": "成都",
  878. * "detail_address": "",
  879. * "status": 1,
  880. * "wechat": "",
  881. * "weibo": "",
  882. * "remember_token": "",
  883. * "created_at": "2017-06-25 10:42:06",
  884. * "updated_at": "2017-06-30 09:15:04",
  885. * "deleted_at": null,
  886. * }
  887. * ]
  888. *}
  889. * @apiErrorExample {json} Error-Response:
  890. * HTTP/1.1 400 Bad Request
  891. */
  892. public function care()
  893. {
  894. $user = $this->getUser();
  895. $users =$user->UserCareUser;
  896. return $this->api($users);
  897. }
  898. /**
  899. * @api {get} /api/my/careme 关注我的用户
  900. * @apiDescription 关注我的用户
  901. * @apiGroup My
  902. * @apiPermission Passport
  903. * @apiVersion 0.1.0
  904. * @apiSuccessExample {json} Success-Response:
  905. * HTTP/1.1 200 OK
  906. *{
  907. * "status": true,
  908. * "status_code": 0,
  909. * "message": "",
  910. * "data":[] or
  911. * "data": [
  912. * {
  913. * "id": 2,
  914. * "phone": "13880642881",
  915. * "nickname": "name2",
  916. * "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
  917. * "birthday": "2000-06-21",
  918. * "sign": 0,
  919. * "money": 0,
  920. * "coin": 800,
  921. * "sex": 1,
  922. * "signture": "我的个性签名2",
  923. * "height": 200,
  924. * "work": "兼职",
  925. * "emotion": 2,
  926. * "address": "370105",
  927. * "city": "成都",
  928. * "detail_address": "",
  929. * "status": 1,
  930. * "wechat": "",
  931. * "weibo": "",
  932. * "remember_token": "",
  933. * "created_at": "2017-06-25 10:42:06",
  934. * "updated_at": "2017-06-30 09:15:04",
  935. * "deleted_at": null,
  936. * }
  937. * ]
  938. *}
  939. * @apiErrorExample {json} Error-Response:
  940. * HTTP/1.1 400 Bad Request
  941. */
  942. public function careMe()
  943. {
  944. $user = $this->getUser();
  945. $users =$user->UserCareMe;
  946. return $this->api($users);
  947. }
  948. public function insertSearchTable($id,$keyword)
  949. {
  950. $info = SearchInfoModel::where('user_id',$id)->
  951. where('search',trim($keyword))->first();
  952. if (count($info) == 0) {
  953. SearchInfoModel::create(['user_id'=>$id,'search'=>trim($keyword),'times'=>1]);
  954. }else{
  955. $info->times += 1;
  956. $info->save();
  957. }
  958. }
  959. //我的银行账户
  960. /**
  961. * @api {get} /api/my/bank/list 我的银行账户
  962. * @apiDescription 我的银行账户
  963. * @apiGroup My
  964. * @apiPermission Passport
  965. * @apiVersion 0.1.0
  966. * @apiSuccessExample {json} Success-Response:
  967. * HTTP/1.1 200 OK
  968. *{
  969. * "status": true,
  970. * "status_code": 0,
  971. * "message": "",
  972. * "data":[] or
  973. * "data": [
  974. * {
  975. * "id": 1,
  976. * "user_id": 1,
  977. * "bank_name": "1",
  978. * "bank_number": "1", /账号
  979. * "bank_phone": "1",
  980. * "bank_user": "" 用户名/
  981. * "type": 微信, 微信(支付宝)二维码
  982. * "url": wwww.ddf, 二维码地址
  983. * "is_img": 1,
  984. * }
  985. *]
  986. * @apiErrorExample {json} Error-Response:
  987. * HTTP/1.1 400 Bad Request
  988. */
  989. public function bankList()
  990. {
  991. $user = $this->getUser();
  992. $data = UserBank::where('user_id',$user->id)->orderBy('id','desc')->get();
  993. return $this->api($data);
  994. }
  995. /**
  996. * @api {get} /api/my/bank/account 账户余额
  997. * @apiDescription 账户余额
  998. * @apiGroup My
  999. * @apiPermission Passport
  1000. * @apiVersion 0.1.0
  1001. * @apiSuccessExample {json} Success-Response:
  1002. * HTTP/1.1 200 OK
  1003. *{
  1004. * "status": true,
  1005. * "status_code": 0,
  1006. * "message": "",
  1007. * "data":[] or
  1008. * "data": {
  1009. * "coin": 508, 余额
  1010. * }
  1011. *]
  1012. * @apiErrorExample {json} Error-Response:
  1013. * HTTP/1.1 400 Bad Request
  1014. */
  1015. public function account()
  1016. {
  1017. $user = $this->getUser();
  1018. return $this->api($user);
  1019. }
  1020. // 添加银行卡
  1021. /**
  1022. * @api {post} /api/my/bank/create 添加银行卡
  1023. * @apiDescription 添加银行卡
  1024. * @apiGroup My
  1025. * @apiParam {string} data[bank_name] 银行名称
  1026. * @apiParam {string} data[bank_number] 银行卡号
  1027. * @apiParam {int} data[bank_phone] 银行卡绑定手机号
  1028. * @apiParam {string} data[bank_user] 银行卡用户姓名
  1029. * @apiPermission Passport
  1030. * @apiVersion 0.1.0
  1031. * @apiSuccessExample {json} Success-Response:
  1032. * HTTP/1.1 200 OK
  1033. *{
  1034. * "status": true,
  1035. * "status_code": 0,
  1036. * "message": "",
  1037. * "data": ""
  1038. *}
  1039. * @apiErrorExample {json} Error-Response:
  1040. *{
  1041. * "status": false,
  1042. * "status_code": 700,
  1043. * "message": "操作失败",
  1044. * "data": null
  1045. *}
  1046. */
  1047. public function bankCreate(Request $request)
  1048. {
  1049. $data = $request->data;
  1050. $user = $this->getUser();
  1051. $validator = \Validator::make($request->all(),
  1052. [
  1053. 'data.bank_name' => 'required',
  1054. 'data.bank_number' => 'required',
  1055. 'data.bank_phone' => 'required',
  1056. 'data.bank_user' => 'required',
  1057. ],
  1058. [
  1059. 'data.bank_name.required' => '请选择账号类型',
  1060. 'data.bank_number.required' => '请输入账号',
  1061. 'data.bank_phone.required' => '请输入账号绑定手机号码',
  1062. 'data.bank_user.required' => '请输入账号绑定用户姓名',
  1063. ]
  1064. );
  1065. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1066. $data['user_id'] = $user->id;
  1067. $ok =UserBank::create($data);
  1068. if ($ok) {
  1069. return $this->api('');
  1070. }else{
  1071. return $this->error(ErrorCode::OPERATION_FAILED);
  1072. }
  1073. } /**
  1074. * @api {post} /api/my/bank/qrcode 添加二维码
  1075. * @apiDescription 添加二维码
  1076. * @apiGroup My
  1077. * @apiParam {string} data[type] 类型
  1078. * @apiParam {string} data[qrcode] 二维码图片
  1079. * @apiPermission Passport
  1080. * @apiVersion 0.1.0
  1081. * @apiSuccessExample {json} Success-Response:
  1082. * HTTP/1.1 200 OK
  1083. *{
  1084. * "status": true,
  1085. * "status_code": 0,
  1086. * "message": "",
  1087. * "data": ""
  1088. *}
  1089. * @apiErrorExample {json} Error-Response:
  1090. *{
  1091. * "status": false,
  1092. * "status_code": 700,
  1093. * "message": "操作失败",
  1094. * "data": null
  1095. *}
  1096. */
  1097. public function bankImgCreate(Request $request)
  1098. {
  1099. $data = $request->data;
  1100. $user = $this->getUser();
  1101. $validator = \Validator::make($request->all(),
  1102. [
  1103. 'data.type' => 'required',
  1104. 'data.qrcode' => 'required',
  1105. ],
  1106. [
  1107. 'data.type.required' => '请选择账号类型',
  1108. 'data.qrcode.required' => '请上传二维码图片',
  1109. ]
  1110. );
  1111. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1112. $data['user_id'] = $user->id;
  1113. /* $data['bank_user'] = '';
  1114. $data['bank_phone'] = '';
  1115. $data['bank_number'] = '';
  1116. $data['bank_name'] = '';*/
  1117. $info = UserBank::whereNotNull('qrcode')->where('user_id',$user->id)
  1118. ->where('type',$data['type'])->first(); //定义为二维码
  1119. if (empty($info)) {
  1120. $ok =UserBank::create($data);
  1121. }else{
  1122. $ok = $info->update($data);
  1123. }
  1124. if ($ok) {
  1125. return $this->api('');
  1126. }else{
  1127. return $this->error(ErrorCode::OPERATION_FAILED);
  1128. }
  1129. }
  1130. /**
  1131. * @api {get} /api/my/bank/delete 删除银行卡
  1132. * @apiDescription 删除银行卡
  1133. * @apiGroup My
  1134. * @apiParam {int} id 银行卡id
  1135. * @apiPermission Passport
  1136. * @apiVersion 0.1.0
  1137. * @apiSuccessExample {json} Success-Response:
  1138. * HTTP/1.1 200 OK
  1139. *{
  1140. * "status": true,
  1141. * "status_code": 0,
  1142. * "message": "",
  1143. * "data": ""
  1144. *}
  1145. * @apiErrorExample {json} Error-Response:
  1146. *{
  1147. * "status": false,
  1148. * "status_code": 700,
  1149. * "message": "操作失败",
  1150. * "data": null
  1151. *}
  1152. */
  1153. public function bankDelete(Request $request)
  1154. {
  1155. $id = $request->id;
  1156. $validator = \Validator::make($request->all(),
  1157. [
  1158. 'id' => 'required',
  1159. ],
  1160. [
  1161. 'id.required' => '银行账号不存在',
  1162. ]
  1163. );
  1164. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1165. $ok =UserBank::destroy($id);
  1166. if ($ok) {
  1167. return $this->api('');
  1168. }else{
  1169. return $this->error(ErrorCode::OPERATION_FAILED);
  1170. }
  1171. }
  1172. // 发私信
  1173. /**
  1174. * @api {post} /api/my/letter/store 发送私信
  1175. * @apiDescription 发送私信
  1176. * @apiGroup My
  1177. * @apiParam {string} content 私信内容
  1178. * @apiParam {int} to_user_id 私信对象
  1179. * @apiPermission Passport
  1180. * @apiVersion 0.1.0
  1181. * @apiSuccessExample {json} Success-Response:
  1182. * HTTP/1.1 200 OK
  1183. *{
  1184. * "status": true,
  1185. * "status_code": 0,
  1186. * "message": "",
  1187. * "data": ""
  1188. *}
  1189. * @apiErrorExample {json} Error-Response:
  1190. *{
  1191. * "status": false,
  1192. * "status_code": 700,
  1193. * "message": "操作失败",
  1194. * "data": null
  1195. *}
  1196. */
  1197. public function letterStore(Request $request)
  1198. {
  1199. $validator = \Validator::make($request->all(),
  1200. [
  1201. 'content' => 'required',
  1202. 'to_user_id' => 'required',
  1203. ],
  1204. [
  1205. 'content.required' => '私信内容不存在',
  1206. 'to_user_id.required' => '私信对象不存在',
  1207. ]
  1208. );
  1209. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1210. $user = $this->getUser();
  1211. $user_id = $user->id;
  1212. $info = $request->input('content');
  1213. $to_user_id = $request->input('to_user_id');
  1214. // 链接到最近的一个梦想
  1215. $dream = DreamInfoModel::where('user_id',$user_id)->orderBy('id','desc')->first();
  1216. $dream_id = empty($dream) ? 0 : $dream->id;
  1217. $arr = [
  1218. 'user_id'=>$to_user_id,
  1219. 'info'=>$info,
  1220. 'message'=>$user->nickname.'给你发了个私信哦~点击看看!',
  1221. 'to_user_id'=>$user_id,
  1222. 'dream_id'=>$dream_id,
  1223. 'type_id'=>2,
  1224. 'is_url'=>1,
  1225. 'attr_id'=>9,
  1226. ];
  1227. $ok =SystemInfoModel::create($arr);
  1228. if ($ok) {
  1229. $this->jPush($user->nickname.'给你发了个私信哦~点击看看!','',$to_user_id);
  1230. return $this->api('');
  1231. }else{
  1232. return $this->error(ErrorCode::OPERATION_FAILED);
  1233. }
  1234. } /**
  1235. * @api {get} /api/my/letter/show 查看私信
  1236. * @apiDescription 查看私信
  1237. * @apiGroup My
  1238. * @apiParam {int} id 私信主键id
  1239. * @apiPermission Passport
  1240. * @apiVersion 0.1.0
  1241. * @apiSuccessExample {json} Success-Response:
  1242. * HTTP/1.1 200 OK
  1243. *{
  1244. * "status": true,
  1245. * "status_code": 0,
  1246. * "message": "",
  1247. * "data": ""
  1248. *}
  1249. * @apiErrorExample {json} Error-Response:
  1250. *{
  1251. * "status": false,
  1252. * "status_code": 700,
  1253. * "message": "操作失败",
  1254. * "data": null
  1255. *}
  1256. */
  1257. public function letterShow(Request $request)
  1258. {
  1259. $validator = \Validator::make($request->all(),
  1260. [
  1261. 'id' => 'required',
  1262. ],
  1263. [
  1264. 'id.required' => '私信id不存在',
  1265. ]
  1266. );
  1267. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1268. $user = $this->getUser();
  1269. $user_id = $user->id;
  1270. $id = $request->input('id');
  1271. $data = SystemInfoModel::find($id);
  1272. return $this->api($data);
  1273. }
  1274. }