|
@@ -244,6 +244,70 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, id);
|
|
LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, id);
|
|
|
StoreImg storeImg = storeImgMapper.selectOne(eq);
|
|
StoreImg storeImg = storeImgMapper.selectOne(eq);
|
|
|
storeMainInfoVo.setHeadImgUrl(storeImg != null ? storeImg.getImgUrl() : "");
|
|
storeMainInfoVo.setHeadImgUrl(storeImg != null ? storeImg.getImgUrl() : "");
|
|
|
|
|
+
|
|
|
|
|
+ // 查询头图列表(包含is_extract字段)
|
|
|
|
|
+ Integer imgMode = storeInfo.getImgMode();
|
|
|
|
|
+ Integer headerImgType = null;
|
|
|
|
|
+ if (imgMode != null && imgMode == 1) {
|
|
|
|
|
+ // 多图模式
|
|
|
|
|
+ headerImgType = GroupConstant.IMG_TYPE_MULTI_MODE;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 单图模式(默认)
|
|
|
|
|
+ headerImgType = GroupConstant.IMG_TYPE_SINGLE_MODE;
|
|
|
|
|
+ }
|
|
|
|
|
+ LambdaQueryWrapper<StoreImg> headerImgQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ headerImgQueryWrapper.eq(StoreImg::getImgType, headerImgType);
|
|
|
|
|
+ headerImgQueryWrapper.eq(StoreImg::getStoreId, id);
|
|
|
|
|
+ headerImgQueryWrapper.orderByAsc(StoreImg::getImgSort);
|
|
|
|
|
+ List<StoreImg> headerImgList = storeImgMapper.selectList(headerImgQueryWrapper);
|
|
|
|
|
+ storeMainInfoVo.setHeaderImgList(headerImgList);
|
|
|
|
|
+
|
|
|
|
|
+ //门店头图(20:头图单图模式, 21:头图多图模式)
|
|
|
|
|
+ LambdaQueryWrapper<StoreImg> headImgWrapper = new LambdaQueryWrapper<StoreImg>()
|
|
|
|
|
+ .in(StoreImg::getImgType, 20, 21)
|
|
|
|
|
+ .eq(StoreImg::getStoreId, id)
|
|
|
|
|
+ .eq(StoreImg::getDeleteFlag, 0)
|
|
|
|
|
+ .orderByAsc(StoreImg::getImgSort);
|
|
|
|
|
+ List<StoreImg> headImgList = storeImgMapper.selectList(headImgWrapper);
|
|
|
|
|
+ // 设置头图URL(取第一张图片,如果是多图模式可能有多个)
|
|
|
|
|
+ if (headImgList != null && !headImgList.isEmpty()) {
|
|
|
|
|
+ StoreImg firstHeadImg = headImgList.get(0);
|
|
|
|
|
+ storeMainInfoVo.setHeadImgUrl(firstHeadImg.getImgUrl() != null ? firstHeadImg.getImgUrl() : "");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ storeMainInfoVo.setHeadImgUrl("");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 设置头图审核状态
|
|
|
|
|
+ boolean hasHeadImg = false;
|
|
|
|
|
+ if (headImgList != null && !headImgList.isEmpty()) {
|
|
|
|
|
+ // 检查头图列表中是否有有效的图片地址
|
|
|
|
|
+ for (StoreImg headImg : headImgList) {
|
|
|
|
|
+ String imgUrl = headImg.getImgUrl();
|
|
|
|
|
+ if (imgUrl != null && !imgUrl.trim().isEmpty()) {
|
|
|
|
|
+ hasHeadImg = true;
|
|
|
|
|
+ log.debug("门店头图数据检查,storeId={}, imgType={}, imgUrl={}, 判断为有头图",
|
|
|
|
|
+ id, headImg.getImgType(), imgUrl);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 根据是否有头图数据确定审核状态:有数据返回1(审核通过),没有数据返回2(审核不通过)
|
|
|
|
|
+ Integer headImgStatus = hasHeadImg ? 1 : 2;
|
|
|
|
|
+ // 获取数据库中的head_img_status状态
|
|
|
|
|
+ Integer headImgStatusFromDb = storeInfo.getHeadImgStatus();
|
|
|
|
|
+ // 记录查询结果日志
|
|
|
|
|
+ log.info("门店头图审核状态判断,storeId={}, 查询到头图数量={}, 是否有有效头图={}, 审核状态={}, 数据库原状态={}",
|
|
|
|
|
+ id, headImgList != null ? headImgList.size() : 0, hasHeadImg, headImgStatus, headImgStatusFromDb);
|
|
|
|
|
+ // 实时更新数据库:如果数据库中的状态与实际情况不一致,或者为null,则更新数据库
|
|
|
|
|
+ if (headImgStatusFromDb == null || !headImgStatus.equals(headImgStatusFromDb)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ updateHeadImgStatus(id, headImgStatus);
|
|
|
|
|
+ log.info("门店头图审核状态已实时更新,storeId={}, 原状态={}, 新状态={}", id, headImgStatusFromDb, headImgStatus);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("更新门店头图审核状态失败,storeId={}, error={}", id, e.getMessage(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 设置返回的审核状态(以实际的头图数据为准)
|
|
|
|
|
+ storeMainInfoVo.setHeadImgStatus(headImgStatus);
|
|
|
List<StoreUser> storeUsers = storeUserMapper.selectList(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()));
|
|
List<StoreUser> storeUsers = storeUserMapper.selectList(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()));
|
|
|
for (StoreUser storeUser : storeUsers) {
|
|
for (StoreUser storeUser : storeUsers) {
|
|
|
storeMainInfoVo.setLogoutFlagUser(storeUser.getLogoutFlag());
|
|
storeMainInfoVo.setLogoutFlagUser(storeUser.getLogoutFlag());
|
|
@@ -796,8 +860,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
List<String> businessTypeNames = new ArrayList<>();
|
|
List<String> businessTypeNames = new ArrayList<>();
|
|
|
//获取经营种类名称
|
|
//获取经营种类名称
|
|
|
for (String businessType : businessTypes) {
|
|
for (String businessType : businessTypes) {
|
|
|
- StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, businessType).eq(StoreDictionary::getParentId, businessSectionName.getId()));
|
|
|
|
|
- businessTypeNames.add(storeDictionary.getDictDetail());
|
|
|
|
|
|
|
+ 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());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
StoreInfoVo result = new StoreInfoVo();
|
|
StoreInfoVo result = new StoreInfoVo();
|
|
@@ -1251,8 +1321,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
List<String> businessTypeNames = new ArrayList<>();
|
|
List<String> businessTypeNames = new ArrayList<>();
|
|
|
//获取经营种类名称
|
|
//获取经营种类名称
|
|
|
for (String businessType : businessTypes) {
|
|
for (String businessType : businessTypes) {
|
|
|
- StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, businessType).eq(StoreDictionary::getParentId, businessSectionName.getId()));
|
|
|
|
|
- businessTypeNames.add(storeDictionary.getDictDetail());
|
|
|
|
|
|
|
+ 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());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
StoreInfoVo result = new StoreInfoVo();
|
|
StoreInfoVo result = new StoreInfoVo();
|
|
@@ -1429,7 +1505,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
.eq(StoreDictionary::getDictId, parentId)
|
|
.eq(StoreDictionary::getDictId, parentId)
|
|
|
.isNull(StoreDictionary::getParentId));
|
|
.isNull(StoreDictionary::getParentId));
|
|
|
List<StoreDictionary> storeDictionaries = storeDictionaryMapper.selectList(new LambdaQueryWrapper<StoreDictionary>()
|
|
List<StoreDictionary> storeDictionaries = storeDictionaryMapper.selectList(new LambdaQueryWrapper<StoreDictionary>()
|
|
|
- .eq(StoreDictionary::getParentId, businessSection.getId()));
|
|
|
|
|
|
|
+ .eq(StoreDictionary::getTypeName, "business_type")
|
|
|
|
|
+ .eq(StoreDictionary::getParentId, businessSection.getId())
|
|
|
|
|
+ .eq(StoreDictionary::getDeleteFlag, 0));
|
|
|
List<StoreDictionaryVo> voList = new ArrayList<>();
|
|
List<StoreDictionaryVo> voList = new ArrayList<>();
|
|
|
for (StoreDictionary storeDictionary : storeDictionaries) {
|
|
for (StoreDictionary storeDictionary : storeDictionaries) {
|
|
|
StoreDictionaryVo vo = new StoreDictionaryVo();
|
|
StoreDictionaryVo vo = new StoreDictionaryVo();
|
|
@@ -2541,6 +2619,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
new LambdaQueryWrapper<StoreDictionary>()
|
|
new LambdaQueryWrapper<StoreDictionary>()
|
|
|
.in(StoreDictionary::getDictId, businessTypes) // 批量匹配id
|
|
.in(StoreDictionary::getDictId, businessTypes) // 批量匹配id
|
|
|
.eq(StoreDictionary::getParentId, businessSectionDict.getId())
|
|
.eq(StoreDictionary::getParentId, businessSectionDict.getId())
|
|
|
|
|
+ .eq(StoreDictionary::getTypeName, "business_type") // 只查询经营种类,排除擅长标签
|
|
|
|
|
+ .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
);
|
|
);
|
|
|
// 转为Map<dictId, StoreDictionary>,方便快速获取
|
|
// 转为Map<dictId, StoreDictionary>,方便快速获取
|
|
|
Map<String, StoreDictionary> typeDictMap = typeDicts.stream()
|
|
Map<String, StoreDictionary> typeDictMap = typeDicts.stream()
|
|
@@ -3089,6 +3169,98 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 头图上传后AI审核并更新审核状态
|
|
|
|
|
+ * 流程:上传头图 → 调用AI门头识别接口 → 根据结果更新head_img_status → 保存到store_img表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param storeImgInfoVo 图片信息VO
|
|
|
|
|
+ * @return 审核结果 true-审核通过,false-审核不通过
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean auditHeadImageAndUpdateStatus(StoreImgInfoVo storeImgInfoVo) {
|
|
|
|
|
+ // 判断是否是头图(20:单图模式, 21:多图模式)
|
|
|
|
|
+ Integer imgType = storeImgInfoVo.getImgType();
|
|
|
|
|
+ if (imgType == null || (imgType != GroupConstant.IMG_TYPE_SINGLE_MODE && imgType != GroupConstant.IMG_TYPE_MULTI_MODE)) {
|
|
|
|
|
+ // 不是头图,不需要审核,直接返回true
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<StoreImg> storeImgList = storeImgInfoVo.getStoreImgList();
|
|
|
|
|
+ if (storeImgList == null || storeImgList.isEmpty()) {
|
|
|
|
|
+ // 没有图片,设置审核状态为不通过
|
|
|
|
|
+ updateHeadImgStatus(storeImgInfoVo.getStoreId(), 2);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取第一张头图的URL(头图可能有多张,取第一张进行审核)
|
|
|
|
|
+ StoreImg firstHeadImg = storeImgList.get(0);
|
|
|
|
|
+ String imageUrl = firstHeadImg.getImgUrl();
|
|
|
|
|
+ if (imageUrl == null || imageUrl.trim().isEmpty()) {
|
|
|
|
|
+ // 图片URL为空,设置审核状态为不通过
|
|
|
|
|
+ updateHeadImgStatus(storeImgInfoVo.getStoreId(), 2);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取门店信息(需要门店名称用于AI审核)
|
|
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectById(storeImgInfoVo.getStoreId());
|
|
|
|
|
+ if (storeInfo == null) {
|
|
|
|
|
+ log.error("门店不存在,storeId={}", storeImgInfoVo.getStoreId());
|
|
|
|
|
+ updateHeadImgStatus(storeImgInfoVo.getStoreId(), 2);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String merchantName = storeInfo.getStoreName();
|
|
|
|
|
+ if (merchantName == null || merchantName.trim().isEmpty()) {
|
|
|
|
|
+ log.error("门店名称为空,storeId={}", storeImgInfoVo.getStoreId());
|
|
|
|
|
+ updateHeadImgStatus(storeImgInfoVo.getStoreId(), 2);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 调用AI门头识别接口进行审核
|
|
|
|
|
+ Map<String, Object> ocrData = getStoreOcrData(imageUrl, merchantName);
|
|
|
|
|
+ Boolean overallMatch = (Boolean) ocrData.get("overall_match");
|
|
|
|
|
+
|
|
|
|
|
+ // 根据AI审核结果更新head_img_status
|
|
|
|
|
+ // overall_match = true -> 审核通过 -> head_img_status = 1(保持通过状态)
|
|
|
|
|
+ // overall_match = false -> 审核不通过 -> head_img_status = 2(改为不通过)
|
|
|
|
|
+ if (overallMatch != null && overallMatch) {
|
|
|
|
|
+ // AI审核通过,保持审核通过状态(1)
|
|
|
|
|
+ updateHeadImgStatus(storeImgInfoVo.getStoreId(), 1);
|
|
|
|
|
+ log.info("头图AI审核通过,storeId={}, imageUrl={}, headImgStatus=1",
|
|
|
|
|
+ storeImgInfoVo.getStoreId(), imageUrl);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // AI审核不通过,更新为不通过状态(2)
|
|
|
|
|
+ updateHeadImgStatus(storeImgInfoVo.getStoreId(), 2);
|
|
|
|
|
+ log.info("头图AI审核不通过,storeId={}, imageUrl={}, overallMatch={}, headImgStatus=2",
|
|
|
|
|
+ storeImgInfoVo.getStoreId(), imageUrl, overallMatch);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("头图AI审核失败,storeId={}, imageUrl={}, error={}",
|
|
|
|
|
+ storeImgInfoVo.getStoreId(), imageUrl, e.getMessage(), e);
|
|
|
|
|
+ // AI审核失败,设置审核状态为不通过
|
|
|
|
|
+ updateHeadImgStatus(storeImgInfoVo.getStoreId(), 2);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新门店头图审核状态
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param storeId 门店ID
|
|
|
|
|
+ * @param headImgStatus 审核状态 1-审核通过,2-审核不通过
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void updateHeadImgStatus(Integer storeId, Integer headImgStatus) {
|
|
|
|
|
+ LambdaUpdateWrapper<StoreInfo> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ wrapper.eq(StoreInfo::getId, storeId);
|
|
|
|
|
+ wrapper.set(StoreInfo::getHeadImgStatus, headImgStatus);
|
|
|
|
|
+ storeInfoMapper.update(null, wrapper);
|
|
|
|
|
+ log.info("更新门店头图审核状态,storeId={}, headImgStatus={}", storeId, headImgStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 获取活动banner图
|
|
* 获取活动banner图
|
|
|
* 关联查询 store_img 和 store_operational_activity 表
|
|
* 关联查询 store_img 和 store_operational_activity 表
|
|
|
* 关联条件:store_operational_activity.id = store_img.business_id
|
|
* 关联条件:store_operational_activity.id = store_img.business_id
|