|
@@ -4,22 +4,24 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.microsvc.toolkit.common.webportal.exception.BizException;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.activity.ActivityTeacherQuery;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SmsCodeService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
|
|
|
+import com.yonge.cooleshow.biz.dal.mapper.TenantEntryRecordMapper;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TenantApplyRecord;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantApplyRecordWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantApplyRecordMapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantApplyRecordService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 机构入驻申请记录
|
|
@@ -36,6 +38,18 @@ public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordM
|
|
|
@Autowired
|
|
|
private SmsCodeService smsCodeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysAreaService sysAreaService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TenantApplyRecordMapper tenantApplyRecordMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TenantEntryRecordMapper tenantEntryRecordMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TenantInfoService tenantInfoService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询详情
|
|
|
* @param id 详情ID
|
|
@@ -54,9 +68,10 @@ public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordM
|
|
|
* @return IPage<TenantApplyRecord>
|
|
|
*/
|
|
|
@Override
|
|
|
- public IPage<TenantApplyRecord> selectPage(IPage<TenantApplyRecord> page, TenantApplyRecordWrapper.TenantApplyRecordQuery query) {
|
|
|
-
|
|
|
- return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
+ public IPage<TenantApplyRecordWrapper.TenantApplyRecord> selectPage(IPage<TenantApplyRecordWrapper.TenantApplyRecord> page, TenantApplyRecordWrapper.TenantApplyRecordQuery query) {
|
|
|
+ List<TenantApplyRecordWrapper.TenantApplyRecord> records = baseMapper.selectPage(page, query);
|
|
|
+ List<TenantApplyRecordWrapper.TenantApplyRecord> infos = queryArea(records);
|
|
|
+ return page.setRecords(infos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -127,4 +142,137 @@ public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordM
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<TenantApplyRecordWrapper.TenantApply> historyPage(IPage<TenantApplyRecordWrapper.TenantApply> page, TenantApplyRecordWrapper.TenantApplyRecordQuery query) {
|
|
|
+ long id = query.getId();
|
|
|
+ //分页查询
|
|
|
+ List<TenantApplyRecordWrapper.TenantApply> tenantInfos = baseMapper.selectHistoryPage(page, id);
|
|
|
+ //查询对应省市区
|
|
|
+ List<Integer> areaCodeList = tenantInfos.stream().map(next -> {
|
|
|
+ Set<Integer> codes = new HashSet<>();
|
|
|
+ codes.add(next.getCityCode());
|
|
|
+ codes.add(next.getProvinceCode());
|
|
|
+ codes.add(next.getRegionCode());
|
|
|
+ return codes;
|
|
|
+ }).flatMap(Collection::stream).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, String> codeNameMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(areaCodeList)) {
|
|
|
+ List<SysArea> sysAreaList = sysAreaService.queryByCodes(areaCodeList);
|
|
|
+ codeNameMap = sysAreaList.stream().collect(Collectors.toMap(SysArea::getCode,
|
|
|
+ SysArea::getName));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (TenantApplyRecordWrapper.TenantApply next : tenantInfos) {
|
|
|
+ next.setProvinceName(codeNameMap.getOrDefault(next.getProvinceCode(), ""));
|
|
|
+ next.setCityName(codeNameMap.getOrDefault(next.getCityCode(), ""));
|
|
|
+ next.setRegionName(codeNameMap.getOrDefault(next.getRegionCode(), ""));
|
|
|
+ }
|
|
|
+
|
|
|
+ return page.setRecords(tenantInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TenantApplyRecordWrapper.TenantApplyRecord queryNow(TenantApplyRecordWrapper.TenantApplyRecordQuery query) {
|
|
|
+ //查询本次提交记录
|
|
|
+ TenantApplyRecordWrapper.TenantApplyRecord info = baseMapper.queryNow(query);
|
|
|
+ Set<Integer> codes = new HashSet<>();
|
|
|
+ codes.add(info.getCityCode());
|
|
|
+ codes.add(info.getProvinceCode());
|
|
|
+ codes.add(info.getRegionCode());
|
|
|
+
|
|
|
+ //将地区码转化为对应的地名
|
|
|
+ List<Integer> areaCodeList = new ArrayList<>();
|
|
|
+ areaCodeList.addAll(codes);
|
|
|
+
|
|
|
+ Map<Integer, String> codeNameMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(areaCodeList)) {
|
|
|
+ List<SysArea> sysAreaList = sysAreaService.queryByCodes(areaCodeList);
|
|
|
+ codeNameMap = sysAreaList.stream().collect(Collectors.toMap(SysArea::getCode,
|
|
|
+ SysArea::getName));
|
|
|
+ }
|
|
|
+
|
|
|
+ info.setProvinceName(codeNameMap.get(info.getProvinceCode()));
|
|
|
+ info.setCityName(codeNameMap.get(info.getCityCode()));
|
|
|
+ info.setRegionName(codeNameMap.get(info.getRegionCode()));
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean entry(TenantApplyRecordWrapper.TenantEntry entry,Long verifyUserId) {
|
|
|
+ Boolean ifPass = entry.getIfPass();
|
|
|
+ Long id = entry.getId();
|
|
|
+ TenantApplyRecord applyRecord = tenantApplyRecordMapper.selectById(id);
|
|
|
+ TenantEntryRecord entryRecord = new TenantEntryRecord();
|
|
|
+
|
|
|
+ entryRecord.setTenantApplyRecordId(applyRecord.getId());
|
|
|
+ entryRecord.setName(applyRecord.getName());
|
|
|
+ entryRecord.setLogo(applyRecord.getLogo());
|
|
|
+ entryRecord.setProvinceCode(applyRecord.getProvinceCode());
|
|
|
+ entryRecord.setCityCode(applyRecord.getCityCode());
|
|
|
+ entryRecord.setRegionCode(applyRecord.getRegionCode());
|
|
|
+ entryRecord.setUsername(applyRecord.getUsername());
|
|
|
+ entryRecord.setPhone(applyRecord.getPhone());
|
|
|
+ entryRecord.setVerifyUserId(verifyUserId);
|
|
|
+ entryRecord.setReason(entry.getReason());
|
|
|
+ if (ifPass == true){
|
|
|
+ entryRecord.setStatus("PASS");
|
|
|
+ //更改当前记录的审核状态
|
|
|
+ tenantApplyRecordMapper.updateStatusById(id);
|
|
|
+
|
|
|
+ //机构账户新增逻辑
|
|
|
+ TenantInfo tenantInfo = new TenantInfo();
|
|
|
+ tenantInfo.setLogo(applyRecord.getLogo());
|
|
|
+ tenantInfo.setName(applyRecord.getName());
|
|
|
+ tenantInfo.setProvinceCode(applyRecord.getProvinceCode());
|
|
|
+ tenantInfo.setCityCode(applyRecord.getCityCode());
|
|
|
+ tenantInfo.setRegionCode(applyRecord.getRegionCode());
|
|
|
+ tenantInfo.setUsername(applyRecord.getUsername());
|
|
|
+ tenantInfo.setPhone(applyRecord.getPhone());
|
|
|
+ tenantInfo.setEnableFlag(true);
|
|
|
+ tenantInfoService.add(tenantInfo);
|
|
|
+ } else {
|
|
|
+ entryRecord.setStatus("UNPASS");
|
|
|
+ tenantApplyRecordMapper.updateUnpassStatusById(id);
|
|
|
+ }
|
|
|
+ tenantEntryRecordMapper.insert(entryRecord);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 匹配地区码与省市区
|
|
|
+ *
|
|
|
+ * @param tenantInfos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<TenantApplyRecordWrapper.TenantApplyRecord> queryArea(List<TenantApplyRecordWrapper.TenantApplyRecord> tenantInfos) {
|
|
|
+ List<Integer> areaCodeList = tenantInfos.stream().map(next -> {
|
|
|
+ Set<Integer> codes = new HashSet<>();
|
|
|
+ codes.add(next.getCityCode());
|
|
|
+ codes.add(next.getProvinceCode());
|
|
|
+ codes.add(next.getRegionCode());
|
|
|
+ return codes;
|
|
|
+ }).flatMap(Collection::stream).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, String> codeNameMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(areaCodeList)) {
|
|
|
+ List<SysArea> sysAreaList = sysAreaService.queryByCodes(areaCodeList);
|
|
|
+ codeNameMap = sysAreaList.stream().collect(Collectors.toMap(SysArea::getCode,
|
|
|
+ SysArea::getName));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (TenantApplyRecordWrapper.TenantApplyRecord next : tenantInfos) {
|
|
|
+ next.setProvinceName(codeNameMap.getOrDefault(next.getProvinceCode(), ""));
|
|
|
+ next.setCityName(codeNameMap.getOrDefault(next.getCityCode(), ""));
|
|
|
+ next.setRegionName(codeNameMap.getOrDefault(next.getRegionCode(), ""));
|
|
|
+ }
|
|
|
+
|
|
|
+ return tenantInfos;
|
|
|
+ }
|
|
|
}
|