| xqd
@@ -10,6 +10,7 @@ use App\Models\DreamInfoModel;
|
|
|
use App\Models\InteractionInfo;
|
|
|
use App\Models\SearchInfoModel;
|
|
|
use App\Models\Suggest;
|
|
|
+use App\Models\SupportDreamModel;
|
|
|
use App\Models\SystemInfoModel;
|
|
|
use App\Models\UserBank;
|
|
|
use App\Models\UserCareDream;
|
| xqd
@@ -1224,7 +1225,7 @@ class MyController extends Controller
|
|
|
* @apiDescription 发送私信
|
|
|
* @apiGroup My
|
|
|
* @apiParam {string} content 私信内容
|
|
|
- * @apiParam {string} [image] 图片
|
|
|
+ * @apiParam {array} [image] 图片
|
|
|
* @apiParam {string} [video] 视频
|
|
|
* @apiParam {int} to_user_id 私信对象
|
|
|
* @apiPermission Passport
|
| xqd
@@ -1262,7 +1263,12 @@ class MyController extends Controller
|
|
|
$user_id = $user->id;
|
|
|
$info = $request->input('content');
|
|
|
$video = $request->input('video');
|
|
|
- $image = $request->input('image');
|
|
|
+ $img = json_decode($request->input('image'),true);
|
|
|
+ if (is_array($img)) {
|
|
|
+ $image = $img[0];
|
|
|
+ }else{
|
|
|
+ $image = $img;
|
|
|
+ }
|
|
|
$to_user_id = $request->input('to_user_id');
|
|
|
// 链接到最近的一个梦想
|
|
|
$dream = DreamInfoModel::where('user_id',$user_id)->orderBy('id','desc')->first();
|
| xqd
@@ -1332,7 +1338,7 @@ class MyController extends Controller
|
|
|
|
|
|
// 梦想结束时梦想者是否同意见面
|
|
|
/**
|
|
|
- * @api {get} /api/my/system/dream_isok 是否同意见面
|
|
|
+ * @api {get} /api/my/sure_meet 是否同意见面
|
|
|
* @apiDescription 梦想结束时梦想者是否同意见面
|
|
|
* @apiGroup My
|
|
|
* @apiParam {int} dream_id 梦想id
|
| xqd
@@ -1372,12 +1378,44 @@ class MyController extends Controller
|
|
|
$value = $request->input('value');
|
|
|
$dream = DreamInfoModel::find($dream_id);
|
|
|
if (empty($dream)) return $this->error(ErrorCode::DREAM_NOT_EXIST);
|
|
|
+ $support_dream = SupportDreamModel::where('dream_id',$dream_id)->get();
|
|
|
+ $top = [] ;
|
|
|
+ foreach ($support_dream as $item) {
|
|
|
+ if (!array_key_exists($item->user_id,$top)) {
|
|
|
+ $top[$item->user_id] = $item->score;
|
|
|
+ }else{
|
|
|
+ $top[$item->user_id] += $item->score;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ arsort($top);
|
|
|
+ $new_arr = array_values($top);
|
|
|
+ if (!empty($top)) {
|
|
|
+ $top_user = array_search($new_arr[0],$top);
|
|
|
+ }else{
|
|
|
+ $top_user = 0;
|
|
|
+ }
|
|
|
if (empty($value)) {
|
|
|
+// 拒绝见面
|
|
|
|
|
|
}else{
|
|
|
// 同意见面
|
|
|
$dream->is_ok = 1;
|
|
|
$dream->save();
|
|
|
+ if (empty($top)) {
|
|
|
+// 给最大支持者发送消息
|
|
|
+ $message = "你支持的梦想者已经同意见面啦";
|
|
|
+ $arr = [
|
|
|
+ 'user_id'=>0,
|
|
|
+ 'message'=>$message,
|
|
|
+ 'to_user_id'=>$top_user,
|
|
|
+ 'dream_id'=>$dream_id,
|
|
|
+ 'is_end'=>1,
|
|
|
+ 'type_id'=>1,
|
|
|
+ 'is_max'=>1,
|
|
|
+
|
|
|
+ ];
|
|
|
+ SystemInfoModel::firstOrCreate($arr);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|