|
|
|
@ -4,9 +4,11 @@ import com.share.help.Util; |
|
|
|
|
import com.share.help.dao.ActivityHistoryMapper; |
|
|
|
|
import com.share.help.dao.ActivityMapper; |
|
|
|
|
import com.share.help.dao.LeaveWordMapper; |
|
|
|
|
import com.share.help.dao.UserMapper; |
|
|
|
|
import com.share.help.entity.ActivityEntity; |
|
|
|
|
import com.share.help.entity.ActivityHistoryEntity; |
|
|
|
|
import com.share.help.entity.LeaveWordEntity; |
|
|
|
|
import com.share.help.entity.UserEntity; |
|
|
|
|
import com.share.help.entity.custorm.*; |
|
|
|
|
import com.share.help.form.*; |
|
|
|
|
import com.share.help.res.*; |
|
|
|
@ -48,6 +50,8 @@ public class ActivityService{ |
|
|
|
|
@Value("${page-size.help}") |
|
|
|
|
private int helpPageSize; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(ActivityService.class); |
|
|
|
|
|
|
|
|
@ -113,16 +117,26 @@ public class ActivityService{ |
|
|
|
|
* @return 返回报名结果 |
|
|
|
|
*/ |
|
|
|
|
@Transactional |
|
|
|
|
public JSONResponse<DefaultRes,Void> apply(UpdateActivityForm activityForm){ |
|
|
|
|
public JSONResponse<DefaultRes,Void> apply(UpdateActivityForm activityForm) throws RuntimeException{ |
|
|
|
|
// 保存到活动历史记录
|
|
|
|
|
ActivityHistoryEntity activityEntity=new ActivityHistoryEntity(); |
|
|
|
|
activityEntity.setActivityId(activityForm.getActivityId()); |
|
|
|
|
activityEntity.setUserId(activityForm.getUserId()); |
|
|
|
|
activityEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); |
|
|
|
|
activityEntity.setActivityStatus(activityForm.getActivityStatus().name()); |
|
|
|
|
//完成活动结算时间币
|
|
|
|
|
if(ActivityStatus.complete==activityForm.getActivityStatus()){ |
|
|
|
|
int timeScore=activityHistoryMapper.getTimeScore(activityForm.getActivityId(),activityForm.getUserId()); |
|
|
|
|
logger.info("奖励时间币:"+timeScore); |
|
|
|
|
activityEntity.setTimeScore(timeScore); |
|
|
|
|
UserEntity userEntity=userMapper.findOne(activityEntity.getUserId()); |
|
|
|
|
userEntity.setTimeScore(userEntity.getTimeScore()+timeScore); |
|
|
|
|
if(!userMapper.update(userEntity)){ |
|
|
|
|
throw new RuntimeException("结算时间币失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(!activityHistoryMapper.insert(activityEntity)){ |
|
|
|
|
logger.error("保存活动历史记录失败"); |
|
|
|
|
return new JSONResponse<>(DefaultRes.fail,Result.FAIL); |
|
|
|
|
throw new RuntimeException("保存活动历史记录失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 给求助用户发送留言
|
|
|
|
@ -131,15 +145,13 @@ public class ActivityService{ |
|
|
|
|
leaveWordEntity.setSourceUserId(activityForm.getUserId()); |
|
|
|
|
ActivityEntity activity=activityMapper.findOne(activityForm.getActivityId()); |
|
|
|
|
if(activity==null){ |
|
|
|
|
logger.error("查询活动记录失败"); |
|
|
|
|
return new JSONResponse<>(DefaultRes.fail,Result.FAIL); |
|
|
|
|
throw new RuntimeException("查询活动记录失败"); |
|
|
|
|
} |
|
|
|
|
leaveWordEntity.setTargetUserId(activity.getUserId()); |
|
|
|
|
leaveWordEntity.setActivityId(activityForm.getActivityId()); |
|
|
|
|
leaveWordEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); |
|
|
|
|
if(!leaveWordMapper.insert(leaveWordEntity)){ |
|
|
|
|
logger.error("保存留言信息失败"); |
|
|
|
|
return new JSONResponse<>(DefaultRes.fail,Result.FAIL); |
|
|
|
|
throw new RuntimeException("保存留言信息失败"); |
|
|
|
|
} |
|
|
|
|
return new JSONResponse<>(DefaultRes.ok,Result.OK); |
|
|
|
|
} |
|
|
|
|