|
|
@ -1,28 +1,40 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.common.CommonConstant; |
|
|
|
import com.epmet.common.enu.ApplyStatusEnum; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.enums.GenderEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.PointAditiveCalcDao; |
|
|
|
import com.epmet.dao.PointAditiveRecordDao; |
|
|
|
import com.epmet.dao.PointAnnexDao; |
|
|
|
import com.epmet.dao.PointApplyDao; |
|
|
|
import com.epmet.dto.PointApplyDTO; |
|
|
|
import com.epmet.dto.form.PointApplyFormDTO; |
|
|
|
import com.epmet.dto.form.PointApplyPageFormDTO; |
|
|
|
import com.epmet.dto.form.PointAuditFormDTO; |
|
|
|
import com.epmet.dto.result.HomeInfoResultDTO; |
|
|
|
import com.epmet.entity.PointAditiveCalcEntity; |
|
|
|
import com.epmet.entity.PointAditiveRecordEntity; |
|
|
|
import com.epmet.entity.PointAnnexEntity; |
|
|
|
import com.epmet.entity.PointApplyEntity; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.service.PointApplyService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -47,14 +59,29 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Resource |
|
|
|
private PointAnnexDao pointAnnexDao; |
|
|
|
@Resource |
|
|
|
private PointAditiveRecordDao pointAditiveRecordDao; |
|
|
|
@Resource |
|
|
|
private PointAditiveCalcDao pointAditiveCalcDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<PointApplyDTO> page(Map<String, Object> params) { |
|
|
|
IPage<PointApplyEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, PointApplyDTO.class); |
|
|
|
public PageData<PointApplyDTO> page(PointApplyPageFormDTO formDTO) { |
|
|
|
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); |
|
|
|
List<PointApplyDTO> list = baseDao.getList(formDTO); |
|
|
|
PageInfo<PointApplyDTO> pageInfo = new PageInfo<>(list); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
list.forEach(item -> { |
|
|
|
//获取居民信息
|
|
|
|
ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(item.getUserId()); |
|
|
|
if (null != userInfo) { |
|
|
|
item.setHeadImgUrl(userInfo.getHeadImgUrl()); |
|
|
|
item.setGender(GenderEnum.getName(userInfo.getGender())); |
|
|
|
item.setShowName(userInfo.getShowName()); |
|
|
|
item.setStatus(ApplyStatusEnum.getName(item.getStatus())); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -75,8 +102,18 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA |
|
|
|
|
|
|
|
@Override |
|
|
|
public PointApplyDTO get(String id) { |
|
|
|
PointApplyEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, PointApplyDTO.class); |
|
|
|
PointApplyDTO dto = baseDao.getDetail(id); |
|
|
|
if (null == dto) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "内容不存在", "内容不存在"); |
|
|
|
} |
|
|
|
//获取居民信息
|
|
|
|
ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(dto.getUserId()); |
|
|
|
if (null == userInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民信息失败", "获取居民信息失败"); |
|
|
|
} |
|
|
|
dto.setHeadImgUrl(userInfo.getHeadImgUrl()); |
|
|
|
dto.setShowName(userInfo.getShowName()); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -128,10 +165,18 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA |
|
|
|
} |
|
|
|
entity.setHouseId(result.getData().getHouseId()); |
|
|
|
} |
|
|
|
//获取居民信息
|
|
|
|
ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(formDTO.getUserId()); |
|
|
|
if (null == userInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民信息失败", "获取居民信息失败"); |
|
|
|
} |
|
|
|
|
|
|
|
entity.setAgencyId(gridInfo.getPid()); |
|
|
|
entity.setAgencyPids(gridInfo.getPids()); |
|
|
|
entity.setStatus(ApplyStatusEnum.AUDITING.getCode()); |
|
|
|
entity.setName(userInfo.getName()); |
|
|
|
entity.setMobile(userInfo.getMobile()); |
|
|
|
entity.setIdCard(userInfo.getIdNum()); |
|
|
|
baseDao.insert(entity); |
|
|
|
|
|
|
|
//保存附件
|
|
|
@ -150,4 +195,62 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 审核 |
|
|
|
* |
|
|
|
* @param tokenDto |
|
|
|
* @param formDTO |
|
|
|
* @Param tokenDto |
|
|
|
* @Param formDTO |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/6/15 15:20 |
|
|
|
*/ |
|
|
|
@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(); |
|
|
|
} |
|
|
|
//生成积分记录
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |