|
|
@@ -240,10 +240,33 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
storeMainInfoVo.setStoreLabel(storeLabelMapper.selectOne(new LambdaQueryWrapper<StoreLabel>().eq(StoreLabel::getStoreId, id)));
|
|
|
//营业时间
|
|
|
storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, id)));
|
|
|
- //门店头像
|
|
|
- LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, id);
|
|
|
- StoreImg storeImg = storeImgMapper.selectOne(eq);
|
|
|
- storeMainInfoVo.setHeadImgUrl(storeImg != null ? storeImg.getImgUrl() : "");
|
|
|
+ //门店头图(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("");
|
|
|
+ }
|
|
|
+ // 设置头图审核状态
|
|
|
+ // 逻辑说明:
|
|
|
+ // 1. 上传头图后,审核通过时,store_info.head_img_status会被设置为1
|
|
|
+ // 2. 查询时,如果store_info.head_img_status=1,说明头图已审核通过,返回1
|
|
|
+ // 从store_info表获取head_img_status字段值(通过getStoreInfo查询已包含此字段)
|
|
|
+ Integer headImgStatusFromDb = storeMainInfoVo.getHeadImgStatus();
|
|
|
+ if (headImgStatusFromDb != null && headImgStatusFromDb == 1) {
|
|
|
+ // 数据库head_img_status=1(审核通过),返回1
|
|
|
+ storeMainInfoVo.setHeadImgStatus(1); // 审核通过
|
|
|
+ } else {
|
|
|
+ // 数据库head_img_status不为1(待审核0、不通过2、拒绝3或为空),返回2
|
|
|
+ storeMainInfoVo.setHeadImgStatus(2); // 审核不通过
|
|
|
+ }
|
|
|
List<StoreUser> storeUsers = storeUserMapper.selectList(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()));
|
|
|
for (StoreUser storeUser : storeUsers) {
|
|
|
storeMainInfoVo.setLogoutFlagUser(storeUser.getLogoutFlag());
|
|
|
@@ -3089,6 +3112,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图
|
|
|
* 关联查询 store_img 和 store_operational_activity 表
|
|
|
* 关联条件:store_operational_activity.id = store_img.business_id
|