|
@@ -420,7 +420,13 @@ func (this *Invoice) Callbackinvoice() {
|
|
|
if changed == "1" {
|
|
|
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
|
|
@@ -448,8 +454,28 @@ func (this *Invoice) Callbackinvoice() {
|
|
|
}
|
|
|
emailHtml := emailHtml_gr
|
|
|
emailHtmls := fmt.Sprintf(emailHtml, (*res)["phone"], user_mail)
|
|
|
- html := fmt.Sprintf(email_format, order_code, "电子专用发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子专用发票", emailHtmls)
|
|
|
- InvoiceSendMail(user_mail, html)
|
|
|
+ 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, "电子发票")
|
|
|
}()
|
|
|
} else {
|
|
|
var company_mail string
|
|
@@ -466,8 +492,27 @@ func (this *Invoice) Callbackinvoice() {
|
|
|
}
|
|
|
emailHtml := emailHtml_gs
|
|
|
emailHtmls := fmt.Sprintf(emailHtml, (*res)["company_name"], (*res)["taxpayer_identnum"], (*res)["phone"], company_mail)
|
|
|
- html := fmt.Sprintf(email_format, order_code, "电子专用发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子专用发票", emailHtmls)
|
|
|
- InvoiceSendMail((*res)["mail"].(string), html)
|
|
|
+ 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, "电子发票")
|
|
|
|
|
|
}
|
|
|
this.ServeJson(map[string]interface{}{
|
|
@@ -509,8 +554,8 @@ func (this *Invoice) Callbackinvoice() {
|
|
|
}
|
|
|
emailHtml := emailHtml_gr
|
|
|
emailHtmls := fmt.Sprintf(emailHtml, (*res)["phone"], user_mail)
|
|
|
- html := fmt.Sprintf(email_format, order_code, "电子专用发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子专用发票", emailHtmls)
|
|
|
- InvoiceSendMail(user_mail, html)
|
|
|
+ html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
|
|
|
+ InvoiceSendMail(user_mail, html, "电子发票")
|
|
|
|
|
|
}()
|
|
|
|
|
@@ -529,8 +574,8 @@ func (this *Invoice) Callbackinvoice() {
|
|
|
}
|
|
|
emailHtml := emailHtml_gs
|
|
|
emailHtmls := fmt.Sprintf(emailHtml, (*res)["company_name"], (*res)["taxpayer_identnum"], (*res)["phone"], company_mail)
|
|
|
- html := fmt.Sprintf(email_format, order_code, "电子专用发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子专用发票", emailHtmls)
|
|
|
- InvoiceSendMail((*res)["mail"].(string), html)
|
|
|
+ html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
|
|
|
+ InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
|
|
|
|
|
|
}
|
|
|
this.ServeJson(map[string]interface{}{
|
|
@@ -655,7 +700,7 @@ func (this *Invoice) Replaceinvoice() {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- InvoiceSendMail((*res)["mail"].(string), html)
|
|
|
+ InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
@@ -703,7 +748,7 @@ func (this *Invoice) Replaceinvoice() {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- InvoiceSendMail((*res)["mail"].(string), html)
|
|
|
+ InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -939,9 +984,9 @@ func (this *Invoice) Invoiceinfo() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-func InvoiceSendMail(target_mail, html string) {
|
|
|
+func InvoiceSendMail(target_mail, html, title string) {
|
|
|
for k, v := range config.GmailAuth {
|
|
|
- if mail.GSendMail("剑鱼标讯", target_mail, "", "", "电子发票", html, "", "", v) {
|
|
|
+ if mail.GSendMail("剑鱼标讯", target_mail, "", "", title, html, "", "", v) {
|
|
|
log.Println(target_mail, fmt.Sprintf("使用%s发送邮件成功", v.User))
|
|
|
break
|
|
|
}
|
|
@@ -1028,6 +1073,7 @@ func (this *Invoice) InvoiceSubmit() {
|
|
|
"invoice_content": "信息技术服务-技术服务费",
|
|
|
"invoice_status": 0,
|
|
|
"invoice_changed": 1,
|
|
|
+ "company_phone": this.GetString("company_phone"),
|
|
|
"taxpayer_identnum": this.GetString("taxpayer_identnum"),
|
|
|
"create_time": time.Now().Unix(),
|
|
|
"billing_time": time.Now().Unix(),
|
|
@@ -1063,71 +1109,70 @@ func (this *Invoice) InvoiceSubmit() {
|
|
|
}) {
|
|
|
this.ServeJson(NewResult("", errors.New("发票信息保存失败")))
|
|
|
}
|
|
|
+ if this.GetString("invoice_variety") == "电子普通发票" && Allmoney < 1000000 {
|
|
|
+ //走航天金税开票
|
|
|
+ var orders = []map[string]interface{}{}
|
|
|
+ var items = []map[string]interface{}{}
|
|
|
+ item := map[string]interface{}{
|
|
|
+ "name": "技术服务费",
|
|
|
+ "code": config.InvoiceConfig.Code,
|
|
|
+ "yhzcbs": config.InvoiceConfig.Tax_policy,
|
|
|
+ "lineType": config.InvoiceConfig.Invoice_nature,
|
|
|
+ "taxRate": config.InvoiceConfig.Tax_rate,
|
|
|
+ "taxPrice": Allmoney,
|
|
|
+ "totalAmount": Allmoney,
|
|
|
+ "quantity": "1",
|
|
|
+ }
|
|
|
+ items = append(items, item)
|
|
|
+ order := map[string]interface{}{
|
|
|
+ "billNo": onlyIdentifying,
|
|
|
+ "items": items,
|
|
|
+ }
|
|
|
+ orders = append(orders, order)
|
|
|
+ body := map[string]interface{}{
|
|
|
+ "Swno": onlyIdentifying,
|
|
|
+ "custType": "03",
|
|
|
+ "orders": orders,
|
|
|
+ "custTaxNo": this.GetString("taxpayer_identnum"),
|
|
|
+ "changed": "1",
|
|
|
+ "phone": this.GetString("phone"),
|
|
|
+ }
|
|
|
+ if this.GetString("invoice_type") == "单位" {
|
|
|
+ body["custName"] = this.GetString("company_name")
|
|
|
+ } else {
|
|
|
+ body["custName"] = "个人"
|
|
|
+ }
|
|
|
+ htjs(body, orderArr, this.GetString("invoice_type"), this.GetString("company_name"), this.GetString("taxpayer_identnum"), this.GetString("mail"), this.GetString("phone"))
|
|
|
+ } else {
|
|
|
+ //给王航发信息
|
|
|
+ recipientStr := ""
|
|
|
+ deliveryAddressStr := ""
|
|
|
+ if this.GetString("invoice_variety") == "纸质普通发票" || this.GetString("invoice_variety") == "纸质专用发票" {
|
|
|
+ recipientStr = fmt.Sprintf("<p class=\"item\">\n <span class=\"label\">收件人:</span>\n <span class=\"value\">%s</span>\n </p>", this.GetString("recipient"))
|
|
|
+ deliveryAddressStr = fmt.Sprintf("<p class=\"item\">\n <span class=\"label\">收件地址:</span>\n <span class=\"value\">%s</span>\n </p>", this.GetString("delivery_address"))
|
|
|
+ }
|
|
|
+ html := fmt.Sprintf(email_format_new,
|
|
|
+ FormatDate(&now, Date_Full_Layout),
|
|
|
+ strings.Join(orderArr, ","),
|
|
|
+ Allmoney/100,
|
|
|
+ this.GetString("invoice_variety"),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("invoice_type") == "", "--", this.GetString("invoice_type"))),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("company_name") == "", "--", this.GetString("company_name"))),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("taxpayer_identnum") == "", "--", this.GetString("taxpayer_identnum"))),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("company_address") == "", "--", this.GetString("company_address"))),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("company_phone") == "", "--", this.GetString("company_phone"))),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("bank_name") == "", "--", this.GetString("bank_name"))),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("bank_account") == "", "--", this.GetString("bank_account"))),
|
|
|
+ qutil.InterfaceToStr(qutil.If(this.GetString("remark") == "", "--", this.GetString("remark"))),
|
|
|
+ recipientStr,
|
|
|
+ this.GetString("phone"),
|
|
|
+ deliveryAddressStr,
|
|
|
+ )
|
|
|
+ for _, v := range strings.Split(config.Config.FinanceMail, ",") {
|
|
|
+ InvoiceSendMail(v, html, fmt.Sprintf("客户申请开具%s", this.GetString("invoice_variety")))
|
|
|
+ }
|
|
|
+ }
|
|
|
this.ServeJson(NewResult("保存信息成功", nil))
|
|
|
- /*if this.GetString("invoice_variety") == "电子普通发票" && Allmoney < 1000000 {
|
|
|
- //走航天金税开票
|
|
|
- var orders = []map[string]interface{}{}
|
|
|
- var items = []map[string]interface{}{}
|
|
|
- item := map[string]interface{}{
|
|
|
- "name": "技术服务费",
|
|
|
- "code": config.InvoiceConfig.Code,
|
|
|
- "yhzcbs": config.InvoiceConfig.Tax_policy,
|
|
|
- "lineType": config.InvoiceConfig.Invoice_nature,
|
|
|
- "taxRate": config.InvoiceConfig.Tax_rate,
|
|
|
- "taxPrice": Allmoney,
|
|
|
- "totalAmount": Allmoney,
|
|
|
- "quantity": "1",
|
|
|
- }
|
|
|
- items = append(items, item)
|
|
|
- order := map[string]interface{}{
|
|
|
- "billNo": onlyIdentifying,
|
|
|
- "items": items,
|
|
|
- }
|
|
|
- orders = append(orders, order)
|
|
|
- body := map[string]interface{}{
|
|
|
- "Swno": onlyIdentifying,
|
|
|
- "custType": "03",
|
|
|
- "orders": orders,
|
|
|
- "custTaxNo": this.GetString("taxpayer_identnum"),
|
|
|
- "changed": "1",
|
|
|
- "phone": this.GetString("phone"),
|
|
|
- }
|
|
|
- if this.GetString("invoice_type") == "单位" {
|
|
|
- body["custName"] = this.GetString("company_name")
|
|
|
- } else {
|
|
|
- body["custName"] = "个人"
|
|
|
- }
|
|
|
- htjs(body, orderArr)
|
|
|
- } else {
|
|
|
- //给王航发信息
|
|
|
- recipientStr := ""
|
|
|
- deliveryAddressStr := ""
|
|
|
- if this.GetString("invoice_variety") == "纸质普通发票" || this.GetString("invoice_variety") == "纸质专用发票" {
|
|
|
- recipientStr = fmt.Sprintf("<p class=\"item\">\n <span class=\"label\">收件人:</span>\n <span class=\"value\">%s</span>\n </p>", this.GetString("recipient"))
|
|
|
- deliveryAddressStr = fmt.Sprintf("<p class=\"item\">\n <span class=\"label\">收件地址:</span>\n <span class=\"value\">%s</span>\n </p>", this.GetString("delivery_address"))
|
|
|
- }
|
|
|
-
|
|
|
- html := fmt.Sprintf(email_format_new,
|
|
|
- FormatDate(&now, Date_Full_Layout),
|
|
|
- strings.Join(orderArr, ","),
|
|
|
- Allmoney/100,
|
|
|
- this.GetString("invoice_variety"),
|
|
|
- this.GetString("invoice_type"),
|
|
|
- this.GetString("company_name"),
|
|
|
- this.GetString("taxpayer_identnum"),
|
|
|
- this.GetString("company_address"),
|
|
|
- this.GetString("phone"),
|
|
|
- this.GetString("bank_name"),
|
|
|
- this.GetString("bank_account"),
|
|
|
- this.GetString("remark"),
|
|
|
- recipientStr,
|
|
|
- this.GetString("phone"),
|
|
|
- deliveryAddressStr,
|
|
|
- )
|
|
|
- for _, v := range strings.Split(config.Config.FinanceMail, ",") {
|
|
|
- InvoiceSendMail(v, html)
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
// 发票信息查询
|
|
@@ -1148,7 +1193,7 @@ func (this *Invoice) InvoiceQuery() {
|
|
|
}
|
|
|
invoiceOne := util.Mysql.FindOne("invoice", map[string]interface{}{
|
|
|
"only_Identifying": onlyIdentifying,
|
|
|
- }, " bank_account, company_name, phone, mail, invoice_type, invoice_content, url, invoice_status, invoice_serialnum, taxpayer_identnum, operator, operable_time, invoicing_entity, remark, invoice_variety, logistics_code, company_address, bank_name, recipient, delivery_address", "")
|
|
|
+ }, " bank_account, company_name, phone, mail,company_phone, invoice_type, invoice_content, url, invoice_status, invoice_serialnum, taxpayer_identnum, operator, operable_time, invoicing_entity, remark, invoice_variety, logistics_code, company_address, bank_name, recipient, delivery_address", "")
|
|
|
this.ServeJson(NewResult(map[string]interface{}{
|
|
|
"orderCodes": strings.Join(orderArr, ","),
|
|
|
"money": money,
|
|
@@ -1167,7 +1212,7 @@ func GetUserId(orderCode string) (userId string) {
|
|
|
}
|
|
|
|
|
|
// 调航天金税接口
|
|
|
-func htjs(body map[string]interface{}, orderCode []string) {
|
|
|
+func htjs(body map[string]interface{}, orderCode []string, invoiceType, companyName, taxpayerIdentnum, mail, phone string) {
|
|
|
invoice_status := 0
|
|
|
client := &http.Client{}
|
|
|
b, _ := json.Marshal(body)
|
|
@@ -1199,7 +1244,54 @@ func htjs(body map[string]interface{}, orderCode []string) {
|
|
|
"url": resData["path"],
|
|
|
"invoice_status": invoice_status,
|
|
|
})
|
|
|
+ //订单信息保存
|
|
|
+ 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)
|
|
|
+
|
|
|
}
|
|
|
+ sendMail(invoiceType, strings.Join(orderCode, ","), companyName, taxpayerIdentnum, mail, phone, qutil.InterfaceToStr(resData["path"]))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// 判断是全额还是部分回款
|
|
|
+func InvoiceStatusHandle(orderCode string) bool {
|
|
|
+ orderData := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
|
|
|
+ "order_code": orderCode,
|
|
|
+ }, "pay_money", "")
|
|
|
+ if orderData == nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ invoiceData := util.Mysql.SelectBySql("select sum(invoice_order_money) as money from invoice where order_code=? and invoice_status>=0 ", orderCode)
|
|
|
+ if invoiceData == nil || len(*invoiceData) == 0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ allMoney := qutil.Int64All((*invoiceData)[0]["money"])
|
|
|
+ pay_money := qutil.Int64All((*orderData)["pay_money"])
|
|
|
+ if pay_money == allMoney {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+// 电子普票发邮箱
|
|
|
+func sendMail(invoiceType, orderCode, companyName, taxpayerIdentnum, mail, phone, url string) {
|
|
|
+ if invoiceType == "个人" {
|
|
|
+ emailHtml := emailHtml_gr
|
|
|
+ emailHtmls := fmt.Sprintf(emailHtml, phone, mail)
|
|
|
+ html := fmt.Sprintf(email_format, orderCode, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
|
|
|
+ InvoiceSendMail(mail, html, "电子发票")
|
|
|
+ } else {
|
|
|
+ emailHtml := emailHtml_gs
|
|
|
+ emailHtmls := fmt.Sprintf(emailHtml, companyName, taxpayerIdentnum, phone, mail)
|
|
|
+ html := fmt.Sprintf(email_format, orderCode, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
|
|
|
+ InvoiceSendMail(mail, html, "电子发票")
|
|
|
+ }
|
|
|
+}
|