MyController.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  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. $new_data8 = [] ;
  320. if (!empty($count)) {
  321. foreach ($count as $interaction_id => $value) {
  322. $interaction = InteractionInfo::find($interaction_id);
  323. $dream_id = empty($interaction) ? '0':$interaction->dream_id;
  324. $message =empty($interaction) ? '': $interaction->title."互动上已经提起了你".($value)."次!你还不去瞧一瞧?你也太大牌啦!";
  325. $new_data8[] = [
  326. 'dream_id'=>$dream_id,
  327. 'interaction_id'=>$interaction_id,
  328. 'message'=>$message,
  329. "attr_id" => 8,
  330. "is_reply" => 0,
  331. "is_max" => 0,
  332. "is_ok" => 0,
  333. "is_end" => 0,
  334. "is_url" => 0,
  335. "type_id" => 2,
  336. ];
  337. }
  338. }
  339. // dd($new_data8);
  340. $data9 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->where('attr_id','!=',8)->orderBy('id','desc')->get()->toArray();
  341. $data = array_merge($new_data8,$data9);
  342. SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->update(['is_read' => 1]);
  343. return $this->api($data);
  344. }
  345. /**
  346. * @api {get} /api/my/system_info 通知消息
  347. * @apiDescription 通知消息
  348. * @apiGroup My
  349. * @apiPermission Passport
  350. * @apiVersion 0.1.0
  351. * @apiSuccessExample {json} Success-Response:
  352. * HTTP/1.1 200 OK
  353. *{
  354. * "status": true,
  355. * "status_code": 0,
  356. * "message": "",
  357. * "data": [
  358. * {
  359. * ....
  360. * }
  361. * ]
  362. * @apiErrorExample {json} Error-Response:
  363. * HTTP/1.1 400 Bad Request
  364. */
  365. public function systemInfo()
  366. {
  367. $user = $this->getUser();
  368. $data = SystemInfoModel::where('user_id',$user->id)->where('type_id',0)->orderBy('id','desc')->get();
  369. foreach ($data as $item){ //访问接口 标记已读
  370. $item->update(['is_read'=>1]);
  371. }
  372. return $this->api($data);
  373. }
  374. /**
  375. * @api {get} /api/my/info 消息中心
  376. * @apiDescription 消息中心
  377. * @apiGroup My
  378. * @apiPermission Passport
  379. * @apiVersion 0.1.0
  380. * @apiSuccessExample {json} Success-Response:
  381. * HTTP/1.1 200 OK
  382. *{
  383. * "status": true,
  384. * "status_code": 0,
  385. * "message": "",
  386. * "data": {
  387. * "dream_info": {
  388. * "number": 3,
  389. * },
  390. * "sup_info": {
  391. * "number": 0,
  392. * },
  393. * "system_info": {
  394. * "number": 3,
  395. * }
  396. * }
  397. *}
  398. * @apiErrorExample {json} Error-Response:
  399. * HTTP/1.1 400 Bad Request
  400. */
  401. public function info()
  402. {
  403. $user = $this->getUser();
  404. /* $systemInfo1 = SystemInfoModel::where('user_id',$user->id)->whereNull('to_user_id')->orderBy('id','desc')->get();
  405. $systemInfo2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
  406. ->whereNull('to_user_id')->orderBy('id','desc')->get();
  407. $letter1 = SystemInfoModel::where('user_id',$user->id)->whereNotNull('to_user_id')->orderBy('id','desc')->get();
  408. $letter2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
  409. ->whereNotNull('to_user_id')->orderBy('id','desc')->get();
  410. $comments1 = CommentInfoModel::where('to_user_id',$user->id)->orderBy('id','desc')->get();
  411. $comments2 = CommentInfoModel::where('to_user_id',$user->id)->where('is_read','1')->orderBy('id','desc')->get();
  412. $arr = [];
  413. $arr['systemInfo']['number'] = count($systemInfo1) ;
  414. $arr['systemInfo']['is_read'] = count($systemInfo2) ;
  415. $arr['letter']['number'] = count($letter1) ;
  416. $arr['letter']['is_read'] = count($letter2) ;
  417. $arr['reply']['number'] = count($comments1) ;
  418. $arr['reply']['is_read'] = count($comments2) ;*/
  419. // 梦想消息 支持消息 通知消息
  420. $user_id = $user->id;
  421. $dream_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',1)->where('is_read',0)->orderBy('id','desc')->get();
  422. $sup_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',2)->where('is_read',0)->orderBy('id','desc')->get();
  423. $system_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',0)->where('is_read',0)->orderBy('id','desc')->get();
  424. $arr['dream_info']['number'] = count($dream_info) ;
  425. $arr['sup_info']['number'] = count($sup_info) ;
  426. $arr['system_info']['number'] = count($system_info) ;
  427. return $this->api($arr);
  428. }
  429. /**
  430. * @api {get} /api/my/read 设为已读
  431. * @apiDescription 设为已读
  432. * @apiGroup My
  433. * @apiPermission Passport
  434. * @apiVersion 0.1.0
  435. * @apiSuccessExample {json} Success-Response:
  436. * HTTP/1.1 200 OK
  437. *{
  438. * "status": true,
  439. * "status_code": 0,
  440. * "message": "",
  441. * "data": ""
  442. *}
  443. * @apiErrorExample {json} Error-Response:
  444. * HTTP/1.1 400 Bad Request
  445. * {
  446. * "status": false,
  447. * "status_code": 700,
  448. * "message": "操作失败",
  449. * "data": null
  450. *}
  451. */
  452. public function read()
  453. {
  454. $user = $this->getUser();
  455. $id = $user->id;
  456. $system_infos = SystemInfoModel::where(function ($query) use($id){
  457. $query->where('user_id',$id)->where('is_read','0');
  458. })->orWhere(function ($query) use($id){
  459. $query->where('to_user_id',$id)->where('is_read','0');
  460. })->orderBy('id','desc')->get();
  461. $comments = CommentInfoModel::where('user_id',$user->id)->where('is_read','0')->orderBy('id','desc')->get();
  462. foreach ($system_infos as $system_info){
  463. $system_info->update(['is_read'=>1]);
  464. }
  465. foreach ($comments as $comment){
  466. $comment->update(['is_read'=>1]);
  467. }
  468. if (count($system_infos) > 0 || count($comments) > 0) {
  469. return $this->api('');
  470. }else{
  471. return $this->error(ErrorCode::OPERATION_FAILED);
  472. }
  473. }
  474. /**
  475. * @api {get} /api/my/pay/article 支付说明
  476. * @apiDescription 支付说明
  477. * @apiGroup My
  478. * @apiPermission Passport
  479. * @apiVersion 0.1.0
  480. * @apiSuccessExample {json} Success-Response:
  481. * HTTP/1.1 200 OK
  482. *{
  483. * "status": true,
  484. * "status_code": 0,
  485. * "message": "",
  486. *"data": {
  487. * "key": "23453423453", 标题
  488. * "value": "<p><span style=\"color: rgb(255, 0, 0);\">42352345234534是大法官地方<
  489. * img src=\"/ueditor/php/upload/image/20170815/1502779635.jpg\" title=\"1502779635.jpg\" alt=\"a1.jpg\"/>234534</span><
  490. * br/></p>", 内容
  491. *}
  492. * ]
  493. *}
  494. * @apiErrorExample {json} Error-Response:
  495. * HTTP/1.1 400 Bad Request
  496. */
  497. public function payArticle()
  498. {
  499. $data = BaseSettingsModel::where('category','pay_article')->first();
  500. return $this->api($data);
  501. }
  502. /**
  503. * @api {post} /api/my/cash 提现
  504. * @apiDescription 提现
  505. * @apiGroup My
  506. * @apiParam {int} data[bank_id] 银行卡号id
  507. * @apiParam {int} data[cash] 提现金额
  508. * @apiPermission Passport
  509. * @apiVersion 0.1.0
  510. * @apiSuccessExample {json} Success-Response:
  511. * HTTP/1.1 200 OK
  512. *{
  513. * "status": false,
  514. * "status_code": 1413,
  515. * "message": "系统审核中",
  516. * "data": null
  517. *}
  518. * @apiErrorExample {json} Error-Response:
  519. *{
  520. * "status": false,
  521. * "status_code": 700,
  522. * "message": "操作失败",
  523. * "data": null
  524. *}
  525. */
  526. public function cash(Request $request)
  527. {
  528. $data = $request->data;
  529. $user = $this->getUser();
  530. $validator = \Validator::make($request->all(),
  531. [
  532. 'data.bank_id' => 'required|integer',
  533. 'data.cash' => 'required',
  534. ],
  535. [
  536. 'data.bank_id.required' => '请选择提现账号',
  537. 'data.bank_id.integer' => '提现账号不存在',
  538. 'data.cash.required' => '请输入金额',
  539. ]
  540. );
  541. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  542. // $info = [] ;
  543. // $info['from_type'] = '余额';
  544. // $info['from_id'] = $user->id;
  545. // $info['from_name'] = $user->name;
  546. // $info['op'] = '提现';
  547. // $info['from_amount'] = $data['coin'];
  548. // $info['to_type'] = '现金';
  549. // $info['to_id'] = $user->id;
  550. // $info['to_name'] = $data['account']; //账号
  551. // $info['note'] = $data['type'].$data['name'];
  552. // $ok = AccountLog::create($info);
  553. $data['user_id'] = $user->id;
  554. $data['status'] = 1;
  555. $ok = UserCashOut::create($data);
  556. $message = '你提现的¥'.$data["cash"].'已经到账啦,去实现梦想吧!喵~ ';
  557. $info = [
  558. 'user_id' => $user->id,
  559. 'message' => $message,
  560. 'attr_id' => 4,
  561. 'type_id' => 1,
  562. ];
  563. SystemInfoModel::create($info);
  564. // 长连接
  565. $this->jPush($message,'',$user->id);
  566. if ($ok) {
  567. return $this->api(ErrorCode::verify);
  568. }else{
  569. return $this->error(ErrorCode::OPERATION_FAILED);
  570. }
  571. }
  572. // 联系客服
  573. /**
  574. * @api {post} /api/my/suggest 联系客服
  575. * @apiDescription 联系客服
  576. * @apiGroup My
  577. * @apiParam {string} data[content] 内容
  578. * @apiParam {string} data[email] 邮箱
  579. * @apiPermission Passport
  580. * @apiVersion 0.1.0
  581. * @apiSuccessExample {json} Success-Response:
  582. * HTTP/1.1 200 OK
  583. *{
  584. * "status": true,
  585. * "status_code": 0,
  586. * "message": "",
  587. * "data": ""
  588. *}
  589. * @apiErrorExample {json} Error-Response:
  590. *{
  591. * "status": false,
  592. * "status_code": 700,
  593. * "message": "操作失败",
  594. * "data": null
  595. *}
  596. */
  597. public function suggest(Request $request)
  598. {
  599. $data = $request->data;
  600. $user = $this->getUser();
  601. $validator = \Validator::make($request->all(),
  602. [
  603. 'data.content' => 'required',
  604. 'data.email' => 'required|email',
  605. ],
  606. [
  607. 'data.content.required' => '请输入你遇到的问题',
  608. 'data.email.required' => '请输入正确的邮箱地址',
  609. 'data.email.email' => '请输入正确的邮箱地址',
  610. ]
  611. );
  612. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  613. $data['user_id'] = $user->id;
  614. $ok =Suggest::create($data);
  615. if ($ok) {
  616. return $this->api('');
  617. }else{
  618. return $this->error(ErrorCode::OPERATION_FAILED);
  619. }
  620. }
  621. // 回复我的
  622. // public function replyMy()
  623. // {
  624. //
  625. // $user = $this->getUser();
  626. //// 梦想
  627. // $dreams = $user->UserDream;
  628. //
  629. // $data = $user->allInteraction;
  630. // foreach ($data as $item) {
  631. // $item->get_money = $item->dream->get_money;
  632. // $item->money = $item->dream->money;
  633. // }
  634. // dd($data) ;
  635. // if (count($dreams) == 0)
  636. // return $this->error(ErrorCode::DREAM_NOT_EXIST);
  637. // $comments_infos = [];
  638. // foreach ($dreams as $dream){
  639. // $comments_info = $dream->DreamInfo;
  640. // if (count($comments_info) > 0) {
  641. // foreach ($comments_info as $k => $value) {
  642. // $value->dream_name = $dream->dream;
  643. // $value->dream_about = $dream->about;
  644. // $value->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
  645. // $value->progress = $dream->money == 0 ? 0 : floor($dream->get_money/$dream->money);
  646. // $value->reviewer = $value->CommentUser->nickname;
  647. // $value->reviewer_pic = $value->CommentUser->pic;
  648. // }
  649. // $comments_infos[] = $comments_info;
  650. // }
  651. // }
  652. //
  653. // return $this->api(compact('comments_infos'));
  654. // }
  655. /**
  656. * @api {get} /api/my/dream 我的梦想
  657. * @apiDescription 我的梦想
  658. * @apiGroup My
  659. * @apiPermission Passport
  660. * @apiVersion 0.1.0
  661. * @apiSuccessExample {json} Success-Response:
  662. * HTTP/1.1 200 OK
  663. {
  664. "status": true,
  665. "status_code": 0,
  666. "message": "",
  667. "data": {
  668. "current_page": 1,
  669. "data": [
  670. {
  671. "id": 32,
  672. "user_id": 1,
  673. "name": "name",
  674. "about": "13880642880",
  675. "coin": 100,
  676. "end_time": "0000-00-00 00:00:00",
  677. "get_coin": 2017,
  678. "mark": 100,
  679. "status": 127,
  680. "video": "0",
  681. "score": 0,
  682. "sign": "158730",
  683. "code": "http://www.miao.com/qrcodes/WECHATPAY_201708191324294255.png",
  684. "parameter": 0,
  685. "created_at": "2017-08-19 05:22:12",
  686. "updated_at": "2017-08-19 05:24:30",
  687. "img": {
  688. "title": "",
  689. "pic": "http://q8.9026.com/upload/dream/20170629/79c11614cc8a9d37f747e3974d055331.jpg"
  690. }
  691. },
  692. ],
  693. "from": 1,
  694. "last_page": 4,
  695. "next_page_url": "http://www.miao.com/api/my/dream?page=2",
  696. "path": "http://www.miao.com/api/my/dream",
  697. "per_page": 10,
  698. "prev_page_url": null,
  699. "to": 10,
  700. "total": 36
  701. }
  702. }
  703. * @apiErrorExample {json} Error-Response:
  704. * HTTP/1.1 400 Bad Request
  705. */
  706. public function dream()
  707. {
  708. $user = $this->getUser();
  709. $dreams = DreamInfoModel::where('user_id',$user->id)->orderBy('created_at','desc')->with('img')->paginate();
  710. return $this->api($dreams);
  711. }
  712. /**
  713. * @api {get} /api/my/collection 我的收藏
  714. * @apiDescription 我的收藏
  715. * @apiGroup My
  716. * @apiPermission Passport
  717. * @apiParam {string} [keyword] 关键字可选
  718. * @apiVersion 0.1.0
  719. * @apiSuccessExample {json} Success-Response:
  720. * HTTP/1.1 200 OK
  721. *{
  722. * "status": true,
  723. * "status_code": 0,
  724. * "message": "",
  725. * "data": {
  726. * "data": [
  727. * { 梦想详情
  728. * "id": 12,
  729. * "user_id": 2,
  730. * "name": "用户2梦想标题166",
  731. * "about": "用户2梦想介绍666",
  732. * "coin": 2500,
  733. * "time": 21,
  734. * "get_coin": 0,
  735. * "status": 0,
  736. * "video": null,
  737. * "sign": "",
  738. * },
  739. * "img": {
  740. * "title": "",
  741. * "pic": "https://f12f.jpg" 梦想封面图片
  742. * }
  743. * ],
  744. * "users": {
  745. * "2": "https://xxx.jpeg" ID号和头像
  746. * }
  747. * }
  748. *}
  749. * keyword存在
  750. *{
  751. * "status": true,
  752. * "status_code": 0,
  753. * "message": "",
  754. * "data": [
  755. * {
  756. * "id": 2,
  757. * "user_id": 1,
  758. * "dream_id": 12,
  759. * "dream_user_id": 2,
  760. * "interaction_number": 0,
  761. * "created_at": "2017-06-25 13:11:45",
  762. * "updated_at": "2017-06-25 13:11:45",
  763. * "dreams": [ 梦想
  764. * {
  765. * "id": 12,
  766. * "user_id": 2,
  767. * "name": "用户2梦想标题166",
  768. * "about": "用户2梦想介绍666",
  769. * "coin": 2500,
  770. * "end_time": 72000,
  771. * "get_coin": 792,
  772. * "mark": 5484,
  773. * "status": 0,
  774. * "video": "e",
  775. * "score": 158730,
  776. * "sign": "梦想达人",
  777. * "created_at": "2017-06-25 13:10:56",
  778. * "updated_at": "2017-06-28 16:53:39"
  779. * "img": { 图片
  780. * "title": "",
  781. * "pic": "https://timgsa.baidu.com/timg9&di2f.jpg"
  782. * },
  783. * "user": {
  784. *
  785. * }
  786. * }
  787. * ]
  788. * }
  789. * ]
  790. *}
  791. * @apiErrorExample {json} Error-Response:
  792. * HTTP/1.1 400 Bad Request
  793. */
  794. public function collection(Request $request)
  795. {
  796. $user = $this->getUser();
  797. if ($request->keyword) {
  798. $keyword ='%'.$request->keyword.'%';
  799. $data = UserCareDream::where('user_id',$user->id)->
  800. whereHas('dreams',function ($query) use($keyword){
  801. $query->where('end_time','>=',time())->where('name','like',$keyword);
  802. })->with('dreams')->get();
  803. foreach ($data as $item) {
  804. foreach ($item->dreams as $dream) {
  805. $dream->img;
  806. }
  807. }
  808. $this->insertSearchTable($user->id,$request->keyword);
  809. return $this->api($data);
  810. }else{
  811. $dreams = $user->collection;
  812. // $users = [];
  813. foreach ($dreams as $item) {
  814. /* if ($item->pivot->interaction_number > 0) {
  815. $user_info = UserInfoModel::find($item->pivot->dream_user_id);
  816. $avatar = $user_info ? $user_info->avatar : '';
  817. if (!array_key_exists($item->pivot->dream_user_id,$users)) {
  818. $users[$item->pivot->dream_user_id] = $avatar;
  819. }
  820. }*/
  821. $item->img;
  822. $item->user;
  823. }
  824. return $this->api(compact('dreams'));
  825. }
  826. }
  827. /**
  828. * @api {get} /api/my/miao 关于喵喵
  829. * @apiDescription 关于喵喵
  830. * @apiGroup My
  831. * @apiPermission Passport
  832. * @apiVersion 0.1.0
  833. * @apiSuccessExample {json} Success-Response:
  834. * HTTP/1.1 200 OK
  835. *{
  836. * "status": true,
  837. * "status_code": 0,
  838. * "message": "",
  839. * "data": {
  840. * "key": "2511789", 电话
  841. * "value": "关于喵喵介绍" 关于喵喵
  842. * }
  843. *}
  844. * @apiErrorExample {json} Error-Response:
  845. * HTTP/1.1 400 Bad Request
  846. */
  847. public function aboutMiao()
  848. {
  849. $data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
  850. return $this->api($data);
  851. }
  852. /**
  853. * @api {get} /api/my/care 我关注的用户
  854. * @apiDescription 我关注的用户
  855. * @apiGroup My
  856. * @apiPermission Passport
  857. * @apiVersion 0.1.0
  858. * @apiSuccessExample {json} Success-Response:
  859. * HTTP/1.1 200 OK
  860. *{
  861. * "status": true,
  862. * "status_code": 0,
  863. * "message": "",
  864. * "data":[] or
  865. * "data": [
  866. * {
  867. * "id": 2,
  868. * "phone": "13880642881",
  869. * "nickname": "name2",
  870. * "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
  871. * "birthday": "2000-06-21",
  872. * "sign": 0,
  873. * "money": 0,
  874. * "coin": 800,
  875. * "sex": 1,
  876. * "signture": "我的个性签名2",
  877. * "height": 200,
  878. * "work": "兼职",
  879. * "emotion": 2,
  880. * "address": "370105",
  881. * "city": "成都",
  882. * "detail_address": "",
  883. * "status": 1,
  884. * "wechat": "",
  885. * "weibo": "",
  886. * "remember_token": "",
  887. * "created_at": "2017-06-25 10:42:06",
  888. * "updated_at": "2017-06-30 09:15:04",
  889. * "deleted_at": null,
  890. * }
  891. * ]
  892. *}
  893. * @apiErrorExample {json} Error-Response:
  894. * HTTP/1.1 400 Bad Request
  895. */
  896. public function care()
  897. {
  898. $user = $this->getUser();
  899. $users =$user->UserCareUser;
  900. return $this->api($users);
  901. }
  902. /**
  903. * @api {get} /api/my/careme 关注我的用户
  904. * @apiDescription 关注我的用户
  905. * @apiGroup My
  906. * @apiPermission Passport
  907. * @apiVersion 0.1.0
  908. * @apiSuccessExample {json} Success-Response:
  909. * HTTP/1.1 200 OK
  910. *{
  911. * "status": true,
  912. * "status_code": 0,
  913. * "message": "",
  914. * "data":[] or
  915. * "data": [
  916. * {
  917. * "id": 2,
  918. * "phone": "13880642881",
  919. * "nickname": "name2",
  920. * "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
  921. * "birthday": "2000-06-21",
  922. * "sign": 0,
  923. * "money": 0,
  924. * "coin": 800,
  925. * "sex": 1,
  926. * "signture": "我的个性签名2",
  927. * "height": 200,
  928. * "work": "兼职",
  929. * "emotion": 2,
  930. * "address": "370105",
  931. * "city": "成都",
  932. * "detail_address": "",
  933. * "status": 1,
  934. * "wechat": "",
  935. * "weibo": "",
  936. * "remember_token": "",
  937. * "created_at": "2017-06-25 10:42:06",
  938. * "updated_at": "2017-06-30 09:15:04",
  939. * "deleted_at": null,
  940. * }
  941. * ]
  942. *}
  943. * @apiErrorExample {json} Error-Response:
  944. * HTTP/1.1 400 Bad Request
  945. */
  946. public function careMe()
  947. {
  948. $user = $this->getUser();
  949. $users =$user->UserCareMe;
  950. return $this->api($users);
  951. }
  952. public function insertSearchTable($id,$keyword)
  953. {
  954. $info = SearchInfoModel::where('user_id',$id)->
  955. where('search',trim($keyword))->first();
  956. if (count($info) == 0) {
  957. SearchInfoModel::create(['user_id'=>$id,'search'=>trim($keyword),'times'=>1]);
  958. }else{
  959. $info->times += 1;
  960. $info->save();
  961. }
  962. }
  963. //我的银行账户
  964. /**
  965. * @api {get} /api/my/bank/list 我的银行账户
  966. * @apiDescription 我的银行账户
  967. * @apiGroup My
  968. * @apiPermission Passport
  969. * @apiVersion 0.1.0
  970. * @apiSuccessExample {json} Success-Response:
  971. * HTTP/1.1 200 OK
  972. *{
  973. * "status": true,
  974. * "status_code": 0,
  975. * "message": "",
  976. * "data":[] or
  977. * "data": [
  978. * {
  979. * "id": 1,
  980. * "user_id": 1,
  981. * "bank_name": "1",
  982. * "bank_number": "1", /账号
  983. * "bank_phone": "1",
  984. * "bank_user": "" 用户名/
  985. * "type": 微信, 微信(支付宝)二维码
  986. * "url": wwww.ddf, 二维码地址
  987. * "is_img": 1,
  988. * }
  989. *]
  990. * @apiErrorExample {json} Error-Response:
  991. * HTTP/1.1 400 Bad Request
  992. */
  993. public function bankList()
  994. {
  995. $user = $this->getUser();
  996. $data = UserBank::where('user_id',$user->id)->orderBy('id','desc')->get();
  997. return $this->api($data);
  998. }
  999. /**
  1000. * @api {get} /api/my/bank/account 账户余额
  1001. * @apiDescription 账户余额
  1002. * @apiGroup My
  1003. * @apiPermission Passport
  1004. * @apiVersion 0.1.0
  1005. * @apiSuccessExample {json} Success-Response:
  1006. * HTTP/1.1 200 OK
  1007. *{
  1008. * "status": true,
  1009. * "status_code": 0,
  1010. * "message": "",
  1011. * "data":[] or
  1012. * "data": {
  1013. * "coin": 508, 余额
  1014. * }
  1015. *]
  1016. * @apiErrorExample {json} Error-Response:
  1017. * HTTP/1.1 400 Bad Request
  1018. */
  1019. public function account()
  1020. {
  1021. $user = $this->getUser();
  1022. return $this->api($user);
  1023. }
  1024. // 添加银行卡
  1025. /**
  1026. * @api {post} /api/my/bank/create 添加银行卡
  1027. * @apiDescription 添加银行卡
  1028. * @apiGroup My
  1029. * @apiParam {string} data[bank_name] 银行名称
  1030. * @apiParam {string} data[bank_number] 银行卡号
  1031. * @apiParam {int} data[bank_phone] 银行卡绑定手机号
  1032. * @apiParam {string} data[bank_user] 银行卡用户姓名
  1033. * @apiPermission Passport
  1034. * @apiVersion 0.1.0
  1035. * @apiSuccessExample {json} Success-Response:
  1036. * HTTP/1.1 200 OK
  1037. *{
  1038. * "status": true,
  1039. * "status_code": 0,
  1040. * "message": "",
  1041. * "data": ""
  1042. *}
  1043. * @apiErrorExample {json} Error-Response:
  1044. *{
  1045. * "status": false,
  1046. * "status_code": 700,
  1047. * "message": "操作失败",
  1048. * "data": null
  1049. *}
  1050. */
  1051. public function bankCreate(Request $request)
  1052. {
  1053. $data = $request->data;
  1054. $user = $this->getUser();
  1055. $validator = \Validator::make($request->all(),
  1056. [
  1057. 'data.bank_name' => 'required',
  1058. 'data.bank_number' => 'required',
  1059. 'data.bank_phone' => 'required',
  1060. 'data.bank_user' => 'required',
  1061. ],
  1062. [
  1063. 'data.bank_name.required' => '请选择账号类型',
  1064. 'data.bank_number.required' => '请输入账号',
  1065. 'data.bank_phone.required' => '请输入账号绑定手机号码',
  1066. 'data.bank_user.required' => '请输入账号绑定用户姓名',
  1067. ]
  1068. );
  1069. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1070. $data['user_id'] = $user->id;
  1071. $ok =UserBank::create($data);
  1072. if ($ok) {
  1073. return $this->api('');
  1074. }else{
  1075. return $this->error(ErrorCode::OPERATION_FAILED);
  1076. }
  1077. } /**
  1078. * @api {post} /api/my/bank/qrcode 添加二维码
  1079. * @apiDescription 添加二维码
  1080. * @apiGroup My
  1081. * @apiParam {string} data[type] 类型
  1082. * @apiParam {string} data[qrcode] 二维码图片
  1083. * @apiPermission Passport
  1084. * @apiVersion 0.1.0
  1085. * @apiSuccessExample {json} Success-Response:
  1086. * HTTP/1.1 200 OK
  1087. *{
  1088. * "status": true,
  1089. * "status_code": 0,
  1090. * "message": "",
  1091. * "data": ""
  1092. *}
  1093. * @apiErrorExample {json} Error-Response:
  1094. *{
  1095. * "status": false,
  1096. * "status_code": 700,
  1097. * "message": "操作失败",
  1098. * "data": null
  1099. *}
  1100. */
  1101. public function bankImgCreate(Request $request)
  1102. {
  1103. $data = $request->data;
  1104. $user = $this->getUser();
  1105. $validator = \Validator::make($request->all(),
  1106. [
  1107. 'data.type' => 'required',
  1108. 'data.qrcode' => 'required',
  1109. ],
  1110. [
  1111. 'data.type.required' => '请选择账号类型',
  1112. 'data.qrcode.required' => '请上传二维码图片',
  1113. ]
  1114. );
  1115. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1116. $data['user_id'] = $user->id;
  1117. /* $data['bank_user'] = '';
  1118. $data['bank_phone'] = '';
  1119. $data['bank_number'] = '';
  1120. $data['bank_name'] = '';*/
  1121. $info = UserBank::whereNotNull('qrcode')->where('user_id',$user->id)
  1122. ->where('type',$data['type'])->first(); //定义为二维码
  1123. if (empty($info)) {
  1124. $ok =UserBank::create($data);
  1125. }else{
  1126. $ok = $info->update($data);
  1127. }
  1128. if ($ok) {
  1129. return $this->api('');
  1130. }else{
  1131. return $this->error(ErrorCode::OPERATION_FAILED);
  1132. }
  1133. }
  1134. /**
  1135. * @api {get} /api/my/bank/delete 删除银行卡
  1136. * @apiDescription 删除银行卡
  1137. * @apiGroup My
  1138. * @apiParam {int} id 银行卡id
  1139. * @apiPermission Passport
  1140. * @apiVersion 0.1.0
  1141. * @apiSuccessExample {json} Success-Response:
  1142. * HTTP/1.1 200 OK
  1143. *{
  1144. * "status": true,
  1145. * "status_code": 0,
  1146. * "message": "",
  1147. * "data": ""
  1148. *}
  1149. * @apiErrorExample {json} Error-Response:
  1150. *{
  1151. * "status": false,
  1152. * "status_code": 700,
  1153. * "message": "操作失败",
  1154. * "data": null
  1155. *}
  1156. */
  1157. public function bankDelete(Request $request)
  1158. {
  1159. $id = $request->id;
  1160. $validator = \Validator::make($request->all(),
  1161. [
  1162. 'id' => 'required',
  1163. ],
  1164. [
  1165. 'id.required' => '银行账号不存在',
  1166. ]
  1167. );
  1168. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1169. $ok =UserBank::destroy($id);
  1170. if ($ok) {
  1171. return $this->api('');
  1172. }else{
  1173. return $this->error(ErrorCode::OPERATION_FAILED);
  1174. }
  1175. }
  1176. // 发私信
  1177. /**
  1178. * @api {post} /api/my/letter/store 发送私信
  1179. * @apiDescription 发送私信
  1180. * @apiGroup My
  1181. * @apiParam {string} content 私信内容
  1182. * @apiParam {int} to_user_id 私信对象
  1183. * @apiPermission Passport
  1184. * @apiVersion 0.1.0
  1185. * @apiSuccessExample {json} Success-Response:
  1186. * HTTP/1.1 200 OK
  1187. *{
  1188. * "status": true,
  1189. * "status_code": 0,
  1190. * "message": "",
  1191. * "data": ""
  1192. *}
  1193. * @apiErrorExample {json} Error-Response:
  1194. *{
  1195. * "status": false,
  1196. * "status_code": 700,
  1197. * "message": "操作失败",
  1198. * "data": null
  1199. *}
  1200. */
  1201. public function letterStore(Request $request)
  1202. {
  1203. $validator = \Validator::make($request->all(),
  1204. [
  1205. 'content' => 'required',
  1206. 'to_user_id' => 'required',
  1207. ],
  1208. [
  1209. 'content.required' => '私信内容不存在',
  1210. 'to_user_id.required' => '私信对象不存在',
  1211. ]
  1212. );
  1213. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1214. $user = $this->getUser();
  1215. $user_id = $user->id;
  1216. $info = $request->input('content');
  1217. $to_user_id = $request->input('to_user_id');
  1218. // 链接到最近的一个梦想
  1219. $dream = DreamInfoModel::where('user_id',$user_id)->orderBy('id','desc')->first();
  1220. $dream_id = empty($dream) ? 0 : $dream->id;
  1221. $arr = [
  1222. 'user_id'=>$to_user_id,
  1223. 'info'=>$info,
  1224. 'message'=>$user->nickname.'给你发了个私信哦~点击看看!',
  1225. 'to_user_id'=>$user_id,
  1226. 'dream_id'=>$dream_id,
  1227. 'type_id'=>2,
  1228. 'is_url'=>1,
  1229. 'attr_id'=>9,
  1230. ];
  1231. $ok =SystemInfoModel::create($arr);
  1232. if ($ok) {
  1233. $this->jPush($user->nickname.'给你发了个私信哦~点击看看!','',$to_user_id);
  1234. return $this->api('');
  1235. }else{
  1236. return $this->error(ErrorCode::OPERATION_FAILED);
  1237. }
  1238. } /**
  1239. * @api {get} /api/my/letter/show 查看私信
  1240. * @apiDescription 查看私信
  1241. * @apiGroup My
  1242. * @apiParam {int} id 私信主键id
  1243. * @apiPermission Passport
  1244. * @apiVersion 0.1.0
  1245. * @apiSuccessExample {json} Success-Response:
  1246. * HTTP/1.1 200 OK
  1247. *{
  1248. * "status": true,
  1249. * "status_code": 0,
  1250. * "message": "",
  1251. * "data": ""
  1252. *}
  1253. * @apiErrorExample {json} Error-Response:
  1254. *{
  1255. * "status": false,
  1256. * "status_code": 700,
  1257. * "message": "操作失败",
  1258. * "data": null
  1259. *}
  1260. */
  1261. public function letterShow(Request $request)
  1262. {
  1263. $validator = \Validator::make($request->all(),
  1264. [
  1265. 'id' => 'required',
  1266. ],
  1267. [
  1268. 'id.required' => '私信id不存在',
  1269. ]
  1270. );
  1271. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  1272. $user = $this->getUser();
  1273. $user_id = $user->id;
  1274. $id = $request->input('id');
  1275. $data = SystemInfoModel::find($id);
  1276. return $this->api($data);
  1277. }
  1278. }