|
|
@@ -335,9 +335,20 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
public StoreMainInfoVo getDecorationDetail(Integer id) {
|
|
|
StoreInfo storeInfo = storeInfoMapper.selectById(id);
|
|
|
StoreMainInfoVo storeMainInfoVo = storeInfoMapper.getStoreInfo(id);
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String expirationDate = sdf.format(storeMainInfoVo.getExpirationTime());
|
|
|
- storeMainInfoVo.setExpirationDate(expirationDate);
|
|
|
+
|
|
|
+ if (storeInfo == null || storeMainInfoVo == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ // 使用现代日期 API
|
|
|
+ if (storeMainInfoVo.getExpirationTime() != null) {
|
|
|
+ String expirationDate = storeMainInfoVo.getExpirationTime().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDate()
|
|
|
+ .format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ storeMainInfoVo.setExpirationDate(expirationDate);
|
|
|
+ } else {
|
|
|
+ storeMainInfoVo.setExpirationDate(null);
|
|
|
+ }
|
|
|
//审核通过给前台反显未提交
|
|
|
if (storeMainInfoVo.getRenewContractStatus() == 1) {
|
|
|
storeMainInfoVo.setRenewContractStatus(0);
|
|
|
@@ -352,26 +363,29 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
//存入门店地址
|
|
|
storeMainInfoVo.setStoreAddress(storeInfo.getStoreAddress());
|
|
|
- //经营种类
|
|
|
- if (storeInfo.getBusinessTypes() != null) {
|
|
|
- String[] strings = storeInfo.getBusinessTypes().split(",");
|
|
|
- storeMainInfoVo.setBusinessTypesList(Arrays.stream(strings).collect(Collectors.toList()));
|
|
|
- }
|
|
|
+ // //经营种类
|
|
|
+ // if (storeInfo.getBusinessTypes() != null) {
|
|
|
+ // String[] strings = storeInfo.getBusinessTypes().split(",");
|
|
|
+ // storeMainInfoVo.setBusinessTypesList(Arrays.stream(strings).collect(Collectors.toList()));
|
|
|
+ // }
|
|
|
//门店标签
|
|
|
storeMainInfoVo.setStoreLabel(storeLabelMapper.selectOne(new LambdaQueryWrapper<StoreLabel>().eq(StoreLabel::getStoreId, id)));
|
|
|
//营业时间
|
|
|
List<StoreBusinessInfo> storeBusinessInfoList = storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, id));
|
|
|
storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoList);
|
|
|
//营业执照
|
|
|
- storeMainInfoVo.setBusinessLicenseList(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 14).eq(StoreImg::getStoreId, id)));
|
|
|
- //合同照片
|
|
|
- storeMainInfoVo.setContractList(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 15).eq(StoreImg::getStoreId, id)));
|
|
|
- //经营许可证图片照片
|
|
|
- storeMainInfoVo.setFoodLicenceList(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 25).eq(StoreImg::getStoreId, id)));
|
|
|
+ storeMainInfoVo.setBusinessLicenseList(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 14).eq(StoreImg::getStoreId, id).eq(StoreImg::getDeleteFlag, 0)));
|
|
|
+ //其他资质证明图片(img_type=35)
|
|
|
+ storeMainInfoVo.setOtherQualificationImages(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 35).eq(StoreImg::getStoreId, id).eq(StoreImg::getDeleteFlag, 0).orderByAsc(StoreImg::getImgSort)));
|
|
|
+ // //合同照片
|
|
|
+ // storeMainInfoVo.setContractList(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 15).eq(StoreImg::getStoreId, id).eq(StoreImg::getDeleteFlag, 0)));
|
|
|
+ // //经营许可证图片照片
|
|
|
+ // storeMainInfoVo.setFoodLicenceList(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 25).eq(StoreImg::getStoreId, id).eq(StoreImg::getDeleteFlag, 0)));
|
|
|
//是否连锁
|
|
|
String isChain = (storeInfo.getIsChain() == 0) ? "否" : "是";
|
|
|
storeMainInfoVo.setIsChainStr(isChain);
|
|
|
- storeMainInfoVo.setFoodLicenceExpirationTime(storeInfo.getFoodLicenceExpirationTime());
|
|
|
+ // //经营许可证到期时间
|
|
|
+ // storeMainInfoVo.setFoodLicenceExpirationTime(storeInfo.getFoodLicenceExpirationTime());
|
|
|
return storeMainInfoVo;
|
|
|
}
|
|
|
|
|
|
@@ -850,26 +864,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public StoreInfoVo saveStoreInfo(StoreInfoDto storeInfoDto) throws Exception {
|
|
|
- //获取经营板块id
|
|
|
- Integer businessSection = storeInfoDto.getBusinessSection();
|
|
|
- //查询经营板块名称
|
|
|
- StoreDictionary businessSectionName = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, businessSection).eq(StoreDictionary::getTypeName, "business_section"));
|
|
|
- //查询经营种类
|
|
|
- List<String> businessTypes = storeInfoDto.getBusinessTypes();
|
|
|
- List<String> businessTypeNames = new ArrayList<>();
|
|
|
- //获取经营种类名称
|
|
|
- for (String businessType : businessTypes) {
|
|
|
- StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>()
|
|
|
- .eq(StoreDictionary::getDictId, businessType)
|
|
|
- .eq(StoreDictionary::getParentId, businessSectionName.getId())
|
|
|
- .eq(StoreDictionary::getTypeName, "business_type")
|
|
|
- .eq(StoreDictionary::getDeleteFlag, 0));
|
|
|
- if (storeDictionary != null) {
|
|
|
- businessTypeNames.add(storeDictionary.getDictDetail());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ public StoreInfoVo saveStoreInfo(StoreInfoDto storeInfoDto) {
|
|
|
StoreInfoVo result = new StoreInfoVo();
|
|
|
StoreInfo storeInfo = new StoreInfo();
|
|
|
BeanUtils.copyProperties(storeInfoDto, storeInfo);
|
|
|
@@ -889,42 +884,63 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
storeInfo.setStorePass(DEFAULT_PASSWORD);
|
|
|
storeInfo.setPassType(0);
|
|
|
}
|
|
|
- //板块及类型
|
|
|
- storeInfo.setBusinessSection(businessSection);
|
|
|
- storeInfo.setBusinessSectionName(businessSectionName.getDictDetail());
|
|
|
- storeInfo.setBusinessTypes(String.join(",", businessTypes));
|
|
|
- storeInfo.setBusinessTypesName(String.join(",", businessTypeNames));
|
|
|
-
|
|
|
- //处理分类信息
|
|
|
- List<String> businessClassify = storeInfoDto.getBusinessClassify();
|
|
|
- if (!CollectionUtils.isEmpty(businessClassify)) {
|
|
|
- List<String> businessClassifyNames = new ArrayList<>();
|
|
|
- //批量查询分类名称
|
|
|
- List<StoreDictionary> classifyDicts = storeDictionaryMapper.selectList(
|
|
|
- new LambdaQueryWrapper<StoreDictionary>()
|
|
|
- .in(StoreDictionary::getDictId, businessClassify)
|
|
|
- .eq(StoreDictionary::getTypeName, "business_classify")
|
|
|
- .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
- );
|
|
|
- //转为Map方便快速获取
|
|
|
- Map<String, StoreDictionary> classifyDictMap = classifyDicts.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- dict -> dict.getDictId().toString(),
|
|
|
- Function.identity(),
|
|
|
- (existing, replacement) -> existing
|
|
|
- ));
|
|
|
- //提取分类名称
|
|
|
- for (String classifyId : businessClassify) {
|
|
|
- StoreDictionary dict = classifyDictMap.get(classifyId);
|
|
|
- if (Objects.nonNull(dict)) {
|
|
|
- businessClassifyNames.add(dict.getDictDetail());
|
|
|
- } else {
|
|
|
- log.warn("无效的分类id:" + classifyId);
|
|
|
- }
|
|
|
- }
|
|
|
- storeInfo.setBusinessClassify(String.join(",", businessClassify));
|
|
|
- storeInfo.setBusinessClassifyName(String.join(",", businessClassifyNames));
|
|
|
+
|
|
|
+ // 经营板块
|
|
|
+ if (storeInfoDto.getBusinessSection() != null) {
|
|
|
+ storeInfo.setBusinessSection(storeInfoDto.getBusinessSection());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(storeInfoDto.getBusinessSectionName())) {
|
|
|
+ storeInfo.setBusinessSectionName(storeInfoDto.getBusinessSectionName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 经营种类
|
|
|
+ if (!CollectionUtils.isEmpty(storeInfoDto.getBusinessTypes())) {
|
|
|
+ storeInfo.setBusinessTypes(String.join(",", storeInfoDto.getBusinessTypes()));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(storeInfoDto.getBusinessTypeName())) {
|
|
|
+ storeInfo.setBusinessTypeName(storeInfoDto.getBusinessTypeName());
|
|
|
}
|
|
|
+
|
|
|
+ // 经营类目
|
|
|
+ if (StringUtils.isNotEmpty(storeInfoDto.getBusinessCategoryName())) {
|
|
|
+ storeInfo.setBusinessCategoryName(storeInfoDto.getBusinessCategoryName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 店铺评价:直接使用传入的值
|
|
|
+ if (StringUtils.isNotEmpty(storeInfoDto.getStoreEvaluate())) {
|
|
|
+ storeInfo.setStoreEvaluate(storeInfoDto.getStoreEvaluate());
|
|
|
+ }
|
|
|
+
|
|
|
+ // //处理分类信息(保留原有逻辑,如果还有使用的话)
|
|
|
+ // List<String> businessClassify = storeInfoDto.getBusinessClassify();
|
|
|
+ // if (!CollectionUtils.isEmpty(businessClassify)) {
|
|
|
+ // List<String> businessClassifyNames = new ArrayList<>();
|
|
|
+ // //批量查询分类名称
|
|
|
+ // List<StoreDictionary> classifyDicts = storeDictionaryMapper.selectList(
|
|
|
+ // new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ // .in(StoreDictionary::getDictId, businessClassify)
|
|
|
+ // .eq(StoreDictionary::getTypeName, "business_classify")
|
|
|
+ // .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
+ // );
|
|
|
+ // //转为Map方便快速获取
|
|
|
+ // Map<String, StoreDictionary> classifyDictMap = classifyDicts.stream()
|
|
|
+ // .collect(Collectors.toMap(
|
|
|
+ // dict -> dict.getDictId().toString(),
|
|
|
+ // Function.identity(),
|
|
|
+ // (existing, replacement) -> existing
|
|
|
+ // ));
|
|
|
+ // //提取分类名称
|
|
|
+ // for (String classifyId : businessClassify) {
|
|
|
+ // StoreDictionary dict = classifyDictMap.get(classifyId);
|
|
|
+ // if (Objects.nonNull(dict)) {
|
|
|
+ // businessClassifyNames.add(dict.getDictDetail());
|
|
|
+ // } else {
|
|
|
+ // log.warn("无效的分类id:" + classifyId);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // storeInfo.setBusinessClassify(String.join(",", businessClassify));
|
|
|
+ // storeInfo.setBusinessClassifyName(String.join(",", businessClassifyNames));
|
|
|
+ // }
|
|
|
|
|
|
//存入审批状态为待审批
|
|
|
storeInfo.setStoreApplicationStatus(0);
|
|
|
@@ -939,113 +955,113 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
storeInfo.setCommissionRate("3");
|
|
|
}
|
|
|
|
|
|
- // 处理食品经营许可证OCR数据
|
|
|
- if (StringUtils.isNotEmpty(storeInfoDto.getFoodLicenceUrl())) {
|
|
|
- // 查询食品经营许可证OCR识别记录
|
|
|
- OcrImageUpload foodLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
- .eq(OcrImageUpload::getImageUrl, storeInfoDto.getFoodLicenceUrl())
|
|
|
- .eq(OcrImageUpload::getOcrType, OcrTypeEnum.FOOD_MANAGE_LICENSE.getCode())
|
|
|
- .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
- .last("limit 1")
|
|
|
- );
|
|
|
- if (foodLicenceOcr != null && StringUtils.isNotEmpty(foodLicenceOcr.getOcrResult())) {
|
|
|
- try {
|
|
|
- com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(foodLicenceOcr.getOcrResult());
|
|
|
- // 食品经营许可证OCR字段:validToDate(优先)、standardizedValidToDate
|
|
|
- Date expirationTime = parseFoodLicenceExpirationDate(ocrResult);
|
|
|
- if (expirationTime != null) {
|
|
|
- storeInfo.setFoodLicenceExpirationTime(expirationTime);
|
|
|
- } else if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
- // OCR解析结果为空时,使用DTO中传入的值
|
|
|
- storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- log.info("使用DTO中的食品经营许可证到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- }
|
|
|
- // 设置食品经营许可证状态为"待审核"(字典值2)
|
|
|
- storeInfo.setFoodLicenceStatus(2);
|
|
|
- storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
- log.info("食品经营许可证OCR数据解析成功,到期时间:{}", storeInfo.getFoodLicenceExpirationTime());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("解析食品经营许可证OCR数据失败", e);
|
|
|
- // 解析失败时使用DTO中传入的值
|
|
|
- if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
- storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- log.info("OCR解析失败,使用DTO中的食品经营许可证到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- }
|
|
|
- storeInfo.setFoodLicenceStatus(2);
|
|
|
- storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 没有OCR记录时,使用DTO中传入的值
|
|
|
- if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
- storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- log.info("无OCR记录,使用DTO中的食品经营许可证到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- }
|
|
|
- storeInfo.setFoodLicenceStatus(2);
|
|
|
- storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 没有食品经营许可证URL,初始化状态为"未提交"(字典值0)
|
|
|
- storeInfo.setFoodLicenceStatus(0);
|
|
|
- if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
- storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- log.info("无食品经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 处理娱乐经营许可证OCR数据(复用营业执照OCR类型,数据库中ocr_type存的是BUSINESS_LICENSE)
|
|
|
- if (StringUtils.isNotEmpty(storeInfoDto.getEntertainmentLicenceUrl())) {
|
|
|
- // 查询娱乐经营许可证OCR识别记录
|
|
|
- OcrImageUpload entertainmentLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
- .eq(OcrImageUpload::getImageUrl, storeInfoDto.getEntertainmentLicenceUrl())
|
|
|
- .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode())
|
|
|
- .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
- .last("limit 1")
|
|
|
- );
|
|
|
- if (entertainmentLicenceOcr != null && StringUtils.isNotEmpty(entertainmentLicenceOcr.getOcrResult())) {
|
|
|
- try {
|
|
|
- com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(entertainmentLicenceOcr.getOcrResult());
|
|
|
- // 娱乐经营许可证OCR字段(复用营业执照类型):validToDate(优先,格式"20220903")、validPeriod(格式"2020年09月04日至2022年09月03日")
|
|
|
- Date expirationTime = parseEntertainmentLicenceExpirationDate(ocrResult);
|
|
|
- if (expirationTime != null) {
|
|
|
- storeInfo.setEntertainmentLicenceExpirationTime(expirationTime);
|
|
|
- } else if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
- // OCR解析结果为空时,使用DTO中传入的值
|
|
|
- storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- log.info("使用DTO中的娱乐经营许可证到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- }
|
|
|
- // 设置娱乐经营许可证状态为"待审核"(字典值2)
|
|
|
- storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
- storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
- log.info("娱乐经营许可证OCR数据解析成功,到期时间:{}", storeInfo.getEntertainmentLicenceExpirationTime());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("解析娱乐经营许可证OCR数据失败", e);
|
|
|
- // 解析失败时使用DTO中传入的值
|
|
|
- if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
- storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- log.info("OCR解析失败,使用DTO中的娱乐经营许可证到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- }
|
|
|
- storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
- storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 没有OCR记录时,使用DTO中传入的值
|
|
|
- if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
- storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- log.info("无OCR记录,使用DTO中的娱乐经营许可证到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- }
|
|
|
- storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
- storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 没有娱乐经营许可证URL,初始化状态为"未提交"(字典值0)
|
|
|
- storeInfo.setEntertainmentLicenceStatus(0);
|
|
|
- if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
- storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- log.info("无娱乐经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- }
|
|
|
- }
|
|
|
+ // // 处理食品经营许可证OCR数据
|
|
|
+ // if (StringUtils.isNotEmpty(storeInfoDto.getFoodLicenceUrl())) {
|
|
|
+ // // 查询食品经营许可证OCR识别记录
|
|
|
+ // OcrImageUpload foodLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ // new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ // .eq(OcrImageUpload::getImageUrl, storeInfoDto.getFoodLicenceUrl())
|
|
|
+ // .eq(OcrImageUpload::getOcrType, OcrTypeEnum.FOOD_MANAGE_LICENSE.getCode())
|
|
|
+ // .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ // .last("limit 1")
|
|
|
+ // );
|
|
|
+ // if (foodLicenceOcr != null && StringUtils.isNotEmpty(foodLicenceOcr.getOcrResult())) {
|
|
|
+ // try {
|
|
|
+ // com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(foodLicenceOcr.getOcrResult());
|
|
|
+ // // 食品经营许可证OCR字段:validToDate(优先)、standardizedValidToDate
|
|
|
+ // Date expirationTime = parseFoodLicenceExpirationDate(ocrResult);
|
|
|
+ // if (expirationTime != null) {
|
|
|
+ // storeInfo.setFoodLicenceExpirationTime(expirationTime);
|
|
|
+ // } else if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
+ // // OCR解析结果为空时,使用DTO中传入的值
|
|
|
+ // storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // log.info("使用DTO中的食品经营许可证到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // // 设置食品经营许可证状态为"待审核"(字典值2)
|
|
|
+ // storeInfo.setFoodLicenceStatus(2);
|
|
|
+ // storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
+ // log.info("食品经营许可证OCR数据解析成功,到期时间:{}", storeInfo.getFoodLicenceExpirationTime());
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // log.error("解析食品经营许可证OCR数据失败", e);
|
|
|
+ // // 解析失败时使用DTO中传入的值
|
|
|
+ // if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
+ // storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // log.info("OCR解析失败,使用DTO中的食品经营许可证到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // storeInfo.setFoodLicenceStatus(2);
|
|
|
+ // storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // // 没有OCR记录时,使用DTO中传入的值
|
|
|
+ // if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
+ // storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // log.info("无OCR记录,使用DTO中的食品经营许可证到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // storeInfo.setFoodLicenceStatus(2);
|
|
|
+ // storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // // 没有食品经营许可证URL,初始化状态为"未提交"(字典值0)
|
|
|
+ // storeInfo.setFoodLicenceStatus(0);
|
|
|
+ // if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
+ // storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // log.info("无食品经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // // 处理娱乐经营许可证OCR数据(复用营业执照OCR类型,数据库中ocr_type存的是BUSINESS_LICENSE)
|
|
|
+ // if (StringUtils.isNotEmpty(storeInfoDto.getEntertainmentLicenceUrl())) {
|
|
|
+ // // 查询娱乐经营许可证OCR识别记录
|
|
|
+ // OcrImageUpload entertainmentLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ // new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ // .eq(OcrImageUpload::getImageUrl, storeInfoDto.getEntertainmentLicenceUrl())
|
|
|
+ // .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode())
|
|
|
+ // .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ // .last("limit 1")
|
|
|
+ // );
|
|
|
+ // if (entertainmentLicenceOcr != null && StringUtils.isNotEmpty(entertainmentLicenceOcr.getOcrResult())) {
|
|
|
+ // try {
|
|
|
+ // com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(entertainmentLicenceOcr.getOcrResult());
|
|
|
+ // // 娱乐经营许可证OCR字段(复用营业执照类型):validToDate(优先,格式"20220903")、validPeriod(格式"2020年09月04日至2022年09月03日")
|
|
|
+ // Date expirationTime = parseEntertainmentLicenceExpirationDate(ocrResult);
|
|
|
+ // if (expirationTime != null) {
|
|
|
+ // storeInfo.setEntertainmentLicenceExpirationTime(expirationTime);
|
|
|
+ // } else if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
+ // // OCR解析结果为空时,使用DTO中传入的值
|
|
|
+ // storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // log.info("使用DTO中的娱乐经营许可证到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // // 设置娱乐经营许可证状态为"待审核"(字典值2)
|
|
|
+ // storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
+ // storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
+ // log.info("娱乐经营许可证OCR数据解析成功,到期时间:{}", storeInfo.getEntertainmentLicenceExpirationTime());
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // log.error("解析娱乐经营许可证OCR数据失败", e);
|
|
|
+ // // 解析失败时使用DTO中传入的值
|
|
|
+ // if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
+ // storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // log.info("OCR解析失败,使用DTO中的娱乐经营许可证到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
+ // storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // // 没有OCR记录时,使用DTO中传入的值
|
|
|
+ // if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
+ // storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // log.info("无OCR记录,使用DTO中的娱乐经营许可证到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
+ // storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // // 没有娱乐经营许可证URL,初始化状态为"未提交"(字典值0)
|
|
|
+ // storeInfo.setEntertainmentLicenceStatus(0);
|
|
|
+ // if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
+ // storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // log.info("无娱乐经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
// 处理营业执照OCR数据(复用营业执照OCR类型,数据库中ocr_type存的是BUSINESS_LICENSE)
|
|
|
// 营业执照使用 businessLicenseAddress 列表中的第一个URL查询OCR
|
|
|
@@ -1109,21 +1125,23 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 计算并设置到期时间为五个过期时间的最小值(包含身份证过期时间)
|
|
|
+ // 计算并设置到期时间为过期时间的最小值(仅包含营业执照过期时间)
|
|
|
List<Date> expirationTimeList = new ArrayList<>();
|
|
|
// 收集所有非空的过期时间
|
|
|
if (storeInfoDto.getExpirationTime() != null) {
|
|
|
expirationTimeList.add(storeInfoDto.getExpirationTime());
|
|
|
}
|
|
|
- if (storeInfo.getFoodLicenceExpirationTime() != null) {
|
|
|
- expirationTimeList.add(storeInfo.getFoodLicenceExpirationTime());
|
|
|
- }
|
|
|
- if (storeInfo.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
- expirationTimeList.add(storeInfo.getEntertainmentLicenceExpirationTime());
|
|
|
- }
|
|
|
+ // 仅保留营业执照过期时间
|
|
|
if (storeInfo.getBusinessLicenseExpirationTime() != null) {
|
|
|
expirationTimeList.add(storeInfo.getBusinessLicenseExpirationTime());
|
|
|
}
|
|
|
+ // // 以下字段已废弃,不再使用
|
|
|
+ // if (storeInfo.getFoodLicenceExpirationTime() != null) {
|
|
|
+ // expirationTimeList.add(storeInfo.getFoodLicenceExpirationTime());
|
|
|
+ // }
|
|
|
+ // if (storeInfo.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
+ // expirationTimeList.add(storeInfo.getEntertainmentLicenceExpirationTime());
|
|
|
+ // }
|
|
|
// 取最小值设置为门店到期时间
|
|
|
if (!expirationTimeList.isEmpty()) {
|
|
|
Date minExpirationTime = Collections.min(expirationTimeList);
|
|
|
@@ -1158,59 +1176,76 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
storeImg.setImgUrl(licenseAddress);
|
|
|
storeImgMapper.insert(storeImg);
|
|
|
}
|
|
|
- //存入店铺合同图片
|
|
|
- if (!CollectionUtils.isEmpty(storeInfoDto.getContractImageList())) {
|
|
|
- List<String> contractImageList = storeInfoDto.getContractImageList();
|
|
|
- //先移除此前数据
|
|
|
- storeImgMapper.delete(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeInfo.getId()).eq(StoreImg::getImgType, 15));
|
|
|
- for (String licenseAddress : contractImageList) {
|
|
|
+
|
|
|
+ //存入其他资质证明图片(限九张)
|
|
|
+ if (!CollectionUtils.isEmpty(storeInfoDto.getOtherQualificationImages())) {
|
|
|
+ List<String> otherQualificationImages = storeInfoDto.getOtherQualificationImages();
|
|
|
+ // 限制最多9张
|
|
|
+ int maxCount = Math.min(otherQualificationImages.size(), 9);
|
|
|
+ for (int i = 0; i < maxCount; i++) {
|
|
|
StoreImg storeImg = new StoreImg();
|
|
|
storeImg.setStoreId(storeInfo.getId());
|
|
|
- storeImg.setImgType(15);
|
|
|
- storeImg.setImgSort(0);
|
|
|
- storeImg.setImgDescription("合同图片");
|
|
|
- storeImg.setImgUrl(licenseAddress);
|
|
|
+ storeImg.setImgType(35); // 其他资质证明图片
|
|
|
+ storeImg.setImgSort(i + 1);
|
|
|
+ storeImg.setImgDescription("其他资质证明");
|
|
|
+ storeImg.setImgUrl(otherQualificationImages.get(i));
|
|
|
storeImgMapper.insert(storeImg);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //存入店铺经营许可证图片
|
|
|
- if (StringUtils.isNotEmpty(storeInfoDto.getFoodLicenceUrl())) {
|
|
|
- StoreImg storeImg = new StoreImg();
|
|
|
- storeImg.setStoreId(storeInfo.getId());
|
|
|
- storeImg.setImgType(25);
|
|
|
- storeImg.setImgSort(0);
|
|
|
- storeImg.setImgDescription("经营许可证审核通过图片");
|
|
|
- storeImg.setImgUrl(storeInfoDto.getFoodLicenceUrl());
|
|
|
- storeImgMapper.insert(storeImg);
|
|
|
- }
|
|
|
- //存入店铺娱乐经营许可证图片
|
|
|
- if (StringUtils.isNotEmpty(storeInfoDto.getEntertainmentLicenceUrl())) {
|
|
|
- StoreImg storeImg = new StoreImg();
|
|
|
- storeImg.setStoreId(storeInfo.getId());
|
|
|
- storeImg.setImgType(26);
|
|
|
- storeImg.setImgSort(0);
|
|
|
- storeImg.setImgDescription("娱乐经营许可证审核通过图片");
|
|
|
- storeImg.setImgUrl(storeInfoDto.getEntertainmentLicenceUrl());
|
|
|
- storeImgMapper.insert(storeImg);
|
|
|
- }
|
|
|
-
|
|
|
- //存入身份证正反面图片
|
|
|
- saveIdCardImages(storeInfo.getId(), storeUser.getId().toString(), storeInfo);
|
|
|
-
|
|
|
- // 更新门店到期时间,包含身份证过期时间
|
|
|
- if (storeInfo.getIdCardExpirationTime() != null) {
|
|
|
- List<Date> allExpirationTimeList = new ArrayList<>();
|
|
|
- if (storeInfo.getExpirationTime() != null) {
|
|
|
- allExpirationTimeList.add(storeInfo.getExpirationTime());
|
|
|
- }
|
|
|
- allExpirationTimeList.add(storeInfo.getIdCardExpirationTime());
|
|
|
- Date minExpirationTime = Collections.min(allExpirationTimeList);
|
|
|
- storeInfo.setExpirationTime(minExpirationTime);
|
|
|
- // 更新数据库中的过期时间
|
|
|
- storeInfoMapper.updateById(storeInfo);
|
|
|
- log.info("更新门店到期时间,包含身份证过期时间,最小值:{}", minExpirationTime);
|
|
|
- }
|
|
|
+
|
|
|
+ // //存入店铺合同图片
|
|
|
+ // if (!CollectionUtils.isEmpty(storeInfoDto.getContractImageList())) {
|
|
|
+ // List<String> contractImageList = storeInfoDto.getContractImageList();
|
|
|
+ // //先移除此前数据
|
|
|
+ // storeImgMapper.delete(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeInfo.getId()).eq(StoreImg::getImgType, 15));
|
|
|
+ // for (String licenseAddress : contractImageList) {
|
|
|
+ // StoreImg storeImg = new StoreImg();
|
|
|
+ // storeImg.setStoreId(storeInfo.getId());
|
|
|
+ // storeImg.setImgType(15);
|
|
|
+ // storeImg.setImgSort(0);
|
|
|
+ // storeImg.setImgDescription("合同图片");
|
|
|
+ // storeImg.setImgUrl(licenseAddress);
|
|
|
+ // storeImgMapper.insert(storeImg);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //存入店铺经营许可证图片
|
|
|
+ // if (StringUtils.isNotEmpty(storeInfoDto.getFoodLicenceUrl())) {
|
|
|
+ // StoreImg storeImg = new StoreImg();
|
|
|
+ // storeImg.setStoreId(storeInfo.getId());
|
|
|
+ // storeImg.setImgType(25);
|
|
|
+ // storeImg.setImgSort(0);
|
|
|
+ // storeImg.setImgDescription("经营许可证审核通过图片");
|
|
|
+ // storeImg.setImgUrl(storeInfoDto.getFoodLicenceUrl());
|
|
|
+ // storeImgMapper.insert(storeImg);
|
|
|
+ // }
|
|
|
+ // //存入店铺娱乐经营许可证图片
|
|
|
+ // if (StringUtils.isNotEmpty(storeInfoDto.getEntertainmentLicenceUrl())) {
|
|
|
+ // StoreImg storeImg = new StoreImg();
|
|
|
+ // storeImg.setStoreId(storeInfo.getId());
|
|
|
+ // storeImg.setImgType(26);
|
|
|
+ // storeImg.setImgSort(0);
|
|
|
+ // storeImg.setImgDescription("娱乐经营许可证审核通过图片");
|
|
|
+ // storeImg.setImgUrl(storeInfoDto.getEntertainmentLicenceUrl());
|
|
|
+ // storeImgMapper.insert(storeImg);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //存入身份证正反面图片
|
|
|
+ // saveIdCardImages(storeInfo.getId(), storeUser.getId().toString(), storeInfo);
|
|
|
+ //
|
|
|
+ // // 更新门店到期时间,包含身份证过期时间
|
|
|
+ // if (storeInfo.getIdCardExpirationTime() != null) {
|
|
|
+ // List<Date> allExpirationTimeList = new ArrayList<>();
|
|
|
+ // if (storeInfo.getExpirationTime() != null) {
|
|
|
+ // allExpirationTimeList.add(storeInfo.getExpirationTime());
|
|
|
+ // }
|
|
|
+ // allExpirationTimeList.add(storeInfo.getIdCardExpirationTime());
|
|
|
+ // Date minExpirationTime = Collections.min(allExpirationTimeList);
|
|
|
+ // storeInfo.setExpirationTime(minExpirationTime);
|
|
|
+ // // 更新数据库中的过期时间
|
|
|
+ // storeInfoMapper.updateById(storeInfo);
|
|
|
+ // log.info("更新门店到期时间,包含身份证过期时间,最小值:{}", minExpirationTime);
|
|
|
+ // }
|
|
|
|
|
|
//初始化标签数据
|
|
|
LambdaQueryWrapper<TagStoreRelation> tagStoreRelationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -2593,53 +2628,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
// 校验当前店铺存在未完成的订单及正在销售的商品
|
|
|
verificationStoreInfoStatus(storeInfodto);
|
|
|
|
|
|
- // 1. 处理经营板块及经营种类
|
|
|
- Integer businessSection = storeInfodto.getBusinessSection();
|
|
|
- StoreDictionary businessSectionDict = null;
|
|
|
- List<String> businessTypeNames = new ArrayList<>();
|
|
|
-
|
|
|
- // 查询经营板块(非空判断,避免后续空指针)
|
|
|
- if (Objects.nonNull(businessSection)) {
|
|
|
- businessSectionDict = storeDictionaryMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<StoreDictionary>()
|
|
|
- .eq(StoreDictionary::getDictId, businessSection)
|
|
|
- .eq(StoreDictionary::getTypeName, "business_section")
|
|
|
- );
|
|
|
- // 若经营板块不存在,可根据业务抛出异常或默认处理
|
|
|
- if (Objects.isNull(businessSectionDict)) {
|
|
|
- throw new IllegalArgumentException("经营板块不存在:" + businessSection);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 批量查询经营种类(替代循环查询,解决N+1问题)
|
|
|
- List<String> businessTypes = storeInfodto.getBusinessTypes();
|
|
|
- if (Objects.nonNull(businessSectionDict) && !CollectionUtils.isEmpty(businessTypes)) {
|
|
|
- // 一次查询所有符合条件的经营种类
|
|
|
- List<StoreDictionary> typeDicts = storeDictionaryMapper.selectList(
|
|
|
- new LambdaQueryWrapper<StoreDictionary>()
|
|
|
- .in(StoreDictionary::getDictId, businessTypes) // 批量匹配id
|
|
|
- .eq(StoreDictionary::getParentId, businessSectionDict.getId())
|
|
|
- .eq(StoreDictionary::getTypeName, "business_type") // 只查询经营种类,排除擅长标签
|
|
|
- .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
- );
|
|
|
- // 转为Map<dictId, StoreDictionary>,方便快速获取
|
|
|
- Map<String, StoreDictionary> typeDictMap = typeDicts.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- dict -> dict.getDictId().toString(), // 假设dictId是字符串类型,若为数字需转换
|
|
|
- Function.identity(),
|
|
|
- (existing, replacement) -> existing // 处理重复id(理论上不会有)
|
|
|
- ));
|
|
|
- // 提取经营种类名称
|
|
|
- for (String typeId : businessTypes) {
|
|
|
- StoreDictionary dict = typeDictMap.get(typeId);
|
|
|
- if (Objects.nonNull(dict)) {
|
|
|
- businessTypeNames.add(dict.getDictDetail());
|
|
|
- } else {
|
|
|
- // 可选:记录无效的经营种类id,便于排查
|
|
|
- log.warn("无效的经营种类id:" + typeId + "(所属板块:" + businessSectionDict.getDictDetail() + ")");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // 1. 处理经营板块及经营种类(不再查询字典表,直接使用传入的名称)
|
|
|
|
|
|
// 2. 构建StoreInfo对象
|
|
|
StoreInfo storeInfo = new StoreInfo();
|
|
|
@@ -2661,50 +2650,63 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
|
|
|
// 4. 设置门店状态、经营板块及类型
|
|
|
storeInfo.setStoreStatus(storeInfodto.getStoreStatus());
|
|
|
- // 经营板块(非空时才设置)
|
|
|
- if (Objects.nonNull(businessSection)) {
|
|
|
- storeInfo.setBusinessSection(businessSection);
|
|
|
- }
|
|
|
- // 经营板块名称(非空时才设置)
|
|
|
- if (Objects.nonNull(businessSectionDict)) {
|
|
|
- storeInfo.setBusinessSectionName(businessSectionDict.getDictDetail());
|
|
|
- }
|
|
|
- // 经营种类及名称(非空时拼接)
|
|
|
- if (!CollectionUtils.isEmpty(businessTypes) && !CollectionUtils.isEmpty(businessTypeNames)) {
|
|
|
- storeInfo.setBusinessTypes(String.join(",", businessTypes));
|
|
|
- storeInfo.setBusinessTypesName(String.join(",", businessTypeNames));
|
|
|
- }
|
|
|
-
|
|
|
- // 处理分类信息
|
|
|
- List<String> businessClassify = storeInfodto.getBusinessClassify();
|
|
|
- if (!CollectionUtils.isEmpty(businessClassify)) {
|
|
|
- List<String> businessClassifyNames = new ArrayList<>();
|
|
|
- //批量查询分类名称
|
|
|
- List<StoreDictionary> classifyDicts = storeDictionaryMapper.selectList(
|
|
|
- new LambdaQueryWrapper<StoreDictionary>()
|
|
|
- .in(StoreDictionary::getDictId, businessClassify)
|
|
|
- .eq(StoreDictionary::getTypeName, "business_classify")
|
|
|
- .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
- );
|
|
|
- //转为Map方便快速获取
|
|
|
- Map<String, StoreDictionary> classifyDictMap = classifyDicts.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- dict -> dict.getDictId().toString(),
|
|
|
- Function.identity(),
|
|
|
- (existing, replacement) -> existing
|
|
|
- ));
|
|
|
- //提取分类名称
|
|
|
- for (String classifyId : businessClassify) {
|
|
|
- StoreDictionary dict = classifyDictMap.get(classifyId);
|
|
|
- if (Objects.nonNull(dict)) {
|
|
|
- businessClassifyNames.add(dict.getDictDetail());
|
|
|
- } else {
|
|
|
- log.warn("无效的分类id:" + classifyId);
|
|
|
- }
|
|
|
- }
|
|
|
- storeInfo.setBusinessClassify(String.join(",", businessClassify));
|
|
|
- storeInfo.setBusinessClassifyName(String.join(",", businessClassifyNames));
|
|
|
+
|
|
|
+ // 经营板块
|
|
|
+ if (storeInfodto.getBusinessSection() != null) {
|
|
|
+ storeInfo.setBusinessSection(storeInfodto.getBusinessSection());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(storeInfodto.getBusinessSectionName())) {
|
|
|
+ storeInfo.setBusinessSectionName(storeInfodto.getBusinessSectionName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 经营种类
|
|
|
+ if (!CollectionUtils.isEmpty(storeInfodto.getBusinessTypes())) {
|
|
|
+ storeInfo.setBusinessTypes(String.join(",", storeInfodto.getBusinessTypes()));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(storeInfodto.getBusinessTypeName())) {
|
|
|
+ storeInfo.setBusinessTypeName(storeInfodto.getBusinessTypeName());
|
|
|
}
|
|
|
+
|
|
|
+ // 经营类目
|
|
|
+ if (StringUtils.isNotEmpty(storeInfodto.getBusinessCategoryName())) {
|
|
|
+ storeInfo.setBusinessCategoryName(storeInfodto.getBusinessCategoryName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 店铺评价:直接使用传入的值(前端传入以逗号拼接的三个值:环境,卫生,口味)
|
|
|
+ if (StringUtils.isNotEmpty(storeInfodto.getStoreEvaluate())) {
|
|
|
+ storeInfo.setStoreEvaluate(storeInfodto.getStoreEvaluate());
|
|
|
+ }
|
|
|
+
|
|
|
+ // // 处理分类信息(已废弃,不再使用)
|
|
|
+ // List<String> businessClassify = storeInfodto.getBusinessClassify();
|
|
|
+ // if (!CollectionUtils.isEmpty(businessClassify)) {
|
|
|
+ // List<String> businessClassifyNames = new ArrayList<>();
|
|
|
+ // //批量查询分类名称
|
|
|
+ // List<StoreDictionary> classifyDicts = storeDictionaryMapper.selectList(
|
|
|
+ // new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ // .in(StoreDictionary::getDictId, businessClassify)
|
|
|
+ // .eq(StoreDictionary::getTypeName, "business_classify")
|
|
|
+ // .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
+ // );
|
|
|
+ // //转为Map方便快速获取
|
|
|
+ // Map<String, StoreDictionary> classifyDictMap = classifyDicts.stream()
|
|
|
+ // .collect(Collectors.toMap(
|
|
|
+ // dict -> dict.getDictId().toString(),
|
|
|
+ // Function.identity(),
|
|
|
+ // (existing, replacement) -> existing
|
|
|
+ // ));
|
|
|
+ // //提取分类名称
|
|
|
+ // for (String classifyId : businessClassify) {
|
|
|
+ // StoreDictionary dict = classifyDictMap.get(classifyId);
|
|
|
+ // if (Objects.nonNull(dict)) {
|
|
|
+ // businessClassifyNames.add(dict.getDictDetail());
|
|
|
+ // } else {
|
|
|
+ // log.warn("无效的分类id:" + classifyId);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // storeInfo.setBusinessClassify(String.join(",", businessClassify));
|
|
|
+ // storeInfo.setBusinessClassifyName(String.join(",", businessClassifyNames));
|
|
|
+ // }
|
|
|
|
|
|
// 5. 处理行政区域信息(抽取为方法,减少重复) 不存在单独查的情况
|
|
|
if (!Objects.isNull(storeInfo.getAdministrativeRegionProvinceAdcode())) {
|
|
|
@@ -5952,6 +5954,238 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Map<String, Object> getBusinessLicenseStatus(int id) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectOne(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getId, id));
|
|
|
+ if (storeInfo == null) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 审核通过给前台反显未提交
|
|
|
+ if (storeInfo.getBusinessLicenseStatus() != null && storeInfo.getBusinessLicenseStatus() == 1) {
|
|
|
+ map.put("businessLicenseStatus", 0);
|
|
|
+ } else {
|
|
|
+ map.put("businessLicenseStatus", storeInfo.getBusinessLicenseStatus() != null ? storeInfo.getBusinessLicenseStatus() : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 营业执照图片列表(img_type=14)
|
|
|
+ List<StoreImg> businessLicenseImgList = storeImgMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StoreImg>()
|
|
|
+ .eq(StoreImg::getStoreId, id)
|
|
|
+ .eq(StoreImg::getImgType, 14)
|
|
|
+ .eq(StoreImg::getDeleteFlag, 0)
|
|
|
+ .orderByAsc(StoreImg::getImgSort)
|
|
|
+ );
|
|
|
+ if (!CollectionUtils.isEmpty(businessLicenseImgList)) {
|
|
|
+ map.put("businessLicenseImgList", businessLicenseImgList);
|
|
|
+ } else {
|
|
|
+ map.put("businessLicenseImgList", new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 营业执照到期时间
|
|
|
+ if (storeInfo.getBusinessLicenseExpirationTime() != null) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+ map.put("businessLicenseExpirationTime", sdf.format(storeInfo.getBusinessLicenseExpirationTime()));
|
|
|
+ } else {
|
|
|
+ map.put("businessLicenseExpirationTime", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 拒绝原因
|
|
|
+ if (StringUtils.isNotEmpty(storeInfo.getBusinessLicenseReason())) {
|
|
|
+ map.put("businessLicenseReason", storeInfo.getBusinessLicenseReason());
|
|
|
+ } else {
|
|
|
+ map.put("businessLicenseReason", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int uploadBusinessLicense(StoreImg storeImg) {
|
|
|
+ // 删除旧的营业执照图片(逻辑删除)
|
|
|
+ LambdaUpdateWrapper<StoreImg> deleteWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ deleteWrapper.eq(StoreImg::getStoreId, storeImg.getStoreId())
|
|
|
+ .eq(StoreImg::getImgType, 14)
|
|
|
+ .set(StoreImg::getDeleteFlag, 1);
|
|
|
+ storeImgMapper.update(null, deleteWrapper);
|
|
|
+
|
|
|
+ // 插入新的营业执照图片
|
|
|
+ storeImg.setImgType(14);
|
|
|
+ storeImg.setImgDescription("营业执照");
|
|
|
+ storeImg.setImgSort(0);
|
|
|
+ storeImg.setDeleteFlag(0);
|
|
|
+ storeImgMapper.insert(storeImg);
|
|
|
+
|
|
|
+ // 插入营业执照历史记录(licenseStatus=3表示营业执照,licenseExecuteStatus=2表示审核中)
|
|
|
+ StoreLicenseHistory licenseHistory = new StoreLicenseHistory();
|
|
|
+ licenseHistory.setStoreId(storeImg.getStoreId());
|
|
|
+ licenseHistory.setLicenseStatus(3); // 3-营业执照
|
|
|
+ licenseHistory.setLicenseExecuteStatus(2); // 2-审核中
|
|
|
+ licenseHistory.setImgUrl(storeImg.getImgUrl());
|
|
|
+ licenseHistory.setDeleteFlag(0);
|
|
|
+ licenseHistoryMapper.insert(licenseHistory);
|
|
|
+
|
|
|
+ // 更新店铺信息
|
|
|
+ StoreInfo storeInfo = new StoreInfo();
|
|
|
+ storeInfo.setId(storeImg.getStoreId());
|
|
|
+ storeInfo.setBusinessLicenseStatus(2); // 2-待审核
|
|
|
+ storeInfo.setUpdateBusinessLicenseTime(new Date());
|
|
|
+
|
|
|
+ // 从OCR识别记录中获取营业执照到期时间
|
|
|
+ if (StringUtils.isNotEmpty(storeImg.getImgUrl())) {
|
|
|
+ OcrImageUpload businessLicenseOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ .eq(OcrImageUpload::getImageUrl, storeImg.getImgUrl())
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode())
|
|
|
+ .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (businessLicenseOcr != null && StringUtils.isNotEmpty(businessLicenseOcr.getOcrResult())) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(businessLicenseOcr.getOcrResult());
|
|
|
+ // 解析营业执照到期时间
|
|
|
+ Date expirationTime = parseBusinessLicenseExpirationDate(ocrResult);
|
|
|
+ if (expirationTime != null) {
|
|
|
+ storeInfo.setBusinessLicenseExpirationTime(expirationTime);
|
|
|
+ log.info("营业执照OCR数据解析成功,门店ID:{},到期时间:{}", storeImg.getStoreId(), expirationTime);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析营业执照OCR数据失败,门店ID:{}", storeImg.getStoreId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ storeInfoMapper.updateById(storeInfo);
|
|
|
+
|
|
|
+ // 调用AI审核接口
|
|
|
+ try {
|
|
|
+ StoreInfo storeInfoForAi = storeInfoMapper.selectById(storeImg.getStoreId());
|
|
|
+ if (storeInfoForAi != null && StringUtils.isNotEmpty(storeInfoForAi.getStoreName())) {
|
|
|
+ Map<String, Object> ocrData = getStoreOcrData(storeImg.getImgUrl(), storeInfoForAi.getStoreName());
|
|
|
+ Boolean overallMatch = (Boolean) ocrData.get("overall_match");
|
|
|
+ log.info("营业执照AI审核结果,门店ID:{},overallMatch:{}", storeImg.getStoreId(), overallMatch);
|
|
|
+ // 注意:AI审核结果不影响当前状态,审核状态由后台管理员审核后更新
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("调用营业执照AI审核接口失败,门店ID:{}", storeImg.getStoreId(), e);
|
|
|
+ // AI审核失败不影响业务流程,继续执行
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StoreLicenseHistory> getBusinessLicenseHistory(Integer storeId) {
|
|
|
+ // 查询营业执照变更记录(licenseStatus=3表示营业执照)
|
|
|
+ // 包括审核中的记录(licenseExecuteStatus=2)和已删除的记录(用于显示拒绝记录)
|
|
|
+ return licenseHistoryMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StoreLicenseHistory>()
|
|
|
+ .eq(StoreLicenseHistory::getStoreId, storeId)
|
|
|
+ .eq(StoreLicenseHistory::getLicenseStatus, 3) // 3-营业执照
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .eq(StoreLicenseHistory::getLicenseExecuteStatus, 2) // 审核中
|
|
|
+ .or()
|
|
|
+ .eq(StoreLicenseHistory::getDeleteFlag, 0) // 未删除的记录
|
|
|
+ )
|
|
|
+ .orderByDesc(StoreLicenseHistory::getCreatedTime)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getOtherQualificationStatus(int id) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectOne(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getId, id));
|
|
|
+ if (storeInfo == null) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其他资质证明图片列表(img_type=35)
|
|
|
+ List<StoreImg> otherQualificationImgList = storeImgMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StoreImg>()
|
|
|
+ .eq(StoreImg::getStoreId, id)
|
|
|
+ .eq(StoreImg::getImgType, 35)
|
|
|
+ .eq(StoreImg::getDeleteFlag, 0)
|
|
|
+ .orderByAsc(StoreImg::getImgSort)
|
|
|
+ );
|
|
|
+ if (!CollectionUtils.isEmpty(otherQualificationImgList)) {
|
|
|
+ map.put("otherQualificationImgList", otherQualificationImgList);
|
|
|
+ } else {
|
|
|
+ map.put("otherQualificationImgList", new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int uploadOtherQualification(List<StoreImg> storeImgList) {
|
|
|
+ if (CollectionUtils.isEmpty(storeImgList)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取门店ID
|
|
|
+ Integer storeId = storeImgList.get(0).getStoreId();
|
|
|
+ if (storeId == null) {
|
|
|
+ throw new IllegalArgumentException("门店ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 限制最多9张
|
|
|
+ int maxCount = Math.min(storeImgList.size(), 9);
|
|
|
+
|
|
|
+ // 删除旧的其他资质证明图片(逻辑删除)
|
|
|
+ LambdaUpdateWrapper<StoreImg> deleteWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ deleteWrapper.eq(StoreImg::getStoreId, storeId)
|
|
|
+ .eq(StoreImg::getImgType, 35)
|
|
|
+ .set(StoreImg::getDeleteFlag, 1);
|
|
|
+ storeImgMapper.update(null, deleteWrapper);
|
|
|
+
|
|
|
+ // 获取门店信息用于AI审核
|
|
|
+ StoreInfo storeInfoForAi = storeInfoMapper.selectById(storeId);
|
|
|
+ String merchantName = storeInfoForAi != null ? storeInfoForAi.getStoreName() : null;
|
|
|
+
|
|
|
+ // 插入新的其他资质证明图片(最多9张)
|
|
|
+ for (int i = 0; i < maxCount; i++) {
|
|
|
+ StoreImg storeImg = storeImgList.get(i);
|
|
|
+ storeImg.setStoreId(storeId);
|
|
|
+ storeImg.setImgType(35); // 其他资质证明图片
|
|
|
+ storeImg.setImgDescription("其他资质证明");
|
|
|
+ storeImg.setImgSort(i + 1);
|
|
|
+ storeImg.setDeleteFlag(0);
|
|
|
+ storeImgMapper.insert(storeImg);
|
|
|
+
|
|
|
+ // 插入其他资质证明历史记录(licenseStatus=4表示其他资质证明,licenseExecuteStatus=2表示审核中)
|
|
|
+ StoreLicenseHistory licenseHistory = new StoreLicenseHistory();
|
|
|
+ licenseHistory.setStoreId(storeId);
|
|
|
+ licenseHistory.setLicenseStatus(4); // 4-其他资质证明
|
|
|
+ licenseHistory.setLicenseExecuteStatus(2); // 2-审核中
|
|
|
+ licenseHistory.setImgUrl(storeImg.getImgUrl());
|
|
|
+ licenseHistory.setDeleteFlag(0);
|
|
|
+ licenseHistoryMapper.insert(licenseHistory);
|
|
|
+
|
|
|
+ // 调用AI审核接口(每张图片都审核)
|
|
|
+ if (StringUtils.isNotEmpty(merchantName) && StringUtils.isNotEmpty(storeImg.getImgUrl())) {
|
|
|
+ try {
|
|
|
+ Map<String, Object> ocrData = getStoreOcrData(storeImg.getImgUrl(), merchantName);
|
|
|
+ Boolean overallMatch = (Boolean) ocrData.get("overall_match");
|
|
|
+ log.info("其他资质证明AI审核结果,门店ID:{},图片URL:{},overallMatch:{}", storeId, storeImg.getImgUrl(), overallMatch);
|
|
|
+ // 注意:AI审核结果不影响当前状态,审核状态由后台管理员审核后更新
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("调用其他资质证明AI审核接口失败,门店ID:{},图片URL:{}", storeId, storeImg.getImgUrl(), e);
|
|
|
+ // AI审核失败不影响业务流程,继续执行
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return maxCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StoreLicenseHistory> getOtherQualificationHistory(Integer storeId) {
|
|
|
+ // 查询其他资质证明变更记录(licenseStatus=4表示其他资质证明)
|
|
|
+ // 查询所有状态的记录:审核中(2)、审核拒绝(3)、审核通过(1)
|
|
|
+ return licenseHistoryMapper.queryLicenceByStatusList(storeId, 4, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public StoreThreeLevelStructureVo getStoreThreeLevelStructure(Integer storeId) {
|
|
|
// 1. 根据门店ID查询门店信息
|
|
|
StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
|