mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 20:12:48 +00:00
Merge commit 'c6568969c7b2d538d27cb4ca0ee412d4dbdceb56' into pro
This commit is contained in:
commit
d189fb100a
@ -2180,35 +2180,39 @@ class DialogController extends AbstractController
|
|||||||
return Base::retError('内容最大不能超过200000字');
|
return Base::retError('内容最大不能超过200000字');
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
$userid = $user->userid;
|
return AbstractModel::transaction(function () use ($user, $uuid, $dialog_id, $list, $text) {
|
||||||
if ($uuid) {
|
if ($uuid) {
|
||||||
$dialogMsg = WebSocketDialogMsg::whereDialogId($dialog_id)
|
$dialogMsg = WebSocketDialogMsg::whereDialogId($dialog_id)
|
||||||
->whereType('word-chain')
|
->lockForUpdate()
|
||||||
->orderByDesc('created_at')
|
->whereType('word-chain')
|
||||||
->where('msg', 'like', "%$uuid%")
|
->orderByDesc('created_at')
|
||||||
->value('msg');
|
->where('msg', 'like', "%$uuid%")
|
||||||
$list = array_reverse(array_merge($dialogMsg['list'] ?? [], $list));
|
->value('msg');
|
||||||
$list = array_reduce($list, function ($result, $item) {
|
$list = array_reverse(array_merge($dialogMsg['list'] ?? [], $list));
|
||||||
$fieldValue = $item['id']; // 指定字段名
|
$list = array_reduce($list, function ($result, $item) {
|
||||||
if (!isset($result[$fieldValue])) {
|
$fieldValue = $item['id']; // 指定字段名
|
||||||
$result[$fieldValue] = $item;
|
if (!isset($result[$fieldValue])) {
|
||||||
}
|
$result[$fieldValue] = $item;
|
||||||
return $result;
|
}
|
||||||
}, []);
|
return $result;
|
||||||
$list = array_reverse(array_values($list));
|
}, []);
|
||||||
}
|
$list = array_reverse(array_values($list));
|
||||||
//
|
} else {
|
||||||
usort($list, function($a, $b) {
|
$uuid = Base::generatePassword(36);
|
||||||
return $a['id'] - $b['id'];
|
}
|
||||||
|
//
|
||||||
|
usort($list, function ($a, $b) {
|
||||||
|
return $a['id'] - $b['id'];
|
||||||
|
});
|
||||||
|
//
|
||||||
|
$msgData = [
|
||||||
|
'text' => $text,
|
||||||
|
'list' => $list,
|
||||||
|
'userid' => $user->userid,
|
||||||
|
'uuid' => $uuid,
|
||||||
|
];
|
||||||
|
return WebSocketDialogMsg::sendMsg(null, $dialog_id, 'word-chain', $msgData, $user->userid);
|
||||||
});
|
});
|
||||||
//
|
|
||||||
$msgData = [
|
|
||||||
'text' => $text,
|
|
||||||
'list' => $list,
|
|
||||||
'userid' => $userid,
|
|
||||||
'uuid' => $uuid ?: Base::generatePassword(36),
|
|
||||||
];
|
|
||||||
return WebSocketDialogMsg::sendMsg(null, $dialog_id, 'word-chain', $msgData, $user->userid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2249,8 +2253,6 @@ class DialogController extends AbstractController
|
|||||||
WebSocketDialog::checkDialog($dialog_id);
|
WebSocketDialog::checkDialog($dialog_id);
|
||||||
//
|
//
|
||||||
$action = null;
|
$action = null;
|
||||||
$userid = $user->userid;
|
|
||||||
$result = [];
|
|
||||||
if ($type != 'create') {
|
if ($type != 'create') {
|
||||||
if ($type == 'vote' && empty($votes)) {
|
if ($type == 'vote' && empty($votes)) {
|
||||||
return Base::retError('参数错误');
|
return Base::retError('参数错误');
|
||||||
@ -2258,42 +2260,50 @@ class DialogController extends AbstractController
|
|||||||
if (empty($uuid)) {
|
if (empty($uuid)) {
|
||||||
return Base::retError('参数错误');
|
return Base::retError('参数错误');
|
||||||
}
|
}
|
||||||
$dialogMsgs = WebSocketDialogMsg::whereDialogId($dialog_id)
|
return AbstractModel::transaction(function () use ($user, $uuid, $dialog_id, $type, $votes) {
|
||||||
->whereType('vote')
|
//
|
||||||
->orderByDesc('created_at')
|
$dialogMsgs = WebSocketDialogMsg::whereDialogId($dialog_id)
|
||||||
->where('msg', 'like', "%$uuid%")
|
->lockForUpdate()
|
||||||
->get();
|
->whereType('vote')
|
||||||
//
|
->orderByDesc('created_at')
|
||||||
if ($type == 'again') {
|
->where('msg', 'like', "%$uuid%")
|
||||||
$res = WebSocketDialogMsg::sendMsg(null, $dialog_id, 'vote', $dialogMsgs[0]->msg, $user->userid);
|
->get();
|
||||||
if (Base::isError($res)) {
|
//
|
||||||
return $res;
|
$result = [];
|
||||||
}
|
if ($type == 'again') {
|
||||||
$result[] = $res['data'];
|
$res = WebSocketDialogMsg::sendMsg(null, $dialog_id, 'vote', $dialogMsgs[0]->msg, $user->userid);
|
||||||
} else {
|
|
||||||
foreach ($dialogMsgs as $dialogMsg) {
|
|
||||||
$action = "change-{$dialogMsg->id}";
|
|
||||||
$msgData = $dialogMsg->msg;
|
|
||||||
if ($type == 'finish') {
|
|
||||||
$msgData['state'] = 0;
|
|
||||||
} else {
|
|
||||||
$msgDataVotes = $msgData['votes'] ?? [];
|
|
||||||
if (in_array($userid, array_column($msgDataVotes, 'userid'))) {
|
|
||||||
return Base::retError('不能重复投票');
|
|
||||||
}
|
|
||||||
$msgDataVotes[] = [
|
|
||||||
'userid' => $userid,
|
|
||||||
'votes' => $votes,
|
|
||||||
];
|
|
||||||
$msgData['votes'] = $msgDataVotes;
|
|
||||||
}
|
|
||||||
$res = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'vote', $msgData, $user->userid);
|
|
||||||
if (Base::isError($res)) {
|
if (Base::isError($res)) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
$result[] = $res['data'];
|
$result[] = $res['data'];
|
||||||
|
} else {
|
||||||
|
foreach ($dialogMsgs as $dialogMsg) {
|
||||||
|
$action = "change-{$dialogMsg->id}";
|
||||||
|
$msgData = $dialogMsg->msg;
|
||||||
|
if ($type == 'finish') {
|
||||||
|
$msgData['state'] = 0;
|
||||||
|
} else {
|
||||||
|
$msgDataVotes = $msgData['votes'] ?? [];
|
||||||
|
if (in_array($user->userid, array_column($msgDataVotes, 'userid'))) {
|
||||||
|
return Base::retError('不能重复投票');
|
||||||
|
}
|
||||||
|
$msgDataVotes[] = [
|
||||||
|
'userid' => $user->userid,
|
||||||
|
'votes' => $votes,
|
||||||
|
];
|
||||||
|
$msgData['votes'] = $msgDataVotes;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$res = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'vote', $msgData, $user->userid);
|
||||||
|
if (Base::isError($res)) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
$result[] = $res['data'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
//
|
||||||
|
return Base::retSuccess('发送成功', $result);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
$strlen = mb_strlen($text);
|
$strlen = mb_strlen($text);
|
||||||
$noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));
|
$noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));
|
||||||
@ -2306,7 +2316,7 @@ class DialogController extends AbstractController
|
|||||||
$msgData = [
|
$msgData = [
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'list' => $list,
|
'list' => $list,
|
||||||
'userid' => $userid,
|
'userid' => $user->userid,
|
||||||
'uuid' => $uuid ?: Base::generatePassword(36),
|
'uuid' => $uuid ?: Base::generatePassword(36),
|
||||||
'multiple' => $multiple,
|
'multiple' => $multiple,
|
||||||
'anonymous' => $anonymous,
|
'anonymous' => $anonymous,
|
||||||
@ -2317,9 +2327,8 @@ class DialogController extends AbstractController
|
|||||||
if (Base::isError($res)) {
|
if (Base::isError($res)) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
$result[] = $res['data'];
|
return Base::retSuccess('发送成功', [$res['data']]);
|
||||||
}
|
}
|
||||||
return Base::retSuccess('发送成功', $result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
<em>{{ $L('投票') }}</em>
|
<em>{{ $L('投票') }}</em>
|
||||||
<span>{{ msgData.msg.multiple == 1 ? $L('多选') : $L('单选')}}</span>
|
<span>{{ msgData.msg.multiple == 1 ? $L('多选') : $L('单选')}}</span>
|
||||||
<span>{{ msgData.msg.multiple == 1 ? $L('匿名') : $L('实名')}}</span>
|
<span>{{ msgData.msg.anonymous == 1 ? $L('匿名') : $L('实名')}}</span>
|
||||||
</div>
|
</div>
|
||||||
<pre v-html="$A.formatTextMsg(msgData.msg.text, userId)"></pre>
|
<pre v-html="$A.formatTextMsg(msgData.msg.text, userId)"></pre>
|
||||||
<template v-if="(msgData.msg.votes || []).filter(h=>h.userid == userId).length == 0">
|
<template v-if="(msgData.msg.votes || []).filter(h=>h.userid == userId).length == 0">
|
||||||
@ -126,9 +126,9 @@
|
|||||||
<span>{{ getVoteProgress(msgData.msg,item.id).progress + '%' }}</span>
|
<span>{{ getVoteProgress(msgData.msg,item.id).progress + '%' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<Progress :percent="Number(getVoteProgress(msgData.msg,item.id).progress)" :stroke-width="5" hide-info/>
|
<Progress :percent="Number(getVoteProgress(msgData.msg,item.id).progress)" :stroke-width="5" hide-info/>
|
||||||
<div v-if="msgData.msg.anonymous" class="avatar-row">
|
<div v-if="msgData.msg.anonymous == 0" class="avatar-row">
|
||||||
<template v-for="votes in (msgData.msg.votes || []).filter(h=>h.votes.indexOf(item.id) != -1)">
|
<template v-for="votes in (msgData.msg.votes || []).filter(h=>h.votes.indexOf(item.id) != -1)">
|
||||||
<UserAvatar :userid="votes.userid" :size="18" />
|
<UserAvatar :userid="votes.userid" :size="18" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user