diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointApplyServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointApplyServiceImpl.java index 51588a6586..33065999d5 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointApplyServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointApplyServiceImpl.java @@ -41,6 +41,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -79,6 +80,12 @@ public class PointApplyServiceImpl extends BaseServiceImpl(list, pageInfo.getTotal()); @@ -208,49 +215,65 @@ public class PointApplyServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PointAditiveCalcEntity::getCustomerId, tokenDto.getCustomerId()); - wrapper.eq(PointAditiveCalcEntity::getSubjectId, subjectId); - wrapper.eq(PointAditiveCalcEntity::getCategoryCode, dto.getCategoryCode()); - PointAditiveCalcEntity calc = pointAditiveCalcDao.selectOne(wrapper); - if (null != calc) { - calc.setUpdatedBy(null); - calc.setUpdatedTime(null); - calc.setTotal(calc.getTotal() + dto.getPointValue()); - pointAditiveCalcDao.updateById(calc); + List ids = new ArrayList<>(); + if (CollectionUtils.isEmpty(formDTO.getIds())) { + ids.add(formDTO.getId()); } else { - calc = new PointAditiveCalcEntity(); - calc.setCustomerId(tokenDto.getCustomerId()); - calc.setCategoryCode(dto.getCategoryCode()); - calc.setSubjectId(subjectId); - calc.setSpend(NumConstant.ZERO); - calc.setTotal(dto.getPointValue()); - pointAditiveCalcDao.insert(calc); + ids = formDTO.getIds(); } + ids.forEach(id -> { + //获取积分申请信息 + PointApplyDTO dto = get(id); + if (NumConstant.ZERO_STR.equals(dto.getStatus())) { + //更新审核状态 + PointApplyEntity entity = ConvertUtils.sourceToTarget(formDTO, PointApplyEntity.class); + baseDao.updateById(entity); + + String subjectId; + + if (CommonConstant.MORAL_EDUCATION.equals(dto.getCategoryCode())) { + subjectId = dto.getHouseId(); + } else { + subjectId = dto.getUserId(); + } + //生成积分记录 + PointAditiveRecordEntity record = new PointAditiveRecordEntity(); + record.setCustomerId(tokenDto.getCustomerId()); + record.setTitle(dto.getTitle()); + record.setStatement(dto.getStatement()); + record.setPointValue(dto.getPointValue()); + record.setCategoryCode(dto.getCategoryCode()); + record.setSubjectId(subjectId); + record.setBusinessId(dto.getId()); + record.setBusinessCode(CommonConstant.POINT_APPLY); + pointAditiveRecordDao.insert(record); + //重新计算总分 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(PointAditiveCalcEntity::getCustomerId, tokenDto.getCustomerId()); + wrapper.eq(PointAditiveCalcEntity::getSubjectId, subjectId); + wrapper.eq(PointAditiveCalcEntity::getCategoryCode, dto.getCategoryCode()); + PointAditiveCalcEntity calc = pointAditiveCalcDao.selectOne(wrapper); + if (null != calc) { + calc.setUpdatedBy(null); + calc.setUpdatedTime(null); + calc.setTotal(calc.getTotal() + dto.getPointValue()); + pointAditiveCalcDao.updateById(calc); + } else { + calc = new PointAditiveCalcEntity(); + calc.setCustomerId(tokenDto.getCustomerId()); + calc.setCategoryCode(dto.getCategoryCode()); + calc.setSubjectId(subjectId); + calc.setSpend(NumConstant.ZERO); + calc.setTotal(dto.getPointValue()); + pointAditiveCalcDao.insert(calc); + } + } + }); + + } } \ No newline at end of file