WH01243 5 年之前
父節點
當前提交
38e4f91670

+ 2 - 1
invoice/src/api/InvoiceController.go

@@ -66,7 +66,8 @@ func InvoiceDownload(context *gin.Context) {
 func InvoiceSee(context *gin.Context) {
 	result := &model.BaseResult{}
 	swno := context.Request.FormValue("swno")
-	code,path,msg:=InvoiceService.InvoiceSee(swno,entity.SaleTax)
+	model := context.Request.FormValue("model")
+	code,path,msg:=InvoiceService.InvoiceSee(swno,entity.SaleTax,model)
 	result.Data=path
 	result.Msg=msg
 	result.Code=code

+ 2 - 7
invoice/src/config.json

@@ -1,10 +1,4 @@
 {
-    "Title" : "您的剑鱼标讯订单【v%】电子发票已开具",
-    "Body" :"<html><head><meta charset=\"UTF-8\"><title></title></head><style>label{display: block;border: 1px solid red;width: 90px;}span{display: block;margin-top: 5px;border: 1px solid red;width: 90px;}td{border: 1px solid red;width: 480px;padding:10px 10px ;}div{width: 100px;margin-left:20px ;display: inline;float: left;}</style><body><table><tr><td><div><label>我的:</label><span>名字</span></div><div><label>我的:</label><span>名字</span></div><div><label>我的:</label><span>名字</span></div><div><label>我的:</label><span>名字</span></div><div><label>我的:</label><span>名字</span></div></td></tr></table></body></html>",
-    "Sender" : "2399761917@qq.com",
-    "SPassword" : "cntzknpoplpeecig",
-    "SMTPAddr" : "smtp.qq.com",
-    "SMTPPort" : 25,
     "SuccessCode": "0000",
     "LineUpCode": "1089",
     "SealCode":"4002",
@@ -18,5 +12,6 @@
     "SpecialRedFlag":"0",
     "OperationCode": "10",
     "Verified": "0",
-    "Kpr": "梁艺晓"
+    "Kpr": "梁艺晓",
+    "JyUrl": "http://192.168.20.191:86/jypay/invoice/callback"
 }

+ 1 - 6
invoice/src/entity/Invoice.go

@@ -102,12 +102,6 @@ type MailboxConf struct {
 	SMTPPort int
 }
 
-var Title string
-var Body string
-var Sender string
-var SPassword string
-var SMTPAddr string
-var SMTPPort int
 var SuccessCode string
 var LineUpCode string
 var TimingCron string
@@ -123,3 +117,4 @@ var SpecialRedFlag string
 var OperationCode string
 var Verified string
 var Kpr string
+var  JyUrl string

+ 1 - 7
invoice/src/main.go

@@ -35,13 +35,6 @@ func Init() {
 	util.Log()
 	var Config map[string]interface{}
 	core.ReadConfig("./config.json", &Config)
-	entity.Title = fmt.Sprint(Config["Title"])
-	entity.Body = fmt.Sprint(Config["Body"])
-	entity.Sender = fmt.Sprint(Config["Sender"])
-	entity.SPassword = fmt.Sprint(Config["SPassword"])
-	entity.SMTPAddr = fmt.Sprint(Config["SMTPAddr"])
-	SMTPPortint := util.SafeConvert2Int(Config["SMTPPort"])
-	entity.SMTPPort = SMTPPortint
 	entity.SuccessCode = fmt.Sprint(Config["SuccessCode"])
 	entity.LineUpCode = fmt.Sprint(Config["LineUpCode"])
 	entity.TimingCron = fmt.Sprint(Config["TimingCron"])
@@ -55,6 +48,7 @@ func Init() {
 	entity.OperationCode = fmt.Sprint(Config["OperationCode"])
 	entity.Verified = fmt.Sprint(Config["Verified"])
 	entity.Kpr=fmt.Sprint(Config["Kpr"])
+	entity.JyUrl=fmt.Sprint(Config["JyUrl"])
 	keys := redis.GetKeys(core.GetConfiguration().Redis.Modules, "fp_*")
 	invoiceService := service.InvoiceService{}
 	for numb, _ := range keys {

+ 31 - 11
invoice/src/service/InvoiceService.go

@@ -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()