DreamController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <?php
  2. namespace App\Http\Controllers\Api\V1;
  3. use App\Models\AccountLog;
  4. use App\Models\BaseSettingsModel;
  5. use App\Models\DreamImages;
  6. use App\Models\DreamInfoModel;
  7. use App\Models\InteractionInfo;
  8. use App\Models\SearchInfoModel;
  9. use App\Models\SupportDreamModel;
  10. use App\Models\SystemInfoModel;
  11. use App\Models\UserCareDream;
  12. use App\Models\UserCareUser;
  13. use App\Models\UserInfoModel;
  14. use Illuminate\Http\Request;
  15. use App\Services\Base\ErrorCode;
  16. class DreamController extends Controller
  17. {
  18. /**
  19. * @api {get} /api/dream/show 梦想详情
  20. * @apiDescription 梦想详情
  21. * @apiGroup Dream
  22. * @apiPermission Passport
  23. * @apiVersion 0.1.0
  24. * @apiParam {int} [type=home] home interaction paihang 默认all
  25. * @apiParam {int} id 梦想ID
  26. * @apiSuccessExample {json} Success-Response:
  27. * HTTP/1.1 200 OK
  28. * 主页
  29. {
  30. "status": true,
  31. "status_code": 0,
  32. "message": "",
  33. "data": {
  34. "id": 4,
  35. "user_id": 1,
  36. "a": 1, //支持乘数系数 后台配置
  37. "c": 1, //支持乘数系数 后台配置
  38. "name": "梦想标题1",
  39. "about": "梦想介绍",
  40. "coin": 2500,
  41. "time": 21,
  42. "get_coin": 600,
  43. "status": 0,
  44. "video": null,
  45. "score": 100079365,
  46. "sign": "",
  47. "created_at": "2017-06-25 11:47:45",
  48. "updated_at": "2017-06-25 15:10:50",
  49. "is_collection" : 1 1已收藏 0未收藏
  50. "show_button" : 1 1关注按钮显示 0不显示
  51. "top3user": [ 支持者前三
  52. {
  53. "id": 2,
  54. "phone": "13880642881",
  55. "nickname": "name2",
  56. "avatar": "https://timgsa.baidu.com/timg?imamb.224_0.jpeg",
  57. "score": 2399
  58. }
  59. ],
  60. "number": 1 支持乘数
  61. "imgs": [ 梦想图片
  62. {
  63. "title": "",
  64. "pic": "https://timgsa.ba0170524%2Feaca9092ca852e6e9c6ec46b7b14f12f.jpg"
  65. },
  66. {
  67. "title": "",
  68. "pic": "https://timgsa.baid524%2Feaca9092ca852e6e9c6ec46b7b14f12f.jpg"
  69. },
  70. {
  71. "title": "",
  72. "pic": "https://timgsa20170524%2Feaca9092ca852e6e9c6ec46b7b14f12f.jpg"
  73. }
  74. ],
  75. "user": { 梦想用户
  76. "id": 1,
  77. "phone": "13880642880",
  78. "nickname": "name1",
  79. "avatar": "https://timgsumb.224_0.jpeg",
  80. "birthday": "2000-06-21",
  81. "sign": 0,
  82. "money": 0,
  83. "coin": 1300,
  84. "sex": 1,
  85. "signture": "",
  86. "height": 170,
  87. "work": "",
  88. "emotion": 1,
  89. "address": "",
  90. "city": "",
  91. "detail_address": "",
  92. "status": 1,
  93. "wechat": "",
  94. "weibo": "",
  95. "remember_token": "",
  96. "created_at": "2017-06-25 10:27:08",
  97. "updated_at": "2017-06-25 15:20:11",
  98. "deleted_at": null
  99. }
  100. }
  101. }
  102. * @apiErrorExample {json} Error-Response:
  103. *HTTP/1.1 400 Bad Request
  104. *{
  105. * "status": false,
  106. * "status_code": 1105,
  107. * "message": "用户不存在",
  108. * "data": null
  109. * }
  110. */
  111. public function show(Request $request)
  112. {
  113. $user = $this->getUser();
  114. $type = $request->type; //类型
  115. $id = $request->id; //梦想ID
  116. $user_care_dream = UserCareDream::where('user_id',$user->id)->where('dream_id',$id)->first();
  117. $is_collection = empty($user_care_dream) ? 0 :1 ;
  118. if (empty($id)) return $this->error(ErrorCode::KEY_ERROR);
  119. $support_dream = SupportDreamModel::where('dream_id',$id)->get();
  120. $top = [] ;
  121. $topuser = []; //所有支持用户排行
  122. $top3user = []; // 支持用户排行前三
  123. foreach ($support_dream as $item) {
  124. if (!array_key_exists($item->user_id,$top)) {
  125. $top[$item->user_id] = $item->score;
  126. }else{
  127. $top[$item->user_id] += $item->score;
  128. }
  129. }
  130. arsort($top);
  131. foreach ($top as $user_id => $score){
  132. $user = UserInfoModel::find($user_id);
  133. $user->score = $score;
  134. $topuser[] = $user;
  135. if(count($top3user) <= 2) $top3user[] = $user ;
  136. }
  137. if ($type == 'paihang') return $this->api($topuser);
  138. $interactions = InteractionInfo::where('dream_id',$id)->orderBy('id','desc')->get();
  139. foreach ($interactions as $item) {
  140. $item->comments;
  141. foreach ($item->comments as $comment) {
  142. $comment->pic = UserInfoModel::find($comment->user_id)->pic;
  143. $comment->replay;
  144. foreach ($comment->replay as $k1 => $v1){
  145. $v1->pic = UserInfoModel::find($v1->user_id)->pic;
  146. }
  147. }
  148. }
  149. if ($type == 'interaction') return $this->api($interactions);
  150. // 梦想 图片 支持者前三 支持乘数参数 用户余额 梦想分数
  151. // $money = $user->money;
  152. $dream_info = DreamInfoModel::find($id);
  153. $setting = BaseSettingsModel::where('category','score')->select('key','value')->first();
  154. $a = count($setting) > 0 ? $setting->key : 0;
  155. $created_at = $dream_info ? $dream_info->created_at : 0;
  156. $b = intval((time()-strtotime($created_at))/60) ;
  157. $c = count($setting) > 0 ? $setting->value : 0;
  158. $number =round( -$a * $b + $c,1);
  159. if ($number <= 1) $number = 1;
  160. $dream = DreamInfoModel::with(['imgs','user'])->find($id);
  161. $dream->user_coin = $user->coin;
  162. $dream->topuser = $topuser;
  163. $dream->top3user = $top3user;
  164. $dream->interactions = $interactions;
  165. $dream->number = $number;
  166. $dream->is_collection = $is_collection;
  167. $dream->a = $a;
  168. $dream->c = $c;
  169. // 如果当前梦想用户就是当前登录用户就不显示关注按钮
  170. $show_button = $dream->user_id == $user->id ? '0' : '1';
  171. $dream->show_button = $show_button;
  172. return $this->api($dream);
  173. }
  174. /**
  175. * @api {post} /api/dream/support 支持梦想
  176. * @apiDescription 支持梦想
  177. * @apiGroup Dream
  178. * @apiPermission Passport
  179. * @apiVersion 0.1.0
  180. * @apiParam {int} coin 支持梦想币数量
  181. * @apiParam {int} id 梦想ID
  182. * @apiSuccessExample {json} Success-Response:
  183. * HTTP/1.1 200 OK
  184. {
  185. "status": true,
  186. "status_code": 0,
  187. "message": "",
  188. "data": {
  189. "id": 12,
  190. "user_id": 2,
  191. "name": "用户2梦想标题166",
  192. "about": "用户2梦想介绍666",
  193. "coin": 2500,
  194. "time": 21,
  195. "get_coin": 704,
  196. "status": 0,
  197. "video": null,
  198. "score": 158730,
  199. "mark": 158730,
  200. "sign": "",
  201. "created_at": "2017-06-25 13:10:56",
  202. "updated_at": "2017-06-27 18:16:02",
  203. "top3user": [ 支持者前三
  204. {
  205. "id": 1,
  206. "phone": "13880642880",
  207. "nickname": "name1",
  208. "avatar": "https://timgsa.bumb.224_0.jpeg",
  209. "birthday": "2000-06-21",
  210. "sign": 0,
  211. "money": 0,
  212. "coin": 596,
  213. "sex": 1,
  214. "signture": "我的个性签名1",
  215. "height": 170,
  216. "work": "网红",
  217. "emotion": 1,
  218. "address": "",
  219. "city": "上海",
  220. "detail_address": "",
  221. "status": 1,
  222. "wechat": "",
  223. "weibo": "",
  224. "remember_token": "",
  225. "created_at": "2017-06-25 10:27:08",
  226. "updated_at": "2017-06-27 18:16:02",
  227. "deleted_at": null,
  228. "score": 5062
  229. }
  230. ]
  231. "number": 4.8
  232. "is_collection" : 1 1已收藏 0未收藏
  233. }
  234. }
  235. * @apiErrorExample {json} Error-Response:
  236. *HTTP/1.1 400 Bad Request
  237. * {
  238. * "state": false,
  239. * "code": 1000,
  240. * "message": "传入参数不正确",
  241. * "data": null or []
  242. * }
  243. * 可能出现的代码
  244. * {
  245. * "status": false,
  246. * "status_code": 1303,
  247. * "message": "余额不足",
  248. * "data": null
  249. * }
  250. * {
  251. * "status": false,
  252. * "status_code": 1410,
  253. * "message": "支持已达上限",
  254. * "data": null
  255. * }
  256. *
  257. */
  258. public function support(Request $request)
  259. {
  260. $validator = \Validator::make($request->all(),
  261. [
  262. 'coin' => 'required',
  263. 'id' => 'required',
  264. ],
  265. [
  266. 'coin.required' => '梦想币不能为空',
  267. 'id.required' => '支持梦想id不能为空',
  268. ]
  269. );
  270. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  271. $user = $this->getUser();
  272. $dream_id = $request->id;
  273. $dream = DreamInfoModel::find($dream_id);
  274. $user_id = $dream->user_id;
  275. $coin = $request->coin;
  276. if ($dream->get_coin >= $dream->coin) {
  277. return $this->error(ErrorCode::SUP_TOP);
  278. } elseif($coin + $dream->get_coin > $dream->coin){
  279. $coin = $dream->coin - $dream->get_coin;
  280. }
  281. $user_care_dream = UserCareDream::where('user_id', $user->id)->where('dream_id', $dream_id)->first();
  282. $is_collection = empty($user_care_dream) ? 0 :1 ;
  283. $setting = BaseSettingsModel::where('category','score')->select('key','value')->first();
  284. $a = count($setting) > 0 ? $setting->key : '';
  285. $b = intval((time()-strtotime($dream->created_at))/60) ;
  286. $c = count($setting) > 0 ? $setting->value : '';
  287. //Todo 支持乘数目公式
  288. $number =round( -$a * $b + $c,1);
  289. if ($number <= 1) $number = 1;
  290. if ($user->coin < $coin) {
  291. return $this->error(ErrorCode::COIN_NOT_ENOUGH);
  292. }else{
  293. $user->coin -= $coin;
  294. $user->save();
  295. $dream->get_coin += $coin;
  296. $dream->mark += $coin*$number;
  297. $dream->save();
  298. $data = [
  299. 'user_id'=>$user->id,
  300. 'dream_id'=>$dream_id,
  301. 'to_user_id'=>$user_id,
  302. 'coin'=>$coin,
  303. 'score'=>$coin*$number,
  304. ];
  305. $ok = SupportDreamModel::create($data);
  306. if (!$ok) {
  307. return $this->error(ErrorCode::MERCHANT_SERVICE_STATUS_INVALID);
  308. }
  309. // 记录充值记录 新增系统消息
  310. $data = [
  311. 'from_id' =>$user->id,
  312. 'to_id' => $user_id,
  313. 'from_amount' => $coin,
  314. 'to_amount' => $coin,
  315. 'from_type' => AccountLog::TYPE_COIN,
  316. 'to_type' => AccountLog::TYPE_COIN,
  317. 'op' => AccountLog::OP_SUPPORT,
  318. ];
  319. AccountLog::create($data);
  320. $message = UserInfoModel::find($user->id)->nickname.'为你的梦想捐赠'.$coin.'梦想币';
  321. $info = [
  322. 'user_id' => $user_id,
  323. 'message' => $message,
  324. ];
  325. SystemInfoModel::create($info);
  326. // 支持成功返回数据到当前页面 top3user
  327. $support_dream = SupportDreamModel::where('dream_id',$dream_id)->get();
  328. $top = [] ;
  329. $top3user = []; // 支持用户排行前三
  330. foreach ($support_dream as $item) {
  331. if (!array_key_exists($item->user_id,$top)) {
  332. $top[$item->user_id] = $item->score;
  333. }else{
  334. $top[$item->user_id] += $item->score;
  335. }
  336. }
  337. arsort($top);
  338. foreach ($top as $user_id => $score){
  339. $user = UserInfoModel::find($user_id);
  340. $user->score = $score;
  341. if(count($top3user) <= 2) $top3user[] = $user ;
  342. }
  343. // 梦想分 mark
  344. $dream->top3user = $top3user;
  345. $dream->is_collection = $is_collection;
  346. $user_coin = $user->coin;
  347. return $this->api(compact('dream','user_coin'));
  348. }
  349. }
  350. // 收藏关注梦想
  351. /**
  352. * @api {get} /api/dream/collection 收藏梦想
  353. * @apiDescription 收藏梦想
  354. * @apiGroup Dream
  355. * @apiPermission Passport
  356. * @apiVersion 0.1.0
  357. * @apiParam {int} id 梦想ID
  358. * @apiParam {int} is_collection 0取消关注 1关注
  359. * @apiSuccessExample {json} Success-Response:
  360. * HTTP/1.1 200 OK
  361. *{
  362. * "status": true,
  363. * "status_code": 0,
  364. * "message": "",
  365. * "data": {
  366. * "is_collection": 1 1已关注 0 未关注
  367. * }
  368. *}
  369. * @apiErrorExample {json} Error-Response:
  370. *HTTP/1.1 400 Bad Request
  371. * {
  372. * "state": false,
  373. * "code": 1000,
  374. * "message": "传入参数不正确",
  375. * "data": null or []
  376. * }
  377. *
  378. */
  379. public function collection(Request $request)
  380. {
  381. $validator = \Validator::make($request->all(),
  382. [
  383. 'id' => 'required',
  384. 'is_collection' => 'required',
  385. ],
  386. [
  387. 'id.required' => '收藏梦想id不能为空',
  388. 'is_collection.required' => '关注值不存在',
  389. ]
  390. );
  391. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  392. $user = $this->getUser();
  393. if(!$dream = DreamInfoModel::find($request->id)){
  394. $this->error(ErrorCode::CLIENT_WRONG_PARAMS);
  395. }
  396. $data = [
  397. 'user_id' =>$user->id,
  398. 'dream_id' =>$request->id,
  399. 'dream_user_id' =>$dream->user_id,
  400. ];
  401. $is_collection = $request->is_collection;
  402. $user_care_dream = UserCareDream::where('user_id',$user->id)->
  403. where('dream_id',$request->id)->first();
  404. if ($is_collection) {
  405. if (empty($user_care_dream)) {
  406. UserCareDream::create($data);
  407. }
  408. }else{
  409. UserCareDream::where('user_id',$user->id)->
  410. where('dream_id',$request->id)->delete();
  411. }
  412. // 并且同时会关注这个梦想者
  413. $array = [
  414. 'user_id' =>$user->id,
  415. 'other_user_id' =>$dream->user_id,
  416. ];
  417. $user_care_user = UserCareUser::where('user_id',$user->id)->
  418. where('other_user_id',$dream->user_id)->first();
  419. if (empty($user_care_user)) {
  420. UserCareUser::create($array);
  421. // 关注成功发送私信
  422. $message = BaseSettingsModel::where('category','message')->first();
  423. $message = empty($message) ? '' : $message->value;
  424. $info2 = [
  425. 'user_id'=>$request->id,
  426. 'to_user_id' => $dream->user_id,
  427. 'message' =>$message
  428. ];
  429. SystemInfoModel::create($info2);
  430. }
  431. return $this->api($is_collection);
  432. }
  433. /**
  434. * @api {get} /api/dream/search 梦想搜索
  435. * @apiDescription 梦想搜索)
  436. * @apiGroup Dream
  437. * @apiPermission none
  438. * @apiVersion 0.1.0
  439. * @apiParam {string} keyword 关键字
  440. * @apiSuccessExample {json} Success-Response:
  441. * HTTP/1.1 200 OK
  442. {
  443. "status": true,
  444. "status_code": 0,
  445. "message": "",
  446. "data": [
  447. {
  448. "id": 5,
  449. "user_id": 1,
  450. "name": "梦想标题1",
  451. "about": "梦想介绍",
  452. "coin": 2500,
  453. "time": 72000,
  454. "get_coin": 0,
  455. "mark": 0,
  456. "status": 0,
  457. "video": "url",
  458. "score": 100079365,
  459. "sign": "梦想达人",
  460. "created_at": "2017-06-25 12:45:22",
  461. "updated_at": "2017-06-28 15:50:41",
  462. "user": {},
  463. "imgs": []
  464. },
  465. ]
  466. }
  467. * @apiErrorExample {json} Error-Response:
  468. * HTTP/1.1 400 Bad Request
  469. */
  470. public function search(Request $request)
  471. {
  472. $user = $this->getUser();
  473. if (empty($request->keyword)) {
  474. return $this->api('');
  475. }
  476. $keyword ='%'.$request->keyword.'%';
  477. $data = DreamInfoModel::where('name','like',$keyword)->
  478. orWhere('sign','like',$keyword)->with(['user','img'])->get();
  479. foreach ($data as $k => $dream) {
  480. $info = UserCareDream::where('dream_id',$dream->id)->get();
  481. $dream->care_num = count($info);
  482. $dream->img = $dream->img?$dream->img->pic:'';
  483. }
  484. $this->insertSearchTable($user->id,$request->keyword);
  485. return $this->api($data);
  486. }
  487. public function insertSearchTable($id,$keyword)
  488. {
  489. $info = SearchInfoModel::where('user_id',$id)->
  490. where('search',trim($keyword))->first();
  491. if (count($info) == 0) {
  492. SearchInfoModel::create(['user_id'=>$id,'search'=>trim($keyword),'times'=>1]);
  493. }else{
  494. $info->times += 1;
  495. $info->save();
  496. }
  497. }
  498. /**
  499. * @api {post} /api/dream/store 发布梦想
  500. * @apiDescription 发布梦想
  501. * @apiParam {string} pics 梦想图片 数组
  502. * @apiParam {string} video 梦想视频
  503. * @apiParam {string} name 梦想标题
  504. * @apiParam {string} about 梦想介绍
  505. * @apiParam {int} coin 梦想币
  506. * @apiParam {int} time 实现时间默认21*3600
  507. * @apiGroup Dream
  508. * @apiPermission Passport
  509. * @apiVersion 0.1.0
  510. * @apiSuccessExample {json} Success-Response:
  511. * {
  512. * "status": true,
  513. * "status_code": 0,
  514. * "message": "",
  515. * "data": ""
  516. *}
  517. * HTTP/1.1 200 OK
  518. * @apiErrorExample {json} Error-Response:
  519. * {
  520. * "status": false,
  521. * "status_code": 1203,
  522. * "message": "附件不存在",
  523. * "data": null
  524. * }
  525. * HTTP/1.1 400 Bad Request
  526. */
  527. public function store(Request $request)
  528. {
  529. $user = $this->getUser();
  530. $validator = \Validator::make($request->all(),
  531. [
  532. 'name' => 'required',
  533. 'about' => 'required',
  534. 'coin' => 'required|integer',
  535. 'days' => 'required|integer',
  536. ],
  537. [
  538. 'name.required' => '梦想标题必填',
  539. 'about.required' => '梦想介绍必填',
  540. 'coin.required' => '梦想币必填',
  541. 'coin.integer' => '梦想币必须是正整数',
  542. 'days.required' => '实现时间必填',
  543. 'days.integer' => '实现时间必须是正整数',
  544. ]
  545. );
  546. if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
  547. \Log::debug($user);
  548. $data2 = $user->myCareNum;
  549. $care_num = count($data2);
  550. $setting = BaseSettingsModel::where('category','paihang')->first();
  551. $a = $setting?$setting->key:1;
  552. $b = $setting?$setting->value:1;
  553. $t = 21*3600 / 60;
  554. $days = $request->days;
  555. $data = $request->except('_token','pics','days');
  556. $data['user_id'] = $user->id;
  557. $data['end_time'] = date('Y-m-d H:i:s',strtotime('+'.$days.' days'));
  558. \Log::debug($data['end_time'].' care_num:'.$care_num.' a:'.$a.' b:'.$b.' t:'.$t);
  559. if ($care_num == 0) {
  560. $data['score'] = (($a/$t) + $b)*100000000 ;
  561. }else{
  562. $data['score'] = (log($care_num) + ($a/$t) + $b)*100000000 ;
  563. }
  564. $data['created_at'] = date('Y-m-d H:i:s');
  565. $data['updated_at'] = date('Y-m-d H:i:s');
  566. $dream_id = DreamInfoModel::insertGetId($data);
  567. // 生成二维码
  568. $info['transaction_id'] = date('YmdHis') . mt_rand(1000, 9999);
  569. $info['code'] = 'WECHATPAY_' . $info['transaction_id'];
  570. $code_url = env('APP_URL').'/user/meet?dream_id='.$dream_id;
  571. $code_path = public_path('qrcodes/'.$info['code'].'.png');
  572. \QrCode::format('png')->size(500)->generate($code_url,$code_path);
  573. $code = env('APP_URL').'/qrcodes/'.$info['code'].'.png';
  574. DreamInfoModel::where('id',$dream_id)->update(compact('code'));
  575. if ($dream_id) {
  576. // 梦想创建成功 关联关系中最新动态+1
  577. /* $info = UserCareUser::where('other_user_id',$user->id)->paginate(20);
  578. foreach ($info as $item) {
  579. $item->dream_num += 1;
  580. $item->updated_at = date('Y-m-d H:i:s');
  581. $item->save();
  582. }*/
  583. $pics = $request->pics;
  584. $video = $request->video;
  585. if (!is_array($pics) && empty($pics) && empty($video)) {
  586. DreamInfoModel::destroy($dream_id);
  587. return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
  588. }
  589. $data = [];
  590. if (is_array($pics)) {
  591. foreach ($pics as $v){
  592. $data[] = [
  593. 'dream_id'=>$dream_id,
  594. 'pic' => $v,
  595. 'created_at' =>date('Y-m-d H:i:s'),
  596. 'updated_at' =>date('Y-m-d H:i:s'),
  597. ];
  598. }
  599. DreamImages::insert($data);
  600. }
  601. // 梦想创建成功后所有关注我的梦想的人也会收到我最新梦想发布的消息
  602. $ids = UserCareDream::where('dream_user_id',$user->id)->select('user_id')->get()->toArray();
  603. $id_arrs = array_column($ids,'user_id');
  604. if (!empty($id_arrs)) {
  605. $arr = [] ;
  606. foreach ($id_arrs as $id){
  607. $arr[] = [
  608. 'to_user_id' => $id,
  609. 'user_id' => $user->id,
  610. 'message' => '关注的梦想有新的梦想动态'.$dream_id,
  611. ];
  612. }
  613. SystemInfoModel::insert($arr);
  614. }
  615. return $this->api('');
  616. }
  617. }
  618. }