|
|
@ -890,19 +890,43 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
businesses.add(business);
|
|
|
|
businesses.add(business);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvInvoiceSplit split = new InvInvoiceSplit();
|
|
|
|
|
|
|
|
split.setCurrency("RMB");
|
|
|
|
|
|
|
|
split.setLinkId(link.getGID());
|
|
|
|
|
|
|
|
List<String> detailIds = invInvoiceSplitMapper.getDetailIdsBylinkdIdAndCurrency(split);
|
|
|
|
|
|
|
|
|
|
|
|
fee = new InvFeeInfo();
|
|
|
|
|
|
|
|
fee.setLinkId(info.getGID());
|
|
|
|
//获取人民币的发票明细
|
|
|
|
fee.setCurrency("RMB");
|
|
|
|
List<InvInvoiceDetail> details = getDetails(detailIds);
|
|
|
|
List<InvFeeInfo> fees = invFeeInfoMapper.getListBylink(fee);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fee = new InvFeeInfo();
|
|
|
|
|
|
|
|
// fee.setLinkId(info.getGID());
|
|
|
|
|
|
|
|
// fee.setCurrency("RMB");
|
|
|
|
|
|
|
|
// List<InvFeeInfo> fees = invFeeInfoMapper.getListBylink(fee);
|
|
|
|
|
|
|
|
|
|
|
|
int rmbamount =0;
|
|
|
|
int rmbamount =0;
|
|
|
|
BigDecimal sumfees = new BigDecimal(0);
|
|
|
|
BigDecimal sumfees = new BigDecimal(0);
|
|
|
|
if(null != fees && fees.size()>0){
|
|
|
|
String rmbsplits = "";
|
|
|
|
sumfees = fees.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
|
|
|
|
|
rmbamount = getInvoiceAmount(fees,link,sumfees);
|
|
|
|
if(null != details && details.size()>0){
|
|
|
|
|
|
|
|
sumfees = details.stream().map(InvInvoiceDetail::getTaxExcludedAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
|
|
|
|
|
rmbamount = details.size();
|
|
|
|
|
|
|
|
rmbsplits = getSplits(details);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvInvoiceSplit splitusd = new InvInvoiceSplit();
|
|
|
|
|
|
|
|
splitusd.setCurrency("USD");
|
|
|
|
|
|
|
|
splitusd.setLinkId(link.getGID());
|
|
|
|
|
|
|
|
List<String> detailIdusds = invInvoiceSplitMapper.getDetailIdsBylinkdIdAndCurrency(splitusd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取USD的发票明细
|
|
|
|
|
|
|
|
List<InvInvoiceDetail> detailusds = getDetails(detailIdusds);
|
|
|
|
|
|
|
|
|
|
|
|
InvFeeInfo feeNoRmb = new InvFeeInfo();
|
|
|
|
InvFeeInfo feeNoRmb = new InvFeeInfo();
|
|
|
|
feeNoRmb.setLinkId(info.getGID());
|
|
|
|
feeNoRmb.setLinkId(info.getGID());
|
|
|
|
List<InvFeeInfo> feesNoRmb = invFeeInfoMapper.getListBylinkNoRmb(feeNoRmb);
|
|
|
|
List<InvFeeInfo> feesNoRmb = invFeeInfoMapper.getListBylinkNoRmb(feeNoRmb);
|
|
|
@ -910,18 +934,26 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
int usdamount =0;
|
|
|
|
int usdamount =0;
|
|
|
|
BigDecimal usdInvoiceAmount = new BigDecimal(0);
|
|
|
|
BigDecimal usdInvoiceAmount = new BigDecimal(0);
|
|
|
|
BigDecimal usdfees = new BigDecimal(0);
|
|
|
|
BigDecimal usdfees = new BigDecimal(0);
|
|
|
|
if(null != feesNoRmb && feesNoRmb.size()>0){
|
|
|
|
|
|
|
|
usdfees = feesNoRmb.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
|
String usdsplits="";
|
|
|
|
usdamount = getInvoiceAmount(feesNoRmb,link,usdfees);
|
|
|
|
if(null != detailusds && detailusds.size()>0){
|
|
|
|
usdInvoiceAmount = usdfees.multiply(feesNoRmb.get(0).getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
//usd转为人民币金额
|
|
|
|
|
|
|
|
usdInvoiceAmount = detailusds.stream().map(InvInvoiceDetail::getTaxExcludedAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
|
|
|
|
|
usdamount = detailusds.size();
|
|
|
|
|
|
|
|
//usd原币金额
|
|
|
|
|
|
|
|
usdfees = usdInvoiceAmount.divide(feesNoRmb.get(0).getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
usdsplits = getSplits(detailusds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
link.setUsdInvoiceAmount(usdInvoiceAmount);
|
|
|
|
link.setUsdInvoiceAmount(usdInvoiceAmount);
|
|
|
|
link.setRmbAmount(rmbamount);
|
|
|
|
link.setRmbAmount(rmbamount);
|
|
|
|
link.setUsdAmount(usdamount);
|
|
|
|
link.setUsdAmount(usdamount);
|
|
|
|
link.setRmbFees(sumfees);
|
|
|
|
link.setRmbFees(sumfees);
|
|
|
|
link.setUsdFess(usdfees);
|
|
|
|
link.setUsdFess(usdfees);
|
|
|
|
|
|
|
|
link.setRmbsplits(rmbsplits);
|
|
|
|
|
|
|
|
link.setUsdsplits(usdsplits);
|
|
|
|
|
|
|
|
|
|
|
|
if(usdInvoiceAmount.compareTo(invoiceAmount)==1 && sumfees.compareTo(invoiceAmount)==1){
|
|
|
|
if(usdInvoiceAmount.compareTo(invoiceAmount)==1 && sumfees.compareTo(invoiceAmount)==1){
|
|
|
|
link.setInvoiceAmount(rmbamount+usdamount);
|
|
|
|
link.setInvoiceAmount(rmbamount+usdamount);
|
|
|
@ -935,14 +967,45 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
link.setBillList(businesses);
|
|
|
|
link.setBillList(businesses);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return link;
|
|
|
|
return link;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<InvInvoiceDetail> getDetails(List<String> detail){
|
|
|
|
|
|
|
|
List<InvInvoiceDetail> details = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(null != detail && detail.size()>0){
|
|
|
|
|
|
|
|
for(String str : detail){
|
|
|
|
|
|
|
|
InvInvoiceDetail det = invInvoiceDetailMapper.getByGId(str);
|
|
|
|
|
|
|
|
if(null != det){
|
|
|
|
|
|
|
|
details.add(det);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return details;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getSplits(List<InvInvoiceDetail> details){
|
|
|
|
|
|
|
|
String split = "";
|
|
|
|
|
|
|
|
for(InvInvoiceDetail usd : details){
|
|
|
|
|
|
|
|
List<InvInvoiceSplit> splits = invInvoiceSplitMapper.getBydetailId(usd.getGID());
|
|
|
|
|
|
|
|
if(null != splits && splits.size()>0){
|
|
|
|
|
|
|
|
for(InvInvoiceSplit spl : splits){
|
|
|
|
|
|
|
|
split = split+spl.getSplitAmountRMB()+"元,";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
split = split.substring(0, split.length()-1);
|
|
|
|
|
|
|
|
return split;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public HttpResult uploadInvoice(InvLinkInfo info) {
|
|
|
|
public HttpResult uploadInvoice(InvLinkInfo info) {
|
|
|
@ -967,6 +1030,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
InvInvoiceInfo invoice = invInvoiceInfoMapper.getByGid(invoiceIds.get(i));
|
|
|
|
InvInvoiceInfo invoice = invInvoiceInfoMapper.getByGid(invoiceIds.get(i));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
data = new ResponseData();
|
|
|
|
data = new ResponseData();
|
|
|
|
|
|
|
|
log.info(df.format(new Date())+"开始调用瑞宏开票接口"+",invoiceId="+invoice.getGID());
|
|
|
|
data = UploadData.doPost(cmdName, getKpData(invoice));
|
|
|
|
data = UploadData.doPost(cmdName, getKpData(invoice));
|
|
|
|
invoice.setSerialNo(data.getSerialNo());
|
|
|
|
invoice.setSerialNo(data.getSerialNo());
|
|
|
|
invoice.setApiSendTime(df.parse(df.format(new Date())));
|
|
|
|
invoice.setApiSendTime(df.parse(df.format(new Date())));
|
|
|
@ -988,14 +1052,13 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
public HttpResult getInvoice(InvLinkInfo info) {
|
|
|
|
public HttpResult getInvoice(InvLinkInfo info) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<InvInvoiceInfo> list = invInvoiceInfoMapper.selectcheck();
|
|
|
|
List<InvInvoiceInfo> list = invInvoiceInfoMapper.selectcheck();
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
ResponseData data = null;
|
|
|
|
ResponseData data = null;
|
|
|
|
for(InvInvoiceInfo invoice : list){
|
|
|
|
for(InvInvoiceInfo invoice : list){
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
data = new ResponseData();
|
|
|
|
data = new ResponseData();
|
|
|
|
|
|
|
|
log.info(df.format(new Date())+"开始调用瑞宏查询接口"+",invoiceId="+invoice.getGID());
|
|
|
|
data = UploadData.doPost(cmdCxName, getCx1Data(invoice));
|
|
|
|
data = UploadData.doPost(cmdCxName, getCx1Data(invoice));
|
|
|
|
if(0 == data.getCode()){
|
|
|
|
if(0 == data.getCode()){
|
|
|
|
|
|
|
|
|
|
|
|