Commit 5b06ace9 authored by luzhuang's avatar luzhuang

积分异常

parent 3ac0fbb8
...@@ -1694,6 +1694,12 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1694,6 +1694,12 @@ public class BLessonServiceImpl implements BLessonService {
log.debug("-----------------正在设置积分详情-------------------"); log.debug("-----------------正在设置积分详情-------------------");
UserUtil.setCurrentPersistOperation(bPersonValue); UserUtil.setCurrentPersistOperation(bPersonValue);
bPersonValueRepository.add(bPersonValue); bPersonValueRepository.add(bPersonValue);
long nowValue = bPersonValueRepository.findUserValue(personId);
if(nowValue < 0){
throw new ServiceException(ResultServiceEnums.VALUE_HAVE_ERROR);
}
//积分变化后 s_user表中value字段重新统计 //积分变化后 s_user表中value字段重新统计
int line = bPersonValueRepository.updateUserValue(personId, lockNum); int line = bPersonValueRepository.updateUserValue(personId, lockNum);
//TODO 判断返回值 抛异常 //TODO 判断返回值 抛异常
......
...@@ -79,5 +79,14 @@ public interface BPersonValueRepository extends BaseMapper<BPersonValue> { ...@@ -79,5 +79,14 @@ public interface BPersonValueRepository extends BaseMapper<BPersonValue> {
"( remarks,create_by,create_date,update_by,update_date,del_flag,flag,business_id,person_id,`event`,`value`,type ,lesson_id)" + "( remarks,create_by,create_date,update_by,update_date,del_flag,flag,business_id,person_id,`event`,`value`,type ,lesson_id)" +
" VALUES( #{remarks},#{createBy},#{createDate},#{updateBy},#{updateDate},#{delFlag},#{flag},#{businessId},#{personId},#{event},#{value},#{type} ,#{lessonId})") " VALUES( #{remarks},#{createBy},#{createDate},#{updateBy},#{updateDate},#{delFlag},#{flag},#{businessId},#{personId},#{event},#{value},#{type} ,#{lessonId})")
int add(BPersonValue bPersonValue); int add(BPersonValue bPersonValue);
/**
* 查询用户重新统计的积分
* @param personId
* @return
*/
@Select("SELECT ((select IFNULL((select sum(`value`) from b_person_value where del_flag != 1 and flag = 1 and type = 0 and person_id = #{personId}) ,0 )) -" +
"(select IFNULL((select sum(`value`) from b_person_value where del_flag != 1 and flag = 1 and type = 1 and person_id = #{personId}) ,0 ))) ")
Long findUserValue(@Param("personId")String personId);
} }
...@@ -58,6 +58,7 @@ public class BPersonValueServiceImpl implements BPersonValueService { ...@@ -58,6 +58,7 @@ public class BPersonValueServiceImpl implements BPersonValueService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public int add(PersonValueDto personValueDto,String corpId) { public int add(PersonValueDto personValueDto,String corpId) {
BPersonValue bPersonValue = new BPersonValue(); BPersonValue bPersonValue = new BPersonValue();
BeanUtils.copyProperties(personValueDto, bPersonValue); BeanUtils.copyProperties(personValueDto, bPersonValue);
...@@ -81,6 +82,12 @@ public class BPersonValueServiceImpl implements BPersonValueService { ...@@ -81,6 +82,12 @@ public class BPersonValueServiceImpl implements BPersonValueService {
bPersonValue.setEvent(sysUser.getName()+"发放积分"); bPersonValue.setEvent(sysUser.getName()+"发放积分");
}else if("1".equals(personValueDto.getType())){ }else if("1".equals(personValueDto.getType())){
bPersonValue.setEvent(sysUser.getName()+"扣除积分"); bPersonValue.setEvent(sysUser.getName()+"扣除积分");
long nowValue = bPersonValueRepository.findUserValue(personValueDto.getPersonId());
if(nowValue < 0){
throw new ServiceException(ResultServiceEnums.VALUE_HAVE_ERROR);
}
//扣减时先判断 当前积分是否大于扣减积分 //扣减时先判断 当前积分是否大于扣减积分
Long x = bPersonValueRepository.judgeUserValue(personValueDto.getPersonId(),personValueDto.getValue()); Long x = bPersonValueRepository.judgeUserValue(personValueDto.getPersonId(),personValueDto.getValue());
if(x < 0){ if(x < 0){
......
...@@ -257,6 +257,7 @@ public enum ResultServiceEnums { ...@@ -257,6 +257,7 @@ public enum ResultServiceEnums {
FILE_OVER_PAGES(157,"文件页数超过规定个数"), FILE_OVER_PAGES(157,"文件页数超过规定个数"),
FILE_CHECK_ERROR(158,"文件格式与后缀名不符,请上传其他文件"), FILE_CHECK_ERROR(158,"文件格式与后缀名不符,请上传其他文件"),
NOT_FILE(159,"未选择上传文件"), NOT_FILE(159,"未选择上传文件"),
VALUE_HAVE_ERROR(160,"积分异常,请联系管理员"),
; ;
private Integer code; private Integer code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment