팝빌 api 모듈 연동 추가

This commit is contained in:
lch 2021-04-22 09:28:05 +00:00
parent 1704c8219f
commit 02f854807b
10 changed files with 695 additions and 415 deletions

View File

@ -2,12 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;
using System.Web.Mvc;
using NP.Model;
using System.Net.Http;
using NP.Base.Popbill;
namespace NP.BO.Controllers
{
public class croomController : BOBaseController
@ -770,6 +768,7 @@ namespace NP.BO.Controllers
}
vm.PayTaxes = Dao.Get<PayTax>("cr.paytaxes", ht);
vm.pagetotalcount = GetCount(vm.PayTaxes.FirstOrDefault());
return View(vm);
}
public ActionResult taxdetail(VMCRoom vm)
@ -793,6 +792,18 @@ namespace NP.BO.Controllers
else
vm.PayTaxItem = Dao.Get<PayItem>("cr.paytaxitem2", new System.Collections.Hashtable() { { "taxno", vm.longval } });
#region Popbill
var mgtKey = vm.PayTaxes.First()?.mgtKey;
if (!string.IsNullOrEmpty(mgtKey))
{
ViewBag.Taxinvoice = PopbillService.GetTaxinvoice(mgtKey);
}
else
{
ViewBag.Taxinvoice = PopbillService.GetTaxinvoiceR();
}
#endregion
return View(vm);
}
public ActionResult taxsmart(VMCRoom vm)

View File

@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using NP.Base.Popbill;
using Spring.Web.Mvc;
namespace BO
@ -18,7 +14,7 @@ namespace BO
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
PopbillConfig.StartTaxinvoiceService();
}
}
}

View File

@ -5,7 +5,7 @@
<div>
<ul class="pagination pagination-md" style="margin: 0;">
<li class="active"><a href="#" data-toggle="tab">요청현황</a></li>
<li><a href="#" onclick="gotab();" data-toggle="tab">스마트빌</a></li>
@*<li><a href="#" onclick="gotab();" data-toggle="tab">스마트빌</a></li>*@
</ul>
</div>
<section class="panel panel-default">
@ -100,6 +100,44 @@
</tbody></table>
</section>
<form id="sform" method="post">
<section class="panel panel-default">
<header class="panel-heading"><strong><i class="fa fa-bars"></i> 공급업체정보<span class=""></span></strong></header>
<table class="regtable" style="margin-top: 0;">
<colgroup><col width="200"><col width="400" /><col width="200" /><col /></colgroup>
<tbody>
<tr>
<th>회사명</th>
<td><input type="text" class="form-control dev" name="asname" value="@ViewBag.Taxinvoice.invoicerCorpName" /></td>
<th>대표자</th>
<td><input type="text" class="form-control dev" name="ceoname" value="@ViewBag.Taxinvoice.invoicerCEOName" /></td>
</tr>
<tr>
<th>사업자등록번호</th>
<td><input type="text" class="form-control dev" name="brno" value="@ViewBag.Taxinvoice.invoicerCorpNum" /></td>
<th>업태</th>
<td><input type="text" class="form-control dev" name="btype" value="@ViewBag.Taxinvoice.invoicerBizType" /></td>
</tr>
<tr>
<th>종목</th>
<td><input type="text" class="form-control dev" name="bkind" value="@ViewBag.Taxinvoice.invoicerBizClass" /></td>
<th>사업장주소</th>
<td><input type="text" class="form-control dev" name="asaddr" value="@ViewBag.Taxinvoice.invoicerAddr" /></td>
</tr>
<tr>
<th>담당자</th>
<td><input type="text" class="form-control dev" name="manname" value="@ViewBag.Taxinvoice.invoicerContactName" /></td>
<th>연락처</th>
<td><input type="text" class="form-control dev" name="telno" value="@ViewBag.Taxinvoice.invoicerTEL" /></td>
</tr>
<tr>
<th>이메일주소</th>
<td><input type="text" class="form-control dev" name="email" value="@ViewBag.Taxinvoice.invoicerEmail" /></td>
<th>문서번호</th>
<td><input type="text" class="form-control dev" name="email" value="@ViewBag.Taxinvoice.invoicerMgtKey" placeholder="결제일-결제번호?" /></td>
</tr>
</tbody>
</table>
</section>
<section class="panel panel-default">
<header class="panel-heading"><strong><i class="fa fa-bars"></i> 발행업체정보<span class=""></span></strong></header>
<table class="regtable" style="margin-top: 0;">

View File

@ -78,6 +78,24 @@
<add key="mastersms" value="10d3158b52019fa6b7e5563b1e35cf8c48a8caf9" />
<add key="mtssendnum" value="15447660" />
<add key="mtsdb" value="Server=218.232.111.111;Database=mtsyicte;User ID=mtsyicteremote;Password=dev1@#" />
<!--팝빌 API 연동정보-->
<!--팝빌회원 링크아이디(LinkID)-->
<add key="Popbill.LinkID" value="YJCTE" />
<!--팝빌회원 비밀키(SecretKey)-->
<add key="Popbill.SecretKey" value="nC+bFG/XTCAQ3XtsRVdPWx70wJwq8XTE5vGeW2/uxyg=" />
<!--팝빌회원 사업자번호, '-' 제외 10자리-->
<add key="Popbill.CorpNum" value="6218204003" />
<!--팝빌회원 아이디(비필수)-->
<add key="Popbill.UserID" value="" />
<!--연동환경 설정값, 개발용(true), 상업용(false)-->
<add key="Popbill.TaxinvoiceService.IsTest" value="true" />
<!--인증토큰 IP 제한기능 사용여부, 권장(true)-->
<add key="Popbill.TaxinvoiceService.IPRestrictOnOff" value="true" />
<!--팝빌 API 서비스 고정 IP 사용여부(GA), true-사용, false-미사용, 기본값(false)-->
<add key="Popbill.TaxinvoiceService.UseStaticIP" value="false" />
<!--로컬서버 시간 사용 여부 true-사용, false-미사용, 기본값(false)-->
<add key="Popbill.TaxinvoiceService.UseLocalTimeYN" value="false" />
</appSettings>
<common>
<logging>
@ -233,7 +251,7 @@
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<!-- <system.codedom>
<!-- <system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />

View File

@ -60,6 +60,9 @@
<Reference Include="INIpayNet">
<HintPath>..\References\inipay\INIpayNet.dll</HintPath>
</Reference>
<Reference Include="Linkhub">
<HintPath>..\References\Popbill\Linkhub.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\log4net.dll</HintPath>
@ -79,6 +82,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\NPDao.dll</HintPath>
</Reference>
<Reference Include="Popbill">
<HintPath>..\References\Popbill\Popbill.dll</HintPath>
</Reference>
<Reference Include="QRCoder, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\QRCoder.dll</HintPath>
@ -156,6 +162,8 @@
<Compile Include="Lib\KISA256.cs" />
<Compile Include="Lib\Logger.cs" />
<Compile Include="Lib\Logging.cs" />
<Compile Include="Popbill\PopbillConfig.cs" />
<Compile Include="Popbill\PopbillService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Lib\Helpers.cs" />
</ItemGroup>
@ -173,5 +181,8 @@
<Name>Model</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,82 @@
using Popbill;
using Popbill.Taxinvoice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Configuration;
namespace NP.Base.Popbill
{
public class PopbillConfig
{
/// <summary>
/// 링크아이디
/// </summary>
private static string _linkID;
/// <summary>
/// 비밀키
/// </summary>
private static string _secretKey;
/// <summary>
/// 사업자번호
/// </summary>
private static string _corpNum;
/// <summary>
/// 회원아이디
/// </summary>
private static string _userID;
/// <summary>
/// 링크아이디
/// </summary>
public static string LinkID => _linkID;
/// <summary>
/// 사업자번호
/// </summary>
public static string CorpNum => _corpNum;
/// <summary>
/// 회원아이디(비필수)
/// </summary>
public static string UserID => _userID;
/// <summary>
/// 세금계산서 서비스 객체 선언
/// </summary>
public static TaxinvoiceService taxinvoiceService;
/// <summary>
/// 서비스시작
/// </summary>
public static void StartTaxinvoiceService()
{
try
{
_linkID = WebConfigurationManager.AppSettings["Popbill.LinkID"];
_secretKey = WebConfigurationManager.AppSettings["Popbill.SecretKey"];
_corpNum = WebConfigurationManager.AppSettings["Popbill.CorpNum"];
_userID = WebConfigurationManager.AppSettings["Popbill.UserID"];
// 세금계산서 서비스 객체 초기화
taxinvoiceService = new TaxinvoiceService(_linkID, _secretKey);
// 연동환경 설정값, 개발용(true), 상업용(false)
taxinvoiceService.IsTest = bool.Parse(WebConfigurationManager.AppSettings["Popbill.TaxinvoiceService.IsTest"]);
// 인증토큰 IP 제한기능 사용여부, 권장(true)
taxinvoiceService.IPRestrictOnOff = bool.Parse(WebConfigurationManager.AppSettings["Popbill.TaxinvoiceService.IPRestrictOnOff"]);
// 팝빌 API 서비스 고정 IP 사용여부(GA), true-사용, false-미사용, 기본값(false)
taxinvoiceService.UseStaticIP = bool.Parse(WebConfigurationManager.AppSettings["Popbill.TaxinvoiceService.UseStaticIP"]);
// 로컬서버 시간 사용 여부 true-사용, false-미사용, 기본값(false)
taxinvoiceService.UseLocalTimeYN = bool.Parse(WebConfigurationManager.AppSettings["Popbill.TaxinvoiceService.UseLocalTimeYN"]);
}
catch (PopbillException ex)
{
Logger.TryError(ex.Message, ex);
}
}
}
}

View File

@ -0,0 +1,106 @@
using NP.Base;
using Popbill;
using Popbill.Taxinvoice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Configuration;
namespace NP.Base.Popbill
{
public class PopbillService
{
/// <summary>
/// 세금계산서 문서번호{mgtKey} 생성
/// </summary>
/// <returns></returns>
public static string MakeMgtKey()
{
string mgtKey = string.Empty;
try
{
string date = DateTime.Now.ToString("yyyy-MM-dd");
string no = 1.ToString("D5");//수정->발행문서 검색 후 순번 + 1 하는 거로 변경
mgtKey = $"{date}-L{no}";
}
catch (PopbillException ex)
{
Logger.TryError(ex.Message, ex);
}
return mgtKey;
}
/// <summary>
/// 세금계산서 상세정보
/// </summary>
/// <param name="mgtKey"></param>
/// <returns></returns>
public static Taxinvoice GetTaxinvoice(string mgtKey)
{
Taxinvoice taxinvoice = null;
try
{
taxinvoice = PopbillConfig.taxinvoiceService.GetDetailInfo(PopbillConfig.CorpNum, MgtKeyType.SELL, mgtKey);
}
catch (PopbillException ex)
{
Logger.TryError(ex.Message, ex);
}
return taxinvoice;
}
/// <summary>
/// 세금계산서 공급자정보
/// </summary>
/// <returns></returns>
public static Taxinvoice GetTaxinvoiceR()
{
Taxinvoice Taxinvoice = null;
try
{
CorpInfo corpInfo = PopbillConfig.taxinvoiceService.GetCorpInfo(PopbillConfig.CorpNum, PopbillConfig.UserID);
Contact contact = PopbillConfig.taxinvoiceService.ListContact(PopbillConfig.CorpNum, PopbillConfig.UserID).Where(w => w.mgrYN == true).FirstOrDefault();
Taxinvoice = new Taxinvoice
{
invoicerAddr = corpInfo?.addr,
invoicerCEOName = corpInfo?.ceoname,
invoicerCorpName = corpInfo?.corpName,
invoicerMgtKey = MakeMgtKey(),
invoicerCorpNum = PopbillConfig.CorpNum,
invoicerBizClass = corpInfo?.bizClass,
invoicerBizType = corpInfo?.bizType,
invoicerContactName = contact?.personName,
invoicerEmail = contact?.email,
invoicerHP = contact?.hp,
invoicerTEL = contact?.tel
};
}
catch (PopbillException ex)
{
Logger.TryError(ex.Message, ex);
}
return Taxinvoice;
}
/// <summary>
/// 세금계산서 즉시 발행
/// </summary>
/// <param name="taxinvoice"></param>
/// <param name="forceIssue"></param>
/// <param name="memo"></param>
/// <returns></returns>
public static IssueResponse RegistIssue(Taxinvoice taxinvoice, bool forceIssue, string memo)
{
IssueResponse IssueResponse = null;
try
{
PopbillConfig.taxinvoiceService.RegistIssue(PopbillConfig.CorpNum, taxinvoice, forceIssue, memo);
}
catch (PopbillException ex)
{
Logger.TryError(ex.Message, ex);
}
return IssueResponse;
}
}
}

View File

@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Mvc;
using System.Web.Routing;
using NP.Base.Popbill;
using Spring.Web.Mvc;
namespace FO
@ -19,6 +14,7 @@ namespace FO
RouteConfig.RegisterRoutes(RouteTable.Routes);
//BundleConfig.RegisterBundles(BundleTable.Bundles);
MvcHandler.DisableMvcResponseHeader = true;
PopbillConfig.StartTaxinvoiceService();
}
}
}

View File

@ -81,6 +81,24 @@
<add key="mtssendnum" value="15447660" />
<add key="mtsdb" value="Server=218.232.111.111;Database=mtsyicte;User ID=mtsyicteremote;Password=dev1@#" />
<!--MTS SMSMMS 발신번호, 알림톡발신키-->
<!--팝빌 API 연동정보-->
<!--팝빌회원 링크아이디(LinkID)-->
<add key="Popbill.LinkID" value="YJCTE" />
<!--팝빌회원 비밀키(SecretKey)-->
<add key="Popbill.SecretKey" value="nC+bFG/XTCAQ3XtsRVdPWx70wJwq8XTE5vGeW2/uxyg=" />
<!--팝빌회원 사업자번호, '-' 제외 10자리-->
<add key="Popbill.CorpNum" value="6218204003" />
<!--팝빌회원 아이디(비필수)-->
<add key="Popbill.UserID" value="" />
<!--연동환경 설정값, 개발용(true), 상업용(false)-->
<add key="Popbill.TaxinvoiceService.IsTest" value="true" />
<!--인증토큰 IP 제한기능 사용여부, 권장(true)-->
<add key="Popbill.TaxinvoiceService.IPRestrictOnOff" value="true" />
<!--팝빌 API 서비스 고정 IP 사용여부(GA), true-사용, false-미사용, 기본값(false)-->
<add key="Popbill.TaxinvoiceService.UseStaticIP" value="false" />
<!--로컬서버 시간 사용 여부 true-사용, false-미사용, 기본값(false)-->
<add key="Popbill.TaxinvoiceService.UseLocalTimeYN" value="false" />
</appSettings>
<!-- to see logging output in the attached debugger -->
<common>
@ -279,7 +297,7 @@
</staticContent>-->
</system.webServer>
<!-- <system.codedom>
<!-- <system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />

View File

@ -915,6 +915,10 @@ namespace NP.Model
public String username { get; set; }
public String userid { get; set; }
public int? iscancel { get; set; }
/// <summary>
/// 세금계산서 문서번호
/// </summary>
public String mgtKey { get; set; }
}
[Serializable]
public class PayRfd : BaseModel