|
@@ -17,12 +17,12 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.geo.Point;
|
|
import org.springframework.data.geo.Point;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
|
+import org.springframework.http.*;
|
|
|
|
|
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartRequest;
|
|
import org.springframework.web.multipart.MultipartRequest;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
@@ -41,14 +41,12 @@ import shop.alien.store.service.*;
|
|
|
import shop.alien.store.util.CommonConstant;
|
|
import shop.alien.store.util.CommonConstant;
|
|
|
import shop.alien.store.util.FileUploadUtil;
|
|
import shop.alien.store.util.FileUploadUtil;
|
|
|
import shop.alien.store.util.GroupConstant;
|
|
import shop.alien.store.util.GroupConstant;
|
|
|
|
|
+import shop.alien.store.util.ai.AiAuthTokenUtil;
|
|
|
import shop.alien.store.util.ali.AliApi;
|
|
import shop.alien.store.util.ali.AliApi;
|
|
|
import shop.alien.util.ali.AliOSSUtil;
|
|
import shop.alien.util.ali.AliOSSUtil;
|
|
|
import shop.alien.util.common.DistanceUtil;
|
|
import shop.alien.util.common.DistanceUtil;
|
|
|
import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
|
-import shop.alien.util.common.constant.CouponStatusEnum;
|
|
|
|
|
-import shop.alien.util.common.constant.CouponTypeEnum;
|
|
|
|
|
-import shop.alien.util.common.constant.DiscountCouponEnum;
|
|
|
|
|
-import shop.alien.util.common.constant.OrderStatusEnum;
|
|
|
|
|
|
|
+import shop.alien.util.common.constant.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
@@ -143,6 +141,12 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
|
|
|
|
|
private final LifeBlacklistMapper lifeBlacklistMapper;
|
|
private final LifeBlacklistMapper lifeBlacklistMapper;
|
|
|
|
|
|
|
|
|
|
+ private final OcrImageUploadMapper ocrImageUploadMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final AiAuthTokenUtil aiAuthTokenUtil;
|
|
|
|
|
+
|
|
|
|
|
+ private final RestTemplate restTemplate;
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private StoreIncomeDetailsRecordService storeIncomeDetailsRecordService;
|
|
private StoreIncomeDetailsRecordService storeIncomeDetailsRecordService;
|
|
|
|
|
|
|
@@ -153,6 +157,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
@Value("${spring.web.resources.excel-generate-path}")
|
|
@Value("${spring.web.resources.excel-generate-path}")
|
|
|
private String excelGeneratePath;
|
|
private String excelGeneratePath;
|
|
|
|
|
|
|
|
|
|
+ @Value("${third-party-identification.base-url}")
|
|
|
|
|
+ private String identificationPath;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 懒得查, 留着导出Excel
|
|
* 懒得查, 留着导出Excel
|
|
|
*/
|
|
*/
|
|
@@ -2604,4 +2611,64 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
}
|
|
|
return filteredList;
|
|
return filteredList;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, Object> getStoreOcrData(String storeId, String imageUrl) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ LambdaQueryWrapper<OcrImageUpload> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(OcrImageUpload::getStoreId, storeId)
|
|
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode());
|
|
|
|
|
+ OcrImageUpload ocrImageUploads = ocrImageUploadMapper.selectOne(queryWrapper);
|
|
|
|
|
+ if(ocrImageUploads== null){
|
|
|
|
|
+ throw new RuntimeException("未找到OCI识别数据!");
|
|
|
|
|
+ }
|
|
|
|
|
+ String accessToken = aiAuthTokenUtil.getAccessToken();
|
|
|
|
|
+
|
|
|
|
|
+ HttpHeaders aiHeaders = new HttpHeaders();
|
|
|
|
|
+ aiHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
+ aiHeaders.set("Authorization", "Bearer " + accessToken);
|
|
|
|
|
+ Map<String, Object> jsonBody = new HashMap<>();
|
|
|
|
|
+ List<String> imageUrls = new ArrayList<>();
|
|
|
|
|
+ imageUrls.add(imageUrl);
|
|
|
|
|
+ jsonBody.put("image_urls", imageUrls);
|
|
|
|
|
+ String ocrResult = ocrImageUploads.getOcrResult();
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(ocrResult);
|
|
|
|
|
+ jsonBody.put("merchant_name", jsonObject.get("companyName"));
|
|
|
|
|
+
|
|
|
|
|
+ HttpEntity<Map<String, Object>> request = new HttpEntity<>(jsonBody, aiHeaders);
|
|
|
|
|
+ ResponseEntity<String> response = null;
|
|
|
|
|
+ HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
|
|
|
|
|
+ factory.setConnectTimeout(5000);
|
|
|
|
|
+ factory.setReadTimeout(60000);
|
|
|
|
|
+ restTemplate.setRequestFactory(factory);
|
|
|
|
|
+ try {
|
|
|
|
|
+ response = restTemplate.postForEntity(identificationPath, request, String.class);
|
|
|
|
|
+ if (response.getStatusCodeValue() != 200) {
|
|
|
|
|
+ throw new RuntimeException("AI内容审核接口调用失败 http状态:" + response.getStatusCode());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException("AI接口调用失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ com.alibaba.fastjson2.JSONObject responseNode = com.alibaba.fastjson2.JSONObject.parseObject(response.getBody());
|
|
|
|
|
+ if (responseNode == null) {
|
|
|
|
|
+ throw new RuntimeException("AI接口调用失败,响应内容为空");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Integer code = responseNode.getInteger("code");
|
|
|
|
|
+ if (code == 200) {
|
|
|
|
|
+ Map<String, Object> dataMap = (Map<String, Object>) responseNode.get("data");
|
|
|
|
|
+ if (Objects.nonNull(dataMap)) {
|
|
|
|
|
+ // 获取match_results(JSON中是数组,反序列化为List<Map>)
|
|
|
|
|
+ List<Map<String, Object>> matchResults = (List<Map<String, Object>>) dataMap.get("match_results");
|
|
|
|
|
+ map.put("overall_match", dataMap.get("overall_match"));
|
|
|
|
|
+ if (Objects.nonNull(matchResults) && !matchResults.isEmpty()) {
|
|
|
|
|
+ map.put("match_reason", matchResults.get(0).get("match_reason"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new RuntimeException("AI接口调用失败,错误码: " + code);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|