1.修复活动发起者时间币没有扣除

2.修复管理后台活动管理参与者列表显示重复用户
master
pan 5 years ago
parent ed8d5c0a4a
commit 09741ca25e
  1. 3
      src/main/java/com/share/help/dao/ActivityMapper.java
  2. 34
      src/main/java/com/share/help/res/ActivitySendUser.java
  3. 26
      src/main/java/com/share/help/service/ActivityService.java
  4. 8
      src/main/resources/mapping/ActivityMapper.xml
  5. 8
      src/test/java/com/share/help/HelpApplicationTests.java

@ -6,6 +6,7 @@ import com.share.help.entity.custorm.ActivitySimple;
import com.share.help.entity.custorm.FindActivityRes;
import com.share.help.entity.custorm.SeekHelpSum;
import com.share.help.form.manager.ActiveUserRes;
import com.share.help.res.ActivitySendUser;
import com.share.help.res.ManagerActivityRes;
import com.share.help.res.Page;
import org.apache.ibatis.annotations.Delete;
@ -80,4 +81,6 @@ public interface ActivityMapper {
//查询活跃用户
List<ActiveUserRes> queryActiveUser(@Param("userId") String userId,@Param("serviceAddress") String serviceAddress);
//查询活动举办者信息
ActivitySendUser querySendUser(@Param("activityId") Long activityId);
}

@ -0,0 +1,34 @@
package com.share.help.res;
//查询活动举办人信息
public class ActivitySendUser {
private Long activityId;
private String userId;
private Integer timeScore;
public Long getActivityId() {
return activityId;
}
public void setActivityId(Long activityId) {
this.activityId = activityId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Integer getTimeScore() {
return timeScore;
}
public void setTimeScore(Integer timeScore) {
this.timeScore = timeScore;
}
}

@ -12,10 +12,7 @@ import com.share.help.entity.UserEntity;
import com.share.help.entity.custorm.*;
import com.share.help.form.*;
import com.share.help.form.manager.ActiveUserRes;
import com.share.help.res.DefaultRes;
import com.share.help.res.JSONResponse;
import com.share.help.res.Page;
import com.share.help.res.Result;
import com.share.help.res.*;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -171,7 +168,7 @@ public class ActivityService{
@Transactional
public JSONResponse<DefaultRes,Integer> apply(UpdateActivityForm activityForm) throws RuntimeException{
//记录用户完成活动返回的时间币
Integer timeScore = null;
int resultScore=0;
// 保存到活动历史记录
ActivityHistoryEntity activityEntity=new ActivityHistoryEntity();
@ -181,16 +178,25 @@ public class ActivityService{
activityEntity.setActivityStatus(activityForm.getActivityStatus().name());
//完成活动结算时间币
if(ActivityStatus.complete==activityForm.getActivityStatus()){
timeScore=activityHistoryMapper.getTimeScore(activityForm.getActivityId(),activityForm.getUserId());
logger.info("奖励时间币:"+timeScore);
int timeScore=activityHistoryMapper.getTimeScore(activityForm.getActivityId(),activityForm.getUserId());
logger.info("奖励用户"+activityForm.getUserId()+"时间币:"+timeScore);
activityEntity.setTimeScore(timeScore);
UserEntity userEntity=userMapper.findOne(activityEntity.getUserId());
timeScore+=userEntity.getTimeScore();
userEntity.setTimeScore(timeScore);
resultScore=timeScore+userEntity.getTimeScore();
userEntity.setTimeScore(resultScore);
if(!userMapper.update(userEntity)){
throw new RuntimeException("结算时间币失败");
}
ActivitySendUser activitySendUser=activityMapper.querySendUser(activityForm.getActivityId());
UserEntity sendUser=userMapper.findOne(activitySendUser.getUserId());
logger.info("扣除用户"+activitySendUser.getUserId()+"时间币"+timeScore);
sendUser.setTimeScore(sendUser.getTimeScore()-timeScore);
if(!userMapper.update(sendUser)){
throw new RuntimeException("扣除时间币失败");
}
}
if(!activityHistoryMapper.insert(activityEntity)){
throw new RuntimeException("保存活动历史记录失败");
@ -210,7 +216,7 @@ public class ActivityService{
if(!leaveWordMapper.insert(leaveWordEntity)){
throw new RuntimeException("保存留言信息失败");
}
return new JSONResponse<DefaultRes,Integer>(DefaultRes.ok,Result.OK).setBody(timeScore);
return new JSONResponse<DefaultRes,Integer>(DefaultRes.ok,Result.OK).setBody(resultScore);
}
/**

@ -80,7 +80,7 @@
activity.activity_start_time as activityStartTime,
activity.activity_end_time as activityEndTime,
activity.user_id as seekHelpUser,
group_concat(activity_history.user_id) as helpUser
group_concat(distinct activity_history.user_id) as helpUser
from activity_history,activity where activity.activity_id=activity_history.activity_id group by activity.activity_id
union all
select activity_id as activityId,
@ -185,4 +185,10 @@ limit #{start},#{count}
limit 0,3
</select>
<select id="querySendUser" resultType="com.share.help.res.ActivitySendUser">
select activity.activity_id as activityId, user.user_id as userId, user.time_score as timeScore
from activity,
user
where activity.activity_id =#{activityId} and activity.user_id=user.user_id
</select>
</mapper>

@ -7,6 +7,7 @@ import com.share.help.entity.UserEntity;
import com.share.help.entity.custorm.*;
import com.share.help.form.ActivityStatus;
import com.share.help.form.manager.ActiveUserRes;
import com.share.help.res.ActivitySendUser;
import com.share.help.res.ManagerActivityRes;
import com.share.help.res.Page;
import com.share.help.res.TimeScore;
@ -331,4 +332,11 @@ class HelpApplicationTests {
TimeScore timeScore= activityHistoryMapper.queryActivityHistory("123",65L);
Assertions.assertEquals(24, (int) timeScore.getTimeScore());
}
//测试查询时间币
@Test
public void testQuerySendUser(){
ActivitySendUser activitySendUser=activityMapper.querySendUser(63L);
Assertions.assertEquals(20,activitySendUser.getTimeScore());
}
}

Loading…
Cancel
Save