|
|
@@ -3,11 +3,8 @@ 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 {
|
|
|
@@ -47,67 +44,101 @@ func (this *OilInvoiceController) GetInvoiceData() {
|
|
|
// @Description 更新发票状态
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
// @router /updateisinvoice [get]
|
|
|
-func (this *OilInvoiceController) UpdateIsInvoice() {
|
|
|
-
|
|
|
- id := this.GetString("Id")
|
|
|
- srcIds := this.GetString("SrcIds")
|
|
|
- session := utils.DBE.NewSession()
|
|
|
- defer session.Close()
|
|
|
- err := session.Begin()
|
|
|
-
|
|
|
- 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)
|
|
|
-
|
|
|
+func (this *OilInvoiceController) UpdateIsInvoice() string {
|
|
|
+
|
|
|
+ //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\":\"\"}]}}"
|
|
|
var errinfo ErrorInfo
|
|
|
- if err != nil {
|
|
|
- session.Rollback()
|
|
|
+ invoiceJson := invoice.Post(url, params)
|
|
|
+ if invoiceJson.Status != "0000"{
|
|
|
+ //session.Rollback()
|
|
|
errinfo.Code = -1
|
|
|
- errinfo.Message = "操作失败!"
|
|
|
+ errinfo.Message = "操作失败!" + invoiceJson.Fpqqlsh
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
- return
|
|
|
+ } else if invoiceJson.Status == "0000" && invoiceJson.Fpqqlsh != "" {
|
|
|
+ // 根据流水号查询结果
|
|
|
+ url := "https://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action"
|
|
|
+ params := "{'identity':'" + identity + "','fpqqlsh':['20170104160449979446']}"
|
|
|
+ invoiceJson1 := invoice.SerialNumberPost(url, params)
|
|
|
+ if invoiceJson1.Result != "success"{
|
|
|
+ //session.Rollback()
|
|
|
+ errinfo.Code = -1
|
|
|
+ errinfo.Message = "操作失败!" + invoiceJson1.ErrorMsg
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else if invoiceJson1.Result == "success" && invoiceJson1.List != "" {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- var payinfo paymentinfo.OilPaymentInfo
|
|
|
- payinfo.IsInvoice = "1"
|
|
|
- paycols := []string{"IsInvoice"}
|
|
|
- where := "Id in (" + srcIds + ")"
|
|
|
- err = svc.UpdateEntityBywheretbl(OilPaymentInfoName, &payinfo, paycols, where)
|
|
|
+ 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()
|
|
|
+ //}
|
|
|
+}
|
|
|
|
|
|
- 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()
|
|
|
- }
|
|
|
-}
|