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