|
| 1 | +package com.jangburich.domain.barobill.application; |
| 2 | + |
| 3 | +import com.baroservice.api.BarobillApiService; |
| 4 | +import com.baroservice.ws.ArrayOfTaxInvoiceTradeLineItem; |
| 5 | +import com.baroservice.ws.InvoiceParty; |
| 6 | +import com.baroservice.ws.TaxInvoice; |
| 7 | +import com.baroservice.ws.TaxInvoiceTradeLineItem; |
| 8 | +import com.jangburich.domain.barobill.dto.request.GetCertificateRegistURLRequest; |
| 9 | +import com.jangburich.domain.barobill.dto.request.RegistCorpRequest; |
| 10 | +import java.util.regex.Pattern; |
| 11 | +import lombok.RequiredArgsConstructor; |
| 12 | +import org.springframework.stereotype.Service; |
| 13 | +import org.springframework.transaction.annotation.Transactional; |
| 14 | + |
| 15 | +@Service |
| 16 | +@RequiredArgsConstructor |
| 17 | +@Transactional(readOnly = true) |
| 18 | +public class BarobillService { |
| 19 | + |
| 20 | + private final BarobillApiService barobillApiService; |
| 21 | + private static final String CERT_KEY = "164D08BA-4305-4256-8E8C-0BD955D08862"; |
| 22 | + |
| 23 | + @Transactional |
| 24 | + public void registCorp(RegistCorpRequest registCorpRequest) { |
| 25 | + int result = barobillApiService.taxInvoice.registCorp(CERT_KEY, registCorpRequest.corpNum(), |
| 26 | + registCorpRequest.corpName(), registCorpRequest.ceoName(), registCorpRequest.bizType(), registCorpRequest.bizClass(), |
| 27 | + registCorpRequest.postNum(), registCorpRequest.addr1(), |
| 28 | + registCorpRequest.addr2(), registCorpRequest.memberName(), registCorpRequest.juminNum(), registCorpRequest.id(), registCorpRequest.pwd(), registCorpRequest.grade(), |
| 29 | + registCorpRequest.tel(), registCorpRequest.hp(), registCorpRequest.email()); |
| 30 | + |
| 31 | + if (result < 0) { // 호출 실패 |
| 32 | + System.out.println(result); |
| 33 | + } else { // 호출 성공 |
| 34 | + System.out.println(result); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + public void getCertificateRegistURL(GetCertificateRegistURLRequest getCertificateRegistURLRequest) { |
| 39 | + String result = barobillApiService.taxInvoice.getCertificateRegistURL(CERT_KEY, |
| 40 | + getCertificateRegistURLRequest.corpNum(), getCertificateRegistURLRequest.id(), |
| 41 | + getCertificateRegistURLRequest.pwd()); |
| 42 | + |
| 43 | + if (Pattern.compile("^-[0-9]{5}").matcher(result).matches()) { // 호출 실패 |
| 44 | + System.out.println(result); |
| 45 | + } else { // 호출 성공 |
| 46 | + System.out.println(result); |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + @Transactional |
| 51 | + public void registAndReverseIssueTaxInvoice() { |
| 52 | + // 공급자, 공급받는자의 관리번호 채번 |
| 53 | + String invoicerMgtNum = "000001-R"; |
| 54 | + String invoiceeMgtNum = "000001-E"; |
| 55 | + |
| 56 | + // 공급자, 공급받는자의 바로빌 아이디 불러오기 |
| 57 | + String invoicerBarobillID = "barobill"; |
| 58 | + String invoiceeBarobillID = "barobill"; |
| 59 | + |
| 60 | + // 세금계산서 내용을 담은 클래스(또는 구조체) 생성 |
| 61 | + TaxInvoice taxInvoice = new TaxInvoice(); |
| 62 | + |
| 63 | + /**/ |
| 64 | + taxInvoice.setIssueDirection(1); |
| 65 | + taxInvoice.setTaxInvoiceType(1); |
| 66 | + |
| 67 | + taxInvoice.setModifyCode(""); |
| 68 | + |
| 69 | + taxInvoice.setTaxType(1); |
| 70 | + taxInvoice.setTaxCalcType(1); |
| 71 | + taxInvoice.setPurposeType(2); |
| 72 | + |
| 73 | + taxInvoice.setWriteDate(""); |
| 74 | + |
| 75 | + taxInvoice.setAmountTotal(""); |
| 76 | + taxInvoice.setTaxTotal(""); |
| 77 | + taxInvoice.setTotalAmount(""); |
| 78 | + taxInvoice.setCash(""); |
| 79 | + taxInvoice.setChkBill(""); |
| 80 | + taxInvoice.setNote(""); |
| 81 | + taxInvoice.setCredit(""); |
| 82 | + |
| 83 | + taxInvoice.setRemark1(""); |
| 84 | + taxInvoice.setRemark2(""); |
| 85 | + taxInvoice.setRemark3(""); |
| 86 | + |
| 87 | + taxInvoice.setKwon(""); |
| 88 | + taxInvoice.setHo(""); |
| 89 | + taxInvoice.setSerialNum(""); |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + /**/ |
| 94 | + |
| 95 | + // 공급자 정보 |
| 96 | + taxInvoice.setInvoicerParty(new InvoiceParty()); |
| 97 | + taxInvoice.getInvoicerParty().setMgtNum(""); |
| 98 | + taxInvoice.getInvoicerParty().setCorpNum(""); |
| 99 | + taxInvoice.getInvoicerParty().setTaxRegID(""); |
| 100 | + taxInvoice.getInvoicerParty().setCorpName(""); |
| 101 | + taxInvoice.getInvoicerParty().setCEOName(""); |
| 102 | + taxInvoice.getInvoicerParty().setAddr(""); |
| 103 | + taxInvoice.getInvoicerParty().setBizType(""); |
| 104 | + taxInvoice.getInvoicerParty().setBizClass(""); |
| 105 | + taxInvoice.getInvoicerParty().setContactID(""); |
| 106 | + taxInvoice.getInvoicerParty().setContactName(""); |
| 107 | + taxInvoice.getInvoicerParty().setTEL(""); |
| 108 | + taxInvoice.getInvoicerParty().setHP(""); |
| 109 | + taxInvoice.getInvoicerParty().setEmail(""); |
| 110 | + |
| 111 | + //공급받는자 정보 |
| 112 | + taxInvoice.setInvoiceeParty(new InvoiceParty()); |
| 113 | + taxInvoice.getInvoiceeParty().setCorpNum(""); |
| 114 | + taxInvoice.getInvoiceeParty().setTaxRegID(""); |
| 115 | + taxInvoice.getInvoiceeParty().setCorpName(""); |
| 116 | + taxInvoice.getInvoiceeParty().setCEOName(""); |
| 117 | + taxInvoice.getInvoiceeParty().setAddr(""); |
| 118 | + taxInvoice.getInvoiceeParty().setBizType(""); |
| 119 | + taxInvoice.getInvoiceeParty().setBizClass(""); |
| 120 | + taxInvoice.getInvoiceeParty().setContactID(""); |
| 121 | + taxInvoice.getInvoiceeParty().setContactName(""); |
| 122 | + taxInvoice.getInvoiceeParty().setTEL(""); |
| 123 | + taxInvoice.getInvoiceeParty().setHP(""); |
| 124 | + taxInvoice.getInvoiceeParty().setEmail(""); |
| 125 | + |
| 126 | + // 수탁자 정보 |
| 127 | + taxInvoice.setBrokerParty(new InvoiceParty()); |
| 128 | + taxInvoice.getBrokerParty().setCorpNum(""); |
| 129 | + taxInvoice.getBrokerParty().setTaxRegID(""); |
| 130 | + taxInvoice.getBrokerParty().setCorpName(""); |
| 131 | + taxInvoice.getBrokerParty().setCEOName(""); |
| 132 | + taxInvoice.getBrokerParty().setAddr(""); |
| 133 | + taxInvoice.getBrokerParty().setBizType(""); |
| 134 | + taxInvoice.getBrokerParty().setBizClass(""); |
| 135 | + taxInvoice.getBrokerParty().setContactID(""); |
| 136 | + taxInvoice.getBrokerParty().setContactName(""); |
| 137 | + taxInvoice.getBrokerParty().setTEL(""); |
| 138 | + taxInvoice.getBrokerParty().setHP(""); |
| 139 | + taxInvoice.getBrokerParty().setEmail(""); |
| 140 | + |
| 141 | + // 품목 |
| 142 | + taxInvoice.setTaxInvoiceTradeLineItems(new ArrayOfTaxInvoiceTradeLineItem()); |
| 143 | + |
| 144 | + TaxInvoiceTradeLineItem taxInvoiceTradeLineItem = new TaxInvoiceTradeLineItem(); |
| 145 | + taxInvoiceTradeLineItem.setPurchaseExpiry(""); |
| 146 | + taxInvoiceTradeLineItem.setName(""); |
| 147 | + taxInvoiceTradeLineItem.setInformation(""); |
| 148 | + taxInvoiceTradeLineItem.setChargeableUnit(""); |
| 149 | + taxInvoiceTradeLineItem.setUnitPrice(""); |
| 150 | + taxInvoiceTradeLineItem.setAmount(""); |
| 151 | + taxInvoiceTradeLineItem.setTax(""); |
| 152 | + taxInvoiceTradeLineItem.setDescription(""); |
| 153 | + |
| 154 | + taxInvoice.getTaxInvoiceTradeLineItems().getTaxInvoiceTradeLineItem().add(taxInvoiceTradeLineItem); |
| 155 | + |
| 156 | + } |
| 157 | +} |
0 commit comments