|
|
|
@ -2,18 +2,16 @@ package com.base.springcloud.service.imp; |
|
|
|
|
|
|
|
import com.base.springcloud.bo.MerchantConfigBO; |
|
|
|
import com.base.springcloud.dao.MerchantConfigMapper; |
|
|
|
import com.base.springcloud.dto.MerchantConfigRspDTO; |
|
|
|
import com.base.springcloud.entity.MerchantConfig; |
|
|
|
import com.base.springcloud.service.MerchantService; |
|
|
|
import com.base.springcloud.util.FtpUtil; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.*; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
@ -29,6 +27,9 @@ public class MerchantServiceImp implements MerchantService { |
|
|
|
@Autowired |
|
|
|
private FtpUtil ftpUtil; |
|
|
|
|
|
|
|
@Value("${test_ftp.file_path}") |
|
|
|
public String FTP_BASEPATH; |
|
|
|
|
|
|
|
/** |
|
|
|
* 支付信息配置 |
|
|
|
* @param merchantConfigBO |
|
|
|
@ -36,12 +37,12 @@ public class MerchantServiceImp implements MerchantService { |
|
|
|
@Override |
|
|
|
public void paymentConfigure(MerchantConfigBO merchantConfigBO) { |
|
|
|
// 证书上传服务器
|
|
|
|
//String certPath = uplodWecPayCert(merchantConfigBO.getMerchantId(),merchantConfigBO.getCertFile());
|
|
|
|
String certPath = uplodWecWindow(merchantConfigBO.getMchId(),merchantConfigBO.getCertFile()); |
|
|
|
// 商户支付信息保存
|
|
|
|
MerchantConfig merchantConfig = new MerchantConfig(); |
|
|
|
merchantConfig.setId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
merchantConfig.setCreateTime(new Date()); |
|
|
|
//merchantConfig.setCertPath(certPath);
|
|
|
|
merchantConfig.setCertPath(certPath); |
|
|
|
BeanUtils.copyProperties(merchantConfigBO,merchantConfig); |
|
|
|
int count = merchantConfigMapper.insert(merchantConfig); |
|
|
|
if(count > 0) return; |
|
|
|
@ -98,6 +99,27 @@ public class MerchantServiceImp implements MerchantService { |
|
|
|
return merchantConfigBOList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 测试文件上传 |
|
|
|
*/ |
|
|
|
private String uplodWecWindow(String mchId, MultipartFile certfile){ |
|
|
|
if (certfile.isEmpty()) { |
|
|
|
// TODO 抛出业务异常
|
|
|
|
return "文件上传失败!"; |
|
|
|
} |
|
|
|
|
|
|
|
String fileName = certfile.getOriginalFilename(); |
|
|
|
String suffixName = fileName.substring(fileName.lastIndexOf(".")); |
|
|
|
File file = new File(FTP_BASEPATH + mchId + suffixName); |
|
|
|
try { |
|
|
|
certfile.transferTo(file); |
|
|
|
return file.getPath() + fileName; |
|
|
|
} catch (IOException e) { |
|
|
|
// TODO 抛出业务异常
|
|
|
|
} |
|
|
|
return "文件上传失败!"; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 证书上传服务器 |
|
|
|
* @param mchId |
|
|
|
|