|
|
@@ -1036,7 +1036,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 计算并设置到期时间为四个过期时间的最小值
|
|
|
+ // 计算并设置到期时间为五个过期时间的最小值(包含身份证过期时间)
|
|
|
List<Date> expirationTimeList = new ArrayList<>();
|
|
|
// 收集所有非空的过期时间
|
|
|
if (storeInfoDto.getExpirationTime() != null) {
|
|
|
@@ -1051,11 +1051,12 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
if (storeInfo.getBusinessLicenseExpirationTime() != null) {
|
|
|
expirationTimeList.add(storeInfo.getBusinessLicenseExpirationTime());
|
|
|
}
|
|
|
+ // 注意:身份证过期时间在saveIdCardImages方法中设置,这里先不包含,后续会在saveIdCardImages后更新
|
|
|
// 取最小值设置为门店到期时间
|
|
|
if (!expirationTimeList.isEmpty()) {
|
|
|
Date minExpirationTime = Collections.min(expirationTimeList);
|
|
|
storeInfo.setExpirationTime(minExpirationTime);
|
|
|
- log.info("设置门店到期时间为四个过期时间的最小值:{}", minExpirationTime);
|
|
|
+ log.info("设置门店到期时间为过期时间的最小值:{}", minExpirationTime);
|
|
|
}
|
|
|
|
|
|
storeInfoMapper.insert(storeInfo);
|
|
|
@@ -1122,6 +1123,23 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
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<>();
|
|
|
tagStoreRelationLambdaQueryWrapper.eq(TagStoreRelation::getStoreId, storeInfo.getId());
|
|
|
@@ -4830,6 +4848,157 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
return parseDateString(endDateStr);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存身份证正反面图片到store_img表,并解析OCR结果设置过期时间和状态
|
|
|
+ *
|
|
|
+ * @param storeId 门店ID
|
|
|
+ * @param storeUserId 店铺用户ID
|
|
|
+ * @param storeInfo 门店信息对象(用于设置身份证状态和过期时间)
|
|
|
+ */
|
|
|
+ private void saveIdCardImages(Integer storeId, String storeUserId, StoreInfo storeInfo) {
|
|
|
+ try {
|
|
|
+ // 查询身份证OCR识别记录(根据storeUserId和ocrType=ID_CARD)
|
|
|
+ List<OcrImageUpload> idCardOcrList = ocrImageUploadMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ .eq(OcrImageUpload::getStoreUserId, storeUserId)
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.ID_CARD.getCode())
|
|
|
+ .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(idCardOcrList)) {
|
|
|
+ log.info("未找到身份证OCR记录,storeUserId={}", storeUserId);
|
|
|
+ // 没有OCR记录时,初始化状态为"未提交"(字典值0)
|
|
|
+ storeInfo.setIdCardStatus(0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String idCardFrontUrl = null;
|
|
|
+ String idCardBackUrl = null;
|
|
|
+ Date idCardExpirationTime = null;
|
|
|
+
|
|
|
+ // 遍历OCR记录,区分正面和反面
|
|
|
+ for (OcrImageUpload ocrRecord : idCardOcrList) {
|
|
|
+ if (StringUtils.isEmpty(ocrRecord.getOcrResult())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 解析OCR结果JSON
|
|
|
+ com.alibaba.fastjson2.JSONObject ocrResultJson = com.alibaba.fastjson2.JSONObject.parseObject(ocrRecord.getOcrResult());
|
|
|
+
|
|
|
+ // 检查是正面还是反面
|
|
|
+ if (ocrResultJson.containsKey("face")) {
|
|
|
+ // 身份证正面
|
|
|
+ idCardFrontUrl = ocrRecord.getImageUrl();
|
|
|
+ log.info("找到身份证正面图片,URL={}", idCardFrontUrl);
|
|
|
+ } else if (ocrResultJson.containsKey("back")) {
|
|
|
+ // 身份证反面
|
|
|
+ idCardBackUrl = ocrRecord.getImageUrl();
|
|
|
+ log.info("找到身份证反面图片,URL={}", idCardBackUrl);
|
|
|
+
|
|
|
+ // 从反面OCR结果中提取有效期限
|
|
|
+ com.alibaba.fastjson2.JSONObject backData = ocrResultJson.getJSONObject("back");
|
|
|
+ if (backData != null) {
|
|
|
+ com.alibaba.fastjson2.JSONObject data = backData.getJSONObject("data");
|
|
|
+ if (data != null) {
|
|
|
+ String validPeriod = data.getString("validPeriod");
|
|
|
+ if (StringUtils.isNotEmpty(validPeriod)) {
|
|
|
+ idCardExpirationTime = parseIdCardExpirationDate(validPeriod);
|
|
|
+ if (idCardExpirationTime != null) {
|
|
|
+ log.info("解析身份证有效期限成功,过期时间:{}", idCardExpirationTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析身份证OCR结果失败,ocrRecordId={}", ocrRecord.getId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存身份证正面图片到store_img表(img_type=33)
|
|
|
+ if (StringUtils.isNotEmpty(idCardFrontUrl)) {
|
|
|
+ StoreImg frontImg = new StoreImg();
|
|
|
+ frontImg.setStoreId(storeId);
|
|
|
+ frontImg.setImgType(33);
|
|
|
+ frontImg.setImgSort(1);
|
|
|
+ frontImg.setImgDescription("身份证正面");
|
|
|
+ frontImg.setImgUrl(idCardFrontUrl);
|
|
|
+ storeImgMapper.insert(frontImg);
|
|
|
+ log.info("保存身份证正面图片成功,storeId={}, imgUrl={}", storeId, idCardFrontUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存身份证反面图片到store_img表(img_type=34)
|
|
|
+ if (StringUtils.isNotEmpty(idCardBackUrl)) {
|
|
|
+ StoreImg backImg = new StoreImg();
|
|
|
+ backImg.setStoreId(storeId);
|
|
|
+ backImg.setImgType(34);
|
|
|
+ backImg.setImgSort(2);
|
|
|
+ backImg.setImgDescription("身份证反面");
|
|
|
+ backImg.setImgUrl(idCardBackUrl);
|
|
|
+ storeImgMapper.insert(backImg);
|
|
|
+ log.info("保存身份证反面图片成功,storeId={}, imgUrl={}", storeId, idCardBackUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置身份证状态和过期时间
|
|
|
+ if (StringUtils.isNotEmpty(idCardFrontUrl) || StringUtils.isNotEmpty(idCardBackUrl)) {
|
|
|
+ // 有身份证图片时,设置状态为"待审核"(字典值2,使用foodLicenceStatus字典)
|
|
|
+ storeInfo.setIdCardStatus(2);
|
|
|
+ storeInfo.setUpdateIdCardTime(new Date());
|
|
|
+ if (idCardExpirationTime != null) {
|
|
|
+ storeInfo.setIdCardExpirationTime(idCardExpirationTime);
|
|
|
+ }
|
|
|
+ log.info("设置身份证状态为待审核,过期时间:{}", idCardExpirationTime);
|
|
|
+ } else {
|
|
|
+ // 没有身份证图片时,初始化状态为"未提交"(字典值0)
|
|
|
+ storeInfo.setIdCardStatus(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("保存身份证图片失败,storeId={}, storeUserId={}", storeId, storeUserId, e);
|
|
|
+ // 发生异常时,初始化状态为"未提交"(字典值0)
|
|
|
+ storeInfo.setIdCardStatus(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析身份证有效期限
|
|
|
+ * 身份证OCR返回格式:validPeriod="2023.05.29-2033.05.29"
|
|
|
+ *
|
|
|
+ * @param validPeriod 有效期限字符串,格式:"2023.05.29-2033.05.29"
|
|
|
+ * @return 到期日期,如果解析失败则返回null
|
|
|
+ */
|
|
|
+ private Date parseIdCardExpirationDate(String validPeriod) {
|
|
|
+ if (StringUtils.isEmpty(validPeriod)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理"长期"或"永久"情况
|
|
|
+ if (validPeriod.contains("长期") || validPeriod.contains("永久")) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 身份证格式:2023.05.29-2033.05.29,提取结束日期
|
|
|
+ if (validPeriod.contains("-")) {
|
|
|
+ String[] parts = validPeriod.split("-");
|
|
|
+ if (parts.length >= 2) {
|
|
|
+ String endDateStr = parts[1].trim();
|
|
|
+ // 将 "2023.05.29" 格式转换为 "2023-05-29"
|
|
|
+ endDateStr = endDateStr.replace(".", "-");
|
|
|
+ return parseDateString(endDateStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果格式不匹配,尝试直接解析
|
|
|
+ String normalizedDateStr = validPeriod.replace(".", "-");
|
|
|
+ return parseDateString(normalizedDateStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("解析身份证有效期限失败,validPeriod={}", validPeriod, e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public StoreInfoVo getClientStoreDetail(String storeId, String userId, String jingdu, String weidu) {
|
|
|
StoreInfoVo result = new StoreInfoVo();
|