|
@@ -16,6 +16,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.LifeUser;
|
|
import shop.alien.entity.store.LifeUser;
|
|
|
import shop.alien.entity.store.StoreAliPayErrorLog;
|
|
import shop.alien.entity.store.StoreAliPayErrorLog;
|
|
|
import shop.alien.entity.store.StoreAliPayLog;
|
|
import shop.alien.entity.store.StoreAliPayLog;
|
|
@@ -26,6 +28,8 @@ import shop.alien.store.service.StoreAliPayErrorLogService;
|
|
|
import shop.alien.store.service.StoreAliPayLogService;
|
|
import shop.alien.store.service.StoreAliPayLogService;
|
|
|
import shop.alien.store.service.StoreAliPayRefundLogService;
|
|
import shop.alien.store.service.StoreAliPayRefundLogService;
|
|
|
import shop.alien.store.service.StoreUserService;
|
|
import shop.alien.store.service.StoreUserService;
|
|
|
|
|
+import shop.alien.store.util.ali.ocr.OcrStrategy;
|
|
|
|
|
+import shop.alien.store.util.ali.ocr.OcrStrategyFactory;
|
|
|
import shop.alien.util.common.RandomCreateUtil;
|
|
import shop.alien.util.common.RandomCreateUtil;
|
|
|
import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
|
import shop.alien.util.common.UrlEncode;
|
|
import shop.alien.util.common.UrlEncode;
|
|
@@ -33,6 +37,7 @@ import shop.alien.util.system.OSUtil;
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.Base64;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -57,6 +62,8 @@ public class AliApi {
|
|
|
|
|
|
|
|
private final StoreAliPayRefundLogService storeAliPayRefundLogService;
|
|
private final StoreAliPayRefundLogService storeAliPayRefundLogService;
|
|
|
|
|
|
|
|
|
|
+ private final OcrStrategyFactory ocrStrategyFactory;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 商家端appId
|
|
* 商家端appId
|
|
|
*/
|
|
*/
|
|
@@ -401,15 +408,25 @@ public class AliApi {
|
|
|
model.setOrderTitle("商家转账");
|
|
model.setOrderTitle("商家转账");
|
|
|
// 设置收款方信息
|
|
// 设置收款方信息
|
|
|
Participant payeeInfo = new Participant();
|
|
Participant payeeInfo = new Participant();
|
|
|
- payeeInfo.setCertType("IDENTITY_CARD");
|
|
|
|
|
- payeeInfo.setCertNo(idCard);
|
|
|
|
|
- payeeInfo.setIdentityType("ALIPAY_LOGON_ID");
|
|
|
|
|
- if(account!=null){
|
|
|
|
|
|
|
+ // 智能判断收款方类型
|
|
|
|
|
+ if (account.startsWith("2088") && account.length() == 16) {
|
|
|
|
|
+ // 如果是商户ID格式(2088开头的16位数字)
|
|
|
|
|
+ payeeInfo.setIdentityType("ALIPAY_USER_ID");
|
|
|
|
|
+ log.info("检测到收款方为商户ID: {}", account);
|
|
|
|
|
+// payeeInfo.setName("爱丽恩严(大连)商务科技有限公司");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 默认为支付宝账号(手机号或邮箱)
|
|
|
|
|
+ payeeInfo.setIdentityType("ALIPAY_LOGON_ID");
|
|
|
|
|
+ log.info("检测到收款方为支付宝账号: {}", account);
|
|
|
|
|
+ payeeInfo.setCertType("IDENTITY_CARD");
|
|
|
|
|
+ payeeInfo.setCertNo(idCard);
|
|
|
|
|
+ payeeInfo.setName(name);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(null != account){
|
|
|
payeeInfo.setIdentity(account);
|
|
payeeInfo.setIdentity(account);
|
|
|
}else{
|
|
}else{
|
|
|
payeeInfo.setIdentity(phone);
|
|
payeeInfo.setIdentity(phone);
|
|
|
}
|
|
}
|
|
|
- payeeInfo.setName(name);
|
|
|
|
|
model.setPayeeInfo(payeeInfo);
|
|
model.setPayeeInfo(payeeInfo);
|
|
|
// 设置业务备注
|
|
// 设置业务备注
|
|
|
model.setRemark("爱丽恩提现业务");
|
|
model.setRemark("爱丽恩提现业务");
|
|
@@ -734,6 +751,33 @@ public class AliApi {
|
|
|
return sdf.format(new Date()) + RandomCreateUtil.getRandomNum(4);
|
|
return sdf.format(new Date()) + RandomCreateUtil.getRandomNum(4);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 支付宝OCR识别(使用策略工厂模式)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param imageId 图片id
|
|
|
|
|
+ * @param ocrType OCR识别类型
|
|
|
|
|
+ * @return OCR识别结果
|
|
|
|
|
+ * @throws Exception 识别异常
|
|
|
|
|
+ */
|
|
|
|
|
+ public R ocrRequest(String imageId, String ocrType) throws Exception {
|
|
|
|
|
+ OcrStrategy strategy = ocrStrategyFactory.getStrategy(ocrType);
|
|
|
|
|
+ return strategy.recognize(imageId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 支付宝OCR识别(Base64方式,使用策略工厂模式)
|
|
|
|
|
+ * 目前没用w
|
|
|
|
|
+ * @param imageFile 图片文件
|
|
|
|
|
+ * @param ocrType OCR识别类型
|
|
|
|
|
+ * @return OCR识别结果
|
|
|
|
|
+ * @throws Exception 识别异常
|
|
|
|
|
+ */
|
|
|
|
|
+ public R ocrRequestByBase64(MultipartFile imageFile, String ocrType) throws Exception {
|
|
|
|
|
+ OcrStrategy strategy = ocrStrategyFactory.getStrategy(ocrType);
|
|
|
|
|
+ byte[] imageBytes = imageFile.getBytes();
|
|
|
|
|
+ String imageBase64 = Base64.getEncoder().encodeToString(imageBytes);
|
|
|
|
|
+ return strategy.recognizeByBase64(imageBase64);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
private String getMassage(String subCode) {
|
|
private String getMassage(String subCode) {
|
|
|
switch (subCode) {
|
|
switch (subCode) {
|