DreamController.php 23 KB

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