|
@@ -54,6 +54,7 @@ class questionlogic {
|
|
|
if (empty($quinfo)) {
|
|
|
return backarr(0, "用户不可答题");
|
|
|
}
|
|
|
+ $answertime = $quinfo['id'];
|
|
|
|
|
|
$answers = $arr['answers'];
|
|
|
Db::startTrans();
|
|
@@ -67,22 +68,28 @@ class questionlogic {
|
|
|
$type = $qbinfo['type'];
|
|
|
if (in_array($type, [1, 2])) {
|
|
|
$answerid = $value['answer_id'];
|
|
|
- $qboinfo = $m_qbo->getinfobywhere($qbid, $answerid);
|
|
|
- if (empty($qboinfo)) {
|
|
|
- throw new \Exception("无答案内容");
|
|
|
+ $answerid_arr = array_filter(explode(",", $answerid));
|
|
|
+ $label_arr = [];
|
|
|
+ foreach ($answerid_arr as $key => $aid) {
|
|
|
+ $qboinfo = $m_qbo->getinfobywhere($qbid, $aid);
|
|
|
+ if (empty($qboinfo)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $label_arr[] = $qboinfo['label'];
|
|
|
}
|
|
|
- $label = $qboinfo['label'];
|
|
|
+ $label = implode(" ", $label_arr);
|
|
|
$insertData = [
|
|
|
'user_id' => $userid,
|
|
|
'seqb_id' => $qbid,
|
|
|
'answer' => $answerid,
|
|
|
'label' => $label,
|
|
|
'createtime' => date("Y-m-d H:i:s"),
|
|
|
+ 'answer_time' => $answertime,
|
|
|
];
|
|
|
$m_qar->addinfo($insertData);
|
|
|
}
|
|
|
if (in_array($type, [3])) {
|
|
|
- $answer_str = $value['answer_str'];
|
|
|
+ $answer_str = !isset($value['answer_str']) || empty($value['answer_str']) ? "" : $value['answer_str'];
|
|
|
$insertData = [
|
|
|
'user_id' => $userid,
|
|
|
'seqb_id' => $qbid,
|
|
@@ -94,7 +101,7 @@ class questionlogic {
|
|
|
}
|
|
|
|
|
|
$quid = $quinfo['id'];
|
|
|
- $m_qu->updinfobyid($quid, ['is_active' => 0]);
|
|
|
+ $m_qu->updinfobyid($quid, ['is_active' => 0, 'is_answer' => 1, 'answer_time' => date("Y-m-d H:i:s")]);
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|