开票注释添加

master
pangyang 2 years ago
parent 70d52f2b0f
commit 0e2ba4c402

@ -66,6 +66,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
//判断是否数字
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*");
if(str.indexOf(".")>0){//判断是否有小数点
@ -79,6 +80,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
}
//上传链接、业务数据和费用数据
@Transactional
@Override
public HttpResult getlink(String json) {
@ -106,6 +108,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
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{
@ -138,6 +141,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
}
//赋值给链表状态
linkinfo.setStatus("0");
linkinfo.setSendStatus("0");
try {
@ -150,6 +154,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
// JSONArray array = jsonObj.getJSONArray("BillList");
//生成业务信息
List<InvBusinessInfo> array = linkinfo.getBillList();
for(int i=0; i<array.size(); i++) {
@ -178,6 +183,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
e.printStackTrace();
}
// invBusinessInfoMapper.deleteByGID(businessinfo);
//重新上传,如果存在就更新
invBusinessInfoMapper.updateInvBusinessInfo(businessinfo);
gid = businessinfo.getGID();
bsno = businessinfo.getBSNO();
@ -193,6 +199,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
List<InvFeeInfo> feearray = business.getFeeList();
//重新生成费用信息
for(int j=0; j<feearray.size(); j++) {
InvFeeInfo fee = feearray.get(j);
@ -216,9 +223,12 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
//重新上传的时候删除原来的数据
deleteSplit(linkinfo);
//生成发票,发票明细,发票分割
createSplit(linkinfo);
//判断链接备注情况(remarkTemplate)
List<String> invoiceIds = invInvoiceSplitMapper.getIdsBylinkdId(linkinfo.getGID());
for(String str : invoiceIds){
@ -305,6 +315,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
//重新上传时,删除发票、发票明细、分票情况
public void deleteSplit(InvLinkInfo link){
List<String> list = invInvoiceSplitMapper.getIdsBylinkdId(link.getGID());
@ -326,7 +337,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
//组装发票明细
InvInvoiceDetail getInvInvoiceDetail(InvInvoiceInfo invoice,InvFeeInfo feeinfo,BigDecimal amount){
InvInvoiceDetail detail = new InvInvoiceDetail();
detail.setGID(UUID.randomUUID().toString().replace("-", ""));
@ -358,6 +369,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
//组装发票分配
InvInvoiceSplit getInvInvoiceSplit(InvInvoiceInfo invoice,InvInvoiceDetail detail,InvFeeInfo feeinfo,InvLinkInfo link,BigDecimal amount){
InvInvoiceSplit split = new InvInvoiceSplit();
split.setGID(UUID.randomUUID().toString().replace("-", ""));
@ -388,6 +400,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
//开始生成发票、发票明细、发票分配
void invoicepzRmb(List<InvFeeInfo> fees,InvLinkInfo link,BigDecimal sumfees){
if(null != fees && fees.size()>0){
@ -407,7 +420,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
//如果费用总计小于等于最大开票金额
if(checkinvocie.compareTo(sumfees) == 1){
if(checkinvocie.compareTo(sumfees) == 1 || checkinvocie.compareTo(sumfees) == 0 ){
InvInvoiceInfo invoice = new InvInvoiceInfo();
BeanUtils.copyProperties(link,invoice);
invoice.setStatus(null);
@ -426,20 +439,19 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
InvInvoiceSplit split = getInvInvoiceSplit(invoice,detail,feeinfo,link,feeinfo.getAmount());
invInvoiceSplitMapper.add(split);
}
}else{
}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++){
@ -459,11 +471,15 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
InvInvoiceSplit split = getInvInvoiceSplit(invoice,detail,feeinfo,link,checkinvocie);
invInvoiceSplitMapper.add(split);
}
//当前费用对开票限额取余所剩的金额
BigDecimal remainAmount = results[1].setScale(2, BigDecimal.ROUND_HALF_UP);
amount = remainAmount;
//如果剩余金额大于0
if(remainAmount.compareTo(new BigDecimal(0))==1){
//生成发票分配
InvInvoiceSplit split = getInvInvoiceSplit(new InvInvoiceInfo(),new InvInvoiceDetail(),feeinfo,link,amount);
splits.add(split);
//如果是最后一行费用数据,生成发票、发票明细、发票分配
if((i==fees.size()-1)){
invoice = new InvInvoiceInfo();
BeanUtils.copyProperties(link,invoice);
@ -484,19 +500,21 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
}
}else{
}else{//如果当前费用小于开票限额
InvInvoiceSplit split = getInvInvoiceSplit(new InvInvoiceInfo(),new InvInvoiceDetail(),feeinfo,link,feeinfo.getAmount());
splits.add(split);
//获取当前费用加上上一次剩余的金额
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){
InvFeeInfo feeinfoold = fees.get(i-1);
invoice = new InvInvoiceInfo();
@ -529,7 +547,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
// invInvoiceSplitMapper.add(splitcheck);
}
//判断当前金额
//对当前金额取余
BigDecimal[] results = feeinfo.getAmount().divideAndRemainder(checkinvocie);
int size = results[0].intValue();
for(int m=0;m<size;m++){
@ -549,9 +567,12 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
InvInvoiceSplit split = getInvInvoiceSplit(invoice,detail,feeinfo,link,checkinvocie);
invInvoiceSplitMapper.add(split);
}
//当前费用对开票限额取余所剩的金额
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();
BeanUtils.copyProperties(link,invoice);
@ -593,20 +614,6 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
invInvoiceInfoMapper.add(invoice);
InvInvoiceDetail detail = getInvInvoiceDetail(invoice,feeinfoold,checkamount);
invInvoiceDetailMapper.add(detail);
//生成发票分配
// InvInvoiceSplit split = getInvInvoiceSplit(invoice,detail,feeinfoold,link,checkamount);
// invInvoiceSplitMapper.add(split);
// splits.add(split);
//
// if(null != splits && splits.size()>0){
// for(InvInvoiceSplit sp : splits){
// sp.setInvoiceId(invoice.getGID());
// sp.setInvoiceDetailId(detail.getGID());
// sp.setGID(UUID.randomUUID().toString().replace("-", ""));
// invInvoiceSplitMapper.add(sp);
// }
// }
if(null != splits && splits.size()>0){
for(InvInvoiceSplit sp : splits){
@ -634,13 +641,9 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
InvInvoiceSplit spl = getInvInvoiceSplit(invoice,det,feeinfo,link,feeinfo.getAmount());
invInvoiceSplitMapper.add(spl);
}
amount = feeinfo.getAmount();
//先清空发票分配
splits = new ArrayList<>();
//把当前的发票分配添加进集合
InvInvoiceSplit spl = getInvInvoiceSplit(invoice,detail,feeinfo,link,feeinfo.getAmount());
splits.add(spl);
@ -650,7 +653,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}else{
//如果amount等于最大开票金额
if(amount.compareTo(checkinvocie)==0){
//生成发票和发票明细
//生成发票和发票明细、发票配置
invoice = new InvInvoiceInfo();
BeanUtils.copyProperties(link,invoice);
invoice.setStatus(null);
@ -678,11 +681,12 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
}
amount = new BigDecimal(0);
splits = new ArrayList<>();
}else{
}else{//如果amount小于最大开票金额
//生成发票分配
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();
@ -728,6 +732,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
// @Transactional
// @Override
//生成发票、发票明细、发票分配
public HttpResult createSplit(InvLinkInfo info) {
log.info("连接id====={}",info.getGID());
@ -747,12 +752,14 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
InvFeeInfo fee = new InvFeeInfo();
fee.setLinkId(info.getGID());
fee.setCurrency("RMB");
//人民币费用合计
List<InvFeeInfo> fees = invFeeInfoMapper.getListBylink(fee);
BigDecimal sumfees = fees.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
InvFeeInfo feeNoRmb = new InvFeeInfo();
feeNoRmb.setLinkId(info.getGID());
//非人民币费用合计
List<InvFeeInfo> feesNoRmb = invFeeInfoMapper.getListBylinkNoRmb(feeNoRmb);
BigDecimal sumNormbfees = feesNoRmb.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
@ -761,40 +768,6 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
invoicepzRmb(fees,link,sumfees);
//创建非人民币发票
invoicepzRmb(feesNoRmb,link,sumNormbfees);
//
// List<String> invoiceIds = invInvoiceSplitMapper.getIdsBylinkdId(link.getGID());
//
//// List<InvInvoiceInfo> list = invInvoiceInfoMapper.getByIds(link.getGID());
//
// if(null !=invoiceIds && invoiceIds.size()>0){
// ResponseData data = null;
// for(int i=0;i<invoiceIds.size();i++){
// InvInvoiceInfo invoice = invInvoiceInfoMapper.getByGid(invoiceIds.get(i));
// try {
// data = new ResponseData();
// data = UploadData.doPost(cmdName, getKpData(invoice));
// invoice.setSerialNo(data.getSerialNo());
// invoice.setApiSendTime(df.parse(df.format(new Date())));
// invInvoiceInfoMapper.updateById(invoice);
// } catch (Exception e) {
// e.printStackTrace();
// }
// if( i==0 && 0 != data.getCode()){
// throw new RuntimeException("接口调用失败");
// }
//
// }
// }
//
// if(0 !=1 ){
// throw new RuntimeException("接口调用失败");
// }else{
// return HttpResult.ok("开票成功","");
// }
//
return HttpResult.ok("上传数据成功","");
}

Loading…
Cancel
Save