|
@@ -8,6 +8,7 @@ import (
|
|
|
. "dashoo.cn/backend/api/controllers"
|
|
. "dashoo.cn/backend/api/controllers"
|
|
|
baseparameter "dashoo.cn/business2/parameter"
|
|
baseparameter "dashoo.cn/business2/parameter"
|
|
|
"dashoo.cn/utils"
|
|
"dashoo.cn/utils"
|
|
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
"time"
|
|
"time"
|
|
@@ -17,6 +18,66 @@ type OilInvoiceController struct {
|
|
|
BaseController
|
|
BaseController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+type InvoiceJson struct {
|
|
|
|
|
+ Identity string `json:"identity"`
|
|
|
|
|
+ Order InvoiceOrderJson `json:"order"`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+type SelectInvoiceJson struct {
|
|
|
|
|
+ Identity string `json:"identity"`
|
|
|
|
|
+ Fpqqlsh string `json:"fpqqlsh"`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+type InvoiceOrderJson struct {
|
|
|
|
|
+ Buyername string `json:"buyername"`
|
|
|
|
|
+ Phone string `json:"phone"`
|
|
|
|
|
+ Taxnum string `json:"taxnum"`
|
|
|
|
|
+ Address string `json:"address"`
|
|
|
|
|
+ Account string `json:"account"`
|
|
|
|
|
+ Telephone string `json:"telephone"`
|
|
|
|
|
+ Orderno string `json:"orderno"`
|
|
|
|
|
+ Invoicedate string `json:"invoicedate"`
|
|
|
|
|
+ Clerk string `json:"clerk"`
|
|
|
|
|
+ Saleaccount string `json:"saleaccount"`
|
|
|
|
|
+ Salephone string `json:"salephone"`
|
|
|
|
|
+ Saleaddress string `json:"saleaddress"`
|
|
|
|
|
+ Saletaxnum string `json:"saletaxnum"`
|
|
|
|
|
+ Kptype string `json:"kptype"`
|
|
|
|
|
+ Message string `json:"message"`
|
|
|
|
|
+ Payee string `json:"payee"`
|
|
|
|
|
+ Checker string `json:"checker"`
|
|
|
|
|
+ Tsfs string `json:"tsfs"`
|
|
|
|
|
+ Email string `json:"email"`
|
|
|
|
|
+ Qdbz string `json:"qdbz"`
|
|
|
|
|
+ Qdxmmc string `json:"qdxmmc"`
|
|
|
|
|
+ Dkbz string `json:"dkbz"`
|
|
|
|
|
+ Deptid string `json:"deptid"`
|
|
|
|
|
+ Clerkid string `json:"clerkid"`
|
|
|
|
|
+ InvoiceLine string `json:"invoiceLine"`
|
|
|
|
|
+ Cpybz string `json:"cpybz"`
|
|
|
|
|
+ Detail []InvoiceDetailJson `json:"detail"`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+type InvoiceDetailJson struct {
|
|
|
|
|
+ Goodsname string `json:"goodsname"`
|
|
|
|
|
+ Num string `json:"num"`
|
|
|
|
|
+ Price string `json:"price"`
|
|
|
|
|
+ Hsbz string `json:"hsbz"`
|
|
|
|
|
+ Taxrate string `json:"taxrate"`
|
|
|
|
|
+ Spec string `json:"spec"`
|
|
|
|
|
+ Unit string `json:"unit"`
|
|
|
|
|
+ Spbm string `json:"spbm"`
|
|
|
|
|
+ Zsbm string `json:"zsbm"`
|
|
|
|
|
+ Fphxz string `json:"fphxz"`
|
|
|
|
|
+ Yhzcbs string `json:"yhzcbs"`
|
|
|
|
|
+ Zzstsgl string `json:"zzstsgl"`
|
|
|
|
|
+ Lslbs string `json:"lslbs"`
|
|
|
|
|
+ Kce string `json:"kce"`
|
|
|
|
|
+ Taxfreeamt string `json:"taxfreeamt"`
|
|
|
|
|
+ Tax string `json:"tax"`
|
|
|
|
|
+ Taxamt string `json:"taxamt"`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// @Title 获取信息
|
|
// @Title 获取信息
|
|
|
// @Description get user by token
|
|
// @Description get user by token
|
|
|
// @Success 200 {object} map[string]interface{}
|
|
// @Success 200 {object} map[string]interface{}
|
|
@@ -57,7 +118,6 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
session := utils.DBE.NewSession()
|
|
session := utils.DBE.NewSession()
|
|
|
defer session.Close()
|
|
defer session.Close()
|
|
|
err := session.Begin()
|
|
err := session.Begin()
|
|
|
-
|
|
|
|
|
paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
key := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceKey64")
|
|
key := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceKey64")
|
|
|
|
|
|
|
@@ -77,8 +137,10 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
svcp := paymentinfo.GetPaymentService(utils.DBE)
|
|
svcp := paymentinfo.GetPaymentService(utils.DBE)
|
|
|
where = "p.Id in (" + entity.SrcIds + ")"
|
|
where = "p.Id in (" + entity.SrcIds + ")"
|
|
|
svcp.GetPaymentinfoList1(where, &paylist)
|
|
svcp.GetPaymentinfoList1(where, &paylist)
|
|
|
- paramsString := ""
|
|
|
|
|
|
|
+ //paramsString := ""
|
|
|
|
|
+ var paramsDetail []InvoiceDetailJson
|
|
|
for _, pay := range paylist {
|
|
for _, pay := range paylist {
|
|
|
|
|
+ var detail InvoiceDetailJson
|
|
|
var amount float64
|
|
var amount float64
|
|
|
var rate1 float64
|
|
var rate1 float64
|
|
|
var a float64
|
|
var a float64
|
|
@@ -94,6 +156,9 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
rate := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceRate")
|
|
rate := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceRate")
|
|
|
//含税
|
|
//含税
|
|
|
israte := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "IsInvoiceRate")
|
|
israte := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "IsInvoiceRate")
|
|
|
|
|
+ //"yhzcbs":"1","zzstsgl":"免税","lslbs":"1" ----免税
|
|
|
|
|
+ //"yhzcbs":1,"zzstsgl":"不征税", "lslbs":2 ----不征税
|
|
|
|
|
+ //"yhzcbs":"0","zzstsgl":"","lslbs":3 -------零税率
|
|
|
if israte == "" {
|
|
if israte == "" {
|
|
|
zzstsgl = ""
|
|
zzstsgl = ""
|
|
|
rate1,_ = strconv.ParseFloat(rate, 64)
|
|
rate1,_ = strconv.ParseFloat(rate, 64)
|
|
@@ -106,6 +171,7 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
yhzcbs = "1"
|
|
yhzcbs = "1"
|
|
|
tax = "0.00"
|
|
tax = "0.00"
|
|
|
a,_ = strconv.ParseFloat(tax, 64)
|
|
a,_ = strconv.ParseFloat(tax, 64)
|
|
|
|
|
+ zzstsgl = "免税"
|
|
|
rate = "0.00"
|
|
rate = "0.00"
|
|
|
} else if israte == "2" {
|
|
} else if israte == "2" {
|
|
|
//不征税
|
|
//不征税
|
|
@@ -131,15 +197,66 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
} else if pay.OilPaymentInfo.PayType == "7" {
|
|
} else if pay.OilPaymentInfo.PayType == "7" {
|
|
|
typeString = "信息变更交费"
|
|
typeString = "信息变更交费"
|
|
|
}
|
|
}
|
|
|
- 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)) + "}"
|
|
|
|
|
|
|
+ //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)) + "}"
|
|
|
|
|
+ detail.Goodsname = pay.SupplierTypeName + " " + typeString
|
|
|
|
|
+ detail.Hsbz = "1"
|
|
|
|
|
+ detail.Taxrate = rate
|
|
|
|
|
+ detail.Fphxz = "0"
|
|
|
|
|
+ detail.Yhzcbs = yhzcbs
|
|
|
|
|
+ detail.Zzstsgl = zzstsgl
|
|
|
|
|
+ detail.Lslbs = israte
|
|
|
|
|
+ detail.Tax = tax
|
|
|
|
|
+ detail.Taxamt = strconv.Itoa(int(amount))
|
|
|
|
|
+ detail.Taxfreeamt = fmt.Sprintf("%.2f", amount-a)
|
|
|
|
|
+ paramsDetail = append(paramsDetail, detail)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 身份认证,在诺诺网备案后,由诺诺网提供,每个企业一个
|
|
// 身份认证,在诺诺网备案后,由诺诺网提供,每个企业一个
|
|
|
identity := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceIdentity")
|
|
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':'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 params InvoiceJson
|
|
|
|
|
+ var paramsOrder InvoiceOrderJson
|
|
|
|
|
+ params.Identity = identity
|
|
|
|
|
+ paramsOrder.Detail = paramsDetail
|
|
|
|
|
+ paramsOrder.Buyername = entity.SupplierName
|
|
|
|
|
+ paramsOrder.Taxnum = entity.CommercialNo
|
|
|
|
|
+ paramsOrder.Phone = supplierEntity.Mobile
|
|
|
|
|
+ paramsOrder.Address = entity.Address
|
|
|
|
|
+ paramsOrder.Account = entity.DepositBank + " " + entity.BankAccount
|
|
|
|
|
+ paramsOrder.Telephone = supplierEntity.Telphone
|
|
|
|
|
+ paramsOrder.Orderno = "dg21" + entity.BankSerialNum
|
|
|
|
|
+ paramsOrder.Invoicedate = time.Now().Format("2006-01-02 15:04:05")
|
|
|
|
|
+ paramsOrder.Clerk = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePeople3")
|
|
|
|
|
+ paramsOrder.Saleaccount = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceSaleaccount")
|
|
|
|
|
+ paramsOrder.Salephone = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePhone")
|
|
|
|
|
+ paramsOrder.Saleaddress = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceAddress")
|
|
|
|
|
+ paramsOrder.Saletaxnum = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceSaletaxnum")
|
|
|
|
|
+ paramsOrder.Kptype = "1"
|
|
|
|
|
+ paramsOrder.Payee = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePeople1")
|
|
|
|
|
+ paramsOrder.Checker = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoicePeople2")
|
|
|
|
|
+ paramsOrder.Tsfs = "2" //-1,不推送;0,邮箱;1,手机(默认);2,邮箱、手机
|
|
|
|
|
+ paramsOrder.Email = entity.Email
|
|
|
|
|
+ paramsOrder.Qdbz = "0"
|
|
|
|
|
+ paramsOrder.Dkbz = "0"
|
|
|
|
|
+ paramsOrder.InvoiceLine = "p"
|
|
|
|
|
+ params.Order = paramsOrder
|
|
|
var errinfo ErrorInfo
|
|
var errinfo ErrorInfo
|
|
|
- invoiceJson := invoice.Post(url, params, key)
|
|
|
|
|
|
|
+ paramsStr, err := json.Marshal(params)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ errinfo.Code = -1
|
|
|
|
|
+ errinfo.Message = "转json失败!"
|
|
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
|
|
+ this.ServeJSON()
|
|
|
|
|
+ }
|
|
|
|
|
+ //param1 := "{'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':'" + 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+"]}}"
|
|
|
|
|
+
|
|
|
|
|
+ fmt.Println(string(paramsStr), "参数")
|
|
|
|
|
+ invoiceJson := invoice.Post(url, string(paramsStr), key)
|
|
|
fmt.Println(invoiceJson, "诺诺接口返回")
|
|
fmt.Println(invoiceJson, "诺诺接口返回")
|
|
|
if invoiceJson.Status != "0000"{
|
|
if invoiceJson.Status != "0000"{
|
|
|
//session.Rollback()
|
|
//session.Rollback()
|
|
@@ -148,14 +265,24 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
} else if invoiceJson.Status == "0000" && invoiceJson.Fpqqlsh != "" {
|
|
} else if invoiceJson.Status == "0000" && invoiceJson.Fpqqlsh != "" {
|
|
|
|
|
+ time.Sleep(time.Second * 5)
|
|
|
|
|
+ var sel SelectInvoiceJson
|
|
|
|
|
+ key := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceKey64")
|
|
|
|
|
+ sel.Identity = paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceIdentity")
|
|
|
|
|
+ sel.Fpqqlsh = invoiceJson.Fpqqlsh
|
|
|
|
|
+ selS, err := json.Marshal(sel)
|
|
|
|
|
+ invoice := invoiceinfo.GetInvoiceService(utils.DBE)
|
|
|
|
|
+ url1 := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceLiuShuiUrl")
|
|
|
|
|
+ //params := "{'identity':'" + identity + "','fpqqlsh':['" + invoiceJson.Fpqqlsh + "']}"
|
|
|
|
|
+ invoiceJson1 := invoice.SerialNumberPost(url1, string(selS), key)
|
|
|
|
|
+ fmt.Print(invoiceJson1)
|
|
|
// 根据流水号查询结果
|
|
// 根据流水号查询结果
|
|
|
- url := paramSvc.GetBaseparameterMessage("INVOICE", "paramset", "InvoiceLiuShuiUrl")
|
|
|
|
|
- params := "{'identity':'" + identity + "','fpqqlsh':['" + invoiceJson.Fpqqlsh + "']}"
|
|
|
|
|
- invoiceJson1 := invoice.SerialNumberPost(url, params, key)
|
|
|
|
|
|
|
+ //params := "{'identity':'" + identity + "','fpqqlsh':['" + invoiceJson.Fpqqlsh + "']}"
|
|
|
|
|
+ //invoiceJson1 := invoice.SerialNumberPost(url, params, key)
|
|
|
if invoiceJson1.Result != "success"{
|
|
if invoiceJson1.Result != "success"{
|
|
|
//session.Rollback()
|
|
//session.Rollback()
|
|
|
errinfo.Code = -1
|
|
errinfo.Code = -1
|
|
|
- errinfo.Message = "操作失败!" + invoiceJson1.ErrorMsg
|
|
|
|
|
|
|
+ errinfo.Message = "开票查询失败!" + invoiceJson1.ErrorMsg
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
} else if invoiceJson1.Result == "success" && len(invoiceJson1.InvoiceList) > 0{
|
|
} else if invoiceJson1.Result == "success" && len(invoiceJson1.InvoiceList) > 0{
|