Browse Source

积分相关修改

master
zhaoqifeng 3 years ago
parent
commit
110aef3278
  1. 103
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointApplyServiceImpl.java

103
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<PointApplyDao, PointA
item.setShowName(userInfo.getShowName());
item.setStatus(ApplyStatusEnum.getName(item.getStatus()));
}
//获取网格信息
//从缓存获取网格信息
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(item.getGridId());
if (null != gridInfo) {
item.setGridName(gridInfo.getGridName());
}
});
}
return new PageData<>(list, pageInfo.getTotal());
@ -208,49 +215,65 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA
*/
@Override
public void audit(TokenDto tokenDto, PointAuditFormDTO formDTO) {
//更新审核状态
PointApplyEntity entity = ConvertUtils.sourceToTarget(formDTO, PointApplyEntity.class);
baseDao.updateById(entity);
String subjectId;
//获取积分申请信息
PointApplyDTO dto = get(formDTO.getId());
if (CommonConstant.MORAL_EDUCATION.equals(dto.getCategoryCode())) {
subjectId = dto.getHouseId();
} else {
subjectId = dto.getUserId();
if (StringUtils.isBlank(formDTO.getId()) && CollectionUtils.isEmpty(formDTO.getIds())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "请选择待审核的申请", "请选择待审核的申请");
}
//生成积分记录
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<PointAditiveCalcEntity> 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<String> 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<PointAditiveCalcEntity> 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);
}
}
});
}
}
Loading…
Cancel
Save