|
|
@ -9,6 +9,7 @@ import com.djy.invoice.dto.*;
|
|
|
|
import com.djy.invoice.model.*;
|
|
|
|
import com.djy.invoice.model.*;
|
|
|
|
import com.djy.invoice.model.mapper.*;
|
|
|
|
import com.djy.invoice.model.mapper.*;
|
|
|
|
import com.djy.invoice.service.InvLinkInfoService;
|
|
|
|
import com.djy.invoice.service.InvLinkInfoService;
|
|
|
|
|
|
|
|
import com.djy.invoice.service.ParameterFeignClient;
|
|
|
|
import com.djy.invoice.service.UploadData;
|
|
|
|
import com.djy.invoice.service.UploadData;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import okhttp3.*;
|
|
|
|
import okhttp3.*;
|
|
|
@ -24,6 +25,7 @@ import java.text.DateFormat;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
@ -42,8 +44,8 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
private InvInvoiceDetailMapper invInvoiceDetailMapper;
|
|
|
|
private InvInvoiceDetailMapper invInvoiceDetailMapper;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private InvInvoiceSplitMapper invInvoiceSplitMapper;
|
|
|
|
private InvInvoiceSplitMapper invInvoiceSplitMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ParameterFeignClient parameterFeignClient;
|
|
|
|
|
|
|
|
|
|
|
|
private static String cmdName;
|
|
|
|
private static String cmdName;
|
|
|
|
private static String cmdCxName;
|
|
|
|
private static String cmdCxName;
|
|
|
@ -55,9 +57,27 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
private static String urlPath;
|
|
|
|
private static String urlPath;
|
|
|
|
|
|
|
|
|
|
|
|
public static BigDecimal invoiceAmount;
|
|
|
|
// public static BigDecimal invoiceAmount;
|
|
|
|
private static final String dateFormat = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
private static final String dateFormat = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
|
|
|
|
private static final String dateFormat1 = "yyyy-MM-dd";
|
|
|
|
|
|
|
|
|
|
|
|
private static final DateFormat df = new SimpleDateFormat(dateFormat);
|
|
|
|
private static final DateFormat df = new SimpleDateFormat(dateFormat);
|
|
|
|
|
|
|
|
private static final DateFormat df1 = new SimpleDateFormat(dateFormat1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isNumeric(String str){
|
|
|
|
|
|
|
|
Pattern pattern = Pattern.compile("[0-9]*");
|
|
|
|
|
|
|
|
if(str.indexOf(".")>0){//判断是否有小数点
|
|
|
|
|
|
|
|
if(str.indexOf(".")==str.lastIndexOf(".") && str.split("\\.").length==2){ //判断是否只有一个小数点
|
|
|
|
|
|
|
|
return pattern.matcher(str.replace(".","")).matches();
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
return pattern.matcher(str).matches();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -79,13 +99,29 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
// List<InvLinkInfo> links = JSONObject.parseArray(jsonObj.toJSONString() , InvLinkInfo.class);// 将string类型直接封装成对象
|
|
|
|
// List<InvLinkInfo> links = JSONObject.parseArray(jsonObj.toJSONString() , InvLinkInfo.class);// 将string类型直接封装成对象
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal exchangeRate = new BigDecimal(0);
|
|
|
|
|
|
|
|
|
|
|
|
for(InvLinkInfo linkinfo : links){
|
|
|
|
for(InvLinkInfo linkinfo : links){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpResult result = parameterFeignClient.getParameter(linkinfo.getCompanyId());
|
|
|
|
|
|
|
|
String amount =(String)result.getData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(null == amount){
|
|
|
|
|
|
|
|
return HttpResult.error(20060,"linkId="+linkinfo.getLinkId()+",CompanyId="+linkinfo.getCompanyId()+",开票数额不存在,请检查");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
boolean boolea = isNumeric(amount);
|
|
|
|
|
|
|
|
if(false == boolea){
|
|
|
|
|
|
|
|
return HttpResult.error(20050,"linkId="+linkinfo.getLinkId()+",CompanyId="+linkinfo.getCompanyId()+",开票数额格式不正确,请检查");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// linkinfo.setGID((String)jsonObj.get("LinkId"));
|
|
|
|
// linkinfo.setGID((String)jsonObj.get("LinkId"));
|
|
|
|
linkinfo.setGID(linkinfo.getLinkId());
|
|
|
|
linkinfo.setGID(linkinfo.getLinkId());
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(linkinfo);
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(linkinfo);
|
|
|
|
if(null != link){
|
|
|
|
if(null != link){
|
|
|
|
if(!"0".equals(link.getStatus())){
|
|
|
|
if(!"0".equals(link.getStatus())){
|
|
|
|
return HttpResult.ok("该链接已经开票或在开票中,不能上传数据");
|
|
|
|
return HttpResult.error(20090,"链接id="+link.getGID()+"已经开票或在开票中,不能上传数据");
|
|
|
|
}else{//删除链接表,重新插入
|
|
|
|
}else{//删除链接表,重新插入
|
|
|
|
invLinkInfoMapper.deleteByGID(link);
|
|
|
|
invLinkInfoMapper.deleteByGID(link);
|
|
|
|
|
|
|
|
|
|
|
@ -161,6 +197,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
InvFeeInfo fee = feearray.get(j);
|
|
|
|
InvFeeInfo fee = feearray.get(j);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exchangeRate = fee.getExchangeRate();
|
|
|
|
// JSONObject feeobject = feearray.getJSONObject(j);
|
|
|
|
// JSONObject feeobject = feearray.getJSONObject(j);
|
|
|
|
// InvFeeInfo fee = JSONObject.parseObject(feeobject.toJSONString() , InvFeeInfo.class);// 将string类型直接封装成对象
|
|
|
|
// InvFeeInfo fee = JSONObject.parseObject(feeobject.toJSONString() , InvFeeInfo.class);// 将string类型直接封装成对象
|
|
|
|
fee.setGID(fee.getFeeId());
|
|
|
|
fee.setGID(fee.getFeeId());
|
|
|
@ -179,13 +216,84 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deleteSplit(linkinfo);
|
|
|
|
deleteSplit(linkinfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HttpResult httpresult = createSplit(linkinfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createSplit(linkinfo);
|
|
|
|
createSplit(linkinfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> invoiceIds = invInvoiceSplitMapper.getIdsBylinkdId(linkinfo.getGID());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(String str : invoiceIds){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvInvoiceInfo invoice = invInvoiceInfoMapper.getByGid(str);
|
|
|
|
|
|
|
|
String remark="";
|
|
|
|
|
|
|
|
String requiredRemark="";
|
|
|
|
|
|
|
|
List<String> busineesIds = invInvoiceSplitMapper.getSplitsByInvoiceId(str);
|
|
|
|
|
|
|
|
BigDecimal rmbAmount = new BigDecimal(0);
|
|
|
|
|
|
|
|
BigDecimal usdAmount = new BigDecimal(0);
|
|
|
|
|
|
|
|
String remarkTemplate = linkinfo.getRemarkTemplate();
|
|
|
|
|
|
|
|
for(String busid : busineesIds){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvBusinessInfo busi = invBusinessInfoMapper.getById(busid);
|
|
|
|
|
|
|
|
InvInvoiceSplit invsplit = invInvoiceSplitMapper.getAmount(str,busid);
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("主提单号")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("主提单号]",busi.getMBLNO()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("委托单位")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("委托单位]",busi.getCustNO()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("开船日期")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("开船日期]",df1.format(busi.getETD())+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("船名")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("船名]",busi.getVessel()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("航次")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("航次]",busi.getVoyno()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("装货港")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("装货港]",busi.getPortLoad()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("卸货港")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("卸货港]",busi.getPortDischarge()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("目的港")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("目的港]",busi.getDestination()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("集装箱")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("集装箱]",busi.getCntrTotal()+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("折算汇率")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("折算汇率]",exchangeRate+"]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("外币金额")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("外币金额]",invsplit.getSplitAmount()+"]");
|
|
|
|
|
|
|
|
usdAmount = usdAmount.add(invsplit.getSplitAmount());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("人民币金额")){
|
|
|
|
|
|
|
|
remarkTemplate = remarkTemplate.replaceAll("人民币金额]",invsplit.getSplitAmountRMB()+"]");
|
|
|
|
|
|
|
|
rmbAmount = rmbAmount.add(invsplit.getSplitAmountRMB());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
requiredRemark = requiredRemark+remarkTemplate+"\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String amountstr = "";
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("外币金额(总计)")){
|
|
|
|
|
|
|
|
requiredRemark = requiredRemark.replaceAll("外币金额\\(总计\\):"+"\\[","").replaceAll("外币金额\\(总计\\)\\]","");
|
|
|
|
|
|
|
|
amountstr = amountstr+"外币金额(总计):["+usdAmount.toString()+"]";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(remarkTemplate.contains("人民币金额(总计)")){
|
|
|
|
|
|
|
|
requiredRemark = requiredRemark.replaceAll("人民币金额\\(总计\\):"+"\\[","").replaceAll("人民币金额\\(总计\\)\\]","");
|
|
|
|
|
|
|
|
amountstr = amountstr+"人民币金额(总计):["+rmbAmount.toString()+"]";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// invoice.setRequireRemark(requiredRemark+amountstr);
|
|
|
|
|
|
|
|
invoice.setRequireRemark(requiredRemark+amountstr);
|
|
|
|
|
|
|
|
invInvoiceInfoMapper.updateById(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -278,150 +386,16 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int getInvoiceAmount(List<InvFeeInfo> fees,InvLinkInfo link,BigDecimal sumfees){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<InvInvoiceInfo> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(null != fees && fees.size()>0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal checkinvocie = new BigDecimal(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if("RMB".equals(fees.get(0).getCurrency())){
|
|
|
|
|
|
|
|
checkinvocie = invoiceAmount;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
checkinvocie = invoiceAmount.divide(fees.get(0).getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果费用总计小于等于最大开票金额
|
|
|
|
|
|
|
|
if(checkinvocie.compareTo(sumfees) == 1){
|
|
|
|
|
|
|
|
InvInvoiceInfo invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal amount = new BigDecimal(0);
|
|
|
|
|
|
|
|
// List<InvInvoiceDetail> details = new ArrayList<>();
|
|
|
|
|
|
|
|
List<InvInvoiceSplit> splits = new ArrayList<>();
|
|
|
|
|
|
|
|
InvInvoiceInfo invoice = null;
|
|
|
|
|
|
|
|
for(int i=0;i<fees.size();i++){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
InvFeeInfo feeinfo = fees.get(i);
|
|
|
|
|
|
|
|
if(i==0){
|
|
|
|
|
|
|
|
if(feeinfo.getAmount().compareTo(checkinvocie)==1 || feeinfo.getAmount().compareTo(checkinvocie)==0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal[] results = feeinfo.getAmount().divideAndRemainder(checkinvocie);
|
|
|
|
|
|
|
|
int size = results[0].intValue();
|
|
|
|
|
|
|
|
for(int m=0;m<size;m++){
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BigDecimal remainAmount = results[1].setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
amount = remainAmount;
|
|
|
|
|
|
|
|
if(remainAmount.compareTo(new BigDecimal(0))==1){
|
|
|
|
|
|
|
|
if((i==fees.size()-1)){
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
amount = amount.add(feeinfo.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
amount = amount.add(feeinfo.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
//如果加金额大于指定金额,则不加金额,取前边的数值
|
|
|
|
|
|
|
|
if(amount.compareTo(checkinvocie)==1){
|
|
|
|
|
|
|
|
BigDecimal checkamount = amount.subtract(feeinfo.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
if(feeinfo.getAmount().compareTo(checkinvocie)==1 || feeinfo.getAmount().compareTo(checkinvocie)==0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把以前的
|
|
|
|
|
|
|
|
if(checkamount.compareTo(new BigDecimal(0))==1){
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断当前金额
|
|
|
|
|
|
|
|
BigDecimal[] results = feeinfo.getAmount().divideAndRemainder(checkinvocie);
|
|
|
|
|
|
|
|
int size = results[0].intValue();
|
|
|
|
|
|
|
|
for(int m=0;m<size;m++){
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BigDecimal remainAmount = results[1].setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
amount = remainAmount;
|
|
|
|
|
|
|
|
if((i==fees.size()-1) && (amount.compareTo(new BigDecimal(0))== 1)){
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
splits = new ArrayList<>();
|
|
|
|
|
|
|
|
if(remainAmount.compareTo(new BigDecimal(0))==1){
|
|
|
|
|
|
|
|
InvInvoiceSplit split = getInvInvoiceSplit(new InvInvoiceInfo(),new InvInvoiceDetail(),feeinfo,link,amount);
|
|
|
|
|
|
|
|
splits.add(split);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//生成发票和发票明细
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if((i==fees.size()-1) && (feeinfo.getAmount().compareTo(new BigDecimal(0))== 1)){
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
amount = feeinfo.getAmount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//如果amount等于最大开票金额
|
|
|
|
|
|
|
|
if(amount.compareTo(checkinvocie)==0){
|
|
|
|
|
|
|
|
//生成发票和发票明细
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
amount = new BigDecimal(0);
|
|
|
|
|
|
|
|
splits = new ArrayList<>();
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//生成发票分配
|
|
|
|
|
|
|
|
InvInvoiceSplit split = getInvInvoiceSplit(new InvInvoiceInfo(),new InvInvoiceDetail(),feeinfo,link,feeinfo.getAmount());
|
|
|
|
|
|
|
|
splits.add(split);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(i==fees.size()-1){
|
|
|
|
|
|
|
|
BigDecimal sums = splits.stream().map(InvInvoiceSplit::getAmountTotal).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
|
|
|
|
|
invoice = new InvInvoiceInfo();
|
|
|
|
|
|
|
|
list.add(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list.size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void invoicepzRmb(List<InvFeeInfo> fees,InvLinkInfo link,BigDecimal sumfees){
|
|
|
|
void invoicepzRmb(List<InvFeeInfo> fees,InvLinkInfo link,BigDecimal sumfees){
|
|
|
|
if(null != fees && fees.size()>0){
|
|
|
|
if(null != fees && fees.size()>0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpResult result = parameterFeignClient.getParameter(link.getCompanyId());
|
|
|
|
|
|
|
|
String amountParam=(String)result.getData();
|
|
|
|
|
|
|
|
BigDecimal invoiceAmount = new BigDecimal(amountParam);
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal checkinvocie = new BigDecimal(0);
|
|
|
|
BigDecimal checkinvocie = new BigDecimal(0);
|
|
|
|
|
|
|
|
|
|
|
|
if("RMB".equals(fees.get(0).getCurrency())){
|
|
|
|
if("RMB".equals(fees.get(0).getCurrency())){
|
|
|
@ -851,7 +825,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
// kpInvoice.setPayee("");
|
|
|
|
// kpInvoice.setPayee("");
|
|
|
|
//kpInvoice.setReviewer("");
|
|
|
|
//kpInvoice.setReviewer("");
|
|
|
|
kpInvoice.setTaxpayerCode(UploadData.getTaxpayerCode()); // 收款方纳税人识别号
|
|
|
|
kpInvoice.setTaxpayerCode(UploadData.getTaxpayerCode()); // 收款方纳税人识别号
|
|
|
|
kpInvoice.setRemark("发票备注信息"); // 发票备注
|
|
|
|
kpInvoice.setRemark(invoice.getRequireRemark()); // 发票备注
|
|
|
|
|
|
|
|
|
|
|
|
//发票明细内容,最多支持100条
|
|
|
|
//发票明细内容,最多支持100条
|
|
|
|
List<KpInvoiceItem> itemList=new ArrayList<KpInvoiceItem>();// 发票项目明细列表
|
|
|
|
List<KpInvoiceItem> itemList=new ArrayList<KpInvoiceItem>();// 发票项目明细列表
|
|
|
@ -887,6 +861,13 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
log.info("连接id====={}",info.getGID());
|
|
|
|
log.info("连接id====={}",info.getGID());
|
|
|
|
|
|
|
|
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(info);
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpResult result = parameterFeignClient.getParameter(link.getCompanyId());
|
|
|
|
|
|
|
|
String amount =(String)result.getData();
|
|
|
|
|
|
|
|
BigDecimal invoiceAmount = new BigDecimal(amount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvFeeInfo fee = new InvFeeInfo();
|
|
|
|
InvFeeInfo fee = new InvFeeInfo();
|
|
|
|
fee.setLinkId(info.getGID());
|
|
|
|
fee.setLinkId(info.getGID());
|
|
|
|
List<String> businessIds = invFeeInfoMapper.getBusinessIds(fee);
|
|
|
|
List<String> businessIds = invFeeInfoMapper.getBusinessIds(fee);
|
|
|
@ -1059,7 +1040,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(info);
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(info);
|
|
|
|
|
|
|
|
|
|
|
|
if(!"0".equals(link.getStatus())){
|
|
|
|
if(!"0".equals(link.getStatus())){
|
|
|
|
return HttpResult.error("该链接已经开票或在开票中,不能发送数据");
|
|
|
|
return HttpResult.error(20070,"该链接已经开票或在开票中,不能发送数据");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
link.setEmail(info.getEmail());
|
|
|
|
link.setEmail(info.getEmail());
|
|
|
@ -1085,7 +1066,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( i==0 && 0 != data.getCode()){
|
|
|
|
if( i==0 && 0 != data.getCode()){
|
|
|
|
throw new RuntimeException("接口调用失败");
|
|
|
|
throw new RuntimeException("接口调用失败,"+JSONObject.toJSONString(data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1316,13 +1297,13 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
InvLinkInfoServiceImpl.cmdCxName = cmdCxName;
|
|
|
|
InvLinkInfoServiceImpl.cmdCxName = cmdCxName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static BigDecimal getInvoiceAmount() {
|
|
|
|
// public static BigDecimal getInvoiceAmount() {
|
|
|
|
return invoiceAmount;
|
|
|
|
// return invoiceAmount;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
@Value("${invoice.invoiceAmount}")
|
|
|
|
// @Value("${invoice.invoiceAmount}")
|
|
|
|
public void setInvoiceAmount(BigDecimal invoiceAmount) {
|
|
|
|
// public void setInvoiceAmount(BigDecimal invoiceAmount) {
|
|
|
|
InvLinkInfoServiceImpl.invoiceAmount = invoiceAmount;
|
|
|
|
// InvLinkInfoServiceImpl.invoiceAmount = invoiceAmount;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getSendTo() {
|
|
|
|
public static String getSendTo() {
|
|
|
|