开票页面展示判断发票生成数量金额

master
pangyang 2 years ago
parent 398d8db1d6
commit a36f334d2e

@ -19,7 +19,7 @@ public class InvLinkInfoController {
@Operation(description = "外部调用接口")
@PostMapping("getlink")
public HttpResult getlink(@RequestBody InvLinkInfo info) {
public HttpResult getlink(InvLinkInfo info) {
return invLinkInfoService.getlink(info);
}
@ -46,9 +46,8 @@ public class InvLinkInfoController {
@PostMapping("uploadInvoice")
public HttpResult uploadInvoice(InvLinkInfo info) {
invLinkInfoService.uploadInvoice(info);
return invLinkInfoService.uploadInvoice(info);
return HttpResult.ok();
}
@Operation(description = "查询发票")

@ -88,5 +88,10 @@ public class InvLinkInfo {
//发送状态 0未发送 1已发送
private String SendStatus;
//人民币拆分金额
private String rmbsplits;
//usd拆分金额
private String usdsplits;
}

@ -11,6 +11,9 @@ public interface InvInvoiceDetailMapper extends CommonMapper<InvInvoiceDetail> {
InvInvoiceDetail getByInvoiceGId(String GID);
InvInvoiceDetail getByGId(String GID);
void deleteByGID(InvInvoiceDetail info);
}

@ -19,6 +19,12 @@ public interface InvInvoiceSplitMapper extends CommonMapper<InvInvoiceSplit> {
String getlinkdId(String GID);
List<String> getDetailIdsBylinkdIdAndCurrency(InvInvoiceSplit info);
List<InvInvoiceSplit> getBydetailId(String detailId);
}

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

@ -39,6 +39,10 @@
select * from InvInvoiceDetail info WHERE InvId = #{GID}
</select>
<select id="getByGId" resultMap="invInvoiceDetailMap" parameterType="String">
select * from InvInvoiceDetail info WHERE GID = #{GID}
</select>
<delete id="deleteByGID" parameterType="com.djy.invoice.model.InvInvoiceDetail" >

@ -38,6 +38,19 @@
</select>
<select id="getDetailIdsBylinkdIdAndCurrency" resultType="String" parameterType="com.djy.invoice.model.InvInvoiceSplit">
SELECT distinct(split.InvoiceDetailId) from InvInvoiceSplit split
where split.LinkId = #{LinkId}
<if test="Currency!=null">
and Currency=#{Currency}
</if>
<if test="Currency!=null and Currency !='RMB' ">
and Currency != 'RMB'
</if>
ORDER BY split.FeeId ASC , split.SplitAmountRMB DESC
</select>
<select id="getlinkdId" resultType="String" parameterType="String">
select distinct(split.LinkId) from InvInvoiceInfo info LEFT JOIN InvInvoiceSplit split ON info.GID = split.InvoiceId WHERE info.GID = #{GID}
</select>
@ -47,6 +60,10 @@
SELECT * ,info.BSNO AS 'BSNO' from InvInvoiceSplit split left join InvBusinessInfo info on split.BusinessId = info.GID where split.LinkId = #{GID}
</select>
<select id="getBydetailId" resultMap="invInvoiceSplitMap" parameterType="String">
SELECT * from InvInvoiceSplit split where split.InvoiceDetailId = #{detailId}
</select>
<delete id="deleteByGID" parameterType="com.djy.invoice.model.InvInvoiceInfo" >
delete from InvInvoiceSplit where LinkId=#{GID}

Loading…
Cancel
Save