|
@@ -34,6 +34,7 @@ func (u *InvoiceService) InvoiceAdd(solgan *entity.Invoice, resType string, isLo
|
|
|
if isLoop == 0 {
|
|
|
solgan.Swno = strings.Replace(fmt.Sprintln(solgan.Swno+fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))), "\n", "", -1)
|
|
|
}
|
|
|
+ solgan.CustTelephone = solgan.Phone
|
|
|
solgan.SaleTax = entity.SaleTax
|
|
|
solgan.InvType = entity.InvType
|
|
|
solgan.BillType = entity.BillType
|
|
@@ -57,7 +58,7 @@ func (u *InvoiceService) InvoiceAdd(solgan *entity.Invoice, resType string, isLo
|
|
|
//var err error
|
|
|
//err = nil
|
|
|
//正常
|
|
|
- if (err != nil) {
|
|
|
+ if err != nil {
|
|
|
//if (err == nil) {
|
|
|
util.Loger.Println("开票服有问题", err)
|
|
|
if isLoop == 0 {
|
|
@@ -90,7 +91,7 @@ func (u *InvoiceService) InvoiceAdd(solgan *entity.Invoice, resType string, isLo
|
|
|
util.Loger.Println("流水号:", solgan.Swno, "开具发票:结果", data)
|
|
|
//开票正常时
|
|
|
//data["returnCode"] = entity.LineUpCode
|
|
|
- if (data["returnCode"] == entity.LineUpCode || data["returnCode"] == entity.SealCode || data["returnCode"] == entity.SuccessCode) {
|
|
|
+ if data["returnCode"] == entity.LineUpCode || data["returnCode"] == entity.SealCode || data["returnCode"] == entity.SuccessCode || data["returnCode"] == entity.WaitCode {
|
|
|
pdfData, code, msg := u.InvoiceDownload(solgan.Swno, solgan.SaleTax, isRed, 0, 0, solgan.Changed, resType, solgan.OrderCode)
|
|
|
data1 := make(map[string]interface{})
|
|
|
data1["fpdm"] = pdfData["fpdm"]
|
|
@@ -128,7 +129,7 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string, isRed stri
|
|
|
//err = nil
|
|
|
//正常
|
|
|
//if (err != nil) {
|
|
|
- if (err != nil) {
|
|
|
+ if err != nil {
|
|
|
data1 := make(map[string]interface{})
|
|
|
data1["fpdm"] = ""
|
|
|
data1["fphm"] = ""
|
|
@@ -169,9 +170,9 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string, isRed stri
|
|
|
//dat.ReturnMsg.MsgCode = "1000"
|
|
|
util.Loger.Println("发票下载:", "流水号:", swno, "结果:", dat)
|
|
|
//dat.ReturnMsg.MsgCode = entity.LineUpCode
|
|
|
- if (dat.ReturnMsg.MsgCode == entity.SuccessCode) {
|
|
|
+ if dat.ReturnMsg.MsgCode == entity.SuccessCode {
|
|
|
var swno1 string
|
|
|
- if (isRed == "true") {
|
|
|
+ if isRed == "true" {
|
|
|
swno1 = swno[4:len(swno)]
|
|
|
} else {
|
|
|
swno1 = swno
|
|
@@ -187,7 +188,7 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string, isRed stri
|
|
|
pdfData["fphm"] = "Fphm"*/
|
|
|
pdfData["swno"] = swno
|
|
|
return pdfData, 0, dat.ReturnMsg.Msg
|
|
|
- } else if (dat.ReturnMsg.MsgCode == entity.LineUpCode || dat.ReturnMsg.MsgCode == entity.SealCode) {
|
|
|
+ } else if dat.ReturnMsg.MsgCode == entity.LineUpCode || dat.ReturnMsg.MsgCode == entity.SealCode || dat.ReturnMsg.MsgCode == entity.WaitCode {
|
|
|
if isLoop == 0 {
|
|
|
u.Timer(swno, saleTax, isRed, isfeedback, changed, resType, orderCode)
|
|
|
}
|
|
@@ -203,7 +204,7 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string, isRed stri
|
|
|
//noinspection ALL
|
|
|
func (u *InvoiceService) InvoiceSee(swno string, saleTax string, model string) (int, interface{}, string) {
|
|
|
var swno1 string
|
|
|
- if (model == "true") {
|
|
|
+ if model == "true" {
|
|
|
swno1 = "RED_" + swno
|
|
|
} else {
|
|
|
swno1 = swno
|
|
@@ -227,7 +228,7 @@ func (u *InvoiceService) InvoiceSee(swno string, saleTax string, model string) (
|
|
|
func (u *InvoiceService) InvoiceRedSubmit(fpdm string, fphm string, orderCode string, resType string, changed string, isLoop int, solgan *entity.Invoice) (string, int, interface{}) {
|
|
|
url := entity.Url + "?redSubmitEInvoiceInfo"
|
|
|
model := "1"
|
|
|
- if (changed == "1") {
|
|
|
+ if changed == "1" {
|
|
|
model = "2"
|
|
|
}
|
|
|
song := make(map[string]interface{})
|
|
@@ -248,7 +249,7 @@ func (u *InvoiceService) InvoiceRedSubmit(fpdm string, fphm string, orderCode st
|
|
|
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
|
client := http.Client{}
|
|
|
resp, err := client.Do(request)
|
|
|
- if (err != nil) {
|
|
|
+ if err != nil {
|
|
|
data1 := make(map[string]interface{})
|
|
|
data1["fpdm"] = ""
|
|
|
data1["fphm"] = ""
|
|
@@ -259,7 +260,7 @@ func (u *InvoiceService) InvoiceRedSubmit(fpdm string, fphm string, orderCode st
|
|
|
util.SendPdf(arr, true, solgan.Swno, "发票退票时服务出现问题")
|
|
|
u.OpeningTimer(solgan)
|
|
|
}
|
|
|
- if (model == "2") {
|
|
|
+ if model == "2" {
|
|
|
return "剑鱼标讯订开票服务预警", 3, data1
|
|
|
} else {
|
|
|
return "剑鱼标讯订开票服务预警", 2, data1
|
|
@@ -273,9 +274,9 @@ func (u *InvoiceService) InvoiceRedSubmit(fpdm string, fphm string, orderCode st
|
|
|
}
|
|
|
util.Loger.Println("冲红:", "发票单号:", fpdm, "发票号码:", fphm, "结果:", data)
|
|
|
//data["returnCode"] = entity.LineUpCode
|
|
|
- if (data["returnCode"] == entity.LineUpCode || data["returnCode"] == entity.SealCode || data["returnCode"] == entity.SuccessCode) {
|
|
|
+ if data["returnCode"] == entity.LineUpCode || data["returnCode"] == entity.SealCode || data["returnCode"] == entity.SuccessCode || data["returnCode"] == entity.WaitCode {
|
|
|
pdfData, code, msg := u.InvoiceDownload(data["redSwno"].(string), data["saleTax"].(string), "true", int(0), int(0), changed, resType, orderCode)
|
|
|
- if (fmt.Sprint(code) == "0") {
|
|
|
+ if fmt.Sprint(code) == "0" {
|
|
|
data1 := map[string]interface{}{
|
|
|
"fpdm": pdfData["fpdm"],
|
|
|
"fphm": pdfData["fphm"],
|
|
@@ -292,7 +293,7 @@ func (u *InvoiceService) InvoiceRedSubmit(fpdm string, fphm string, orderCode st
|
|
|
}
|
|
|
return msg, code, data1
|
|
|
}
|
|
|
- } else if (data["returnCode"] == "3002") {
|
|
|
+ } else if data["returnCode"] == "3002" {
|
|
|
return "已经冲红", 4, data
|
|
|
} else {
|
|
|
return fmt.Sprintln(data["returnMsg"]), 1, data
|
|
@@ -306,10 +307,10 @@ func (u *InvoiceService) InvoiceReplace(solgan *entity.Invoice, resType string)
|
|
|
solgan.OrderCode = solgan.Swno
|
|
|
msg, code1, dataMap := invoiceService.InvoiceRedSubmit(solgan.Yfpdm, solgan.Yfphm, solgan.Swno, resType, solgan.Changed, 0, solgan)
|
|
|
util.Loger.Println("换票:", "发票单号:", solgan.Yfpdm, "发票号码:", solgan.Yfphm)
|
|
|
- if (code1 == 1) {
|
|
|
+ if code1 == 1 {
|
|
|
return msg, code1, dataMap
|
|
|
}
|
|
|
- if (code1 == 3) {
|
|
|
+ if code1 == 3 {
|
|
|
return msg, 2, dataMap
|
|
|
}
|
|
|
solgan.Yfphm = ""
|
|
@@ -318,7 +319,7 @@ func (u *InvoiceService) InvoiceReplace(solgan *entity.Invoice, resType string)
|
|
|
msg, code, datamap := u.InvoiceAdd(solgan, resType, 0, "false")
|
|
|
_rdsVal := datamap.(map[string]interface{})
|
|
|
_dataMap := dataMap.(map[string]interface{})
|
|
|
- if (code1 == 4) {
|
|
|
+ if code1 == 4 {
|
|
|
_rdsVal["chcode"] = 0
|
|
|
_rdsVal["isch"] = true
|
|
|
} else {
|
|
@@ -329,7 +330,7 @@ func (u *InvoiceService) InvoiceReplace(solgan *entity.Invoice, resType string)
|
|
|
_rdsVal["chswno"] = _dataMap["swno"]
|
|
|
_rdsVal["chpath"] = _dataMap["path"]
|
|
|
}
|
|
|
- if (code1 == 3) {
|
|
|
+ if code1 == 3 {
|
|
|
code = 2
|
|
|
}
|
|
|
return msg, code, _rdsVal
|
|
@@ -340,7 +341,7 @@ func (u *InvoiceService) InvoiceReplace(solgan *entity.Invoice, resType string)
|
|
|
func (u *InvoiceService) Timer(swno string, saleTax string, isRed string, isfeedback int, changed string, resType string, orderCode string) {
|
|
|
util.Loger.Print("定时任务重启", swno, saleTax, isRed, isfeedback, changed, resType)
|
|
|
valueInface := redis.Get(core.GetConfiguration().Redis.Modules, "fp_"+swno)
|
|
|
- if (valueInface == nil) {
|
|
|
+ if valueInface == nil {
|
|
|
swnoMap := make(map[string]interface{}, 0)
|
|
|
swnoMap["swno"] = swno
|
|
|
swnoMap["saleTax"] = saleTax
|
|
@@ -360,7 +361,7 @@ func (u *InvoiceService) Timer(swno string, saleTax string, isRed string, isfeed
|
|
|
util.Loger.Println("定时任务开始:", "流水号:", swno)
|
|
|
valueInface := redis.Get(core.GetConfiguration().Redis.Modules, "fp_"+swno)
|
|
|
swnoMap := make(map[string]interface{}, 0)
|
|
|
- if (valueInface == nil) {
|
|
|
+ if valueInface == nil {
|
|
|
swnoMap["swno"] = swno
|
|
|
swnoMap["saleTax"] = saleTax
|
|
|
swnoMap["isfeedback"] = isfeedback
|
|
@@ -400,14 +401,14 @@ func (u *InvoiceService) Timer(swno string, saleTax string, isRed string, isfeed
|
|
|
}
|
|
|
pdfData, code, _ := u.InvoiceDownload(swno, saleTax, isRed, 1, 0, changed, resType, orderCode)
|
|
|
fmt.Println(pdfData)
|
|
|
- if (code == 0) {
|
|
|
+ if code == 0 {
|
|
|
util.Loger.Println("定时开票成功:", "流水号:", swno)
|
|
|
- if (isfeedback == 0) {
|
|
|
+ if isfeedback == 0 {
|
|
|
//修改发票中状态
|
|
|
dat := util.Callback(swno, saleTax, pdfData["fpdm"].(string), pdfData["fphm"].(string), pdfData["path"].(string), changed, isRed, resType, "", "3", orderCode)
|
|
|
util.Loger.Println("下载成功更改发票结果:", "流水号:", swno, dat)
|
|
|
- util.Loger.Println("下载成功定时任务结束:", "流水号:", swno, )
|
|
|
- if (dat) {
|
|
|
+ util.Loger.Println("下载成功定时任务结束:", "流水号:", swno)
|
|
|
+ if dat {
|
|
|
redis.Del(core.GetConfiguration().Redis.Modules, "fp_"+swno)
|
|
|
util.Loger.Println("删除:", "流水号:", "fp_"+swno)
|
|
|
c.Stop()
|
|
@@ -416,7 +417,7 @@ func (u *InvoiceService) Timer(swno string, saleTax string, isRed string, isfeed
|
|
|
redis.Del(core.GetConfiguration().Redis.Modules, "fp_"+swno)
|
|
|
c.Stop()
|
|
|
}
|
|
|
- } else if (code == 1) {
|
|
|
+ } else if code == 1 {
|
|
|
redis.Del(core.GetConfiguration().Redis.Modules, "fp_"+swno)
|
|
|
fmt.Println("")
|
|
|
util.Callback(swno, saleTax, "", "", "", changed, isRed, resType, "true", "", orderCode)
|
|
@@ -432,7 +433,7 @@ func (u *InvoiceService) Timer(swno string, saleTax string, isRed string, isfeed
|
|
|
func (u *InvoiceService) OpeningTimer(solgan *entity.Invoice) {
|
|
|
util.Loger.Println("发票开具服务有问题")
|
|
|
valueInface := redis.Get(core.GetConfiguration().Redis.Modules, "xx_"+solgan.Swno)
|
|
|
- if (valueInface == nil) {
|
|
|
+ if valueInface == nil {
|
|
|
solgan.Numb = 0
|
|
|
if solgan.Model == "1" || solgan.Model == "2" {
|
|
|
redis.PutKV("xx_"+solgan.Yfphm, solgan)
|
|
@@ -453,7 +454,7 @@ func (u *InvoiceService) OpeningTimer(solgan *entity.Invoice) {
|
|
|
swno = solgan.Swno
|
|
|
}
|
|
|
valueInface := redis.Get(core.GetConfiguration().Redis.Modules, "xx_"+swno)
|
|
|
- if (valueInface == nil) {
|
|
|
+ if valueInface == nil {
|
|
|
solgan.Numb = 0
|
|
|
if solgan.Model == "1" || solgan.Model == "2" {
|
|
|
redis.PutKV("xx_"+solgan.Yfphm, solgan)
|
|
@@ -473,7 +474,7 @@ func (u *InvoiceService) OpeningTimer(solgan *entity.Invoice) {
|
|
|
numb++
|
|
|
solgan.Numb = numb
|
|
|
redis.PutKV("xx_"+swno, solgan)
|
|
|
- } else if (numb == entity.OpenFrequency) {
|
|
|
+ } else if numb == entity.OpenFrequency {
|
|
|
fmt.Println(numb)
|
|
|
util.Callback(solgan.Swno, solgan.SaleTax, solgan.Yfpdm, solgan.Yfphm, "", solgan.Changed, solgan.IsRed, solgan.ResType, "true", solgan.Model, solgan.OrderCode)
|
|
|
if solgan.Model == "1" || solgan.Model == "2" {
|
|
@@ -502,7 +503,7 @@ func (u *InvoiceService) OpeningTimer(solgan *entity.Invoice) {
|
|
|
//重新开具
|
|
|
case "0":
|
|
|
_, code, _ := u.InvoiceAdd(solgan, solgan.ResType, 1, "false")
|
|
|
- if (code == 0) {
|
|
|
+ if code == 0 {
|
|
|
//_rdsVal := datamap.(map[string]interface{})
|
|
|
//util.Callback(solgan.Swno, solgan.SaleTax, "", "", _rdsVal["path"].(string), solgan.Changed, "false", solgan.ResType, "true")
|
|
|
util.Loger.Println("删除:", "流水号:", "xx_"+solgan.Swno)
|
|
@@ -513,7 +514,7 @@ func (u *InvoiceService) OpeningTimer(solgan *entity.Invoice) {
|
|
|
//单独冲红失败
|
|
|
case "1":
|
|
|
_, code, _ := u.InvoiceRedSubmit(solgan.Yfpdm, solgan.Yfphm, solgan.OrderCode, solgan.ResType, solgan.Changed, 1, solgan)
|
|
|
- if (code == 0) {
|
|
|
+ if code == 0 {
|
|
|
//_rdsVal := datamap.(map[string]interface{})
|
|
|
//util.Callback(solgan.Swno, solgan.SaleTax, datamap, "", _rdsVal["path"].(string), solgan.Changed, "false", solgan.ResType, "true")
|
|
|
util.Loger.Println("删除:", "发票号码:", "xx_"+solgan.Yfphm)
|
|
@@ -525,9 +526,9 @@ func (u *InvoiceService) OpeningTimer(solgan *entity.Invoice) {
|
|
|
case "2":
|
|
|
_, code, _ := u.InvoiceRedSubmit(solgan.Yfpdm, solgan.Yfphm, solgan.OrderCode, solgan.ResType, solgan.Changed, 1, solgan)
|
|
|
fmt.Println("code", code)
|
|
|
- if (code == 2 || code == 0) {
|
|
|
+ if code == 2 || code == 0 {
|
|
|
solgan.Model = "0"
|
|
|
- if (code == 0) {
|
|
|
+ if code == 0 {
|
|
|
u.OpeningTimer(solgan)
|
|
|
}
|
|
|
//_rdsVal := datamap.(map[string]interface{})
|
|
@@ -539,14 +540,14 @@ func (u *InvoiceService) OpeningTimer(solgan *entity.Invoice) {
|
|
|
}
|
|
|
case "3":
|
|
|
_, code, _ := u.InvoiceDownload(solgan.Swno, solgan.SaleTax, solgan.IsRed, 1, 0, solgan.Changed, solgan.ResType, solgan.OrderCode)
|
|
|
- if (code == 0) {
|
|
|
+ if code == 0 {
|
|
|
//_rdsVal := datamap.(map[string]interface{})
|
|
|
//util.Callback(solgan.Swno, solgan.SaleTax, datamap, "", _rdsVal["path"].(string), solgan.Changed, "false", solgan.ResType, "true")
|
|
|
util.Loger.Println("删除:", "流水号:", "xx_"+solgan.Swno)
|
|
|
redis.Del(core.GetConfiguration().Redis.Modules, "xx_"+solgan.Swno)
|
|
|
util.Callback(solgan.Swno, solgan.SaleTax, solgan.Yfpdm, solgan.Yfphm, "", solgan.Changed, solgan.IsRed, solgan.ResType, "true", solgan.Model, solgan.OrderCode)
|
|
|
c.Stop()
|
|
|
- } else if (code == 1) {
|
|
|
+ } else if code == 1 {
|
|
|
redis.Del(core.GetConfiguration().Redis.Modules, "xx_"+solgan.Swno)
|
|
|
util.Callback(solgan.Swno, solgan.SaleTax, solgan.Yfpdm, solgan.Yfphm, "", solgan.Changed, solgan.IsRed, solgan.ResType, "true", solgan.Model, solgan.OrderCode)
|
|
|
c.Stop()
|