|
@@ -71,8 +71,25 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
private static final int NS_STATUS_NOT_ON_DUTY = -1;
|
|
private static final int NS_STATUS_NOT_ON_DUTY = -1;
|
|
|
private static final int DEFAULT_STAT_VALUE = 0;
|
|
private static final int DEFAULT_STAT_VALUE = 0;
|
|
|
private static final Integer NOT_DELETED = 0;
|
|
private static final Integer NOT_DELETED = 0;
|
|
|
- private static final String MERCHANT_STATUS_NORMAL = "0";
|
|
|
|
|
|
|
+ private static final Integer MERCHANT_STATUS_NORMAL = 0;
|
|
|
private static final String PASSWORD = "123456";
|
|
private static final String PASSWORD = "123456";
|
|
|
|
|
+ private static final int PROFILE_AUDIT_PENDING = 0;
|
|
|
|
|
+ private static final int PROFILE_AUDIT_APPROVED = 1;
|
|
|
|
|
+ private static final int PROFILE_AUDIT_REJECTED = 2;
|
|
|
|
|
+ private static final Set<String> PROFILE_FILE_TYPES = new LinkedHashSet<>(Arrays.asList(
|
|
|
|
|
+ PORTRAIT.getCode(),
|
|
|
|
|
+ LIFE_PHOTO.getCode(),
|
|
|
|
|
+ PROMOTION_VIDEO.getCode(),
|
|
|
|
|
+ ID_CARD_FRONT.getCode(),
|
|
|
|
|
+ ID_CARD_BACK.getCode(),
|
|
|
|
|
+ ID_CARD_HANDHELD.getCode(),
|
|
|
|
|
+ HEALTH_CERT.getCode(),
|
|
|
|
|
+ QUALIFICATION_CERT.getCode(),
|
|
|
|
|
+ NO_CRIME_RECORD.getCode(),
|
|
|
|
|
+ COMMITMENT_LETTER.getCode(),
|
|
|
|
|
+ COMMITMENT_AUDIO.getCode(),
|
|
|
|
|
+ COMMITMENT_VIDEO.getCode()
|
|
|
|
|
+ ));
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private MaTechnicianMapper maTechnicianMapper;
|
|
private MaTechnicianMapper maTechnicianMapper;
|
|
@@ -284,11 +301,510 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
throw new ServiceException("修改参数不能为空");
|
|
throw new ServiceException("修改参数不能为空");
|
|
|
}
|
|
}
|
|
|
MaTechnician technician = req.getTechnician();
|
|
MaTechnician technician = req.getTechnician();
|
|
|
- Integer merchantId = resolveMerchantId(technician);
|
|
|
|
|
- updateTechnicianBaseInfo(technician);
|
|
|
|
|
|
|
+ MerchantProfileSubmitDTO submitDTO = new MerchantProfileSubmitDTO();
|
|
|
|
|
+ submitDTO.setMerchantId(resolveMerchantId(technician));
|
|
|
|
|
+ if (technician != null) {
|
|
|
|
|
+ submitDTO.setNickName(technician.getTeNickName());
|
|
|
|
|
+ submitDTO.setBrief(technician.getTeBrief());
|
|
|
|
|
+ }
|
|
|
// 处理入驻资料文件
|
|
// 处理入驻资料文件
|
|
|
- List<MerchantApplyFileDto> files = resolveApplyFiles(req.getReq());
|
|
|
|
|
- replaceApplyFilesBySubmittedTypes(merchantId, files);
|
|
|
|
|
|
|
+ submitDTO.setFiles(req.getReq());
|
|
|
|
|
+ submitMerchantProfile(submitDTO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public MerchantProfileVO getMerchantProfile(Integer merchantId) {
|
|
|
|
|
+ MaTechnician merchant = getExistingMerchant(merchantId);
|
|
|
|
|
+ List<MerchantApplyFile> files = listMerchantApplyFiles(merchantId);
|
|
|
|
|
+ MerchantProfileVO profile = new MerchantProfileVO();
|
|
|
|
|
+ profile.setMerchantId(merchant.getId());
|
|
|
|
|
+ profile.setName(merchant.getTeName());
|
|
|
|
|
+ profile.setSex(merchant.getTeSex());
|
|
|
|
|
+ profile.setPhone(merchant.getTePhone());
|
|
|
|
|
+ profile.setAddress(merchant.getTeAddress());
|
|
|
|
|
+ profile.setAreaCode(merchant.getTeAreaCode());
|
|
|
|
|
+ profile.setAvatar(merchant.getTeAvatar());
|
|
|
|
|
+ profile.setNickName(buildTextItem(merchant.getTeNickName(), merchant.getPendingTeNickName(),
|
|
|
|
|
+ merchant.getTeNickNameAuditStatus(), merchant.getTeNickNameAuditRemark()));
|
|
|
|
|
+ profile.setBrief(buildTextItem(merchant.getTeBrief(), merchant.getPendingTeBrief(),
|
|
|
|
|
+ merchant.getTeBriefAuditStatus(), merchant.getTeBriefAuditRemark()));
|
|
|
|
|
+ profile.setFileGroups(buildFileGroups(files));
|
|
|
|
|
+ return profile;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void submitMerchantProfile(MerchantProfileSubmitDTO dto) {
|
|
|
|
|
+ if (dto == null) {
|
|
|
|
|
+ throw new ServiceException("修改参数不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ checkProfileSubmitParam(dto);
|
|
|
|
|
+ MaTechnician merchant = getExistingMerchant(dto.getMerchantId());
|
|
|
|
|
+ boolean changed = submitProfileTextFields(merchant, dto);
|
|
|
|
|
+ List<MerchantApplyFileDto> files = resolveApplyFiles(dto.getFiles());
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(files)) {
|
|
|
|
|
+ submitProfileFiles(merchant.getId(), files);
|
|
|
|
|
+ changed = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!changed) {
|
|
|
|
|
+ throw new ServiceException("请至少提交一项资料修改");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void checkProfileSubmitParam(MerchantProfileSubmitDTO dto) {
|
|
|
|
|
+ if (dto.getNickName() != null) {
|
|
|
|
|
+ checkProfileTextValue(dto.getNickName(), "昵称");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dto.getBrief() != null) {
|
|
|
|
|
+ checkProfileTextValue(dto.getBrief(), "简介");
|
|
|
|
|
+ }
|
|
|
|
|
+ resolveApplyFiles(dto.getFiles());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public int auditMerchantProfile(Integer merchantId, MerchantProfileAuditDTO dto, LoginUser loginUser) {
|
|
|
|
|
+ MaTechnician merchant = getExistingMerchant(merchantId);
|
|
|
|
|
+ if (dto != null && (AUDIT_APPROVED == dto.getAuditStatus() || AUDIT_REJECTED == dto.getAuditStatus())) {
|
|
|
|
|
+ String profileAuditRemark = dto.getAuditRemark() == null ? "" : dto.getAuditRemark().trim();
|
|
|
|
|
+ if (AUDIT_REJECTED == dto.getAuditStatus() && StringUtils.isBlank(profileAuditRemark)) {
|
|
|
|
|
+ throw new ServiceException("审核驳回时审核备注不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (AUDIT_APPROVED == dto.getAuditStatus()) {
|
|
|
|
|
+ checkProfileAuditExpirationDates(dto);
|
|
|
|
|
+ return approveAllPendingProfile(merchant, dto, profileAuditRemark, loginUser);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rejectAllPendingProfile(merchant, profileAuditRemark, loginUser);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dto == null) {
|
|
|
|
|
+ throw new ServiceException("审核参数不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ checkEnumValue(dto.getAuditStatus(), "审核状态", PROFILE_AUDIT_APPROVED, PROFILE_AUDIT_REJECTED);
|
|
|
|
|
+ String auditRemark = dto.getAuditRemark() == null ? "" : dto.getAuditRemark().trim();
|
|
|
|
|
+ if (PROFILE_AUDIT_REJECTED == dto.getAuditStatus() && StringUtils.isBlank(auditRemark)) {
|
|
|
|
|
+ throw new ServiceException("审核驳回时审核备注不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (PROFILE_AUDIT_APPROVED == dto.getAuditStatus() || PROFILE_AUDIT_REJECTED == dto.getAuditStatus()) {
|
|
|
|
|
+ throw new ServiceException("审核状态请使用2-审核通过或3-审核驳回");
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new ServiceException("审核资料类型不正确");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void checkProfileAuditExpirationDates(MerchantProfileAuditDTO dto) {
|
|
|
|
|
+ if (dto.getIdCardExpirationDate() == null
|
|
|
|
|
+ || dto.getHealthCertificateExpirationDate() == null
|
|
|
|
|
+ || dto.getQualificationCertificateExpirationDate() == null) {
|
|
|
|
|
+ throw new ServiceException("审核通过时,身份证到期日期、健康证到期日期、从业资格证到期日期不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int approveAllPendingProfile(MaTechnician merchant, MerchantProfileAuditDTO dto, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ List<MerchantApplyFile> pendingFiles = listPendingProfileFiles(merchant.getId());
|
|
|
|
|
+ boolean hasPendingText = hasPendingProfileText(merchant);
|
|
|
|
|
+ if (!hasPendingText && CollectionUtils.isEmpty(pendingFiles)) {
|
|
|
|
|
+ throw new ServiceException("当前商户没有待审核资料");
|
|
|
|
|
+ }
|
|
|
|
|
+ int rows = approveProfileTechnicianInfo(merchant, dto, auditRemark, loginUser);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(pendingFiles)) {
|
|
|
|
|
+ rows += approvePendingProfileFiles(merchant.getId(), pendingFiles, auditRemark, loginUser);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int rejectAllPendingProfile(MaTechnician merchant, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ List<MerchantApplyFile> pendingFiles = listPendingProfileFiles(merchant.getId());
|
|
|
|
|
+ boolean hasPendingText = hasPendingProfileText(merchant);
|
|
|
|
|
+ if (!hasPendingText && CollectionUtils.isEmpty(pendingFiles)) {
|
|
|
|
|
+ throw new ServiceException("当前商户没有待审核资料");
|
|
|
|
|
+ }
|
|
|
|
|
+ int rows = 0;
|
|
|
|
|
+ if (hasPendingText) {
|
|
|
|
|
+ rows += rejectProfileTextInfo(merchant, auditRemark, loginUser);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(pendingFiles)) {
|
|
|
|
|
+ rows += rejectPendingProfileFiles(merchant.getId(), auditRemark, loginUser);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean hasPendingProfileText(MaTechnician merchant) {
|
|
|
|
|
+ return Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeNickNameAuditStatus())
|
|
|
|
|
+ || Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeBriefAuditStatus());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<MerchantApplyFile> listPendingProfileFiles(Integer merchantId) {
|
|
|
|
|
+ LambdaQueryWrapper<MerchantApplyFile> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ queryWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_PENDING);
|
|
|
|
|
+ return merchantApplyFileMapper.selectList(queryWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int approveProfileTechnicianInfo(MaTechnician merchant, MerchantProfileAuditDTO dto, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ LambdaUpdateWrapper<MaTechnician> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ updateWrapper.eq(MaTechnician::getId, merchant.getId())
|
|
|
|
|
+ .set(MaTechnician::getIdCardExpirationDate, dto.getIdCardExpirationDate())
|
|
|
|
|
+ .set(MaTechnician::getHealthCertificateExpirationDate, dto.getHealthCertificateExpirationDate())
|
|
|
|
|
+ .set(MaTechnician::getQualificationCertificateExpirationDate, dto.getQualificationCertificateExpirationDate())
|
|
|
|
|
+ .set(MaTechnician::getUpdateBy, getAuditUserName(loginUser))
|
|
|
|
|
+ .set(MaTechnician::getUpdateTime, DateUtils.getNowDate());
|
|
|
|
|
+ if (Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeNickNameAuditStatus())) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getTeNickName, merchant.getPendingTeNickName())
|
|
|
|
|
+ .set(MaTechnician::getPendingTeNickName, null)
|
|
|
|
|
+ .set(MaTechnician::getTeNickNameAuditStatus, PROFILE_AUDIT_APPROVED)
|
|
|
|
|
+ .set(MaTechnician::getTeNickNameAuditRemark, auditRemark);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeBriefAuditStatus())) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getTeBrief, merchant.getPendingTeBrief())
|
|
|
|
|
+ .set(MaTechnician::getPendingTeBrief, null)
|
|
|
|
|
+ .set(MaTechnician::getTeBriefAuditStatus, PROFILE_AUDIT_APPROVED)
|
|
|
|
|
+ .set(MaTechnician::getTeBriefAuditRemark, auditRemark);
|
|
|
|
|
+ }
|
|
|
|
|
+ return maTechnicianMapper.update(null, updateWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int rejectProfileTextInfo(MaTechnician merchant, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ LambdaUpdateWrapper<MaTechnician> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ updateWrapper.eq(MaTechnician::getId, merchant.getId())
|
|
|
|
|
+ .set(MaTechnician::getUpdateBy, getAuditUserName(loginUser))
|
|
|
|
|
+ .set(MaTechnician::getUpdateTime, DateUtils.getNowDate());
|
|
|
|
|
+ if (Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeNickNameAuditStatus())) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getTeNickNameAuditStatus, PROFILE_AUDIT_REJECTED)
|
|
|
|
|
+ .set(MaTechnician::getTeNickNameAuditRemark, auditRemark);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeBriefAuditStatus())) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getTeBriefAuditStatus, PROFILE_AUDIT_REJECTED)
|
|
|
|
|
+ .set(MaTechnician::getTeBriefAuditRemark, auditRemark);
|
|
|
|
|
+ }
|
|
|
|
|
+ return maTechnicianMapper.update(null, updateWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int approvePendingProfileFiles(Integer merchantId, List<MerchantApplyFile> pendingFiles, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ Set<String> fileTypes = pendingFiles.stream()
|
|
|
|
|
+ .map(MerchantApplyFile::getFileType)
|
|
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
|
|
+ .collect(Collectors.toCollection(LinkedHashSet::new));
|
|
|
|
|
+ if (fileTypes.isEmpty()) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ String updateBy = getAuditUserName(loginUser);
|
|
|
|
|
+ LambdaUpdateWrapper<MerchantApplyFile> deleteOldWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ deleteOldWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .in(MerchantApplyFile::getFileType, fileTypes)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_APPROVED)
|
|
|
|
|
+ .set(MerchantApplyFile::getIsDelete, 1)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateBy, updateBy)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateTime, LocalDateTime.now());
|
|
|
|
|
+ int rows = merchantApplyFileMapper.update(null, deleteOldWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ LambdaUpdateWrapper<MerchantApplyFile> auditWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ auditWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_PENDING)
|
|
|
|
|
+ .set(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_APPROVED)
|
|
|
|
|
+ .set(MerchantApplyFile::getAuditRemark, auditRemark)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateBy, updateBy)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateTime, LocalDateTime.now());
|
|
|
|
|
+ return rows + merchantApplyFileMapper.update(null, auditWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int rejectPendingProfileFiles(Integer merchantId, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ LambdaUpdateWrapper<MerchantApplyFile> auditWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ auditWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_PENDING)
|
|
|
|
|
+ .set(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_REJECTED)
|
|
|
|
|
+ .set(MerchantApplyFile::getAuditRemark, auditRemark)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateBy, getAuditUserName(loginUser))
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateTime, LocalDateTime.now());
|
|
|
|
|
+ return merchantApplyFileMapper.update(null, auditWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private MaTechnician getExistingMerchant(Integer merchantId) {
|
|
|
|
|
+ if (merchantId == null) {
|
|
|
|
|
+ throw new ServiceException("商户ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ MaTechnician merchant = maTechnicianMapper.selectById(merchantId);
|
|
|
|
|
+ if (merchant == null || (merchant.getIsDelete() != null && !NOT_DELETED.equals(merchant.getIsDelete()))) {
|
|
|
|
|
+ throw new ServiceException("商户不存在或已删除");
|
|
|
|
|
+ }
|
|
|
|
|
+ return merchant;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提交文本资料
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param merchant
|
|
|
|
|
+ * @param dto
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean submitProfileTextFields(MaTechnician merchant, MerchantProfileSubmitDTO dto) {
|
|
|
|
|
+ boolean changed = false;
|
|
|
|
|
+ LambdaUpdateWrapper<MaTechnician> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ updateWrapper.eq(MaTechnician::getId, merchant.getId());
|
|
|
|
|
+
|
|
|
|
|
+ if (dto.getNickName() != null) {
|
|
|
|
|
+ String nickName = checkProfileTextValue(dto.getNickName(), "昵称");
|
|
|
|
|
+ if (PROFILE_AUDIT_PENDING == valueOrApproved(merchant.getTeNickNameAuditStatus())) {
|
|
|
|
|
+ throw new ServiceException("该资料正在审核中,请勿重复提交");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!nickName.equals(merchant.getTeNickName()) || PROFILE_AUDIT_REJECTED == valueOrApproved(merchant.getTeNickNameAuditStatus())) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getPendingTeNickName, nickName)
|
|
|
|
|
+ .set(MaTechnician::getTeNickNameAuditStatus, PROFILE_AUDIT_PENDING)
|
|
|
|
|
+ .set(MaTechnician::getTeNickNameAuditRemark, null);
|
|
|
|
|
+ changed = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (dto.getBrief() != null) {
|
|
|
|
|
+ String brief = checkProfileTextValue(dto.getBrief(), "简介");
|
|
|
|
|
+ if (PROFILE_AUDIT_PENDING == valueOrApproved(merchant.getTeBriefAuditStatus())) {
|
|
|
|
|
+ throw new ServiceException("该资料正在审核中,请勿重复提交");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!brief.equals(merchant.getTeBrief()) || PROFILE_AUDIT_REJECTED == valueOrApproved(merchant.getTeBriefAuditStatus())) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getPendingTeBrief, brief)
|
|
|
|
|
+ .set(MaTechnician::getTeBriefAuditStatus, PROFILE_AUDIT_PENDING)
|
|
|
|
|
+ .set(MaTechnician::getTeBriefAuditRemark, null);
|
|
|
|
|
+ changed = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (changed) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getUpdateTime, DateUtils.getNowDate());
|
|
|
|
|
+ int rows = maTechnicianMapper.update(null, updateWrapper);
|
|
|
|
|
+ if (rows <= 0) {
|
|
|
|
|
+ throw new ServiceException("提交商户资料审核失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return changed;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String checkProfileTextValue(String value, String fieldName) {
|
|
|
|
|
+ if (StringUtils.isBlank(value)) {
|
|
|
|
|
+ throw new ServiceException(fieldName + "不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ return value.trim();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int valueOrApproved(Integer status) {
|
|
|
|
|
+ return status == null ? PROFILE_AUDIT_APPROVED : status;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void submitProfileFiles(Integer merchantId, List<MerchantApplyFileDto> files) {
|
|
|
|
|
+ Map<String, List<MerchantApplyFileDto>> filesByType = files.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(MerchantApplyFileDto::getFileType, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
+ for (Map.Entry<String, List<MerchantApplyFileDto>> entry : filesByType.entrySet()) {
|
|
|
|
|
+ String fileType = entry.getKey();
|
|
|
|
|
+ checkProfileFileType(fileType);
|
|
|
|
|
+ if (hasPendingProfileFile(merchantId, fileType)) {
|
|
|
|
|
+ throw new ServiceException("该资料正在审核中,请勿重复提交");
|
|
|
|
|
+ }
|
|
|
|
|
+ deleteRejectedProfileFiles(merchantId, fileType);
|
|
|
|
|
+ String batchNo = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
+ for (MerchantApplyFileDto file : entry.getValue()) {
|
|
|
|
|
+ MerchantApplyFile applyFile = new MerchantApplyFile();
|
|
|
|
|
+ BeanUtils.copyProperties(file, applyFile);
|
|
|
|
|
+ applyFile.setMerchantId(merchantId);
|
|
|
|
|
+ applyFile.setApplyBatchNo(batchNo);
|
|
|
|
|
+ applyFile.setAuditStatus(PROFILE_AUDIT_PENDING);
|
|
|
|
|
+ applyFile.setAuditRemark(null);
|
|
|
|
|
+ applyFile.setCreateBy(merchantId.toString());
|
|
|
|
|
+ applyFile.setUpdateBy(merchantId.toString());
|
|
|
|
|
+ applyFile.setIsDelete(NOT_DELETED);
|
|
|
|
|
+ merchantApplyFileMapper.insert(applyFile);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void checkProfileFileType(String fileType) {
|
|
|
|
|
+ if (!PROFILE_FILE_TYPES.contains(fileType)) {
|
|
|
|
|
+ throw new ServiceException("资料文件类型不支持修改");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean hasPendingProfileFile(Integer merchantId, String fileType) {
|
|
|
|
|
+ LambdaQueryWrapper<MerchantApplyFile> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ queryWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .eq(MerchantApplyFile::getFileType, fileType)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_PENDING);
|
|
|
|
|
+ return merchantApplyFileMapper.selectCount(queryWrapper) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void deleteRejectedProfileFiles(Integer merchantId, String fileType) {
|
|
|
|
|
+ LambdaUpdateWrapper<MerchantApplyFile> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ updateWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .eq(MerchantApplyFile::getFileType, fileType)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_REJECTED)
|
|
|
|
|
+ .set(MerchantApplyFile::getIsDelete, 1)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateTime, LocalDateTime.now());
|
|
|
|
|
+ merchantApplyFileMapper.update(null, updateWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int auditProfileNickName(Integer merchantId, Integer auditStatus, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ MaTechnician merchant = getExistingMerchant(merchantId);
|
|
|
|
|
+ if (!Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeNickNameAuditStatus())) {
|
|
|
|
|
+ throw new ServiceException("昵称资料不是审核中状态");
|
|
|
|
|
+ }
|
|
|
|
|
+ LambdaUpdateWrapper<MaTechnician> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ updateWrapper.eq(MaTechnician::getId, merchantId)
|
|
|
|
|
+ .set(MaTechnician::getTeNickNameAuditStatus, auditStatus)
|
|
|
|
|
+ .set(MaTechnician::getTeNickNameAuditRemark, auditRemark)
|
|
|
|
|
+ .set(MaTechnician::getUpdateBy, getAuditUserName(loginUser))
|
|
|
|
|
+ .set(MaTechnician::getUpdateTime, DateUtils.getNowDate());
|
|
|
|
|
+ if (PROFILE_AUDIT_APPROVED == auditStatus) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getTeNickName, merchant.getPendingTeNickName())
|
|
|
|
|
+ .set(MaTechnician::getPendingTeNickName, null);
|
|
|
|
|
+ }
|
|
|
|
|
+ return maTechnicianMapper.update(null, updateWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int auditProfileBrief(Integer merchantId, Integer auditStatus, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ MaTechnician merchant = getExistingMerchant(merchantId);
|
|
|
|
|
+ if (!Integer.valueOf(PROFILE_AUDIT_PENDING).equals(merchant.getTeBriefAuditStatus())) {
|
|
|
|
|
+ throw new ServiceException("简介资料不是审核中状态");
|
|
|
|
|
+ }
|
|
|
|
|
+ LambdaUpdateWrapper<MaTechnician> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ updateWrapper.eq(MaTechnician::getId, merchantId)
|
|
|
|
|
+ .set(MaTechnician::getTeBriefAuditStatus, auditStatus)
|
|
|
|
|
+ .set(MaTechnician::getTeBriefAuditRemark, auditRemark)
|
|
|
|
|
+ .set(MaTechnician::getUpdateBy, getAuditUserName(loginUser))
|
|
|
|
|
+ .set(MaTechnician::getUpdateTime, DateUtils.getNowDate());
|
|
|
|
|
+ if (PROFILE_AUDIT_APPROVED == auditStatus) {
|
|
|
|
|
+ updateWrapper.set(MaTechnician::getTeBrief, merchant.getPendingTeBrief())
|
|
|
|
|
+ .set(MaTechnician::getPendingTeBrief, null);
|
|
|
|
|
+ }
|
|
|
|
|
+ return maTechnicianMapper.update(null, updateWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int auditProfileFile(Integer merchantId, String fileType, Integer auditStatus, String auditRemark, LoginUser loginUser) {
|
|
|
|
|
+ if (StringUtils.isBlank(fileType)) {
|
|
|
|
|
+ throw new ServiceException("文件类型不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ checkProfileFileType(fileType);
|
|
|
|
|
+ if (!hasPendingProfileFile(merchantId, fileType)) {
|
|
|
|
|
+ throw new ServiceException("该文件资料不是审核中状态");
|
|
|
|
|
+ }
|
|
|
|
|
+ String updateBy = getAuditUserName(loginUser);
|
|
|
|
|
+ if (PROFILE_AUDIT_APPROVED == auditStatus) {
|
|
|
|
|
+ LambdaUpdateWrapper<MerchantApplyFile> deleteOldWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ deleteOldWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .eq(MerchantApplyFile::getFileType, fileType)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_APPROVED)
|
|
|
|
|
+ .set(MerchantApplyFile::getIsDelete, 1)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateBy, updateBy)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateTime, LocalDateTime.now());
|
|
|
|
|
+ merchantApplyFileMapper.update(null, deleteOldWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+ LambdaUpdateWrapper<MerchantApplyFile> auditWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ auditWrapper.eq(MerchantApplyFile::getMerchantId, merchantId)
|
|
|
|
|
+ .eq(MerchantApplyFile::getFileType, fileType)
|
|
|
|
|
+ .eq(MerchantApplyFile::getAuditStatus, PROFILE_AUDIT_PENDING)
|
|
|
|
|
+ .set(MerchantApplyFile::getAuditStatus, auditStatus)
|
|
|
|
|
+ .set(MerchantApplyFile::getAuditRemark, auditRemark)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateBy, updateBy)
|
|
|
|
|
+ .set(MerchantApplyFile::getUpdateTime, LocalDateTime.now());
|
|
|
|
|
+ return merchantApplyFileMapper.update(null, auditWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String getAuditUserName(LoginUser loginUser) {
|
|
|
|
|
+ if (loginUser != null && loginUser.getUser() != null) {
|
|
|
|
|
+ return loginUser.getUser().getUserName();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private MerchantProfileTextItemVO buildTextItem(String value, String pendingValue, Integer auditStatus, String auditRemark) {
|
|
|
|
|
+ MerchantProfileTextItemVO item = new MerchantProfileTextItemVO();
|
|
|
|
|
+ item.setValue(value);
|
|
|
|
|
+ item.setPendingValue(pendingValue);
|
|
|
|
|
+ item.setAuditStatus(shouldShowAuditStatus(auditStatus) ? auditStatus : null);
|
|
|
|
|
+ item.setAuditStatusText(shouldShowAuditStatus(auditStatus) ? getProfileAuditStatusText(auditStatus) : null);
|
|
|
|
|
+ item.setAuditRemark(shouldShowAuditStatus(auditStatus) ? auditRemark : null);
|
|
|
|
|
+ item.setEditable(!Integer.valueOf(PROFILE_AUDIT_PENDING).equals(auditStatus));
|
|
|
|
|
+ return item;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<MerchantProfileFileGroupVO> buildFileGroups(List<MerchantApplyFile> files) {
|
|
|
|
|
+ Map<String, List<MerchantApplyFile>> filesByType = CollectionUtils.isEmpty(files)
|
|
|
|
|
+ ? Collections.emptyMap()
|
|
|
|
|
+ : files.stream()
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .filter(file -> PROFILE_FILE_TYPES.contains(file.getFileType()))
|
|
|
|
|
+ .collect(Collectors.groupingBy(MerchantApplyFile::getFileType, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
+ List<MerchantProfileFileGroupVO> groups = new ArrayList<>();
|
|
|
|
|
+ for (String fileType : PROFILE_FILE_TYPES) {
|
|
|
|
|
+ List<MerchantApplyFile> typeFiles = filesByType.getOrDefault(fileType, Collections.emptyList());
|
|
|
|
|
+ List<MerchantApplyFile> officialFiles = typeFiles.stream()
|
|
|
|
|
+ .filter(file -> Integer.valueOf(PROFILE_AUDIT_APPROVED).equals(file.getAuditStatus()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ List<MerchantApplyFile> pendingFiles = typeFiles.stream()
|
|
|
|
|
+ .filter(file -> !Integer.valueOf(PROFILE_AUDIT_APPROVED).equals(file.getAuditStatus()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ Integer auditStatus = resolveFileGroupAuditStatus(pendingFiles);
|
|
|
|
|
+ MerchantProfileFileGroupVO group = new MerchantProfileFileGroupVO();
|
|
|
|
|
+ group.setFileType(fileType);
|
|
|
|
|
+ group.setFileTypeName(FileTypeEnum.getDescByCode(fileType));
|
|
|
|
|
+ group.setOfficialFiles(toProfileFileVOList(officialFiles));
|
|
|
|
|
+ group.setPendingFiles(toProfileFileVOList(pendingFiles));
|
|
|
|
|
+ group.setAuditStatus(shouldShowAuditStatus(auditStatus) ? auditStatus : null);
|
|
|
|
|
+ group.setAuditStatusText(shouldShowAuditStatus(auditStatus) ? getProfileAuditStatusText(auditStatus) : null);
|
|
|
|
|
+ group.setAuditRemark(shouldShowAuditStatus(auditStatus) ? resolveFileGroupAuditRemark(pendingFiles) : null);
|
|
|
|
|
+ group.setEditable(!Integer.valueOf(PROFILE_AUDIT_PENDING).equals(auditStatus));
|
|
|
|
|
+ groups.add(group);
|
|
|
|
|
+ }
|
|
|
|
|
+ return groups;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Integer resolveFileGroupAuditStatus(List<MerchantApplyFile> pendingFiles) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(pendingFiles)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (pendingFiles.stream().anyMatch(file -> Integer.valueOf(PROFILE_AUDIT_PENDING).equals(file.getAuditStatus()))) {
|
|
|
|
|
+ return PROFILE_AUDIT_PENDING;
|
|
|
|
|
+ }
|
|
|
|
|
+ return pendingFiles.get(0).getAuditStatus();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String resolveFileGroupAuditRemark(List<MerchantApplyFile> pendingFiles) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(pendingFiles)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return pendingFiles.stream()
|
|
|
|
|
+ .map(MerchantApplyFile::getAuditRemark)
|
|
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
|
|
+ .findFirst()
|
|
|
|
|
+ .orElse(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<MerchantProfileFileVO> toProfileFileVOList(List<MerchantApplyFile> files) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(files)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return files.stream().map(this::toProfileFileVO).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private MerchantProfileFileVO toProfileFileVO(MerchantApplyFile file) {
|
|
|
|
|
+ MerchantProfileFileVO vo = new MerchantProfileFileVO();
|
|
|
|
|
+ vo.setId(file.getId());
|
|
|
|
|
+ vo.setFileName(file.getFileName());
|
|
|
|
|
+ vo.setFileUrl(file.getFileUrl());
|
|
|
|
|
+ vo.setFileSize(file.getFileSize());
|
|
|
|
|
+ vo.setContentType(file.getContentType());
|
|
|
|
|
+ vo.setApplyBatchNo(file.getApplyBatchNo());
|
|
|
|
|
+ vo.setAuditStatus(file.getAuditStatus());
|
|
|
|
|
+ vo.setAuditRemark(file.getAuditRemark());
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean shouldShowAuditStatus(Integer auditStatus) {
|
|
|
|
|
+ return auditStatus != null && !Integer.valueOf(PROFILE_AUDIT_APPROVED).equals(auditStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String getProfileAuditStatusText(Integer auditStatus) {
|
|
|
|
|
+ if (Integer.valueOf(PROFILE_AUDIT_PENDING).equals(auditStatus)) {
|
|
|
|
|
+ return "审核中";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Integer.valueOf(PROFILE_AUDIT_REJECTED).equals(auditStatus)) {
|
|
|
|
|
+ return "审核驳回";
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1127,7 +1643,8 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
if (StringUtils.isBlank(openid)) {
|
|
if (StringUtils.isBlank(openid)) {
|
|
|
throw new IllegalArgumentException("openid不能为空");
|
|
throw new IllegalArgumentException("openid不能为空");
|
|
|
}
|
|
}
|
|
|
- return buildMerchantAuditFile(findMerchantByOpenid(openid));
|
|
|
|
|
|
|
+ MaTechnician merchant = findMerchantByOpenid(openid);
|
|
|
|
|
+ return buildMerchantAuditFile(merchant);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|