hanfucheng hai 1 ano
pai
achega
8cce3a693e

+ 1 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbAnswerController.java

@@ -108,7 +108,6 @@ public class JnbAnswerController extends BaseController {
     */
     @GetMapping("/adoptAnswer")
     public AjaxResult adoptAnswer(JnbAnswer jnbAnswer) {
-        jnbAnswer.setAdopt("1");
-        return toAjax(jnbAnswerService.updateJnbAnswer(jnbAnswer));
+        return toAjax(jnbAnswerService.adoptAnswer(jnbAnswer));
     }
 }

+ 11 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbAnswer.java

@@ -34,6 +34,9 @@ public class JnbAnswer extends BaseEntity
     @Excel(name = "数据状态")
     private String dataStatus;
 
+    //积分
+    private String score;
+
     //微信名
     private String wechatName;
 
@@ -43,6 +46,14 @@ public class JnbAnswer extends BaseEntity
     //头像
     private String headImg;
 
+    public String getScore() {
+        return score;
+    }
+
+    public void setScore(String score) {
+        this.score = score;
+    }
+
     public String getWechatName() {
         return wechatName;
     }

+ 8 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbAnswerService.java

@@ -66,4 +66,12 @@ public interface IJnbAnswerService {
     * @date 2024/3/13 14:50
     */
     public int addAnswer(JnbAnswer jnbAnswer);
+
+    /*
+    * 小程序-答案采纳
+    *
+    * @author 韩福成
+    * @date 2024/3/14 11:21
+    */
+    public int adoptAnswer(JnbAnswer jnbAnswer);
 }

+ 23 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbAnswerServiceImpl.java

@@ -7,6 +7,8 @@ import com.ruoyi.common.utils.uuid.IdUtils;
 import com.sooka.jnb.asking.domain.JnbAnswer;
 import com.sooka.jnb.asking.mapper.JnbAnswerMapper;
 import com.sooka.jnb.asking.service.IJnbAnswerService;
+import com.sooka.jnb.my.domain.ScoreOperate;
+import com.sooka.jnb.my.service.IScoreService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -21,6 +23,9 @@ public class JnbAnswerServiceImpl implements IJnbAnswerService {
     @Autowired
     private JnbAnswerMapper jnbAnswerMapper;
 
+    @Autowired
+    private IScoreService iScoreService;
+
     /**
      * 查询问答列-答案
      *
@@ -102,4 +107,22 @@ public class JnbAnswerServiceImpl implements IJnbAnswerService {
         jnbAnswer.setDataStatus("1");
         return jnbAnswerMapper.insertJnbAnswer(jnbAnswer);
     }
+
+    /*
+    * 小程序-答案采纳
+    *
+    * @author 韩福成
+    * @date 2024/3/14 11:22
+    */
+    @Override
+    public int adoptAnswer(JnbAnswer jnbAnswer) {
+        jnbAnswer.setAdopt("1");
+        ScoreOperate scoreOperate = new ScoreOperate();
+        scoreOperate.setUserId(jnbAnswer.getCreateBy());
+        scoreOperate.setScoreNum(Integer.valueOf(jnbAnswer.getScore()));
+        scoreOperate.setRelevance("2");
+        scoreOperate.setRelevanceDataId(jnbAnswer.getId());
+        iScoreService.addScore(scoreOperate);
+        return jnbAnswerMapper.updateJnbAnswer(jnbAnswer);
+    }
 }

+ 14 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionServiceImpl.java

@@ -13,7 +13,9 @@ import com.sooka.jnb.asking.mapper.JnbQuestionMapper;
 import com.sooka.jnb.asking.service.IJnbAnswerService;
 import com.sooka.jnb.asking.service.IJnbQuestionService;
 import com.sooka.jnb.my.domain.Announcement;
+import com.sooka.jnb.my.domain.ScoreOperate;
 import com.sooka.jnb.my.service.IAnnouncementService;
+import com.sooka.jnb.my.service.IScoreService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -42,6 +44,9 @@ public class JnbQuestionServiceImpl implements IJnbQuestionService {
     @Autowired
     private IJnbAnswerService jnbAnswerService;
 
+    @Autowired
+    private IScoreService iScoreService;
+
     /**
      * 查询问答列-问题
      *
@@ -176,6 +181,15 @@ public class JnbQuestionServiceImpl implements IJnbQuestionService {
         announcement.setAnnoType("jnb_question");
         announcement.setBindId(jnbQuestion.getId());
         announcementService.insertAnnouncement(announcement);
+        if (jnbQuestion.getStatus().equals("1")){
+            //减少积分
+            ScoreOperate scoreOperate = new ScoreOperate();
+            scoreOperate.setUserId(jnbQuestion.getCreateBy());
+            scoreOperate.setScoreNum(Integer.valueOf(jnbQuestion.getScore()));
+            scoreOperate.setRelevance("2");
+            scoreOperate.setRelevanceDataId(jnbQuestion.getId());
+            iScoreService.reduceScore(scoreOperate);
+        }
         return jnbQuestionMapper.updateJnbQuestion(jnbQuestion);
     }
 

+ 5 - 5
sooka-jnb/src/main/resources/mapper/asking/JnbQuestionMapper.xml

@@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.update_time,
             a.data_status,
             GROUP_CONCAT(b.path) path,
-			count(c.id) collect
+			count(DISTINCT c.id) collect
         FROM
             jnb_question a
             left join jnb_question_img b on a.id = b.question_id
@@ -184,8 +184,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.browse,
             GROUP_CONCAT(b.path) path,
             a.create_by,
-            count(c.id) comment,
-	        count(d.id)  collect
+            count(DISTINCT c.id) comment,
+	        count(DISTINCT d.id)  collect
         FROM
             jnb_question a
             left join jnb_question_img b on a.id = b.question_id
@@ -209,8 +209,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.browse,
             GROUP_CONCAT(b.path) path,
             a.create_by,
-            count(c.id) comment,
-	        count(d.id)  collect
+            count(DISTINCT c.id) comment,
+	        count(DISTINCT d.id)  collect
         FROM
             jnb_question a
             left join jnb_question_img b on a.id = b.question_id