开票发票备注和获取开票金额

master
pangyang 2 years ago
parent b9f9768880
commit 70d52f2b0f

@ -31,6 +31,11 @@
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>${spring-cloud-alibaba.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
@ -138,6 +143,12 @@
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version> <version>2.2.2</version>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-ribbon</artifactId>-->
<!--</dependency>-->
</dependencies> </dependencies>
<build> <build>

@ -3,6 +3,7 @@ package com.djy.basic;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
@ -12,12 +13,15 @@ import tk.mybatis.spring.annotation.MapperScan;
@MapperScan(basePackages = "com.djy.**.model") @MapperScan(basePackages = "com.djy.**.model")
@ComponentScan("com.djy.**") @ComponentScan("com.djy.**")
@EnableScheduling @EnableScheduling
@EnableFeignClients
@EnableDiscoveryClient @EnableDiscoveryClient
@SpringBootApplication @SpringBootApplication
public class BasicApplication { public class BasicApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(BasicApplication.class, args); SpringApplication.run(BasicApplication.class, args);
System.out.println("启动成功");
} }
} }

@ -1,13 +1,13 @@
package com.djy.basic.Invoice.controller; package com.djy.basic.Invoice.controller;
import com.djy.basic.Invoice.service.InvoiceRecordService; import com.djy.basic.Invoice.service.InvoiceRecordService;
import com.djy.basic.Invoice.service.ParameterRecordService;
import com.djy.basic.Invoice.vo.req.InvoiceReq; import com.djy.basic.Invoice.vo.req.InvoiceReq;
import com.djy.core.http.HttpResult; import com.djy.core.http.HttpResult;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/invoice") @RequestMapping("/invoice")
@ -16,6 +16,9 @@ public class InvoiceRecordController {
private final InvoiceRecordService invoiceRecordService; private final InvoiceRecordService invoiceRecordService;
@Autowired
private ParameterRecordService parameterRecordService;
public InvoiceRecordController(InvoiceRecordService invoiceRecordService) { public InvoiceRecordController(InvoiceRecordService invoiceRecordService) {
this.invoiceRecordService = invoiceRecordService; this.invoiceRecordService = invoiceRecordService;
} }
@ -26,4 +29,13 @@ public class InvoiceRecordController {
this.invoiceRecordService.getInvoiceInfo(invoiceReq); this.invoiceRecordService.getInvoiceInfo(invoiceReq);
return HttpResult.ok(); return HttpResult.ok();
} }
@PostMapping("getParameter")
public HttpResult getParameter(@RequestBody String companyId){
String amount = parameterRecordService.getAmount(companyId);
System.out.println(amount);
return HttpResult.ok(amount);
}
} }

@ -0,0 +1,17 @@
package com.djy.basic.Invoice.model;
import lombok.Data;
import java.util.Date;
/**
* @description invoiceRecord
* @author
* @date 2022-05-11
*/
@Data
public class ParameterRecord {
private String amount;
}

@ -0,0 +1,12 @@
package com.djy.basic.Invoice.model.mapper;
import com.djy.basic.Invoice.model.InvoiceRecord;
import com.djy.basic.Invoice.model.ParameterRecord;
import com.djy.core.cmapper.CommonMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface ParameterMapper extends CommonMapper<ParameterRecord> {
String getAmount(String companyId);
}

@ -0,0 +1,8 @@
package com.djy.basic.Invoice.service;
import com.djy.basic.Invoice.vo.req.InvoiceReq;
public interface ParameterRecordService {
String getAmount(String companyId);
}

@ -0,0 +1,22 @@
package com.djy.basic.Invoice.service.impl;
import com.djy.basic.Invoice.model.mapper.InvoiceRecordMapper;
import com.djy.basic.Invoice.model.mapper.ParameterMapper;
import com.djy.basic.Invoice.service.InvoiceRecordService;
import com.djy.basic.Invoice.service.ParameterRecordService;
import com.djy.basic.Invoice.vo.req.InvoiceReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ParameterRecordServiceImpl implements ParameterRecordService {
@Autowired
private ParameterMapper parameterMapper;
@Override
public String getAmount(String companyId) {
return parameterMapper.getAmount(companyId);
}
}

@ -3,15 +3,24 @@ spring:
name: basic name: basic
profiles: profiles:
active: dev active: dev
ribbon:
ReadTimeout: 60000 #指的是建立连接所用的时间,适用于网络状况正常的情况下,两端连接所用的时间。
ConnectTimeout: 60000 #指的是建立连接后从服务器读取到可用资源所用的时间。
cloud: cloud:
nacos: nacos:
config: config:
namespace: 26ffe9e3-cddc-415c-9e4e-407557ff6172 namespace: 26ffe9e3-cddc-415c-9e4e-407557ff6172
server-addr: 123.234.225.158:38848 server-addr: 123.234.225.158:38848
username: nacos # username: nacos
password: Ds20040201 # password: Ds20040201
username: djy_nacos
password: 8AF67A95-D9C6-40F4-8F4B-DC819D09E3B9
file-extension: yml file-extension: yml
shared-configs: shared-configs:
- data-id: common-${spring.profiles.active}.yml - data-id: common-${spring.profiles.active}.yml
group: DEV_GROUP group: DEV_GROUP
refresh: true #代表是否允许自动刷新 refresh: true #代表是否允许自动刷新
- dataId: basic-${spring.profiles.active}.yml
group: DEV-GROUP
refresh: true

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.djy.basic.Invoice.model.mapper.ParameterMapper">
<select id="getAmount" resultType="String" parameterType="String">
select ItemCode from company_new_param_value WHERE CompId = #{companyId} and ParaCode ='INVOICE_CUSTOMER_AMOUNT_LIMIT'
</select>
</mapper>

@ -141,6 +141,12 @@
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-ribbon</artifactId>-->
<!--</dependency>-->
<dependency > <dependency >
<groupId >javax.mail </groupId > <groupId >javax.mail </groupId >
<artifactId >mail</artifactId > <artifactId >mail</artifactId >

@ -3,10 +3,13 @@ package com.djy.invoice;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.spring.annotation.MapperScan; import tk.mybatis.spring.annotation.MapperScan;
@EnableAsync @EnableAsync
@ -24,4 +27,5 @@ public class InvoiceApplication {
System.out.println("启动成功"); System.out.println("启动成功");
} }
} }

@ -7,6 +7,7 @@ import com.djy.invoice.dto.SendEmailParams;
import com.djy.invoice.model.InvInvoiceInfo; import com.djy.invoice.model.InvInvoiceInfo;
import com.djy.invoice.model.InvLinkInfo; import com.djy.invoice.model.InvLinkInfo;
import com.djy.invoice.service.InvLinkInfoService; import com.djy.invoice.service.InvLinkInfoService;
import com.djy.invoice.service.ParameterFeignClient;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -23,6 +24,8 @@ public class InvLinkInfoController {
@Autowired @Autowired
private InvLinkInfoService invLinkInfoService; private InvLinkInfoService invLinkInfoService;
@Autowired
private ParameterFeignClient parameterFeignClient;
@Operation(description = "外部调用接口") @Operation(description = "外部调用接口")
@ -65,6 +68,17 @@ public class InvLinkInfoController {
return HttpResult.ok(list); return HttpResult.ok(list);
} }
@Operation(description = "获取参数")
@PostMapping("getParameter")
public HttpResult getParameter() {
String companyId ="9f3b3526-4dd4-4997-b974-1f2adb279389";
HttpResult result = parameterFeignClient.getParameter(companyId);
return result;
}
// @Operation(description = "查询发票") // @Operation(description = "查询发票")
// @PostMapping("getInvoice") // @PostMapping("getInvoice")
// public HttpResult getInvoice(InvLinkInfo info) { // public HttpResult getInvoice(InvLinkInfo info) {

@ -2,6 +2,7 @@ package com.djy.invoice.model.mapper;
import com.djy.core.cmapper.CommonMapper; import com.djy.core.cmapper.CommonMapper;
import com.djy.invoice.model.InvInvoiceSplit; import com.djy.invoice.model.InvInvoiceSplit;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -25,6 +26,12 @@ public interface InvInvoiceSplitMapper extends CommonMapper<InvInvoiceSplit> {
String getLinkIdsByinvoiceId(String invoiceId); String getLinkIdsByinvoiceId(String invoiceId);
List<String> getSplitsByInvoiceId(String invoiceId);
InvInvoiceSplit getAmount(@Param("invoiceId") String invoiceId, @Param("businessId") String businessId);

@ -0,0 +1,16 @@
package com.djy.invoice.service;
import com.djy.core.http.HttpResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@Component
@FeignClient(name="basic")
public interface ParameterFeignClient {
@PostMapping(value = "/basicInfo/invoice/getParameter")
HttpResult getParameter(@RequestBody String companyId);
}

@ -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() {

@ -14,15 +14,15 @@ spring:
username: djy_dev username: djy_dev
password: dev123 password: dev123
virtual-host: inv_customer virtual-host: inv_customer
mail: # mail:
host: smtp.qq.com # 邮箱服务器地址 # host: smtp.qq.com # 邮箱服务器地址
username: 475446853@qq.com # username: 475446853@qq.com
password: dxqhgqtsmdtubjbf # password: dxqhgqtsmdtubjbf
default-encoding: UTF-8 # default-encoding: UTF-8
SendTo: 475446853@qq.com # SendTo: 475446853@qq.com
SmtpConfig: INVOICE # SmtpConfig: INVOICE
subject: 发票信息 # subject: 发票信息
url: http://47.104.73.97:8801/mail/send # url: http://47.104.73.97:8801/mail/send
logging: logging:
level: level:
root: info root: info

@ -3,8 +3,16 @@ spring:
name: invoice name: invoice
profiles: profiles:
active: dev active: dev
ribbon:
ReadTimeout: 60000 #指的是建立连接所用的时间,适用于网络状况正常的情况下,两端连接所用的时间。
ConnectTimeout: 60000 #指的是建立连接后从服务器读取到可用资源所用的时间。
cloud: cloud:
nacos: nacos:
discovery:
namespace: 26ffe9e3-cddc-415c-9e4e-407557ff6172
server-addr: 123.234.225.158:38848
username: djy_nacos
password: 8AF67A95-D9C6-40F4-8F4B-DC819D09E3B9
config: config:
namespace: 26ffe9e3-cddc-415c-9e4e-407557ff6172 namespace: 26ffe9e3-cddc-415c-9e4e-407557ff6172
server-addr: 123.234.225.158:38848 server-addr: 123.234.225.158:38848

@ -42,6 +42,16 @@
</select> </select>
<select id="getSplitsByInvoiceId" resultType="String" parameterType="String">
SELECT distinct(split.BusinessId) from InvInvoiceSplit split where split.InvoiceId = #{invoiceId}
</select>
<select id="getAmount" resultMap="invInvoiceSplitMap" parameterType="String">
SELECT sum(split.SplitAmount) AS SplitAmount,sum(split.SplitAmountRMB) AS SplitAmountRMB from InvInvoiceSplit split
where split.InvoiceId = #{invoiceId} and split.BusinessId = #{businessId}
</select>
<select id="getDetailIdsBylinkdIdAndCurrency" resultType="String" parameterType="com.djy.invoice.model.InvInvoiceSplit"> <select id="getDetailIdsBylinkdIdAndCurrency" resultType="String" parameterType="com.djy.invoice.model.InvInvoiceSplit">
SELECT distinct(split.InvoiceDetailId) from InvInvoiceSplit split SELECT distinct(split.InvoiceDetailId) from InvInvoiceSplit split
where split.LinkId = #{LinkId} where split.LinkId = #{LinkId}

Loading…
Cancel
Save