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