wangjun 1 روز پیش
والد
کامیت
dc57626b21

+ 13 - 6
application/index/logic/questionlogic.php

@@ -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();

+ 1 - 0
application/index/logic/workermanger.php

@@ -707,6 +707,7 @@ class workermanger {
                     'telno' => $uinfo['telno'],
                     'is_active' => $isactive,
                     'createtime' => date("Y-m-d H:i:s"),
+                    'name' => $uinfo['wname'],
                 ];
                 $quid = $m_qu->addinfo($insertData);
             }

+ 5 - 1
application/index/model/gworkermodel.php

@@ -205,7 +205,10 @@ class gworkermodel extends Model {
     public function selinfobywhere($where, $page = 1, $size = 10) {
         $field = "w.*,IFNULL(tab.quactive,0) qu_active,IFNULL(tab.quisanswer,0) qu_isanswer";
         $strsql = "select " . $field . " from t_workerinfo as w
-                   left join (select id,user_id,is_active as quactive,is_answer as quisanswer from t_question_user where is_active=1) as tab on tab.user_id=w.id";
+                   left join (select id,user_id,is_active as quactive,is_answer as quisanswer from t_question_user where id in (
+                        select max(id) from t_question_user GROUP BY user_id
+                        )
+                    ) as tab on tab.user_id=w.id";
         $strsql = "select * from (" . $strsql . ") as tab1";
         $usewhere = [];
         if (isset($where['wname']) && !empty($where['wname'])) {
@@ -219,6 +222,7 @@ class gworkermodel extends Model {
         if (isset($where['qu_isanswer']) && in_array($where['qu_isanswer'], [0, 1]) && "" != $where['qu_isanswer']) {
             $qu_isanswer = $where['qu_isanswer'];
             $usewhere[] = "qu_isanswer='" . $qu_isanswer . "'";
+            $usewhere[] = "qu_active=0";
         }
         if (!empty($usewhere)) {
             $where_str = implode(" and ", $usewhere);