|
|
@ -29,25 +29,28 @@ import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationEnum; |
|
|
|
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationModeEnum; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dao.PointsLogsDao; |
|
|
|
import com.elink.esua.epdc.dto.EpdcAdjustUserPointsDTO; |
|
|
|
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.PointsLogsDTO; |
|
|
|
import com.elink.esua.epdc.dto.UserDTO; |
|
|
|
import com.elink.esua.epdc.dto.constant.PointsNoticeConstant; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.*; |
|
|
|
import com.elink.esua.epdc.dto.result.*; |
|
|
|
import com.elink.esua.epdc.entity.PointsLogsEntity; |
|
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
|
import com.elink.esua.epdc.feign.UsersFeignClient; |
|
|
|
import com.elink.esua.epdc.redis.PointsLogsRedis; |
|
|
|
import com.elink.esua.epdc.service.PointsBehaviorService; |
|
|
|
import com.elink.esua.epdc.service.PointsLogsService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -63,6 +66,7 @@ import java.util.stream.Collectors; |
|
|
|
* @since v1.0.0 2020-04-29 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, PointsLogsEntity> implements PointsLogsService { |
|
|
|
|
|
|
|
@Autowired |
|
|
@ -71,6 +75,9 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points |
|
|
|
@Autowired |
|
|
|
private UsersFeignClient usersFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PointsBehaviorService pointsBehaviorService; |
|
|
|
|
|
|
@ -376,4 +383,114 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points |
|
|
|
usersFeignClient.resetUserPoints(); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<PointsLogsResultDTO> listOfPointsLogs(PointsExchangeLogsFormDTO formDto) { |
|
|
|
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); |
|
|
|
formDto.setPageIndex(pageIndex); |
|
|
|
return baseDao.selectListOfPointsLogs(formDto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result pointsVerification(EpdcWorkPointsVerificationFormDTO formDto) { |
|
|
|
if (null == SecurityUser.getUser() || null == SecurityUser.getDeptId()) { |
|
|
|
throw new RenException("登陆信息超时,请重新登陆"); |
|
|
|
} |
|
|
|
// 获取用户信息
|
|
|
|
EpdcUserPointsFormDTO userPointsFormDTO = new EpdcUserPointsFormDTO(); |
|
|
|
userPointsFormDTO.setUserId(formDto.getUserId()); |
|
|
|
userPointsFormDTO.setPoints(formDto.getPoints()); |
|
|
|
userPointsFormDTO.setOperationType(formDto.getOperationType()); |
|
|
|
Result<UserDTO> userById = usersFeignClient.getUserById(formDto.getUserId()); |
|
|
|
if (!userById.success()) { |
|
|
|
return new Result().error("获取用户信息失败"); |
|
|
|
} |
|
|
|
|
|
|
|
Result<UserDTO> result = usersFeignClient.handleUserPoints(userPointsFormDTO); |
|
|
|
if (!result.success()) { |
|
|
|
return new Result().error(result.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
// 保存积分日志
|
|
|
|
PointsLogsEntity pointsLogsEntity = packagePointsLogs(userById.getData(), formDto); |
|
|
|
this.insert(pointsLogsEntity); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 组装积分日志信息 |
|
|
|
* |
|
|
|
* @param userDto 用户信息 |
|
|
|
* @param formDto 表单信息 |
|
|
|
* @return com.elink.esua.epdc.entity.PointsLogsEntity |
|
|
|
* @author Liuchuang |
|
|
|
* @since 2021/1/19 16:14 |
|
|
|
*/ |
|
|
|
private PointsLogsEntity packagePointsLogs(UserDTO userDto, EpdcWorkPointsVerificationFormDTO formDto) { |
|
|
|
//根据动作编码获取动作信息
|
|
|
|
Result<BehaviorResultDto> behaviorCodeInfoByBehaviorCode = pointsBehaviorService.getBehaviorCodeInfoByBehaviorCode(PointsConstant.behaviorWorkScanCodePointsVerification); |
|
|
|
PointsLogsEntity pointsLogsEntity = new PointsLogsEntity(); |
|
|
|
pointsLogsEntity.setUserId(formDto.getUserId()); |
|
|
|
pointsLogsEntity.setNickname(userDto.getNickname()); |
|
|
|
pointsLogsEntity.setFaceImg(userDto.getFaceImg()); |
|
|
|
pointsLogsEntity.setOperationTime(new Date()); |
|
|
|
pointsLogsEntity.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_WORK_JFHX.getOperationMode()); |
|
|
|
pointsLogsEntity.setRuleCode(PointsConstant.ruleWorkScanCodePointsVerification); |
|
|
|
pointsLogsEntity.setBehaviorCode(PointsConstant.behaviorWorkScanCodePointsVerification); |
|
|
|
pointsLogsEntity.setOperationDesc(behaviorCodeInfoByBehaviorCode.getData().getBehaviorDesc()); |
|
|
|
pointsLogsEntity.setPoints(formDto.getPoints()); |
|
|
|
pointsLogsEntity.setOperationType(formDto.getOperationType()); |
|
|
|
pointsLogsEntity.setReferenceId(formDto.getUserId()); |
|
|
|
if("0".equals(formDto.getOperationType())){ |
|
|
|
pointsLogsEntity.setLavePoints(userDto.getPoints() - formDto.getPoints()); |
|
|
|
}else { |
|
|
|
pointsLogsEntity.setLavePoints(userDto.getPoints() + formDto.getPoints()); |
|
|
|
} |
|
|
|
pointsLogsEntity.setRemark(formDto.getRemark()); |
|
|
|
pointsLogsEntity.setRealName(userDto.getRealName()); |
|
|
|
|
|
|
|
// 赋值积分所属部门
|
|
|
|
Result<Long> userGridIdByUserId = usersFeignClient.getUserGridIdByUserId(formDto.getUserId()); |
|
|
|
Result<ParentAndAllDeptDTO> parentAndAllDept = adminFeignClient.getParentAndAllDept(userGridIdByUserId.getData()); |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDept.getData(); |
|
|
|
pointsLogsEntity.setGrid(parentAndAllDeptDTO.getGrid()); |
|
|
|
pointsLogsEntity.setGridId(parentAndAllDeptDTO.getGridId()); |
|
|
|
pointsLogsEntity.setAllDeptIds(parentAndAllDeptDTO.getAllDeptIds()); |
|
|
|
pointsLogsEntity.setAllDeptNames(parentAndAllDeptDTO.getAllDeptNames()); |
|
|
|
pointsLogsEntity.setParentDeptIds(parentAndAllDeptDTO.getParentDeptIds()); |
|
|
|
pointsLogsEntity.setParentDeptNames(parentAndAllDeptDTO.getParentDeptNames()); |
|
|
|
|
|
|
|
// 组装操作人信息
|
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
Result<String> currentUserDept = adminFeignClient.getParentDeptIds(user.getDeptId()); |
|
|
|
pointsLogsEntity.setCreatedDeptAllDeptIds(currentUserDept.getData()); |
|
|
|
pointsLogsEntity.setCreatedDept(user.getDeptName()); |
|
|
|
pointsLogsEntity.setCreatedDeptId(user.getDeptId()); |
|
|
|
|
|
|
|
return pointsLogsEntity; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public EpdcVerificationLogsResultDTO listOfVerificationLogs(EpdcWorkVerificationLogsFormDTO formDto) { |
|
|
|
log.info("+++++++++++++++++++++++++++++++++++=SecurityUserDeptId():" + SecurityUser.getDeptId()); |
|
|
|
if (null == SecurityUser.getUser() || null == SecurityUser.getDeptId()) { |
|
|
|
throw new RenException("登陆信息超时,请重新登陆"); |
|
|
|
} |
|
|
|
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); |
|
|
|
formDto.setPageIndex(pageIndex); |
|
|
|
formDto.setCurrentUserDeptId(SecurityUser.getDeptId()); |
|
|
|
formDto.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_WORK_JFHX.getOperationMode()); |
|
|
|
|
|
|
|
// 核销记录
|
|
|
|
List<PointsLogsResultDTO> verificationLogs = baseDao.selectListOfVerificationLogs(formDto); |
|
|
|
// 核销总积分
|
|
|
|
Integer pointsTotal = baseDao.selectCountOfVerificationLogs(formDto); |
|
|
|
|
|
|
|
EpdcVerificationLogsResultDTO data = new EpdcVerificationLogsResultDTO(); |
|
|
|
data.setPointsTotal(pointsTotal); |
|
|
|
data.setVerificationLogs(verificationLogs); |
|
|
|
|
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
|