|
@@ -25,6 +25,7 @@ var (
|
|
|
// 发票开具
|
|
|
func (u *InvoiceService) InvoiceAdd(solgan *entity.Invoice) (string, int, interface{}) {
|
|
|
rand.Seed(time.Now().Unix())
|
|
|
+ solgan.InvoMemo=solgan.Swno
|
|
|
solgan.Swno=strings.Replace(fmt.Sprintln(solgan.Swno+fmt.Sprintln(rand.Intn(1000000))), "\n", "", -1)
|
|
|
solgan.SaleTax = entity.SaleTax
|
|
|
solgan.InvType =entity.InvType
|
|
@@ -96,17 +97,18 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string,model int)
|
|
|
}
|
|
|
util.Loger.Println("发票下载:", "流水号:",swno, "发票开具方税号:",saleTax,"结果:", dat)
|
|
|
if (dat.ReturnMsg.MsgCode == entity.SuccessCode) {
|
|
|
+ var swno1 string
|
|
|
if(model==1){
|
|
|
- swno=swno[4 : len(swno)]
|
|
|
+ swno1=swno[4 : len(swno)]
|
|
|
+ }else{
|
|
|
+ swno1=swno
|
|
|
}
|
|
|
pdfData := make(map[string]interface{})
|
|
|
- path := util.ImgHandle(dat.FpMsgs[0].PdfContent, swno,saleTax)
|
|
|
+ path := util.ImgHandle(dat.FpMsgs[0].PdfContent, swno,saleTax,swno1)
|
|
|
pdfData["path"] = path
|
|
|
pdfData["fpdm"] = dat.FpMsgs[0].Fpdm
|
|
|
pdfData["fphm"] = dat.FpMsgs[0].Fphm
|
|
|
- /*if(email!=""){
|
|
|
- //util.SendPdf(email,pathArr,swno)
|
|
|
- }*/
|
|
|
+ pdfData["swno"] = swno
|
|
|
return pdfData, 0, dat.ReturnMsg.Msg
|
|
|
} else if (dat.ReturnMsg.MsgCode == entity.LineUpCode || dat.ReturnMsg.MsgCode == entity.SealCode) {
|
|
|
swnoMap := make(map[string]interface{})
|
|
@@ -123,17 +125,24 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string,model int)
|
|
|
|
|
|
// 发票是否存在
|
|
|
//noinspection ALL
|
|
|
-func (u *InvoiceService) InvoiceSee(swno string, saleTax string) (int, interface{}, string) {
|
|
|
- fool := util.Exists("./static/res/" + saleTax + "/"+swno + ".pdf")
|
|
|
+func (u *InvoiceService) InvoiceSee(swno string, saleTax string,model string) (int, interface{}, string) {
|
|
|
+ var swno1 string
|
|
|
+ if(model=="1"){
|
|
|
+ swno1="RED_"+swno
|
|
|
+ }else{
|
|
|
+ swno1=swno
|
|
|
+ }
|
|
|
+ fool := util.Exists("./static/res/" + saleTax + "/"+swno+"/"+swno1 + ".pdf")
|
|
|
msg := "发票地址"
|
|
|
+
|
|
|
if fool {
|
|
|
pdfData:=make(map[string]interface{})
|
|
|
- pdfData["path"] = entity.PdfUrl+"/static/res/" + saleTax + "/" + swno + ".pdf"
|
|
|
+ pdfData["path"] = entity.PdfUrl+"/static/res/" + saleTax + "/" + swno +"/"+swno1+ ".pdf"
|
|
|
pdfData["fpdm"]=""
|
|
|
pdfData["fphm"]=""
|
|
|
return 0, pdfData, msg
|
|
|
} else {
|
|
|
- path, numb, _ := u.InvoiceDownload(swno, saleTax,0)
|
|
|
+ path, numb, _ := u.InvoiceDownload(swno1, saleTax,0)
|
|
|
return numb, path, msg
|
|
|
}
|
|
|
}
|
|
@@ -189,11 +198,22 @@ func (u *InvoiceService) Timer(swno string, saleTax string,model int ) {
|
|
|
spec := entity.TimingCron
|
|
|
c.AddFunc(spec, func() { // AddFunc 是添加任务的地方,此函数接收两个参数,第一个为表示定时任务的字符串,第二个为真正的真正的任务。
|
|
|
util.Loger.Println("定时任务开始:", "流水号:",swno, "发票开具方税号:",saleTax,)
|
|
|
- _, numb, _ := u.InvoiceDownload(swno, saleTax,model)
|
|
|
+ pdfData,numb, _ := u.InvoiceDownload(swno, saleTax,model)
|
|
|
if (numb == 0) {
|
|
|
util.Loger.Println("定时开票成功:", "流水号:",swno, "发票开具方税号:",saleTax,)
|
|
|
redis.Del(core.GetConfiguration().Redis.Modules, "fp_"+swno)
|
|
|
- util.Loger.Println("定时任务结束:", "流水号:",swno, "发票开具方税号:",saleTax,)
|
|
|
+ //修改发票中状态
|
|
|
+ url:=entity.JyUrl+"?order_code="+swno[0 : len(swno)-6]+"&code=1&pfdm="+pdfData["fpdm"].(string)+"&fphm="+pdfData["fphm"].(string)+"&path="+pdfData["path"].(string)+"&swno="+swno
|
|
|
+ util.Loger.Println("更改发票状态:", "流水号:",swno, "发票开具方税号:",saleTax,)
|
|
|
+ req, _ := http.NewRequest("GET", url, nil)
|
|
|
+ res, _ := http.DefaultClient.Do(req)
|
|
|
+ defer res.Body.Close()
|
|
|
+ body, _ := ioutil.ReadAll(res.Body)
|
|
|
+ dat := make(map[string]interface{})
|
|
|
+ err := json.Unmarshal([]byte(body), &dat)
|
|
|
+ fmt.Println(err)
|
|
|
+ util.Loger.Println("更改发票结果:","流水号:",swno, "发票开具方税号:",saleTax,dat)
|
|
|
+ util.Loger.Println("定时任务结束:", "流水号:",swno, "发票开具方税号:",saleTax)
|
|
|
c.Stop()
|
|
|
}else if (numb == 1){
|
|
|
c.Stop()
|