Browse Source

开票回调订单修改

WH01243 1 year ago
parent
commit
effc4cfd27
1 changed files with 58 additions and 30 deletions
  1. 58 30
      src/jfw/modules/subscribepay/src/service/invoice.go

+ 58 - 30
src/jfw/modules/subscribepay/src/service/invoice.go

@@ -420,13 +420,7 @@ func (this *Invoice) Callbackinvoice() {
 			if changed == "1" {
 				m := make(map[string]interface{})
 				query := make(map[string]interface{})
-				if strings.Contains(order_code, "xx") {
-					//自助开票
-					query["only_Identifying"] = order_code
-				} else {
-					//系统开票
-					query["order_code"] = order_code
-				}
+				query["order_code"] = order_code
 				query["invoice_changed"] = 1
 				m["invoice_code"] = fpdm
 				m["invoice_number"] = fphm
@@ -454,26 +448,6 @@ func (this *Invoice) Callbackinvoice() {
 							}
 							emailHtml := emailHtml_gr
 							emailHtmls := fmt.Sprintf(emailHtml, (*res)["phone"], user_mail)
-							if strings.Contains(order_code, "xx") {
-								//自助开票
-								orderCodeArr := util.Mysql.SelectBySql("select   GROUP_CONCAT(order_code) as  order_code  from   invoice  where  only_Identifying=?", order_code)
-								if len(*orderCodeArr) > 0 {
-									order_code = qutil.ObjToString((*orderCodeArr)[0]["order_code"])
-									for _, v := range strings.Split(order_code, ",") {
-										//订单信息保存
-										updateData := map[string]interface{}{}
-										if InvoiceStatusHandle(v) {
-											updateData["applybill_status"] = 2
-										} else {
-											updateData["applybill_status"] = 3
-										}
-										util.Mysql.Update("dataexport_order", map[string]interface{}{
-											"order_code": v,
-										}, updateData)
-									}
-								}
-
-							}
 							html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
 							InvoiceSendMail(user_mail, html, "电子发票")
 						}()
@@ -522,14 +496,28 @@ func (this *Invoice) Callbackinvoice() {
 				}
 			} else {
 				t := make(map[string]interface{})
-				t["order_code"] = order_code
+
+				if strings.Contains(order_code, "xx") {
+					//自助开票
+					t["only_Identifying"] = order_code
+				} else {
+					//系统开票
+					t["order_code"] = order_code
+				}
 				t["invoice_changed"] = 0
 				user_info := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code}, "user_nickname,user_mail", "")
 				res := util.Mysql.FindOne(dbname, t, "invoice_type,mail,taxpayer_identnum,company_name,phone,url", "")
 				if res != nil {
 					m := make(map[string]interface{})
 					query := make(map[string]interface{})
-					query["order_code"] = order_code
+					if strings.Contains(order_code, "xx") {
+						//自助开票
+						query["only_Identifying"] = order_code
+					} else {
+						//系统开票
+						query["order_code"] = order_code
+					}
+					query["invoice_changed"] = 1
 					m["invoice_code"] = fpdm
 					m["invoice_number"] = fphm
 					m["url"] = "http://" + path
@@ -554,6 +542,26 @@ func (this *Invoice) Callbackinvoice() {
 								}
 								emailHtml := emailHtml_gr
 								emailHtmls := fmt.Sprintf(emailHtml, (*res)["phone"], user_mail)
+								if strings.Contains(order_code, "xx") {
+									//自助开票
+									orderCodeArr := util.Mysql.SelectBySql("select   GROUP_CONCAT(order_code) as  order_code  from   invoice  where  only_Identifying=?", order_code)
+									if len(*orderCodeArr) > 0 {
+										order_code = qutil.ObjToString((*orderCodeArr)[0]["order_code"])
+										for _, v := range strings.Split(order_code, ",") {
+											//订单信息保存
+											updateData := map[string]interface{}{}
+											if InvoiceStatusHandle(v) {
+												updateData["applybill_status"] = 2
+											} else {
+												updateData["applybill_status"] = 3
+											}
+											util.Mysql.Update("dataexport_order", map[string]interface{}{
+												"order_code": v,
+											}, updateData)
+										}
+									}
+
+								}
 								html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
 								InvoiceSendMail(user_mail, html, "电子发票")
 
@@ -574,6 +582,26 @@ func (this *Invoice) Callbackinvoice() {
 							}
 							emailHtml := emailHtml_gs
 							emailHtmls := fmt.Sprintf(emailHtml, (*res)["company_name"], (*res)["taxpayer_identnum"], (*res)["phone"], company_mail)
+							if strings.Contains(order_code, "xx") {
+								//自助开票
+								orderCodeArr := util.Mysql.SelectBySql("select   GROUP_CONCAT(order_code) as  order_code  from   invoice  where  only_Identifying=?", order_code)
+								if len(*orderCodeArr) > 0 {
+									order_code = qutil.ObjToString((*orderCodeArr)[0]["order_code"])
+									for _, v := range strings.Split(order_code, ",") {
+										//订单信息保存
+										updateData := map[string]interface{}{}
+										if InvoiceStatusHandle(v) {
+											updateData["applybill_status"] = 2
+										} else {
+											updateData["applybill_status"] = 3
+										}
+										util.Mysql.Update("dataexport_order", map[string]interface{}{
+											"order_code": v,
+										}, updateData)
+									}
+								}
+
+							}
 							html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
 							InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
 
@@ -1161,7 +1189,7 @@ func (this *Invoice) InvoiceSubmit() {
 			} else {
 				body["custName"] = "个人"
 			}
-			go htjs(body, orderArr, this.GetString("invoice_type"), this.GetString("company_name"), this.GetString("taxpayer_identnum"), this.GetString("mail"), this.GetString("phone"))
+			htjs(body, orderArr, this.GetString("invoice_type"), this.GetString("company_name"), this.GetString("taxpayer_identnum"), this.GetString("mail"), this.GetString("phone"))
 		} else {
 			//给王航发信息
 			recipientStr := ""