|
|
@@ -3,8 +3,11 @@ package oilsupplier
|
|
|
import (
|
|
|
"dashoo.cn/backend/api/business/invoiceinfo"
|
|
|
"dashoo.cn/backend/api/business/paymentinfo"
|
|
|
+ "dashoo.cn/backend/api/business/workflow"
|
|
|
. "dashoo.cn/backend/api/controllers"
|
|
|
"dashoo.cn/utils"
|
|
|
+ "fmt"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type OilInvoiceController struct {
|
|
|
@@ -46,17 +49,19 @@ func (this *OilInvoiceController) GetInvoiceData() {
|
|
|
// @router /updateisinvoice [get]
|
|
|
func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
|
|
|
- //id := this.GetString("Id")
|
|
|
- //srcIds := this.GetString("SrcIds")
|
|
|
- //session := utils.DBE.NewSession()
|
|
|
- //defer session.Close()
|
|
|
- //err := session.Begin()
|
|
|
+ id := this.GetString("Id")
|
|
|
+ srcIds := this.GetString("SrcIds")
|
|
|
+ session := utils.DBE.NewSession()
|
|
|
+ defer session.Close()
|
|
|
+ err := session.Begin()
|
|
|
|
|
|
// 诺诺网发票接口
|
|
|
invoice := invoiceinfo.GetInvoiceService(utils.DBE)
|
|
|
url := "https://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action"
|
|
|
+
|
|
|
+ // 身份认证,在诺诺网备案后,由诺诺网提供,每个企业一个
|
|
|
identity := "2329CC5F90EDAA8208F1F3C72A0CE72A713A9D425CD50CDE"
|
|
|
- params := "{\"identity\":\"2329CC5F90EDAA8208F1F3C72A0CE72A713A9D425CD50CDE\",\"order\":{\"buyername\":\"浙江爱信诺\",\"taxnum\":\"124511234993295177\",\"phone\":\"0\",\"address\":\"浙江省杭州市万塘路\",\"account\":\"\",\"telephone\":\"0\",\"orderno\":\"nuonuo12345\",\"invoicedate\":\"2018-10-31 19:16:51\",\"clerk\":\"黄芝\",\"saleaccount\":\"宇宙行442612010103507108\",\"salephone\":\"0774-7893911\",\"saleaddress\":\"富川瑶族自治县新永路138号\",\"saletaxnum\":\"339901999999142\",\"kptype\":\"1\",\"message\":\"\",\"payee\":\"林莉苏\",\"checker\":\"林莉苏\",\"tsfs\":\"-1\",\"email\":\"502192347@qq.com\",\"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':'浙江爱信1诺','taxnum':'124511234993295177','phone':'0','address':'浙江省杭州市万塘路','account':'','telephone':'0','orderno':'nuonuo367889','invoicedate':'2018-10-31 19:16:51','clerk':'黄芝','saleaccount':'宇宙行442612010103507108','salephone':'0774-7893911','saleaddress':'富川瑶族自治县新永路138号','saletaxnum':'339901999999142','kptype':'1','message':'','payee':'林莉苏','checker':'林莉苏','tsfs':'-1','email':'502192347@qq.com','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':''}]}}"
|
|
|
var errinfo ErrorInfo
|
|
|
invoiceJson := invoice.Post(url, params)
|
|
|
if invoiceJson.Status != "0000"{
|
|
|
@@ -68,7 +73,7 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
} else if invoiceJson.Status == "0000" && invoiceJson.Fpqqlsh != "" {
|
|
|
// 根据流水号查询结果
|
|
|
url := "https://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action"
|
|
|
- params := "{'identity':'" + identity + "','fpqqlsh':['20170104160449979446']}"
|
|
|
+ params := "{'identity':'" + identity + "','fpqqlsh':['" + invoiceJson.Fpqqlsh + "']}"
|
|
|
invoiceJson1 := invoice.SerialNumberPost(url, params)
|
|
|
if invoiceJson1.Result != "success"{
|
|
|
//session.Rollback()
|
|
|
@@ -76,69 +81,67 @@ func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
errinfo.Message = "操作失败!" + invoiceJson1.ErrorMsg
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
- } else if invoiceJson1.Result == "success" && invoiceJson1.List != "" {
|
|
|
- return ""
|
|
|
+ } else if invoiceJson1.Result == "success" && len(invoiceJson1.InvoiceList) > 0{
|
|
|
+ results := invoiceJson1.InvoiceList[0]
|
|
|
+ cols := []string{"IsInvoice", "InvoiceOn", "Url"}
|
|
|
+ svc := invoiceinfo.GetOilInvoiceInfoSession(session)
|
|
|
+ var info invoiceinfo.OilInvoiceInfo
|
|
|
+ info.IsInvoice = "1"
|
|
|
+ info.InvoiceOn = time.Now()
|
|
|
+ info.Url = results.Url
|
|
|
+ _, err = svc.UpdateEntityByIdCols(id, &info, cols)
|
|
|
+
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ session.Rollback()
|
|
|
+ errinfo.Code = -1
|
|
|
+ errinfo.Message = "操作失败!"
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+
|
|
|
+ var payinfo paymentinfo.OilPaymentInfo
|
|
|
+ payinfo.IsInvoice = "1"
|
|
|
+ paycols := []string{"IsInvoice"}
|
|
|
+ where := "Id in (" + srcIds + ")"
|
|
|
+ err = svc.UpdateEntityBywheretbl(OilPaymentInfoName, &payinfo, paycols, where)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ session.Rollback()
|
|
|
+ errinfo.Code = -1
|
|
|
+ errinfo.Message = "操作失败!"
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+
|
|
|
+ svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
+ var ActiComplete workflow.ActiCompleteVM
|
|
|
+ ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_VERIFY
|
|
|
+ ActiComplete.BusinessKey = id
|
|
|
+ ActiComplete.UserId = this.User.Id
|
|
|
+ ActiComplete.Remarks = ""
|
|
|
+ ActiComplete.Result = "1"
|
|
|
+
|
|
|
+ receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
+ fmt.Println(receiveVal)
|
|
|
+ if receiveVal == "true" {
|
|
|
+ session.Commit()
|
|
|
+ errinfo.Code = 0
|
|
|
+ errinfo.Message = "操作成功!"
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ session.Rollback()
|
|
|
+ errinfo.Code = -1
|
|
|
+ errinfo.Message = "操作失败!"
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return invoiceJson.Status
|
|
|
-
|
|
|
-
|
|
|
- //cols := []string{"IsInvoice", "InvoiceOn"}
|
|
|
- //svc := invoiceinfo.GetOilInvoiceInfoSession(session)
|
|
|
- //var info invoiceinfo.OilInvoiceInfo
|
|
|
- //info.IsInvoice = "1"
|
|
|
- //info.InvoiceOn = time.Now()
|
|
|
- //_, err = svc.UpdateEntityByIdCols(id, &info, cols)
|
|
|
- //
|
|
|
-
|
|
|
- //if err != nil {
|
|
|
- // session.Rollback()
|
|
|
- // errinfo.Code = -1
|
|
|
- // errinfo.Message = "操作失败!"
|
|
|
- // this.Data["json"] = &errinfo
|
|
|
- // this.ServeJSON()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //var payinfo paymentinfo.OilPaymentInfo
|
|
|
- //payinfo.IsInvoice = "1"
|
|
|
- //paycols := []string{"IsInvoice"}
|
|
|
- //where := "Id in (" + srcIds + ")"
|
|
|
- //err = svc.UpdateEntityBywheretbl(OilPaymentInfoName, &payinfo, paycols, where)
|
|
|
- //
|
|
|
- //if err != nil {
|
|
|
- // session.Rollback()
|
|
|
- // errinfo.Code = -1
|
|
|
- // errinfo.Message = "操作失败!"
|
|
|
- // this.Data["json"] = &errinfo
|
|
|
- // this.ServeJSON()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
- //var ActiComplete workflow.ActiCompleteVM
|
|
|
- //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_VERIFY
|
|
|
- //ActiComplete.BusinessKey = id
|
|
|
- //ActiComplete.UserId = this.User.Id
|
|
|
- //ActiComplete.Remarks = ""
|
|
|
- //ActiComplete.Result = "1"
|
|
|
- //
|
|
|
- //receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
- //fmt.Println(receiveVal)
|
|
|
- //if receiveVal == "true" {
|
|
|
- // session.Commit()
|
|
|
- // errinfo.Code = 0
|
|
|
- // errinfo.Message = "操作成功!"
|
|
|
- // this.Data["json"] = &errinfo
|
|
|
- // this.ServeJSON()
|
|
|
- //} else {
|
|
|
- // session.Rollback()
|
|
|
- // errinfo.Code = -1
|
|
|
- // errinfo.Message = "操作失败!"
|
|
|
- // this.Data["json"] = &errinfo
|
|
|
- // this.ServeJSON()
|
|
|
- //}
|
|
|
+ return ""
|
|
|
}
|
|
|
|
|
|
|