|
|
@@ -6,6 +6,7 @@ import (
|
|
|
"dashoo.cn/backend/api/business/paymentinfo"
|
|
|
"dashoo.cn/backend/api/business/workflow"
|
|
|
. "dashoo.cn/backend/api/controllers"
|
|
|
+ baseparameter "dashoo.cn/business2/parameter"
|
|
|
"dashoo.cn/utils"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
@@ -57,9 +58,12 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
defer session.Close()
|
|
|
err := session.Begin()
|
|
|
|
|
|
+ paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
+ key := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceKey64")
|
|
|
+
|
|
|
// 诺诺网发票接口
|
|
|
invoice := invoiceinfo.GetInvoiceService(utils.DBE)
|
|
|
- url := "https://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action"
|
|
|
+ url := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceUrl")
|
|
|
var entity invoiceinfo.OilInvoiceInfo
|
|
|
where := "Id=" + id
|
|
|
invoice.GetEntity(&entity, where)
|
|
|
@@ -76,31 +80,67 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
paramsString := ""
|
|
|
for _, pay := range paylist {
|
|
|
var amount float64
|
|
|
- pay.OilPaymentInfo.Amount = "500.00"
|
|
|
- amount,_ = strconv.ParseFloat(pay.OilPaymentInfo.Amount, 64)
|
|
|
- tax := fmt.Sprintf("%.2f", amount * 0.06 / 1.06)
|
|
|
- //tax := math.Trunc(amount * 0.06 / 1.06)
|
|
|
+ var rate1 float64
|
|
|
var a float64
|
|
|
- a,_ = strconv.ParseFloat(tax, 64)
|
|
|
+ var tax string
|
|
|
+ yhzcbs := "0"
|
|
|
+ environment := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "isDev")
|
|
|
+ zzstsgl := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceZzstsgl")
|
|
|
+ if environment == "1" {
|
|
|
+ // 测试环境
|
|
|
+ pay.OilPaymentInfo.Amount = "500.00"
|
|
|
+ }
|
|
|
+ amount,_ = strconv.ParseFloat(pay.OilPaymentInfo.Amount, 64)
|
|
|
+ rate := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceRate")
|
|
|
+ //含税
|
|
|
+ israte := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "IsInvoiceRate")
|
|
|
+ if israte == "" {
|
|
|
+ zzstsgl = ""
|
|
|
+ rate1,_ = strconv.ParseFloat(rate, 64)
|
|
|
+ aq := rate1 + 1
|
|
|
+ tax = fmt.Sprintf("%.2f", amount * rate1 / aq)
|
|
|
+ //tax := math.Trunc(amount * 0.06 / 1.06)
|
|
|
+ a,_ = strconv.ParseFloat(tax, 64)
|
|
|
+ } else if israte == "1" {
|
|
|
+ //免税
|
|
|
+ yhzcbs = "1"
|
|
|
+ tax = "0.00"
|
|
|
+ a,_ = strconv.ParseFloat(tax, 64)
|
|
|
+ rate = "0.00"
|
|
|
+ } else if israte == "2" {
|
|
|
+ //不征税
|
|
|
+ yhzcbs = "1"
|
|
|
+ zzstsgl = "不征税"
|
|
|
+ tax = "0.00"
|
|
|
+ a,_ = strconv.ParseFloat(tax, 64)
|
|
|
+ rate = "0.00"
|
|
|
+ } else if israte == "3" {
|
|
|
+ //普通0税率
|
|
|
+ zzstsgl = ""
|
|
|
+ tax = "0.00"
|
|
|
+ a,_ = strconv.ParseFloat(tax, 64)
|
|
|
+ rate = "0.00"
|
|
|
+ }
|
|
|
typeString := ""
|
|
|
if pay.OilPaymentInfo.PayType == "1" {
|
|
|
typeString = "准入交费"
|
|
|
} else if pay.OilPaymentInfo.PayType == "2" {
|
|
|
- typeString = "准入交费"
|
|
|
+ typeString = "年审交费"
|
|
|
} else if pay.OilPaymentInfo.PayType == "3" {
|
|
|
typeString = "增项交费"
|
|
|
} else if pay.OilPaymentInfo.PayType == "7" {
|
|
|
typeString = "信息变更交费"
|
|
|
}
|
|
|
- paramsString += "{'goodsname':'"+pay.SupplierTypeName+" "+typeString+"','num':'','price':'','hsbz':'1','taxrate':'0.06','spec':'','unit':'','spbm':'10101150101','zsbm':'','fphxz':'0','yhzcbs':'0','zzstsgl':'','lslbs':'','kce':'','taxfreeamt':" + fmt.Sprintf("%.2f", amount-a) + ",'tax':" + tax + ",'taxamt':" + strconv.Itoa(int(amount)) + "}"
|
|
|
+ paramsString += "{'goodsname':'" + pay.SupplierTypeName + " " + typeString + "','num':'','price':'','hsbz':'1','taxrate':'" + rate + "','spec':'','unit':'','spbm':'10101150101','zsbm':'','fphxz':'0','yhzcbs':'" + yhzcbs + "','zzstsgl':'" + zzstsgl + "','lslbs':'" + israte + "','kce':'','taxfreeamt':" + fmt.Sprintf("%.2f", amount-a) + ",'tax':" + tax + ",'taxamt':" + strconv.Itoa(int(amount)) + "}"
|
|
|
}
|
|
|
|
|
|
// 身份认证,在诺诺网备案后,由诺诺网提供,每个企业一个
|
|
|
- identity := "2329CC5F90EDAA8208F1F3C72A0CE72A713A9D425CD50CDE"
|
|
|
+ identity := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceIdentity")
|
|
|
//params := "{'identity':'" + identity + "','order':{'buyername':'" + entity.SupplierName + "','taxnum':'" + entity.CommercialNo + "','phone':'18354222656','address':'" + entity.Address + "','account':'" + entity.DepositBank + entity.BankAccount + "','telephone':'" + supplierEntity.Telphone + "','orderno':'123" + entity.BankSerialNum + "','invoicedate':'" + time.Now().Format("2006-01-02 15:04:05") + "','clerk':'曲岩','saleaccount':'中国工商银行股份有限公司天津市滨海支行 0302023009104728134','salephone':'022-25922501','saleaddress':'大港油田二号院','saletaxnum':'911200007182589087','kptype':'1','message':'','payee':'曲岩','checker':'曲岩','tsfs':'1','email':'" + entity.Email + "','qdbz':'0','qdxmmc':'','dkbz':'0','deptid':'','clerkid':'','invoiceLine':'p','cpybz':'','detail':[{'goodsname':'苹果','num':'1','price':'1','hsbz':'1','taxrate':'0.13','spec':'','unit':'吨','spbm':'10101150101','zsbm':'','fphxz':'0','yhzcbs':'0','zzstsgl':'','lslbs':'','kce':''}]}}"
|
|
|
- params := "{'identity':'" + identity + "','order':{'buyername':'" + entity.SupplierName + "','taxnum':'" + entity.CommercialNo + "','phone':'" + supplierEntity.Mobile + "','address':'" + entity.Address + "','account':'" + entity.DepositBank + " " + entity.BankAccount + "','telephone':'" + supplierEntity.Telphone + "','orderno':'dg123" + entity.BankSerialNum + "','invoicedate':'" + time.Now().Format("2006-01-02 15:04:05") + "','clerk':'曲岩','saleaccount':'中国工商银行股份有限公司天津市滨海支行 0302023009104728134','salephone':'022-25922501','saleaddress':'大港油田二号院','saletaxnum':'339901999999142','kptype':'1','message':'','payee':'曲岩','checker':'曲岩','tsfs':'1','email':'" + entity.Email + "','qdbz':'0','qdxmmc':'','dkbz':'0','deptid':'','clerkid':'','invoiceLine':'p','cpybz':'','detail':["+paramsString+"]}}"
|
|
|
+ params := "{'identity':'" + identity + "','order':{'buyername':'" + entity.SupplierName + "','taxnum':'" + entity.CommercialNo + "','phone':'" + supplierEntity.Mobile + "','address':'" + entity.Address + "','account':'" + entity.DepositBank + " " + entity.BankAccount + "','telephone':'" + supplierEntity.Telphone + "','orderno':'dg" + entity.BankSerialNum + "','invoicedate':'" + time.Now().Format("2006-01-02 15:04:05") + "','clerk':'" + paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePeople3") + "','saleaccount':'" + paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceSaleaccount") + "','salephone':'" + paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePhone") + "','saleaddress':'" + paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceAddress") + "','saletaxnum':'" + paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceSaletaxnum") + "','kptype':'1','message':'','payee':'" + paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePeople1") + "','checker':'" + paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePeople2") + "','tsfs':'1','email':'" + entity.Email + "','qdbz':'0','qdxmmc':'','dkbz':'0','deptid':'','clerkid':'','invoiceLine':'p','cpybz':'','detail':["+paramsString+"]}}"
|
|
|
var errinfo ErrorInfo
|
|
|
- invoiceJson := invoice.Post(url, params)
|
|
|
+ invoiceJson := invoice.Post(url, params, key)
|
|
|
+ fmt.Println(invoiceJson, "诺诺接口返回")
|
|
|
if invoiceJson.Status != "0000"{
|
|
|
//session.Rollback()
|
|
|
errinfo.Code = -1
|
|
|
@@ -109,9 +149,9 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
this.ServeJSON()
|
|
|
} else if invoiceJson.Status == "0000" && invoiceJson.Fpqqlsh != "" {
|
|
|
// 根据流水号查询结果
|
|
|
- url := "https://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action"
|
|
|
+ url := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceLiuShuiUrl")
|
|
|
params := "{'identity':'" + identity + "','fpqqlsh':['" + invoiceJson.Fpqqlsh + "']}"
|
|
|
- invoiceJson1 := invoice.SerialNumberPost(url, params)
|
|
|
+ invoiceJson1 := invoice.SerialNumberPost(url, params, key)
|
|
|
if invoiceJson1.Result != "success"{
|
|
|
//session.Rollback()
|
|
|
errinfo.Code = -1
|
|
|
@@ -170,7 +210,7 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
ActiComplete.Result = "1"
|
|
|
|
|
|
receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
- fmt.Println(receiveVal)
|
|
|
+ fmt.Println("receiveVal:" + receiveVal)
|
|
|
if receiveVal == "true" {
|
|
|
session.Commit()
|
|
|
errinfo.Code = 0
|