ocr 调试,todo
This commit is contained in:
parent
8873bff6e5
commit
d46541b90a
@ -84,8 +84,14 @@ public class WeiXinController extends BaseControllerImpl {
|
|||||||
return CommonResult.success(weiXinService.jsCode2Session(code, encryptedData, iv, activity_id, user_info));
|
return CommonResult.success(weiXinService.jsCode2Session(code, encryptedData, iv, activity_id, user_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取微信的 OpenId")
|
||||||
|
@RequestMapping(value = "/getWxOpenId", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
|
public CommonResult jsCode2Session(@RequestParam(name = "code") String code) {
|
||||||
|
return CommonResult.success(weiXinService.getJsCode2Session(code));
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取微信小程序用户授权手机号,并绑定登录用户")
|
@ApiOperation(value = "获取微信小程序用户授权手机号,并绑定登录用户")
|
||||||
@RequestMapping(value = "/getUserPhoneNumber", method = RequestMethod.GET)
|
@RequestMapping(value = "/getUserPhoneNumber", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
public CommonResult getUserPhoneNumber(@RequestParam(name = "code") String code) {
|
public CommonResult getUserPhoneNumber(@RequestParam(name = "code") String code) {
|
||||||
return CommonResult.success(weiXinService.getUserPhoneNumberAndBindUser(code, getCurrentUser()));
|
return CommonResult.success(weiXinService.getUserPhoneNumberAndBindUser(code, getCurrentUser()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,14 @@ public interface WeiXinService {
|
|||||||
|
|
||||||
Map<String, Object> checkAppLogin(String code);
|
Map<String, Object> checkAppLogin(String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 纯粹获取微信用户的 OpenId
|
||||||
|
*
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, String> getJsCode2Session(String code);
|
||||||
|
|
||||||
Map jsCode2Session(String code, String encryptedData, String iv, String activity_id, String user_info);
|
Map jsCode2Session(String code, String encryptedData, String iv, String activity_id, String user_info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -359,7 +359,14 @@ public class WeiXinServiceImpl implements WeiXinService {
|
|||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> getJsCode2Session(String code) {
|
/**
|
||||||
|
* 纯粹获取微信用户的 OpenId
|
||||||
|
*
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getJsCode2Session(String code) {
|
||||||
//从微信服务器获得session_key,openid,unionid
|
//从微信服务器获得session_key,openid,unionid
|
||||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
|
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -92,6 +93,18 @@ public class OssServiceImpl implements OssService {
|
|||||||
@Value("${upload.filepath}")
|
@Value("${upload.filepath}")
|
||||||
private String FILEPATH;
|
private String FILEPATH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断路径是否存在,不存在创建
|
||||||
|
*
|
||||||
|
* @param dirPath
|
||||||
|
*/
|
||||||
|
private static void isChartPathExist(String dirPath) {
|
||||||
|
File file = new File(dirPath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移动端上传文件
|
* 移动端上传文件
|
||||||
*
|
*
|
||||||
@ -186,13 +199,11 @@ public class OssServiceImpl implements OssService {
|
|||||||
//截图
|
//截图
|
||||||
//todo 放入upload中
|
//todo 放入upload中
|
||||||
String thumb_file_url = "";
|
String thumb_file_url = "";
|
||||||
if (VideoUtil.videoAllowFiles.contains(VideoUtil.getVideoFormat(uploadPath)))
|
if (VideoUtil.videoAllowFiles.contains(VideoUtil.getVideoFormat(uploadPath))) {
|
||||||
{
|
|
||||||
String cover_path = uploadPath.replace("." + VideoUtil.getVideoFormat(uploadPath), ".jpg");
|
String cover_path = uploadPath.replace("." + VideoUtil.getVideoFormat(uploadPath), ".jpg");
|
||||||
String cover_upname = uploadName.replace("." + VideoUtil.getVideoFormat(uploadName), ".jpg");
|
String cover_upname = uploadName.replace("." + VideoUtil.getVideoFormat(uploadName), ".jpg");
|
||||||
|
|
||||||
if (VideoUtil.getVideoCover(uploadPath, cover_path, 1, "375*667"))
|
if (VideoUtil.getVideoCover(uploadPath, cover_path, 1, "375*667")) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
thumb_file_url = uploadObject2OSS(new File(cover_path), ALIYUN_OSS_DIR_PREFIX.concat("/").concat(dir).concat("/").concat(cover_upname));
|
thumb_file_url = uploadObject2OSS(new File(cover_path), ALIYUN_OSS_DIR_PREFIX.concat("/").concat(dir).concat("/").concat(cover_upname));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -200,9 +211,7 @@ public class OssServiceImpl implements OssService {
|
|||||||
|
|
||||||
thumb_file_url = "";
|
thumb_file_url = "";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
thumb_file_url = "";
|
thumb_file_url = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,9 +306,9 @@ public class OssServiceImpl implements OssService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 腾讯云上传
|
* 腾讯云上传
|
||||||
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* @param concat
|
* @param concat
|
||||||
* @return
|
* @return
|
||||||
@ -378,10 +387,10 @@ public class OssServiceImpl implements OssService {
|
|||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||||
String dir = ALIYUN_OSS_DIR_PREFIX + sdf.format(new Date());
|
String dir = ALIYUN_OSS_DIR_PREFIX + sdf.format(new Date());
|
||||||
// 签名有效期
|
// 签名有效期
|
||||||
long expireEndTime = System.currentTimeMillis() + ALIYUN_OSS_EXPIRE * 1000;
|
long expireEndTime = System.currentTimeMillis() + ALIYUN_OSS_EXPIRE * 1000L;
|
||||||
Date expiration = new Date(expireEndTime);
|
Date expiration = new Date(expireEndTime);
|
||||||
// 文件大小
|
// 文件大小
|
||||||
long maxSize = ALIYUN_OSS_MAX_SIZE * 1024 * 1024;
|
long maxSize = (long) ALIYUN_OSS_MAX_SIZE * 1024 * 1024;
|
||||||
// 回调
|
// 回调
|
||||||
OssCallbackParamDTO callback = new OssCallbackParamDTO();
|
OssCallbackParamDTO callback = new OssCallbackParamDTO();
|
||||||
callback.setCallbackUrl(ALIYUN_OSS_CALLBACK);
|
callback.setCallbackUrl(ALIYUN_OSS_CALLBACK);
|
||||||
@ -394,10 +403,10 @@ public class OssServiceImpl implements OssService {
|
|||||||
policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, maxSize);
|
policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, maxSize);
|
||||||
policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
|
policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
|
||||||
String postPolicy = ossClient.generatePostPolicy(expiration, policyConds);
|
String postPolicy = ossClient.generatePostPolicy(expiration, policyConds);
|
||||||
byte[] binaryData = postPolicy.getBytes("utf-8");
|
byte[] binaryData = postPolicy.getBytes(StandardCharsets.UTF_8);
|
||||||
String policy = BinaryUtil.toBase64String(binaryData);
|
String policy = BinaryUtil.toBase64String(binaryData);
|
||||||
String signature = ossClient.calculatePostSignature(postPolicy);
|
String signature = ossClient.calculatePostSignature(postPolicy);
|
||||||
String callbackData = BinaryUtil.toBase64String(JSONUtil.parse(callback).toString().getBytes("utf-8"));
|
String callbackData = BinaryUtil.toBase64String(JSONUtil.parse(callback).toString().getBytes(StandardCharsets.UTF_8));
|
||||||
// 返回结果
|
// 返回结果
|
||||||
result.setAccessKeyId(ossClient.getCredentialsProvider().getCredentials().getAccessKeyId());
|
result.setAccessKeyId(ossClient.getCredentialsProvider().getCredentials().getAccessKeyId());
|
||||||
result.setPolicy(policy);
|
result.setPolicy(policy);
|
||||||
@ -486,7 +495,7 @@ public class OssServiceImpl implements OssService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getUserDirName(UserDto user) {
|
private String getUserDirName(UserDto user) {
|
||||||
if (user.getId() == null) {
|
if (user == null || user.getId() == null) {
|
||||||
throw new ApiException(I18nUtil._("获取用户信息失败!"));
|
throw new ApiException(I18nUtil._("获取用户信息失败!"));
|
||||||
}
|
}
|
||||||
if (user.isPlatform()) {
|
if (user.isPlatform()) {
|
||||||
@ -499,16 +508,4 @@ public class OssServiceImpl implements OssService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断路径是否存在,不存在创建
|
|
||||||
*
|
|
||||||
* @param dirPath
|
|
||||||
*/
|
|
||||||
private static void isChartPathExist(String dirPath) {
|
|
||||||
File file = new File(dirPath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
|
|||||||
|
|
||||||
|
|
||||||
taskService.executeTask(() -> {
|
taskService.executeTask(() -> {
|
||||||
// 申请分账
|
// 1、(电子合同)给商家申请分账功能;2、商家绑定接收方;
|
||||||
|
|
||||||
// 新建一个正式的已审核通过的店铺
|
// 新建一个正式的已审核通过的店铺
|
||||||
Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(esignContract.getMch_mobile());
|
Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(esignContract.getMch_mobile());
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
package com.suisung.mall.shop.lakala.controller.mobile;
|
package com.suisung.mall.shop.lakala.controller.mobile;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||||
import com.suisung.mall.shop.lakala.service.impl.LklTkServiceImpl;
|
import com.suisung.mall.shop.lakala.service.impl.LklTkServiceImpl;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@ -17,7 +18,9 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -44,9 +47,18 @@ public class LklTkController extends BaseControllerImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "上传文件", notes = "上传文件")
|
@ApiOperation(value = "上传文件", notes = "上传文件")
|
||||||
@RequestMapping(value = "/uploadWithOCR", method = {RequestMethod.POST, RequestMethod.GET})
|
@RequestMapping(value = "/uploadOcrImg", method = RequestMethod.POST)
|
||||||
public JSONObject uploadWithOCR(String fileURL) {
|
public CommonResult uploadOcrImg(@RequestParam(name = "upfile") MultipartFile file,
|
||||||
return lklTkService.uploadFileWithOcr("", fileURL, "ID_CARD_FRONT");
|
@RequestParam(name = "imgType") String imgType) {
|
||||||
|
|
||||||
|
return lklTkService.uploadOcrImg(file, imgType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取(身份证、营业执照、身份证)图片的信息", notes = "获取(身份证、营业执照、身份证)图片的信息")
|
||||||
|
@RequestMapping(value = "/imgOcrResult", method = RequestMethod.POST)
|
||||||
|
public CommonResult imgOcrResult(@RequestParam(name = "batchNo") String batchNo,
|
||||||
|
@RequestParam(name = "imgType") String imgType) {
|
||||||
|
return lklTkService.imgOcrResult(batchNo, imgType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,9 @@ import com.suisung.mall.common.api.CommonResult;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉卡拉业务接口
|
||||||
|
*/
|
||||||
public interface LakalaApiService {
|
public interface LakalaApiService {
|
||||||
|
|
||||||
Boolean initLKLSDK();
|
Boolean initLKLSDK();
|
||||||
@ -143,5 +146,13 @@ public interface LakalaApiService {
|
|||||||
*/
|
*/
|
||||||
JSONObject getBankCardBin(String bankCardNo);
|
JSONObject getBankCardBin(String bankCardNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param imgURL
|
||||||
|
* @param imgType 法人身份证正面图:FR_ID_CARD_FRONT;法人身份证反面:FR_ID_CARD_BEHIND;
|
||||||
|
* 身份证正面:ID_CARD_FRONT;身份证反面:ID_CARD_BEHIND;
|
||||||
|
* 营业执照:BUSINESS_LICENSE;银行卡:BANK_CARD
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -556,6 +556,10 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
respData.put("retCode", lklSuccessCode);
|
respData.put("retCode", lklSuccessCode);
|
||||||
respData.put("retMsg", "操作成功!");
|
respData.put("retMsg", "操作成功!");
|
||||||
log.info("商户分账申请业务回调:处理成功");
|
log.info("商户分账申请业务回调:处理成功");
|
||||||
|
|
||||||
|
// TODO 绑定接收方(平台方和代理商),绑定之前,判断是否已经绑定过了?
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,6 +757,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
LklLedgerMerReceiverBind lklLedgerMerReceiverBind = JSONUtil.toBean(StringUtils.convertCamelToSnake(paramsJSON.toString()), LklLedgerMerReceiverBind.class);
|
LklLedgerMerReceiverBind lklLedgerMerReceiverBind = JSONUtil.toBean(StringUtils.convertCamelToSnake(paramsJSON.toString()), LklLedgerMerReceiverBind.class);
|
||||||
lklLedgerMerReceiverBindService.saveOrUpdateByMerCupNoReceiverNo(lklLedgerMerReceiverBind);
|
lklLedgerMerReceiverBindService.saveOrUpdateByMerCupNoReceiverNo(lklLedgerMerReceiverBind);
|
||||||
|
|
||||||
|
|
||||||
return CommonResult.success(lklLedgerMerReceiverBind, "提交成功,待审核中!");
|
return CommonResult.success(lklLedgerMerReceiverBind, "提交成功,待审核中!");
|
||||||
} catch (SDKException e) {
|
} catch (SDKException e) {
|
||||||
log.error("分账绑定关系申请失败:", e);
|
log.error("分账绑定关系申请失败:", e);
|
||||||
@ -797,6 +802,9 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
paramsJSON.getStr("remark"));
|
paramsJSON.getStr("remark"));
|
||||||
if (success) {
|
if (success) {
|
||||||
respData.put("retCode", lklSuccessCode);
|
respData.put("retCode", lklSuccessCode);
|
||||||
|
|
||||||
|
// TODO 新建一个正式的已审核通过的店铺, 新建之前判断是否已经新建过了?
|
||||||
|
|
||||||
respData.put("retMsg", "操作成功!");
|
respData.put("retMsg", "操作成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,10 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
|
import com.suisung.mall.common.api.ResultCode;
|
||||||
import com.suisung.mall.common.constant.CommonConstant;
|
import com.suisung.mall.common.constant.CommonConstant;
|
||||||
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
||||||
import com.suisung.mall.common.utils.RestTemplateHttpUtil;
|
import com.suisung.mall.common.utils.RestTemplateHttpUtil;
|
||||||
import com.suisung.mall.common.utils.StringUtils;
|
import com.suisung.mall.common.utils.StringUtils;
|
||||||
@ -23,6 +26,7 @@ import com.suisung.mall.core.web.service.RedisService;
|
|||||||
import com.suisung.mall.shop.esign.service.EsignContractService;
|
import com.suisung.mall.shop.esign.service.EsignContractService;
|
||||||
import com.suisung.mall.shop.lakala.service.LklLedgerReceiverService;
|
import com.suisung.mall.shop.lakala.service.LklLedgerReceiverService;
|
||||||
import com.suisung.mall.shop.lakala.utils.LakalaUtil;
|
import com.suisung.mall.shop.lakala.utils.LakalaUtil;
|
||||||
|
import com.suisung.mall.shop.page.service.impl.OssServiceImpl;
|
||||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -33,6 +37,7 @@ import org.springframework.data.util.Pair;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
@ -46,6 +51,8 @@ import java.util.Base64;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LklTkServiceImpl {
|
public class LklTkServiceImpl {
|
||||||
|
|
||||||
@ -82,6 +89,10 @@ public class LklTkServiceImpl {
|
|||||||
@Resource
|
@Resource
|
||||||
private EsignContractService esignContractService;
|
private EsignContractService esignContractService;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Resource
|
||||||
|
private OssServiceImpl ossService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@ -135,26 +146,49 @@ public class LklTkServiceImpl {
|
|||||||
/**
|
/**
|
||||||
* 上传文件(图片)到拉卡拉,带 OCR识别卡信息,身份证信息,营业执照信息
|
* 上传文件(图片)到拉卡拉,带 OCR识别卡信息,身份证信息,营业执照信息
|
||||||
*
|
*
|
||||||
* @param fileBase64 图片的base64字符串
|
* @param file 图片URL地址
|
||||||
* @param fileURL 图片的url地址
|
* @param imgType 法人身份证正面图:FR_ID_CARD_FRONT;
|
||||||
* @param imgType 图片类型
|
* 法人身份证反面:FR_ID_CARD_BEHIND;
|
||||||
|
* 身份证正面:ID_CARD_FRONT;
|
||||||
|
* 身份证反面:ID_CARD_BEHIND;
|
||||||
|
* 营业执照:BUSINESS_LICENCE;
|
||||||
|
* 银行卡:BANK_CARD
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public JSONObject uploadFileWithOcr(String fileBase64, String fileURL, String imgType) {
|
public CommonResult uploadOcrImg(MultipartFile file, String imgType) {
|
||||||
|
|
||||||
|
if (file == null || StrUtil.isBlank(imgType)) {
|
||||||
|
return CommonResult.failed("上传文件或图片类型不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
UserDto user = getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
return CommonResult.failed("请先登录");
|
||||||
|
}
|
||||||
|
|
||||||
|
CommonResult ossImgInfo = ossService.uploadFile(file, user);
|
||||||
|
if (ossImgInfo == null) {
|
||||||
|
return CommonResult.failed("上传文件失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ossImgInfo.getStatus() != ResultCode.SUCCESS.getStatus() || ossImgInfo.getData() == null) {
|
||||||
|
return CommonResult.failed(ossImgInfo.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
String imgURL = JSONUtil.parseObj(ossImgInfo.getData()).getStr("url");
|
||||||
|
|
||||||
String authorization = getLklTkAuthorization();
|
String authorization = getLklTkAuthorization();
|
||||||
if (StrUtil.isBlank(authorization)) {
|
if (StrUtil.isBlank(authorization)) {
|
||||||
return JSONUtil.createObj().set("code", 500).set("msg", "获取拉卡拉token失败");
|
return CommonResult.failed("获取拉卡拉token失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject header = new JSONObject();
|
JSONObject header = new JSONObject();
|
||||||
header.put("Authorization", authorization);
|
header.put("Authorization", authorization);
|
||||||
|
|
||||||
String urlPath = isProd() ? "/registration/file/upload" : "/sit/htkregistration/file/upload";
|
|
||||||
|
|
||||||
if (StrUtil.isBlank(fileBase64)) {
|
String updUrlPath = isProd() ? "/registration/file/base/upload" : "/sit/htkregistration/file/base/upload";
|
||||||
// web url 转 base64 字节
|
String fileBase64 = UploadUtil.URLFileToBase64(imgURL);
|
||||||
fileBase64 = UploadUtil.URLFileToBase64(fileURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject requestBody = new JSONObject();
|
JSONObject requestBody = new JSONObject();
|
||||||
requestBody.put("fileBase64", fileBase64);
|
requestBody.put("fileBase64", fileBase64);
|
||||||
@ -162,15 +196,82 @@ public class LklTkServiceImpl {
|
|||||||
requestBody.put("sourcechnl", "0"); // 来源: 0:PC,1:安卓,2:IOS
|
requestBody.put("sourcechnl", "0"); // 来源: 0:PC,1:安卓,2:IOS
|
||||||
requestBody.put("isOcr", "true");
|
requestBody.put("isOcr", "true");
|
||||||
|
|
||||||
ResponseEntity<JSONObject> response = RestTemplateHttpUtil.sendPostBodyBackEntity(buildLklServiceUrl(urlPath), header, requestBody, JSONObject.class);
|
ResponseEntity<JSONObject> updResponse = RestTemplateHttpUtil.sendPostBodyBackEntity(buildLklTkUrl(updUrlPath), header, requestBody, JSONObject.class);
|
||||||
if (ObjectUtil.isEmpty(response)
|
if (ObjectUtil.isEmpty(updResponse)
|
||||||
|| response.getStatusCode() != HttpStatus.OK
|
|| updResponse.getStatusCode() != HttpStatus.OK
|
||||||
|| ObjectUtil.isEmpty(response.getBody())) {
|
|| ObjectUtil.isEmpty(updResponse.getBody())) {
|
||||||
return JSONUtil.createObj().set("code", 500).set("msg", "返回值有误!");
|
return CommonResult.failed("上传文件返回值有误");
|
||||||
}
|
}
|
||||||
|
|
||||||
// {batchNo,status,url,showUrl,result{} }
|
// {batchNo,status,url,showUrl,result{} }
|
||||||
return response.getBody();
|
JSONObject updObj = updResponse.getBody();
|
||||||
|
String batchNo = updObj.getStr("batchNo");
|
||||||
|
if (StrUtil.isBlank(batchNo)) {
|
||||||
|
return CommonResult.failed("上传文件返回值有误");
|
||||||
|
}
|
||||||
|
|
||||||
|
updObj.put("url", imgURL);
|
||||||
|
|
||||||
|
// 调用 OCR 识别接口
|
||||||
|
// String ocrUrlPath = isProd() ? "/registration/ocr/result" : "/sit/htkregistration/ocr/result";
|
||||||
|
// JSONObject ocrRequestBody = new JSONObject();
|
||||||
|
// ocrRequestBody.put("batchNo", batchNo);
|
||||||
|
// ocrRequestBody.put("imgType", imgType);
|
||||||
|
//
|
||||||
|
// ResponseEntity<JSONObject> ocrResponse = RestTemplateHttpUtil.sendPostBodyBackEntity(buildLklTkUrl(ocrUrlPath), header, ocrRequestBody, JSONObject.class);
|
||||||
|
// if (ObjectUtil.isEmpty(ocrResponse)
|
||||||
|
// || ocrResponse.getStatusCode() != HttpStatus.OK
|
||||||
|
// || ObjectUtil.isEmpty(ocrResponse.getBody())) {
|
||||||
|
// return CommonResult.failed("OCR响应数据有误");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// JSONObject ocrObj = ocrResponse.getBody().get("result", JSONObject.class);
|
||||||
|
// if (ObjectUtil.isEmpty(ocrObj)) {
|
||||||
|
// return CommonResult.failed("OCR返回结果有误");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ocrObj.put("url", updObj.getStr("url"));
|
||||||
|
// ocrObj.put("showUrl", updObj.getStr("showUrl"));
|
||||||
|
// ocrObj.put("imgType", imgType);
|
||||||
|
// ocrObj.put("batchNo", batchNo);
|
||||||
|
|
||||||
|
return CommonResult.success(updObj);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonResult imgOcrResult(String batchNo, String imgType) {
|
||||||
|
|
||||||
|
// 调用 OCR 识别接口
|
||||||
|
String authorization = getLklTkAuthorization();
|
||||||
|
if (StrUtil.isBlank(authorization)) {
|
||||||
|
return CommonResult.failed("获取拉卡拉token失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject header = new JSONObject();
|
||||||
|
header.put("Authorization", authorization);
|
||||||
|
|
||||||
|
String ocrUrlPath = isProd() ? "/registration/ocr/result" : "/sit/htkregistration/ocr/result";
|
||||||
|
JSONObject ocrRequestBody = new JSONObject();
|
||||||
|
ocrRequestBody.put("batchNo", batchNo);
|
||||||
|
ocrRequestBody.put("imgType", imgType);
|
||||||
|
|
||||||
|
ResponseEntity<JSONObject> ocrResponse = RestTemplateHttpUtil.sendPostBodyBackEntity(buildLklTkUrl(ocrUrlPath), header, ocrRequestBody, JSONObject.class);
|
||||||
|
if (ObjectUtil.isEmpty(ocrResponse)
|
||||||
|
|| ocrResponse.getStatusCode() != HttpStatus.OK
|
||||||
|
|| ObjectUtil.isEmpty(ocrResponse.getBody())) {
|
||||||
|
return CommonResult.failed("OCR响应数据有误");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject ocrObj = ocrResponse.getBody().get("result", JSONObject.class);
|
||||||
|
if (ObjectUtil.isEmpty(ocrObj)) {
|
||||||
|
return CommonResult.failed("OCR返回结果有误");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return CommonResult.success(ocrObj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -563,4 +664,5 @@ public class LklTkServiceImpl {
|
|||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -553,8 +553,9 @@ public class OssServiceImpl implements OssService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getUserDirName(UserDto user) {
|
private String getUserDirName(UserDto user) {
|
||||||
if (user.getId() == null) {
|
if (user == null || user.getId() == null) {
|
||||||
//throw new ApiException(I18nUtil._("获取用户信息失败!"));
|
//throw new ApiException(I18nUtil._("获取用户信息失败!"));
|
||||||
|
logger.error("cos 文件上传,获取用户信息失败!");
|
||||||
return "media/plantform/default/";
|
return "media/plantform/default/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public class ShopStoreMediaServiceImpl extends BaseServiceImpl<ShopStoreMediaMap
|
|||||||
Long gallery_id = getParameter("gallery_id", 0L);
|
Long gallery_id = getParameter("gallery_id", 0L);
|
||||||
String gallery_type = getParameter("gallery_type", "image");
|
String gallery_type = getParameter("gallery_type", "image");
|
||||||
|
|
||||||
if (user.isStore()) {
|
if (user != null && user.isStore()) {
|
||||||
ShopStoreMedia media_data = Convert.convert(ShopStoreMedia.class, mediaDTO);
|
ShopStoreMedia media_data = Convert.convert(ShopStoreMedia.class, mediaDTO);
|
||||||
media_data.setMedia_type(gallery_type); // todo 目前默认 image
|
media_data.setMedia_type(gallery_type); // todo 目前默认 image
|
||||||
media_data.setStore_id(Convert.toInt(user.getStore_id()));
|
media_data.setStore_id(Convert.toInt(user.getStore_id()));
|
||||||
@ -79,7 +79,7 @@ public class ShopStoreMediaServiceImpl extends BaseServiceImpl<ShopStoreMediaMap
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 平台用户
|
// 平台用户
|
||||||
if (user.isPlatform()) {
|
if (user != null && user.isPlatform()) {
|
||||||
ShopPlantformMedia plantformMedia = Convert.convert(ShopPlantformMedia.class, mediaDTO);
|
ShopPlantformMedia plantformMedia = Convert.convert(ShopPlantformMedia.class, mediaDTO);
|
||||||
plantformMedia.setMedia_type(gallery_type); // todo 目前默认 image
|
plantformMedia.setMedia_type(gallery_type); // todo 目前默认 image
|
||||||
plantformMedia.setMedia_order(1);
|
plantformMedia.setMedia_order(1);
|
||||||
@ -92,8 +92,6 @@ public class ShopStoreMediaServiceImpl extends BaseServiceImpl<ShopStoreMediaMap
|
|||||||
mediaGallery.setGallery_num(mediaGallery.getGallery_num() + 1);
|
mediaGallery.setGallery_num(mediaGallery.getGallery_num() + 1);
|
||||||
shopPlantformMediaGalleryService.edit(mediaGallery);
|
shopPlantformMediaGalleryService.edit(mediaGallery);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user