|
@@ -6,7 +6,9 @@ use App\Models\AccountLog;
|
|
use App\Models\BaseSettingsModel;
|
|
use App\Models\BaseSettingsModel;
|
|
use App\Models\DreamImages;
|
|
use App\Models\DreamImages;
|
|
use App\Models\DreamInfoModel;
|
|
use App\Models\DreamInfoModel;
|
|
|
|
+use App\Models\InteractionInfo;
|
|
use App\Models\SupportDreamModel;
|
|
use App\Models\SupportDreamModel;
|
|
|
|
+use App\Models\SystemInfoModel;
|
|
use App\Models\UserCareDream;
|
|
use App\Models\UserCareDream;
|
|
use App\Models\UserInfoModel;
|
|
use App\Models\UserInfoModel;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
@@ -21,6 +23,7 @@ class DreamController extends Controller
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiParam {int} type interaction paihang 默认index
|
|
* @apiParam {int} type interaction paihang 默认index
|
|
|
|
+ * @apiParam {int} id 梦想ID
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
* 主页
|
|
* 主页
|
|
@@ -75,7 +78,51 @@ class DreamController extends Controller
|
|
* },
|
|
* },
|
|
* ]
|
|
* ]
|
|
*}
|
|
*}
|
|
- *
|
|
|
|
|
|
+ * 互动
|
|
|
|
+ *{
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "data": [
|
|
|
|
+ * {
|
|
|
|
+ * "id": 7,
|
|
|
|
+ * "dream_id": 2,
|
|
|
|
+ * "title": "梦想动态有力来了",
|
|
|
|
+ * "pic1": "http\"//www.baidu.com",
|
|
|
|
+ * "created_at": "2017-06-22 21:09:18",
|
|
|
|
+ * "updated_at": "2017-06-22 21:09:18",
|
|
|
|
+ * "deleted_at": null,
|
|
|
|
+ * "comments": [ 评论
|
|
|
|
+ * {
|
|
|
|
+ * "interaction_id": 7,
|
|
|
|
+ * "user_id": 1,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "不错的梦想",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg", 评论者头像
|
|
|
|
+ * "replay": [ 回复
|
|
|
|
+ * {
|
|
|
|
+ * "user_id": 1,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "我也觉得不错",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg" 回复者头像
|
|
|
|
+ * },
|
|
|
|
+ * {
|
|
|
|
+ * "user_id": 6,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "祝你梦想成真",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ * ]
|
|
|
|
+ * ]
|
|
|
|
+ * },
|
|
|
|
+ * "times": 720000 梦想实现倒计时(s)
|
|
|
|
+ * }
|
|
|
|
+ *}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
*HTTP/1.1 400 Bad Request
|
|
*HTTP/1.1 400 Bad Request
|
|
*{
|
|
*{
|
|
@@ -112,7 +159,19 @@ class DreamController extends Controller
|
|
return $this->api($data);
|
|
return $this->api($data);
|
|
|
|
|
|
} elseif ($type == 'interaction') {
|
|
} elseif ($type == 'interaction') {
|
|
-
|
|
|
|
|
|
+ $times = DreamInfoModel::find($id)->time;
|
|
|
|
+ $data = InteractionInfo::where('dream_id',$id)->orderBy('id','desc')->get();
|
|
|
|
+ foreach ($data as $item) {
|
|
|
|
+ $item->comments = $item->comments;
|
|
|
|
+ foreach ($item->comments as $comment) {
|
|
|
|
+ $comment->pic = UserInfoModel::find($comment->user_id)->pic;
|
|
|
|
+ $comment->replay = $comment->replay;
|
|
|
|
+ foreach ($comment->replay as $k1 => $v1){
|
|
|
|
+ $v1->pic = UserInfoModel::find($v1->user_id)->pic;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $this->api(compact('data','times'));
|
|
}else{
|
|
}else{
|
|
// 梦想 图片 支持者前三 支持乘数参数 用户余额 梦想分数
|
|
// 梦想 图片 支持者前三 支持乘数参数 用户余额 梦想分数
|
|
$score = 0 ;
|
|
$score = 0 ;
|
|
@@ -219,7 +278,7 @@ class DreamController extends Controller
|
|
if (!$ok) {
|
|
if (!$ok) {
|
|
return $this->error(ErrorCode::MERCHANT_SERVICE_STATUS_INVALID);
|
|
return $this->error(ErrorCode::MERCHANT_SERVICE_STATUS_INVALID);
|
|
}
|
|
}
|
|
- // 记录充值记录
|
|
|
|
|
|
+ // 记录充值记录 新增系统消息
|
|
$data = [
|
|
$data = [
|
|
'from_id' =>$user->id,
|
|
'from_id' =>$user->id,
|
|
'to_id' => $user_id,
|
|
'to_id' => $user_id,
|
|
@@ -230,6 +289,13 @@ class DreamController extends Controller
|
|
'op' => AccountLog::OP_SUPPORT,
|
|
'op' => AccountLog::OP_SUPPORT,
|
|
];
|
|
];
|
|
AccountLog::create($data);
|
|
AccountLog::create($data);
|
|
|
|
+ $message = UserInfoModel::find($user->id)->nickname.'为你的梦想捐赠'.$coin.'梦想币';
|
|
|
|
+ $info = [
|
|
|
|
+ 'user_id' => $user_id,
|
|
|
|
+ 'message' => $message,
|
|
|
|
+ ];
|
|
|
|
+ SystemInfoModel::create($info);
|
|
|
|
+
|
|
return $this->api('');
|
|
return $this->api('');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -277,4 +343,66 @@ class DreamController extends Controller
|
|
return $this->api('');
|
|
return $this->api('');
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 发布关于梦想的动态
|
|
|
|
+ /**
|
|
|
|
+ * @api {post} /api/dream/add_info 新增动态
|
|
|
|
+ * @apiDescription 新增动态
|
|
|
|
+ * @apiGroup Dream
|
|
|
|
+ * @apiPermission Passport
|
|
|
|
+ * @apiVersion 0.1.0
|
|
|
|
+ * @apiParam {int} id 梦想ID
|
|
|
|
+ * @apiParam {string} title 梦想标题
|
|
|
|
+ * @apiParam {array} pics[] 图片数组
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
|
+ *{
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": ""
|
|
|
|
+ *}
|
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
|
+ *HTTP/1.1 400 Bad Request
|
|
|
|
+ * {
|
|
|
|
+ * "state": false,
|
|
|
|
+ * "code": 1000,
|
|
|
|
+ * "message": "传入参数不正确",
|
|
|
|
+ * "data": null or []
|
|
|
|
+ * }
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ public function addInfo(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $validator = \Validator::make($request->all(),
|
|
|
|
+ [
|
|
|
|
+ 'id' => 'required',
|
|
|
|
+ 'title' => 'required',
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'title.required' => '动态标题不能为空',
|
|
|
|
+ 'dream_id.required' => '梦想ID不能为空',
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
|
|
+ $pics = $request->pics;
|
|
|
|
+ if (empty($pics) || !is_array($pics)) {
|
|
|
|
+ return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
|
|
|
|
+ }
|
|
|
|
+ $data = [];
|
|
|
|
+ foreach ($pics as $k => $pic) {
|
|
|
|
+ $data['pic'.($k+1)] = $pic;
|
|
|
|
+ }
|
|
|
|
+ $dream_id = $request->id;
|
|
|
|
+ $title = $request->title;
|
|
|
|
+ $data['dream_id'] = $dream_id;
|
|
|
|
+ $data['title'] = $title;
|
|
|
|
+ $ok = InteractionInfo::create($data);
|
|
|
|
+ if ($ok) {
|
|
|
|
+ return $this->api('');
|
|
|
|
+ }else{
|
|
|
|
+ return $this->error(ErrorCode::SAVE_USER_FAILED);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|