Bläddra i källkod

Merge branch 'feature/v4.9.21' of https://jygit.jydev.jianyu360.cn/qmx/jy into dev/v4.9.21_wmh

wenmenghao321 1 år sedan
förälder
incheckning
6bc6365e20
32 ändrade filer med 1964 tillägg och 1773 borttagningar
  1. 7 5
      src/jfw/front/dataExport.go
  2. 3 1
      src/jfw/modules/subscribepay/src/config.json
  3. 7 7
      src/jfw/modules/subscribepay/src/entity/equityActive.go
  4. 1 1
      src/jfw/modules/subscribepay/src/invoice.json
  5. 1693 1686
      src/jfw/modules/subscribepay/src/service/invoice.go
  6. 7 7
      src/web/staticres/electronic_invoice/css/check_invoice.css
  7. 3 0
      src/web/staticres/electronic_invoice/css/invoice.css
  8. 3 0
      src/web/staticres/public-pc/css/header-nav-mini.css
  9. 5 0
      src/web/staticres/public-pc/js/header-nav-mini.js
  10. 30 5
      src/web/staticres/tags/css/no-login-detail.css
  11. 1 1
      src/web/templates/areaPack/pc/page_order.html
  12. 1 1
      src/web/templates/frontRouter/pc/dataFile/sess/orderDetail.html
  13. 1 1
      src/web/templates/order/pc/bidfile/bidfileDetail.html
  14. 1 1
      src/web/templates/order/pc/buyerPortraitPack/detail.html
  15. 1 1
      src/web/templates/order/pc/datareport/detail.html
  16. 1 1
      src/web/templates/order/pc/filePack/detail.html
  17. 1 1
      src/web/templates/order/pc/integral/integralDetail.html
  18. 1 1
      src/web/templates/pc/aiPack_orderDetail.html
  19. 3 3
      src/web/templates/pc/check_invoice.html
  20. 1 1
      src/web/templates/pc/dataPack/packDetail.html
  21. 1 1
      src/web/templates/pc/entniche_orderDetail.html
  22. 115 30
      src/web/templates/pc/invoice.html
  23. 1 1
      src/web/templates/pc/medaratus_orderDetail.html
  24. 1 6
      src/web/templates/pc/member_orderDetail.html
  25. 3 3
      src/web/templates/pc/myOrder.html
  26. 1 0
      src/web/templates/pc/newIndex.html
  27. 2 2
      src/web/templates/pc/orderDetail.html
  28. 1 1
      src/web/templates/pc/subAccount_orderDetail.html
  29. 62 2
      src/web/templates/pc/tags/detail.html
  30. 2 0
      src/web/templates/pc/tags/index.html
  31. 3 2
      src/web/templates/pc/tags/template/bottom-banner.html
  32. 1 1
      src/web/templates/pc/vip_orderDetail.html

+ 7 - 5
src/jfw/front/dataExport.go

@@ -351,11 +351,12 @@ func IsAllowInvoice(res map[string]interface{}) bool {
 	filter := util.ObjToString(res["filter"].(string))
 	filter_map := map[string]interface{}{}
 	_ = json.Unmarshal([]byte(filter), &filter_map)
-	if res["order_status"] == 1 && filter_map["badge"] != "exchange" &&
+	if util.IntAll(res["order_status"]) == 1 && util.InterfaceToStr(filter_map["badge"]) != "exchange" &&
 		//用户下单|| 代用户下单|| qmx下单 已全额回款 发票企业为剑鱼
-		(res["is_backstage_order"] == 0 || res["order_channel"] == "xdqd04" || (res["return_status"] == 1 && public.Mysql.Count("invoice", map[string]interface{}{
-			"order_code": res["order_code"],
-		}) == 0 && res["signing_subject"] == "北京剑鱼信息技术有限公司")) {
+		(util.IntAll(res["is_backstage_order"]) == 0 || util.InterfaceToStr(res["order_channel"]) == "xdqd04" ||
+			(util.IntAll(res["return_status"]) == 1 && public.Mysql.Count("invoice", map[string]interface{}{
+				"order_code": res["order_code"],
+			}) == 0 && util.InterfaceToStr(res["signing_subject"]) == "北京剑鱼信息技术有限公司")) {
 		return true
 	}
 	return false
@@ -992,10 +993,11 @@ func (d *DataExport) Invoice(order_code string) error {
 	res := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
 		"user_id":    userid,
 		"order_code": order_code,
-	}, "user_mail,user_phone", "create_time desc")
+	}, "user_mail,user_phone,company_name", "create_time desc")
 	if *res != nil {
 		d.T["mail"] = (*res)["user_mail"]
 		d.T["phone"] = (*res)["user_phone"]
+		d.T["company_name"] = (*res)["company_name"]
 	}
 	if public.Mysql.CountBySql("select count(1) as count from dataexport_order where user_id = ? and order_code = ? and order_status = ?", userid, order_code, 1) > 0 {
 		return d.Render("/pc/invoice.html", &d.T)

+ 3 - 1
src/jfw/modules/subscribepay/src/config.json

@@ -200,7 +200,9 @@
       "tid": "04"
     },
     "saleDep": {
-      "040000": true
+      "040000": true,
+      "040100": true,
+      "040200": true
     }
   },
   "payRaffle": {

+ 7 - 7
src/jfw/modules/subscribepay/src/entity/equityActive.go

@@ -39,7 +39,7 @@ var equityStockLock = sync.Mutex{} // 赠送视频权益码库存锁
 type EquityActive struct {
 	UserId           string // id 这边取到的id可能是职位id也可能是mongo库id
 	mgoId            string // mongo库id
-	positionId       string // 职位id
+	positionId       int    // 职位id
 	Phone            string // 手机号 用于发短信
 	OrderCode        string // 订单号
 	OrderType        int    // 1购买 2升级 3续费
@@ -203,7 +203,7 @@ func (e *EquityActive) setUserID() {
 	if info != nil && len(*info) > 0 {
 		log.Println("equityActive 获取到redis保存的用户身份信息:", orderKey, info)
 		e.mgoId = common.ObjToString((*info)["mgoId"])
-		e.positionId = fmt.Sprintf("%v", common.IntAll((*info)["positionId"]))
+		e.positionId = common.IntAll((*info)["positionId"])
 		phone = common.ObjToString((*info)["phone"])
 	}
 	if phone != "" {
@@ -229,7 +229,7 @@ func (e *EquityActive) setUserIDPayRaffle() {
 	if info != nil && len(*info) > 0 {
 		log.Println("PayRaffle 获取到redis保存的用户身份信息:", orderKey, info)
 		e.mgoId = common.ObjToString((*info)["mgoId"])
-		e.positionId = fmt.Sprintf("%v", common.IntAll((*info)["positionId"]))
+		e.positionId = common.IntAll((*info)["positionId"])
 		phone = common.ObjToString((*info)["phone"])
 	}
 	if phone != "" {
@@ -272,7 +272,7 @@ func (e *EquityActive) sendVipMsg(eName, code, ex_end_time string) {
 	// 发送站内信
 	p := util.MessageParam{
 		UserIds:     e.mgoId,
-		PositionIds: e.positionId,
+		PositionIds: fmt.Sprintf("%v", e.positionId),
 		Title:       fmt.Sprintf(siteMsg.Title, eName),
 		Content:     fmt.Sprintf(siteMsg.Content, e.ProductType, eName, code, ex_end_time, e.ProductType, eName, code),
 		MsgType:     siteMsg.MsgType,
@@ -309,7 +309,7 @@ func (e *EquityActive) isYearVip() bool {
 // SendPayRaffleMsg 支付成后发送抽奖消息
 func (e *EquityActive) SendPayRaffleMsg() {
 	// 获取用户id
-	e.setUserIDPayRaffle()
+	e.setUserID()
 	if e.mgoId == "" {
 		log.Println("SendPayRaffleMsg 未获取到有效的mgoId", e.OrderCode)
 		return
@@ -331,7 +331,7 @@ func (e *EquityActive) SendPayRaffleMsg() {
 	prizeOrder := map[string]interface{}{
 		"active_id":   activityInfo.ActivityId,
 		"phone":       e.Phone,
-		"position_id": e.positionId,
+		"position_id": common.If(e.positionId>0,e.positionId,nil),
 		"mgo_user_id": e.mgoId,
 		"order_code":  e.OrderCode,
 		"create_time": date.NowFormat(date.Date_Full_Layout),
@@ -352,7 +352,7 @@ func (e *EquityActive) SendPayRaffleMsg() {
 	// 发送站内信
 	p := util.MessageParam{
 		UserIds:     e.mgoId,
-		PositionIds: e.positionId,
+		PositionIds: fmt.Sprintf("%v", e.positionId),
 		Title:       siteMsg.Title,
 		Content:     fmt.Sprintf(siteMsg.Content, activityInfo.Name),
 		MsgType:     siteMsg.MsgType,

+ 1 - 1
src/jfw/modules/subscribepay/src/invoice.json

@@ -10,7 +10,7 @@
     "time":"2022-01-17 10:00:00"
   },
   "invoice_switch": true,
-  "red_invoice_switch": false,
+  "red_invoice_switch": true,
   "red_invoice_msg": "由于系统升级,线上换开发票功能暂时维护阶段,如需换开请直接联系在线客服!",
   "third_party_switch": false,
   "order_createtime": 1704038400,

+ 1693 - 1686
src/jfw/modules/subscribepay/src/service/invoice.go

@@ -1,65 +1,65 @@
 package service
 
 import (
-    . "app.yhyue.com/moapp/jybase/api"
-    qutil "app.yhyue.com/moapp/jybase/common"
-    . "app.yhyue.com/moapp/jybase/date"
-    "app.yhyue.com/moapp/jybase/encrypt"
-    "app.yhyue.com/moapp/jybase/go-xweb/log"
-    "app.yhyue.com/moapp/jybase/go-xweb/xweb"
-    "app.yhyue.com/moapp/jybase/mail"
-    "bytes"
-    "database/sql"
-    "encoding/json"
-    "errors"
-    "fmt"
-    "github.com/google/uuid"
-    "io/ioutil"
-    "jy/src/jfw/modules/subscribepay/src/config"
-    "jy/src/jfw/modules/subscribepay/src/util"
-    "net/http"
-    "os"
-    "strconv"
-    "strings"
-    "sync"
-    "time"
+	. "app.yhyue.com/moapp/jybase/api"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	. "app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/go-xweb/log"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/mail"
+	"bytes"
+	"database/sql"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"github.com/google/uuid"
+	"io/ioutil"
+	"jy/src/jfw/modules/subscribepay/src/config"
+	"jy/src/jfw/modules/subscribepay/src/util"
+	"net/http"
+	"os"
+	"strconv"
+	"strings"
+	"sync"
+	"time"
 )
 
 type Invoice struct {
-    *xweb.Action
-    addinvoice        xweb.Mapper `xweb:"/invoice/add"`            //开发票
-    showinvoice       xweb.Mapper `xweb:"/invoice/show"`           //查看发票
-    newInvoiceShow    xweb.Mapper `xweb:"/invoice/newShow"`        //查看发票
-    showinvoiceList   xweb.Mapper `xweb:"/invoice/showList"`       //新查看发票 p537
-    callbackinvoice   xweb.Mapper `xweb:"/invoice/callback"`       //开发票回调
-    replaceinvoice    xweb.Mapper `xweb:"/invoice/replace"`        //换发票
-    newReplaceinvoice xweb.Mapper `xweb:"/invoice/newReplace"`     //新换发票
-    refundinvoice     xweb.Mapper `xweb:"/invoice/refund"`         //退票
-    invoiceinfo       xweb.Mapper `xweb:"/invoice/info"`           //订单详情数据
-    available         xweb.Mapper `xweb:"/invoice/available"`      //是否可用开发票
-    invoiceswitch     xweb.Mapper `xweb:"/invoice/switch"`         //发票开关
-    invoiceQuery      xweb.Mapper `xweb:"/invoice/query"`          //发票信息查询
-    invoiceSubmit     xweb.Mapper `xweb:"/invoice/submit"`         //发票信息提交
-    getCompanyCode    xweb.Mapper `xweb:"/invoice/getCompanyCode"` //开票联想税号
+	*xweb.Action
+	addinvoice        xweb.Mapper `xweb:"/invoice/add"`            //开发票
+	showinvoice       xweb.Mapper `xweb:"/invoice/show"`           //查看发票
+	newInvoiceShow    xweb.Mapper `xweb:"/invoice/newShow"`        //查看发票
+	showinvoiceList   xweb.Mapper `xweb:"/invoice/showList"`       //新查看发票 p537
+	callbackinvoice   xweb.Mapper `xweb:"/invoice/callback"`       //开发票回调
+	replaceinvoice    xweb.Mapper `xweb:"/invoice/replace"`        //换发票
+	newReplaceinvoice xweb.Mapper `xweb:"/invoice/newReplace"`     //新换发票
+	refundinvoice     xweb.Mapper `xweb:"/invoice/refund"`         //退票
+	invoiceinfo       xweb.Mapper `xweb:"/invoice/info"`           //订单详情数据
+	available         xweb.Mapper `xweb:"/invoice/available"`      //是否可用开发票
+	invoiceswitch     xweb.Mapper `xweb:"/invoice/switch"`         //发票开关
+	invoiceQuery      xweb.Mapper `xweb:"/invoice/query"`          //发票信息查询
+	invoiceSubmit     xweb.Mapper `xweb:"/invoice/submit"`         //发票信息提交
+	getCompanyCode    xweb.Mapper `xweb:"/invoice/getCompanyCode"` //开票联想税号
 }
 
 var dbname = "invoice"
 
 type ReturnJson map[string]interface{}
 type InvoiceInfo struct {
-    code int                    `json:"code"`
-    msg  string                 `json:"msg"`
-    data map[string]interface{} `json:"data"`
+	code int                    `json:"code"`
+	msg  string                 `json:"msg"`
+	data map[string]interface{} `json:"data"`
 }
 
 // 红票信息
 type RedMsg struct {
-    InvoiceCode      string `json:"invoice_code"`
-    InvoiceNumber    string `json:"invoice_number"`
-    Url              string `json:"url"`
-    InvoiceSerialnum string `json:"invoice_serialnum"`
-    InvoiceStatus    string `json:"invoice_status"`
-    BillingTime      int64  `json:"billing_time"`
+	InvoiceCode      string `json:"invoice_code"`
+	InvoiceNumber    string `json:"invoice_number"`
+	Url              string `json:"url"`
+	InvoiceSerialnum string `json:"invoice_serialnum"`
+	InvoiceStatus    string `json:"invoice_status"`
+	BillingTime      int64  `json:"billing_time"`
 }
 
 var emailHtml_gs = `<p class="item">
@@ -102,1777 +102,1784 @@ var email_format = ""
 var email_format_new = ""
 
 func init() {
-    for i := 0; i < 10; i++ {
-        locks[i] = sync.Mutex{}
-    }
-    r, err := os.Open("./mailtemplate.html")
-    if err != nil {
-        log.Println("err", err)
-    }
-    defer r.Close()
-    bs, _ := ioutil.ReadAll(r)
-    email_format = string(bs)
-    r, err = os.Open("./mailtemplateNew.html")
-    if err != nil {
-        log.Println("err", err)
-    }
-    defer r.Close()
-    bs, _ = ioutil.ReadAll(r)
-    email_format_new = string(bs)
+	for i := 0; i < 10; i++ {
+		locks[i] = sync.Mutex{}
+	}
+	r, err := os.Open("./mailtemplate.html")
+	if err != nil {
+		log.Println("err", err)
+	}
+	defer r.Close()
+	bs, _ := ioutil.ReadAll(r)
+	email_format = string(bs)
+	r, err = os.Open("./mailtemplateNew.html")
+	if err != nil {
+		log.Println("err", err)
+	}
+	defer r.Close()
+	bs, _ = ioutil.ReadAll(r)
+	email_format_new = string(bs)
 }
 
 func (this *Invoice) Invoiceswitch() {
-    if config.InvoiceConfig.Invoice_switch {
-        this.ServeJson(map[string]interface{}{
-            "code": "1000",
-        })
-    } else {
-        //更新数据 用于回显
-        userId := qutil.ObjToString(this.GetSession("userId"))
-        order_code := this.GetString("order_code")
-        applyBill_company := this.GetString("company")
-        //获取数据
-        applyBill_type := this.GetString("invoice_type") //个人 单位
-        my_email := this.GetString("email")
-        phone_num := this.GetString("phone_num")
-        code := strings.ToUpper(this.GetString("id_num")) //纳税人识别号
-        data := make(map[string]interface{})
-        dataexport_data := make(map[string]interface{})
-        if userId != "" && my_email != "" && phone_num != "" && order_code != "" {
-            if applyBill_type == "个人" {
-                data["taxpayer_identnum"] = ""
-                data["company_name"] = ""
-                dataexport_data["applyBill_type"] = 0
-                dataexport_data["applyBill_taxnum"] = ""
-                dataexport_data["applybill_company"] = ""
-            } else {
-                data["taxpayer_identnum"] = code
-                data["company_name"] = applyBill_company
-                dataexport_data["applyBill_taxnum"] = code
-                dataexport_data["applybill_company"] = applyBill_company
-                dataexport_data["applyBill_type"] = 1
-            }
-            dataexport_data["user_mail"] = my_email
-            dataexport_data["user_phone"] = phone_num
-            data["order_code"] = order_code
-            data["mail"] = my_email
-            data["phone"] = phone_num
-            data["invoice_type"] = applyBill_type
-            data["create_time"] = time.Now().Unix()
-            data["user_id"] = userId
-            status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
-            if len(*status) <= 0 {
-                //更新 "order_status,applybill_status,order_code,user_mail,applybill_type,applybill_company,user_phone,applybill_taxnum"
-                util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId}, dataexport_data)
-            } else {
-                req := map[string]interface{}{
-                    "order_code":      order_code,
-                    "user_id":         userId,
-                    "invoice_changed": 0,
-                }
-                if len(*status) > 1 {
-                    req["id"] = (*status)[1]["id"]
-                } else {
-                    req["id"] = (*status)[0]["id"]
-                }
-                util.Mysql.Update(dbname, req, data)
-            }
-        }
-        this.ServeJson(map[string]interface{}{
-            "code":   "1001",
-            "messge": "因第三方发票系统升级,开发票功能暂停使用。如有疑问,请咨询客服400-108-6670",
-        })
-    }
+	if config.InvoiceConfig.Invoice_switch {
+		this.ServeJson(map[string]interface{}{
+			"code": "1000",
+		})
+	} else {
+		//更新数据 用于回显
+		userId := qutil.ObjToString(this.GetSession("userId"))
+		order_code := this.GetString("order_code")
+		applyBill_company := this.GetString("company")
+		//获取数据
+		applyBill_type := this.GetString("invoice_type") //个人 单位
+		my_email := this.GetString("email")
+		phone_num := this.GetString("phone_num")
+		code := strings.ToUpper(this.GetString("id_num")) //纳税人识别号
+		data := make(map[string]interface{})
+		dataexport_data := make(map[string]interface{})
+		if userId != "" && my_email != "" && phone_num != "" && order_code != "" {
+			if applyBill_type == "个人" {
+				data["taxpayer_identnum"] = ""
+				data["company_name"] = ""
+				dataexport_data["applyBill_type"] = 0
+				dataexport_data["applyBill_taxnum"] = ""
+				dataexport_data["applybill_company"] = ""
+			} else {
+				data["taxpayer_identnum"] = code
+				data["company_name"] = applyBill_company
+				dataexport_data["applyBill_taxnum"] = code
+				dataexport_data["applybill_company"] = applyBill_company
+				dataexport_data["applyBill_type"] = 1
+			}
+			dataexport_data["user_mail"] = my_email
+			dataexport_data["user_phone"] = phone_num
+			data["order_code"] = order_code
+			data["mail"] = my_email
+			data["phone"] = phone_num
+			data["invoice_type"] = applyBill_type
+			data["create_time"] = time.Now().Unix()
+			data["user_id"] = userId
+			status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
+			if len(*status) <= 0 {
+				//更新 "order_status,applybill_status,order_code,user_mail,applybill_type,applybill_company,user_phone,applybill_taxnum"
+				util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId}, dataexport_data)
+			} else {
+				req := map[string]interface{}{
+					"order_code":      order_code,
+					"user_id":         userId,
+					"invoice_changed": 0,
+				}
+				if len(*status) > 1 {
+					req["id"] = (*status)[1]["id"]
+				} else {
+					req["id"] = (*status)[0]["id"]
+				}
+				util.Mysql.Update(dbname, req, data)
+			}
+		}
+		this.ServeJson(map[string]interface{}{
+			"code":   "1001",
+			"messge": "因第三方发票系统升级,开发票功能暂停使用。如有疑问,请咨询客服400-108-6670",
+		})
+	}
 }
 
 // Addinvoice 用户端-线上开票只能选电子普票
 func (this *Invoice) Addinvoice() error {
-    defer qutil.Catch()
-    userId := qutil.ObjToString(this.GetSession("userId"))
-    var applyBill_status int
-    var order_code, applyBill_company, applyBill_type, price, product_name string
-    order_code = this.GetString("order_code")
-    applyBill_company = this.GetString("company")
-    //获取数据
-    applyBill_type = this.GetString("invoice_type") //个人 单位
-    my_email := this.GetString("email")
-    phone_num := this.GetString("phone_num")
-    code := strings.ToUpper(this.GetString("id_num")) //纳税人识别号
-    isSys, _ := this.GetBool("isSys")
-    jsonData := ReturnJson{}
-    invoice_status := -1   //发票表开票失败
-    updata_status := false //更新表状态
-    if userId != "" && my_email != "" && phone_num != "" && order_code != "" {
-        last := order_code[len([]rune(order_code))-1:]
-        pos := qutil.IntAllDef(last, 0)
-        locks[pos].Lock()
-        defer locks[pos].Unlock()
-        u := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId, "applyBill_status": map[string]interface{}{"ne": 2}}, "order_money,product_type,pay_way,pay_money,is_backstage_order,billingMode,signing_subject,return_status,applybill_status", "")
-        if u != nil {
-            //后端代用户下单支持开票 order_channel = xdqd04
-            if qutil.IntAll((*u)["billingMode"]) == 1 && (qutil.IntAll((*u)["is_backstage_order"]) != 1 || (qutil.IntAll((*u)["is_backstage_order"]) == 1 && qutil.ObjToString((*u)["signing_subject"]) == "h01" && qutil.IntAll((*u)["return_status"]) == 1 && qutil.IntAll((*u)["applybill_status"]) == 0)) {
-                var prices float64
-                //公对公转账 账单金额可以修改 开发票应取实付金额 pay_money
-                //微信支付宝支付 pay_money为订单金额减去微信or支付包红包
-                prices = qutil.Float64All((*u)["pay_money"]) / float64(100)
-                price = strconv.FormatFloat(prices, 'f', -1, 64)
-                product_name = (*u)["product_type"].(string)
-                applyBill_status = 1
-                data := make(map[string]interface{})
-                dataexport_data := make(map[string]interface{})
-                dataexport_data["applyBill_status"] = applyBill_status
-                if applyBill_type == "个人" {
-                    dataexport_data["applyBill_type"] = 0
-                    data["taxpayer_identnum"] = ""
-                    data["company_name"] = ""
-                    dataexport_data["applyBill_taxnum"] = ""
-                    dataexport_data["applybill_company"] = ""
-                } else {
-                    data["taxpayer_identnum"] = code
-                    data["company_name"] = applyBill_company
-                    dataexport_data["applyBill_taxnum"] = code
-                    dataexport_data["applybill_company"] = applyBill_company
-                    dataexport_data["applyBill_type"] = 1
-                }
-                dataexport_data["user_mail"] = my_email
-                data["product_type"] = product_name
-                data["order_code"] = order_code
-                data["mail"] = my_email
-                data["phone"] = phone_num
-                data["invoice_type"] = applyBill_type
-                data["invoice_changed"] = 0
-                data["create_time"] = time.Now().Unix()
-                data["user_id"] = userId
-                data["invoice_status"] = 0
-                data["invoice_money"] = price
-                var orders = []map[string]interface{}{}
-                var items = []map[string]interface{}{}
-                item := map[string]interface{}{
-                    "name":        product_name,
-                    "code":        config.InvoiceConfig.Code,
-                    "yhzcbs":      config.InvoiceConfig.Tax_policy,
-                    "lineType":    config.InvoiceConfig.Invoice_nature,
-                    "taxRate":     config.InvoiceConfig.Tax_rate,
-                    "taxPrice":    price,
-                    "totalAmount": price,
-                    "quantity":    "1",
-                }
-                items = append(items, item)
-                order := map[string]interface{}{
-                    "billNo": order_code,
-                    "items":  items,
-                }
-                orders = append(orders, order)
-                client := &http.Client{}
-                body := map[string]interface{}{
-                    "Swno":      order_code,
-                    "custType":  "03",
-                    "orders":    orders,
-                    "custTaxNo": code,
-                    "phone":     phone_num,
-                    "billDate":  NowFormat(Date_Full_Layout), //单据日期  格式:yyyy-MM-dd HH:mm:ss
-                }
+	defer qutil.Catch()
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	var applyBill_status int
+	var order_code, applyBill_company, applyBill_type, price, product_name string
+	order_code = this.GetString("order_code")
+	applyBill_company = this.GetString("company")
+	//获取数据
+	applyBill_type = this.GetString("invoice_type") //个人 单位
+	my_email := this.GetString("email")
+	phone_num := this.GetString("phone_num")
+	code := strings.ToUpper(this.GetString("id_num")) //纳税人识别号
+	isSys, _ := this.GetBool("isSys")
+	jsonData := ReturnJson{}
+	invoice_status := -1   //发票表开票失败
+	updata_status := false //更新表状态
+	if userId != "" && my_email != "" && phone_num != "" && order_code != "" {
+		last := order_code[len([]rune(order_code))-1:]
+		pos := qutil.IntAllDef(last, 0)
+		locks[pos].Lock()
+		defer locks[pos].Unlock()
+		u := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId, "applyBill_status": map[string]interface{}{"ne": 2}}, "order_money,product_type,pay_way,pay_money,is_backstage_order,billingMode,signing_subject,return_status,applybill_status", "")
+		if u != nil {
+			//后端代用户下单支持开票 order_channel = xdqd04
+			if qutil.IntAll((*u)["billingMode"]) == 1 && (qutil.IntAll((*u)["is_backstage_order"]) != 1 || (qutil.IntAll((*u)["is_backstage_order"]) == 1 && qutil.ObjToString((*u)["signing_subject"]) == "h01" && qutil.IntAll((*u)["return_status"]) == 1 && qutil.IntAll((*u)["applybill_status"]) == 0)) {
+				var prices float64
+				//公对公转账 账单金额可以修改 开发票应取实付金额 pay_money
+				//微信支付宝支付 pay_money为订单金额减去微信or支付包红包
+				prices = qutil.Float64All((*u)["pay_money"]) / float64(100)
+				price = strconv.FormatFloat(prices, 'f', -1, 64)
+				product_name = (*u)["product_type"].(string)
+				applyBill_status = 1
+				data := make(map[string]interface{})
+				dataexport_data := make(map[string]interface{})
+				dataexport_data["applyBill_status"] = applyBill_status
+				if applyBill_type == "个人" {
+					dataexport_data["applyBill_type"] = 0
+					data["taxpayer_identnum"] = ""
+					data["company_name"] = ""
+					dataexport_data["applyBill_taxnum"] = ""
+					dataexport_data["applybill_company"] = ""
+				} else {
+					data["taxpayer_identnum"] = code
+					data["company_name"] = applyBill_company
+					dataexport_data["applyBill_taxnum"] = code
+					dataexport_data["applybill_company"] = applyBill_company
+					dataexport_data["applyBill_type"] = 1
+				}
+				dataexport_data["user_mail"] = my_email
+				data["product_type"] = product_name
+				data["order_code"] = order_code
+				data["mail"] = my_email
+				data["phone"] = phone_num
+				data["invoice_type"] = applyBill_type
+				data["invoice_changed"] = 0
+				data["create_time"] = time.Now().Unix()
+				data["user_id"] = userId
+				data["invoice_status"] = 0
+				data["invoice_money"] = price
+				var orders = []map[string]interface{}{}
+				var items = []map[string]interface{}{}
+				item := map[string]interface{}{
+					"name":        product_name,
+					"code":        config.InvoiceConfig.Code,
+					"yhzcbs":      config.InvoiceConfig.Tax_policy,
+					"lineType":    config.InvoiceConfig.Invoice_nature,
+					"taxRate":     config.InvoiceConfig.Tax_rate,
+					"taxPrice":    price,
+					"totalAmount": price,
+					"quantity":    "1",
+				}
+				items = append(items, item)
+				order := map[string]interface{}{
+					"billNo": order_code,
+					"items":  items,
+				}
+				orders = append(orders, order)
+				client := &http.Client{}
+				body := map[string]interface{}{
+					"Swno":      order_code,
+					"custType":  "03",
+					"orders":    orders,
+					"custTaxNo": code,
+					"phone":     phone_num,
+					"billDate":  NowFormat(Date_Full_Layout), //单据日期  格式:yyyy-MM-dd HH:mm:ss
+				}
 
-                if applyBill_type == "单位" {
-                    body["custName"] = applyBill_company
-                } else {
-                    body["custName"] = applyBill_type
-                }
-                //发送请求之前插入数据,防止请求时间过长
-                if !isSys {
-                    status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
-                    if len(*status) > 0 {
-                        return nil
-                    }
-                    if i := util.Mysql.Insert(dbname, data); i > 0 {
-                        invoice_status = 0
-                    }
-                    if !util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId}, dataexport_data) {
-                        invoice_status = -1
-                    }
-                } else {
-                    if ok := util.Mysql.Update(dbname, map[string]interface{}{
-                        "order_code":      order_code,
-                        "user_id":         userId,
-                        "invoice_changed": 0,
-                    }, data); ok {
-                        invoice_status = 0
-                    }
-                }
-                if config.InvoiceConfig.Third_party_switch {
-                    b, _ := json.Marshal(body)
-                    buffer := bytes.NewBuffer(b)
-                    request, _ := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/Add", buffer)
-                    response, err := client.Do(request)
-                    if err == nil {
-                        res, err := ioutil.ReadAll(response.Body)
-                        if err != nil {
-                            invoice_status = -1
-                        } else {
-                            resMap := qutil.ObjToMap(string(res))
-                            if *resMap != nil {
-                                if qutil.IntAll((*resMap)["code"]) == 0 { //开票成功
-                                    invoice_status = 1
-                                    jsonData["invoice_status"] = invoice_status
-                                } else if qutil.IntAll((*resMap)["code"]) == 2 { //开票中
-                                    // log.Println("开票中")
-                                    invoice_status = 0
-                                    jsonData["invoice_status"] = invoice_status
-                                } else { //开票失败
-                                    // log.Println("开票失败")
-                                    invoice_status = -1
-                                    jsonData["invoice_status"] = invoice_status
-                                }
-                            }
-                            defer response.Body.Close()
-                            resData := (*resMap)["data"].(map[string]interface{})
-                            update_status := util.Mysql.Update(dbname, map[string]interface{}{"order_code": order_code}, map[string]interface{}{
-                                "invoice_serialnum": resData["swno"],
-                                "invoice_code":      resData["fpdm"],
-                                "invoice_number":    resData["fphm"],
-                                "url":               resData["path"],
-                                "invoice_status":    invoice_status,
-                            })
-                            if !update_status {
-                                log.Println("order_ocde:", order_code+"update fail")
-                            }
-                        }
-                    }
-                }
-            }
-        } else {
-            if invoice_status != 1 {
-                log.Println("invoice err:", "updata_status:", updata_status, "order_code:", order_code, "invoice_status:", invoice_status, userId)
-            }
-        }
-    }
-    jsonData["invoice_status"] = invoice_status
-    this.ServeJson(jsonData)
-    return nil
+				if applyBill_type == "单位" {
+					body["custName"] = applyBill_company
+				} else {
+					body["custName"] = applyBill_type
+				}
+				//发送请求之前插入数据,防止请求时间过长
+				if !isSys {
+					status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
+					if len(*status) > 0 {
+						return nil
+					}
+					if i := util.Mysql.Insert(dbname, data); i > 0 {
+						invoice_status = 0
+					}
+					if !util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId}, dataexport_data) {
+						invoice_status = -1
+					}
+				} else {
+					if ok := util.Mysql.Update(dbname, map[string]interface{}{
+						"order_code":      order_code,
+						"user_id":         userId,
+						"invoice_changed": 0,
+					}, data); ok {
+						invoice_status = 0
+					}
+				}
+				if config.InvoiceConfig.Third_party_switch {
+					b, _ := json.Marshal(body)
+					buffer := bytes.NewBuffer(b)
+					request, _ := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/Add", buffer)
+					response, err := client.Do(request)
+					if err == nil {
+						res, err := ioutil.ReadAll(response.Body)
+						if err != nil {
+							invoice_status = -1
+						} else {
+							resMap := qutil.ObjToMap(string(res))
+							if *resMap != nil {
+								if qutil.IntAll((*resMap)["code"]) == 0 { //开票成功
+									invoice_status = 1
+									jsonData["invoice_status"] = invoice_status
+								} else if qutil.IntAll((*resMap)["code"]) == 2 { //开票中
+									// log.Println("开票中")
+									invoice_status = 0
+									jsonData["invoice_status"] = invoice_status
+								} else { //开票失败
+									// log.Println("开票失败")
+									invoice_status = -1
+									jsonData["invoice_status"] = invoice_status
+								}
+							}
+							defer response.Body.Close()
+							resData := (*resMap)["data"].(map[string]interface{})
+							update_status := util.Mysql.Update(dbname, map[string]interface{}{"order_code": order_code}, map[string]interface{}{
+								"invoice_serialnum": resData["swno"],
+								"invoice_code":      resData["fpdm"],
+								"invoice_number":    resData["fphm"],
+								"url":               resData["path"],
+								"invoice_status":    invoice_status,
+							})
+							if !update_status {
+								log.Println("order_ocde:", order_code+"update fail")
+							}
+						}
+					}
+				}
+			}
+		} else {
+			if invoice_status != 1 {
+				log.Println("invoice err:", "updata_status:", updata_status, "order_code:", order_code, "invoice_status:", invoice_status, userId)
+			}
+		}
+	}
+	jsonData["invoice_status"] = invoice_status
+	this.ServeJson(jsonData)
+	return nil
 }
 
 // 查看发票
 func (this *Invoice) Showinvoice() {
-    order_code := this.GetString("order_code")
-    data := make(map[string]interface{})
-    data["order_code"] = order_code
-    status := util.Mysql.Find(dbname, data, "", "create_time", 0, 0)
-    //红冲发票开关
-    redSwitchInfo := map[string]interface{}{
-        "ris": config.InvoiceConfig.Red_invoice_switch,
-        "rim": config.InvoiceConfig.Red_invoice_msg,
-    }
-    if status != nil && len(*status) != 0 {
-        count := len(*status)
-        data := (*status)[count-1]
-        if data != nil {
-            delete(data, "user_id")
-            if url := qutil.InterfaceToStr(data["url"]); url != "" {
-                //ios 移动端
-                if util.IsMobileIOS(this.Request.UserAgent()) {
-                    //国家税务局-增值税电子发票公共服务平台
-                    if strings.Contains(url, "tysl.beijing.chinatax") {
-                        data["url"] = strings.ReplaceAll(url, "/preview.html?code=", "/web-reader/reader?file=")
-                    }
-                }
-                this.ServeJson(map[string]interface{}{
-                    "status":        "success",
-                    "changed":       qutil.If(count > 1, true, false).(bool),
-                    "data":          data,
-                    "redSwitchInfo": redSwitchInfo,
-                })
-            } else {
-                this.ServeJson(map[string]interface{}{
-                    "status":        "processing",
-                    "changed":       qutil.If(count > 1, true, false).(bool),
-                    "data":          data,
-                    "redSwitchInfo": redSwitchInfo,
-                })
-            }
-        } else {
-            this.ServeJson(map[string]interface{}{
-                "status":        "fail",
-                "changed":       false,
-                "data":          "",
-                "redSwitchInfo": redSwitchInfo,
-            })
-        }
-        //if len(*status) > 1 {
-        //	if (*status)[1]["url"] != nil && (*status)[1]["url"] != "" {
-        //		this.ServeJson(map[string]interface{}{
-        //			"status":        "success",
-        //			"changed":       true,
-        //			"data":          (*status)[1],
-        //			"redSwitchInfo": redSwitchInfo,
-        //		})
-        //	} else {
-        //		this.ServeJson(map[string]interface{}{
-        //			"status":        "processing",
-        //			"changed":       true,
-        //			"data":          (*status)[1],
-        //			"redSwitchInfo": redSwitchInfo,
-        //		})
-        //	}
-        //} else {
-        //	if (*status)[0]["url"] != nil && (*status)[0]["url"] != "" {
-        //		this.ServeJson(map[string]interface{}{
-        //			"status":        "success",
-        //			"changed":       false,
-        //			"data":          (*status)[0],
-        //			"redSwitchInfo": redSwitchInfo,
-        //		})
-        //	} else {
-        //		this.ServeJson(map[string]interface{}{
-        //			"status":        "processing",
-        //			"changed":       false,
-        //			"data":          (*status)[0],
-        //			"redSwitchInfo": redSwitchInfo,
-        //		})
-        //	}
-        //}
-    } else {
-        datas := util.Mysql.FindOne("dataexport_order", data, "order_status,applybill_status,order_code,user_mail,applybill_type,applybill_company,user_phone,applybill_taxnum", "")
-        this.ServeJson(map[string]interface{}{
-            "status":        "fail",
-            "data":          "",
-            "datas":         datas,
-            "redSwitchInfo": redSwitchInfo,
-        })
-    }
+	order_code := this.GetString("order_code")
+	data := make(map[string]interface{})
+	data["order_code"] = order_code
+	status := util.Mysql.Find(dbname, data, "", "create_time", 0, 0)
+	//红冲发票开关
+	redSwitchInfo := map[string]interface{}{
+		"ris": config.InvoiceConfig.Red_invoice_switch,
+		"rim": config.InvoiceConfig.Red_invoice_msg,
+	}
+	if status != nil && len(*status) != 0 {
+		count := len(*status)
+		data := (*status)[count-1]
+		if data != nil {
+			delete(data, "user_id")
+			if url := qutil.InterfaceToStr(data["url"]); url != "" {
+				//ios 移动端
+				if util.IsMobileIOS(this.Request.UserAgent()) {
+					//国家税务局-增值税电子发票公共服务平台
+					if strings.Contains(url, "tysl.beijing.chinatax") {
+						data["url"] = strings.ReplaceAll(url, "/preview.html?code=", "/web-reader/reader?file=")
+					}
+				}
+				this.ServeJson(map[string]interface{}{
+					"status":        "success",
+					"changed":       qutil.If(count > 1, true, false).(bool),
+					"data":          data,
+					"redSwitchInfo": redSwitchInfo,
+				})
+			} else {
+				this.ServeJson(map[string]interface{}{
+					"status":        "processing",
+					"changed":       qutil.If(count > 1, true, false).(bool),
+					"data":          data,
+					"redSwitchInfo": redSwitchInfo,
+				})
+			}
+		} else {
+			this.ServeJson(map[string]interface{}{
+				"status":        "fail",
+				"changed":       false,
+				"data":          "",
+				"redSwitchInfo": redSwitchInfo,
+			})
+		}
+		//if len(*status) > 1 {
+		//	if (*status)[1]["url"] != nil && (*status)[1]["url"] != "" {
+		//		this.ServeJson(map[string]interface{}{
+		//			"status":        "success",
+		//			"changed":       true,
+		//			"data":          (*status)[1],
+		//			"redSwitchInfo": redSwitchInfo,
+		//		})
+		//	} else {
+		//		this.ServeJson(map[string]interface{}{
+		//			"status":        "processing",
+		//			"changed":       true,
+		//			"data":          (*status)[1],
+		//			"redSwitchInfo": redSwitchInfo,
+		//		})
+		//	}
+		//} else {
+		//	if (*status)[0]["url"] != nil && (*status)[0]["url"] != "" {
+		//		this.ServeJson(map[string]interface{}{
+		//			"status":        "success",
+		//			"changed":       false,
+		//			"data":          (*status)[0],
+		//			"redSwitchInfo": redSwitchInfo,
+		//		})
+		//	} else {
+		//		this.ServeJson(map[string]interface{}{
+		//			"status":        "processing",
+		//			"changed":       false,
+		//			"data":          (*status)[0],
+		//			"redSwitchInfo": redSwitchInfo,
+		//		})
+		//	}
+		//}
+	} else {
+		datas := util.Mysql.FindOne("dataexport_order", data, "order_status,applybill_status,order_code,user_mail,applybill_type,applybill_company,user_phone,applybill_taxnum", "")
+		this.ServeJson(map[string]interface{}{
+			"status":        "fail",
+			"data":          "",
+			"datas":         datas,
+			"redSwitchInfo": redSwitchInfo,
+		})
+	}
 
 }
 
 // 查看发票
 func (this *Invoice) ShowinvoiceList() {
-    order_code := this.GetString("order_code")
-    //红冲发票开关
-    redSwitchInfo := map[string]interface{}{
-        "ris": config.InvoiceConfig.Red_invoice_switch,
-        "rim": config.InvoiceConfig.Red_invoice_msg,
-    }
-    invoices := ShowList(order_code)
-    if invoices != nil && len(invoices) > 0 {
-        //isIos := util.IsMobileIOS(this.Request.UserAgent())
-        var invoiceData []map[string]interface{}
-        for _, data := range invoices {
-            //是否换过票
-            isChanged := qutil.IntAll(data["isChanged"]) > 1
-            if isChanged && data["invoice_changed"] == 0 { //换过票的 只展示换票后的数据
-                continue
-            }
-            delete(data, "user_id")
-            data["id"] = encrypt.SE.Encode2Hex(qutil.InterfaceToStr(data["id"]))
-            timeLimit := qutil.Int64All(data["create_time"]) <= config.InvoiceConfig.Order_createtime //24年之前的发票不让换票
-            isJyInvoice := !strings.Contains(qutil.InterfaceToStr(data["url"]), "/jyInvoice/")        //非数电票
-            isJyEntity := data["invoicing_entity"] != nil && qutil.InterfaceToStr(data["invoicing_entity"]) != config.InvoiceConfig.SigningSubject
-            data["changed"] = qutil.If(isJyInvoice || isChanged || isJyEntity || timeLimit, true, false)
-            //if url := qutil.InterfaceToStr(data["url"]); url != "" {
-            //	//ios 移动端
-            //	if isIos {
-            //		//国家税务局-增值税电子发票公共服务平台
-            //		if strings.Contains(url, "tysl.beijing.chinatax") {
-            //			data["url"] = strings.ReplaceAll(url, "/preview.html?code=", "/web-reader/reader?file=")
-            //		}
-            //	}
-            //}
-            isReopen := timeLimit
-            //var isReopen bool
-            if data["invoice_status"] == -1 && !isReopen {
-                isReopen = util.Mysql.Count("invoice_fail_record", map[string]interface{}{
-                    "only_Identifying": data["only_Identifying"],
-                    "order_code":       order_code,
-                })+1 >= config.InvoiceConfig.SubmitNum
-            }
-            data["isReopen"] = isReopen
-            invoiceData = append(invoiceData, data)
-        }
-        this.ServeJson(map[string]interface{}{
-            "status":        "success",
-            "invoiceData":   invoiceData,
-            "redSwitchInfo": redSwitchInfo,
-        })
-    } else {
-        data := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
-            "order_code": order_code,
-        }, "order_status,applybill_status,order_code,user_mail,applybill_type,applybill_company,user_phone,applybill_taxnum", "")
-        if data != nil {
-            (*data)["status"] = "fail"
-        }
+	order_code := this.GetString("order_code")
+	//红冲发票开关
+	redSwitchInfo := map[string]interface{}{
+		"ris": config.InvoiceConfig.Red_invoice_switch,
+		"rim": config.InvoiceConfig.Red_invoice_msg,
+	}
+	invoices := ShowList(order_code)
+	if invoices != nil && len(invoices) > 0 {
+		//isIos := util.IsMobileIOS(this.Request.UserAgent())
+		var invoiceData []map[string]interface{}
+		for _, data := range invoices {
+			//是否换过票
+			isChanged := qutil.IntAll(data["isChanged"]) > 1
+			if isChanged && data["invoice_changed"] == 0 { //换过票的 只展示换票后的数据
+				continue
+			}
+			delete(data, "user_id")
+			data["id"] = encrypt.SE.Encode2Hex(qutil.InterfaceToStr(data["id"]))
+			timeLimit := qutil.Int64All(data["create_time"]) <= config.InvoiceConfig.Order_createtime                                //24年之前的发票不让换票
+			isJyInvoice := !(qutil.InterfaceToStr(data["invoice_number"]) != "" && qutil.InterfaceToStr(data["invoice_code"]) == "") //非数电票
+			isJyEntity := data["invoicing_entity"] != nil && qutil.InterfaceToStr(data["invoicing_entity"]) != config.InvoiceConfig.SigningSubject
+			data["changed"] = qutil.If(isJyInvoice || isChanged || isJyEntity || timeLimit, true, false)
+			//if url := qutil.InterfaceToStr(data["url"]); url != "" {
+			//	//ios 移动端
+			//	if isIos {
+			//		//国家税务局-增值税电子发票公共服务平台
+			//		if strings.Contains(url, "tysl.beijing.chinatax") {
+			//			data["url"] = strings.ReplaceAll(url, "/preview.html?code=", "/web-reader/reader?file=")
+			//		}
+			//	}
+			//}
+			isReopen := timeLimit
+			//var isReopen bool
+			if data["invoice_status"] == -1 && !isReopen {
+				isReopen = util.Mysql.Count("invoice_fail_record", map[string]interface{}{
+					"only_Identifying": data["only_Identifying"],
+					"order_code":       order_code,
+				})+1 >= config.InvoiceConfig.SubmitNum
+			}
+			data["isReopen"] = isReopen
+			invoiceData = append(invoiceData, data)
+		}
+		this.ServeJson(map[string]interface{}{
+			"status":        "success",
+			"invoiceData":   invoiceData,
+			"redSwitchInfo": redSwitchInfo,
+		})
+	} else {
+		data := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
+			"order_code": order_code,
+		}, "order_status,applybill_status,order_code,user_mail,applybill_type,applybill_company,user_phone,applybill_taxnum", "")
+		if data != nil {
+			(*data)["status"] = "fail"
+		}
 
-        this.ServeJson(map[string]interface{}{
-            "status":        "fail",
-            "orderData":     data,
-            "redSwitchInfo": redSwitchInfo,
-        })
-    }
+		this.ServeJson(map[string]interface{}{
+			"status":        "fail",
+			"orderData":     data,
+			"redSwitchInfo": redSwitchInfo,
+		})
+	}
 }
 
 func ShowList(order_code string) []map[string]interface{} {
-    data := util.Mysql.SelectBySql(fmt.Sprintf(`SELECT *,(
+	data := util.Mysql.SelectBySql(fmt.Sprintf(`SELECT *,(
   SELECT count(1) as count FROM invoice b WHERE b.order_code = a.order_code and  b.only_Identifying is not null and b.only_Identifying = a.only_Identifying
 ) as isChanged FROM invoice a WHERE order_code = '%s' and invoice_status != -2 and invoice_variety is not null and invoice_variety not  LIKE '%s' ORDER BY create_time DESC`, order_code, "%纸质%"))
-    if data == nil {
-        return nil
-    }
-    return *data
+	if data == nil {
+		return nil
+	}
+	return *data
 }
 
 func (this *Invoice) NewInvoiceShow() {
-    stype := this.GetString("stype")
-    code := this.GetString("code")
-    data := make(map[string]interface{})
-    switch stype {
-    case "1": //订单回显金额
-        data["pay_money"] = ResidueMoney(code)
-    case "2": //发票信息回显
-        invoice := util.Mysql.FindOne("invoice", map[string]interface{}{"id": encrypt.SE.Decode4Hex(code)}, "id,only_Identifying,order_code,invoice_money,invoice_type,invoice_content,invoice_variety,company_name,phone,mail,taxpayer_identnum,invoice_money,invoice_order_money,company_address,bank_name,recipient,delivery_address,bank_account,company_phone", "")
-        if invoice != nil {
-            (*invoice)["id"] = code
-        }
-        data["invoice"] = invoice
-    }
-    this.ServeJson(map[string]interface{}{
-        "data": data,
-    })
+	stype := this.GetString("stype")
+	code := this.GetString("code")
+	data := make(map[string]interface{})
+	switch stype {
+	case "1": //订单回显金额
+		data["pay_money"] = ResidueMoney(code)
+	case "2": //发票信息回显
+		invoice := util.Mysql.FindOne("invoice", map[string]interface{}{"id": encrypt.SE.Decode4Hex(code)}, "id,only_Identifying,order_code,invoice_money,invoice_type,invoice_content,invoice_variety,company_name,phone,mail,taxpayer_identnum,invoice_money,invoice_order_money,company_address,bank_name,recipient,delivery_address,bank_account,company_phone", "")
+		if invoice != nil {
+			(*invoice)["id"] = code
+		}
+		data["invoice"] = invoice
+	}
+	this.ServeJson(map[string]interface{}{
+		"data": data,
+	})
 }
 
 // 开发票回调
 func (this *Invoice) Callbackinvoice() {
-    isRed, _ := this.GetBool("isRed")
-    resType := this.GetString("resType") //红票回调-->"changed":换票 "refund":退票
-    order_code := this.GetString("order_code")
-    applyBill_status := this.GetString("code")
-    fpdm := this.GetString("fpdm")
-    fphm := this.GetString("fphm")
-    path := this.GetString("path")
-    swno := this.GetString("swno")
-    changed := this.GetString("changed")
-    isSys, _ := this.GetBool("isSys") //是否发票系统故障
-    if isSys {
-        q := map[string]interface{}{}
-        q["order_code"] = order_code
-        q["invoice_changed"], _ = strconv.Atoi(changed)
-        sysMap := map[string]interface{}{"invoice_status": -1}
-        ok := util.Mysql.Update(dbname, q, sysMap)
-        if ok {
-            this.ServeJson(map[string]interface{}{
-                "msg":    "发票系统故障回调成功",
-                "status": "success",
-            })
-        }
-        return
-    }
-    if !isRed {
-        if order_code != "" {
-            if changed == "1" {
-                m := make(map[string]interface{})
-                query := make(map[string]interface{})
-                query["order_code"] = order_code
-                query["invoice_changed"] = 1
-                m["invoice_code"] = fpdm
-                m["invoice_number"] = fphm
-                m["url"] = "http://" + path
-                m["invoice_serialnum"] = swno
-                m["invoice_status"] = applyBill_status
-                m["billing_time"] = time.Now().Unix()
-                updata_status := util.Mysql.Update(dbname, query, m)
-                if updata_status {
-                    user_info := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code}, "user_nickname,user_mail", "")
-                    res := util.Mysql.FindOne(dbname, query, "invoice_type,mail,taxpayer_identnum,company_name,phone,url", "")
-                    if (*res)["invoice_type"] == "个人" {
-                        go func() {
-                            var user_mail string
-                            if (*res)["mail"] == nil {
-                                user_mail = (*user_info)["user_mail"].(string)
-                            } else {
-                                user_mail = (*res)["mail"].(string)
-                            }
-                            var url string
-                            if (*res)["url"] == nil {
-                                url = "http://" + path
-                            } else {
-                                url = (*res)["url"].(string)
-                            }
-                            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, "电子发票")
-                        }()
-                    } else {
-                        var company_mail string
-                        if (*res)["mail"] == nil {
-                            company_mail = (*user_info)["user_mail"].(string)
-                        } else {
-                            company_mail = (*res)["mail"].(string)
-                        }
-                        var url string
-                        if (*res)["url"] == nil {
-                            url = "http://" + path
-                        } else {
-                            url = (*res)["url"].(string)
-                        }
-                        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, "电子发票")
+	isRed, _ := this.GetBool("isRed")
+	resType := this.GetString("resType") //红票回调-->"changed":换票 "refund":退票
+	order_code := this.GetString("order_code")
+	applyBill_status := this.GetString("code")
+	fpdm := this.GetString("fpdm")
+	fphm := this.GetString("fphm")
+	path := this.GetString("path")
+	swno := this.GetString("swno")
+	changed := this.GetString("changed")
+	isSys, _ := this.GetBool("isSys") //是否发票系统故障
+	if isSys {
+		q := map[string]interface{}{}
+		q["order_code"] = order_code
+		q["invoice_changed"], _ = strconv.Atoi(changed)
+		sysMap := map[string]interface{}{"invoice_status": -1}
+		ok := util.Mysql.Update(dbname, q, sysMap)
+		if ok {
+			this.ServeJson(map[string]interface{}{
+				"msg":    "发票系统故障回调成功",
+				"status": "success",
+			})
+		}
+		return
+	}
+	if !isRed {
+		if order_code != "" {
+			if changed == "1" {
+				m := make(map[string]interface{})
+				query := make(map[string]interface{})
+				query["order_code"] = order_code
+				query["invoice_changed"] = 1
+				m["invoice_code"] = fpdm
+				m["invoice_number"] = fphm
+				m["url"] = "http://" + path
+				m["invoice_serialnum"] = swno
+				m["invoice_status"] = applyBill_status
+				m["billing_time"] = time.Now().Unix()
+				updata_status := util.Mysql.Update(dbname, query, m)
+				if updata_status {
+					user_info := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code}, "user_nickname,user_mail", "")
+					res := util.Mysql.FindOne(dbname, query, "invoice_type,mail,taxpayer_identnum,company_name,phone,url", "")
+					if (*res)["invoice_type"] == "个人" {
+						go func() {
+							var user_mail string
+							if (*res)["mail"] == nil {
+								user_mail = (*user_info)["user_mail"].(string)
+							} else {
+								user_mail = (*res)["mail"].(string)
+							}
+							var url string
+							if (*res)["url"] == nil {
+								url = "http://" + path
+							} else {
+								url = (*res)["url"].(string)
+							}
+							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, "电子发票")
+						}()
+					} else {
+						var company_mail string
+						if (*res)["mail"] == nil {
+							company_mail = (*user_info)["user_mail"].(string)
+						} else {
+							company_mail = (*res)["mail"].(string)
+						}
+						var url string
+						if (*res)["url"] == nil {
+							url = "http://" + path
+						} else {
+							url = (*res)["url"].(string)
+						}
+						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, "电子发票")
 
-                    }
-                    this.ServeJson(map[string]interface{}{
-                        "msg":    "状态修改成功",
-                        "status": "success",
-                    })
-                }
-            } else {
-                t := make(map[string]interface{})
+					}
+					this.ServeJson(map[string]interface{}{
+						"msg":    "状态修改成功",
+						"status": "success",
+					})
+				}
+			} else {
+				t := make(map[string]interface{})
 
-                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{})
-                    if strings.Contains(order_code, "xx") {
-                        //自助开票
-                        query["only_Identifying"] = order_code
-                    } else {
-                        //系统开票
-                        query["order_code"] = order_code
-                    }
-                    query["invoice_changed"] = 0
-                    m["invoice_code"] = fpdm
-                    m["invoice_number"] = fphm
-                    m["url"] = "http://" + path
-                    m["invoice_serialnum"] = swno
-                    m["invoice_status"] = applyBill_status
-                    m["billing_time"] = time.Now().Unix()
-                    updata_status := util.Mysql.Update(dbname, query, m)
-                    if updata_status {
-                        if (*res)["invoice_type"] == "个人" {
-                            go func() {
-                                var user_mail string
-                                if (*res)["mail"] == nil {
-                                    user_mail = (*user_info)["user_mail"].(string)
-                                } else {
-                                    user_mail = (*res)["mail"].(string)
-                                }
-                                var url string
-                                if (*res)["url"] == nil {
-                                    url = "http://" + path
-                                } else {
-                                    url = (*res)["url"].(string)
-                                }
-                                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)
-                                        }
-                                    }
+				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{})
+					if strings.Contains(order_code, "xx") {
+						//自助开票
+						query["only_Identifying"] = order_code
+					} else {
+						//系统开票
+						query["order_code"] = order_code
+					}
+					query["invoice_changed"] = 0
+					m["invoice_code"] = fpdm
+					m["invoice_number"] = fphm
+					m["url"] = "http://" + path
+					m["invoice_serialnum"] = swno
+					m["invoice_status"] = applyBill_status
+					m["billing_time"] = time.Now().Unix()
+					updata_status := util.Mysql.Update(dbname, query, m)
+					if updata_status {
+						if (*res)["invoice_type"] == "个人" {
+							go func() {
+								var user_mail string
+								if (*res)["mail"] == nil {
+									user_mail = (*user_info)["user_mail"].(string)
+								} else {
+									user_mail = (*res)["mail"].(string)
+								}
+								var url string
+								if (*res)["url"] == nil {
+									url = "http://" + path
+								} else {
+									url = (*res)["url"].(string)
+								}
+								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, "电子发票")
+								}
+								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
-                            if (*res)["mail"] == nil {
-                                company_mail = (*user_info)["user_mail"].(string)
-                            } else {
-                                company_mail = (*res)["mail"].(string)
-                            }
-                            var url string
-                            if (*res)["url"] == nil {
-                                url = "http://" + path
-                            } else {
-                                url = (*res)["url"].(string)
-                            }
-                            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)
-                                    }
-                                }
+						} else {
+							var company_mail string
+							if (*res)["mail"] == nil {
+								company_mail = (*user_info)["user_mail"].(string)
+							} else {
+								company_mail = (*res)["mail"].(string)
+							}
+							var url string
+							if (*res)["url"] == nil {
+								url = "http://" + path
+							} else {
+								url = (*res)["url"].(string)
+							}
+							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, "电子发票")
+							}
+							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{}{
-                            "msg":    "状态修改成功",
-                            "status": "success",
-                        })
-                    }
+						}
+						this.ServeJson(map[string]interface{}{
+							"msg":    "状态修改成功",
+							"status": "success",
+						})
+					}
 
-                } else {
-                    this.ServeJson(map[string]interface{}{
-                        "msg":    "订单不存在",
-                        "status": "fail",
-                    })
-                }
-            }
+				} else {
+					this.ServeJson(map[string]interface{}{
+						"msg":    "订单不存在",
+						"status": "fail",
+					})
+				}
+			}
 
-        } else {
-            this.ServeJson(map[string]interface{}{
-                "msg":    "参数缺失",
-                "status": "fail",
-            })
-        }
-    } else {
-        redMap := map[string]interface{}{}
-        query := map[string]interface{}{}
-        if order_code != "" {
-            query["order_code"] = order_code
-            red := RedMsg{
-                fpdm,
-                fphm,
-                "http://" + path,
-                swno,
-                applyBill_status,
-                time.Now().Unix(),
-            }
-            redStr, _ := json.Marshal(red)
-            redMap["red"] = redStr
-            redMap["invoice_status"] = -2
-        }
-        if resType == "changed" {
-            query["invoice_changed"] = 0
-            ok := util.Mysql.Update(dbname, query, redMap)
-            if ok {
-                this.ServeJson(map[string]interface{}{
-                    "msg":    "用户换票冲红保存成功",
-                    "status": "success",
-                })
-            }
-        } else if resType == "refund" {
-            data := util.Mysql.Find(dbname, query, "", "create_time", 0, 0)
-            if len(*data) == 2 {
-                query["invoice_changed"] = 1
-            } else {
-                query["invoice_changed"] = 0
-            }
-            ok := util.Mysql.Update(dbname, query, redMap)
-            if ok {
-                this.ServeJson(map[string]interface{}{
-                    "msg":    "用户退款冲红保存成功",
-                    "status": "success",
-                })
-            }
-        }
-    }
+		} else {
+			this.ServeJson(map[string]interface{}{
+				"msg":    "参数缺失",
+				"status": "fail",
+			})
+		}
+	} else {
+		redMap := map[string]interface{}{}
+		query := map[string]interface{}{}
+		if order_code != "" {
+			query["order_code"] = order_code
+			red := RedMsg{
+				fpdm,
+				fphm,
+				"http://" + path,
+				swno,
+				applyBill_status,
+				time.Now().Unix(),
+			}
+			redStr, _ := json.Marshal(red)
+			redMap["red"] = redStr
+			redMap["invoice_status"] = -2
+		}
+		if resType == "changed" {
+			query["invoice_changed"] = 0
+			ok := util.Mysql.Update(dbname, query, redMap)
+			if ok {
+				this.ServeJson(map[string]interface{}{
+					"msg":    "用户换票冲红保存成功",
+					"status": "success",
+				})
+			}
+		} else if resType == "refund" {
+			data := util.Mysql.Find(dbname, query, "", "create_time", 0, 0)
+			if len(*data) == 2 {
+				query["invoice_changed"] = 1
+			} else {
+				query["invoice_changed"] = 0
+			}
+			ok := util.Mysql.Update(dbname, query, redMap)
+			if ok {
+				this.ServeJson(map[string]interface{}{
+					"msg":    "用户退款冲红保存成功",
+					"status": "success",
+				})
+			}
+		}
+	}
 }
 
 // 换票
 func (this *Invoice) Replaceinvoice() {
-    //红冲开关
-    if !config.InvoiceConfig.Red_invoice_switch {
-        this.ServeJson(map[string]interface{}{
-            "invoice_status": -1,
-            "invoice_msg":    config.InvoiceConfig.Red_invoice_msg,
-        })
-        return
-    }
-    userId := qutil.ObjToString(this.GetSession("userId"))
-    order_code := this.GetString("order_code")
-    isSys, _ := this.GetBool("isSys")
-    res := util.Mysql.FindOne(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId, "invoice_changed": 0}, "", "") //仅线上开发票可换票
-    if res != nil {
-        order_res := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId, "applyBill_status": map[string]interface{}{"ne": 2}}, "order_money,product_type,user_nickname,user_mail", "")
-        invoice_type := this.GetString("invoice_type")
-        phone := this.GetString("phone_num")
-        e_mail := this.GetString("email")
-        company_name := this.GetString("company")
-        id_num := strings.ToUpper(this.GetString("id_num")) //纳税人识别号
-        if invoice_type == "个人" {
-            if phone == (*res)["phone"] && e_mail == (*res)["mail"] && (*res)["invoice_type"] == "个人" {
-                emailHtml := emailHtml_gr
-                emailHtmls := fmt.Sprintf(emailHtml, phone, e_mail)
-                html := fmt.Sprintf(email_format, order_code, (*res)["url"], emailHtmls)
-                m := make(map[string]interface{})
-                m["order_code"] = order_code
-                m["invoice_changed"] = 1
-                m["invoice_code"] = (*res)["invoice_code"]
-                m["invoice_number"] = (*res)["invoice_number"]
-                m["url"] = (*res)["url"]
-                m["invoice_serialnum"] = (*res)["invoice_serialnum"]
-                m["invoice_status"] = 1
-                m["billing_time"] = time.Now().Unix()
-                m["mail"] = (*res)["mail"]
-                m["phone"] = (*res)["phone"]
-                m["invoice_type"] = (*res)["invoice_type"]
-                m["company_name"] = (*res)["company_name"]
-                m["taxpayer_identnum"] = (*res)["taxpayer_identnum"]
-                m["create_time"] = time.Now().Unix()
-                m["product_type"] = (*res)["product_type"]
-                m["user_id"] = userId
-                if !isSys {
-                    status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
-                    if len(*status) > 1 {
-                        return
-                    }
-                    order_id := util.Mysql.Insert(dbname, m)
-                    if order_id != -1 {
-                        this.ServeJson(map[string]interface{}{
-                            "invoice_status": 1,
-                        })
-                    }
-                } else {
-                    query := map[string]interface{}{}
-                    query["user_id"] = userId
-                    query["order_code"] = order_code
-                    query["invoice_changed"] = 1
-                    ok := util.Mysql.Update(dbname, query, m)
-                    if ok {
-                        this.ServeJson(map[string]interface{}{
-                            "invoice_status": 1,
-                        })
-                    }
-                }
-                InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
-                return
-            }
-        } else {
-            if phone == (*res)["phone"] && e_mail == (*res)["mail"] && id_num == (*res)["taxpayer_identnum"] && company_name == (*res)["company_name"] && (*res)["invoice_type"] == "单位" {
-                emailHtml := emailHtml_gs
-                emailHtmls := fmt.Sprintf(emailHtml, (*res)["company_name"], (*res)["taxpayer_identnum"], (*res)["phone"], e_mail)
-                html := fmt.Sprintf(email_format, order_code, (*res)["url"], emailHtmls)
-                m := make(map[string]interface{})
-                m["order_code"] = order_code
-                m["invoice_changed"] = 1
-                m["invoice_code"] = (*res)["invoice_code"]
-                m["invoice_number"] = (*res)["invoice_number"]
-                m["url"] = (*res)["url"]
-                m["invoice_serialnum"] = (*res)["invoice_serialnum"]
-                m["invoice_status"] = 1
-                m["billing_time"] = time.Now().Unix()
-                m["mail"] = (*res)["mail"]
-                m["phone"] = (*res)["phone"]
-                m["invoice_type"] = (*res)["invoice_type"]
-                m["company_name"] = (*res)["company_name"]
-                m["taxpayer_identnum"] = (*res)["taxpayer_identnum"]
-                m["create_time"] = time.Now().Unix()
-                m["product_type"] = (*res)["product_type"]
-                m["user_id"] = userId
-                if !isSys {
-                    status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
-                    if len(*status) > 1 {
-                        return
-                    }
-                    order_id := util.Mysql.Insert(dbname, m)
-                    if order_id != -1 {
-                        this.ServeJson(map[string]interface{}{
-                            "invoice_status": 1,
-                        })
-                    }
-                } else {
-                    query := map[string]interface{}{}
-                    query["user_id"] = userId
-                    query["order_code"] = order_code
-                    query["invoice_changed"] = 1
-                    ok := util.Mysql.Update(dbname, query, m)
-                    if ok {
-                        this.ServeJson(map[string]interface{}{
-                            "invoice_status": 1,
-                        })
-                    }
-                }
-                InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
-                return
-            }
-        }
-        invoice_status := 0
-        dataexport_data := make(map[string]interface{})
-        if invoice_type == "个人" {
-            dataexport_data["applyBill_type"] = 0
-            dataexport_data["applyBill_taxnum"] = ""
-            dataexport_data["applybill_company"] = ""
-        } else {
-            dataexport_data["applyBill_type"] = 1
-            dataexport_data["applyBill_taxnum"] = id_num
-            dataexport_data["applybill_company"] = company_name
-        }
-        dataexport_data["user_mail"] = e_mail
-        util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId}, dataexport_data)
-        data := make(map[string]interface{})
-        data["order_code"] = order_code
-        data["mail"] = e_mail
-        data["phone"] = phone
-        data["invoice_type"] = invoice_type
-        data["company_name"] = company_name
-        data["taxpayer_identnum"] = id_num
-        data["invoice_changed"] = 1
-        data["create_time"] = time.Now().Unix()
-        data["user_id"] = userId
-        data["invoice_status"] = invoice_status
-        data["product_type"] = (*res)["product_type"]
-        if !isSys {
-            status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
-            if len(*status) == 0 {
-                if id := util.Mysql.Insert(dbname, data); id > 0 {
-                    invoice_status = 1
-                }
-            } else {
-                invoice_status = 1
-            }
-        } else {
-            if ok := util.Mysql.Update(dbname, map[string]interface{}{
-                "order_code":      order_code,
-                "user_id":         userId,
-                "invoice_changed": 1,
-            }, data); ok {
-                invoice_status = 1
-            }
-        }
-        if !config.InvoiceConfig.Third_party_switch {
-            this.ServeJson(map[string]interface{}{
-                "invoice_status": invoice_status,
-            })
-            return
-        }
-        var orders = []map[string]interface{}{}
-        var items = []map[string]interface{}{}
-        prices := qutil.Float64All((*order_res)["order_money"]) / float64(100)
-        price := strconv.FormatFloat(prices, 'f', -1, 64)
-        item := map[string]interface{}{
-            "name":        (*order_res)["product_type"],
-            "code":        config.InvoiceConfig.Code,
-            "yhzcbs":      config.InvoiceConfig.Tax_policy,
-            "lineType":    config.InvoiceConfig.Invoice_nature,
-            "taxRate":     config.InvoiceConfig.Tax_rate,
-            "taxPrice":    price,
-            "totalAmount": price,
-            "quantity":    "1",
-            "phone":       phone,
-            "billDate":    NowFormat(Date_Full_Layout), //单据日期  格式:yyyy-MM-dd HH:mm:ss
-        }
-        items = append(items, item)
-        order := map[string]interface{}{
-            "billNo": order_code,
-            "items":  items,
-        }
-        orders = append(orders, order)
-        client := &http.Client{}
-        body := map[string]interface{}{
-            "Swno":      order_code,
-            "custType":  "03",
-            "orders":    orders,
-            "custTaxNo": id_num,
-            "yfphm":     (*res)["invoice_number"],
-            "yfpdm":     (*res)["invoice_code"],
-            "changed":   "1",
-            "phone":     phone,
-            "redcode":   (*res)["invoice_serialnum"],
-        }
-        if invoice_type == "单位" {
-            body["custName"] = company_name
-        } else {
-            body["custName"] = invoice_type
-        }
-        b, _ := json.Marshal(body)
-        buffer := bytes.NewBuffer(b)
-        request, err := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/Replace", buffer)
-        if err == nil {
-            var invoice_status = 0
-            invoice_res := &InvoiceInfo{}
-            response, err1 := client.Do(request)
-            if err1 != nil {
-                invoice_status = -1
-            } else {
-                res, err := ioutil.ReadAll(response.Body)
-                defer response.Body.Close()
-                if err != nil {
-                    invoice_status = -1
-                } else {
-                    resMap := qutil.ObjToMap(string(res))
-                    if *resMap != nil {
-                        if qutil.IntAll((*resMap)["code"]) == 1 {
-                            invoice_status = -1
-                        }
-                    }
-                    err := json.Unmarshal(res, invoice_res)
-                    if err != nil {
-                        log.Println("序列化出错", err)
-                    } else {
-                        if invoice_res.data["path"] != nil {
-                            invoice_status = 1
-                        }
-                        if invoice_res == nil {
-                            invoice_status = -1
-                        }
-                    }
-                }
-            }
-            updata_status := true
-            if invoice_status == -1 {
-                if !delReplaceInvoice(map[string]interface{}{"order_code": order_code, "invoice_changed": 1}) {
-                    log.Printf("delete replace invoice err: %s", order_code)
-                }
-            } else {
-                updata_status = util.Mysql.Update(dbname, map[string]interface{}{"order_code": order_code, "invoice_changed": 1}, map[string]interface{}{
-                    "invoice_serialnum": invoice_res.data["swno"],
-                    "invoice_code":      invoice_res.data["fpdm"],
-                    "invoice_number":    invoice_res.data["fphm"],
-                    "url":               invoice_res.data["path"],
-                    "invoice_status":    invoice_status,
-                })
-            }
-            if updata_status {
-                this.ServeJson(map[string]interface{}{
-                    "invoice_status": invoice_status,
-                })
-            } else {
-                this.ServeJson(map[string]interface{}{
-                    "invoice_status": 0,
-                })
-            }
-        } else {
-            go func() {
-                //删除该错误发票信息
-                // util.Mysql.Update(dbname, map[string]interface{}{"order_code": order_code, "invoice_changed": 1}, map[string]interface{}{
-                // 	"invoice_status": -1,
-                // })
-                if !delReplaceInvoice(map[string]interface{}{"order_code": order_code, "invoice_changed": 1}) {
-                    log.Printf("delete go func replace invoice err: %s", order_code)
-                }
-            }()
+	//红冲开关
+	if !config.InvoiceConfig.Red_invoice_switch {
+		this.ServeJson(map[string]interface{}{
+			"invoice_status": -1,
+			"invoice_msg":    config.InvoiceConfig.Red_invoice_msg,
+		})
+		return
+	}
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	order_code := this.GetString("order_code")
+	isSys, _ := this.GetBool("isSys")
+	res := util.Mysql.FindOne(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId, "invoice_changed": 0}, "", "") //仅线上开发票可换票
+	if res != nil {
+		order_res := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId, "applyBill_status": map[string]interface{}{"ne": 2}}, "order_money,product_type,user_nickname,user_mail", "")
+		invoice_type := this.GetString("invoice_type")
+		phone := this.GetString("phone_num")
+		e_mail := this.GetString("email")
+		company_name := this.GetString("company")
+		id_num := strings.ToUpper(this.GetString("id_num")) //纳税人识别号
+		if invoice_type == "个人" {
+			if phone == (*res)["phone"] && e_mail == (*res)["mail"] && (*res)["invoice_type"] == "个人" {
+				emailHtml := emailHtml_gr
+				emailHtmls := fmt.Sprintf(emailHtml, phone, e_mail)
+				html := fmt.Sprintf(email_format, order_code, (*res)["url"], emailHtmls)
+				m := make(map[string]interface{})
+				m["order_code"] = order_code
+				m["invoice_changed"] = 1
+				m["invoice_code"] = (*res)["invoice_code"]
+				m["invoice_number"] = (*res)["invoice_number"]
+				m["url"] = (*res)["url"]
+				m["invoice_serialnum"] = (*res)["invoice_serialnum"]
+				m["invoice_status"] = 1
+				m["billing_time"] = time.Now().Unix()
+				m["mail"] = (*res)["mail"]
+				m["phone"] = (*res)["phone"]
+				m["invoice_type"] = (*res)["invoice_type"]
+				m["company_name"] = (*res)["company_name"]
+				m["taxpayer_identnum"] = (*res)["taxpayer_identnum"]
+				m["create_time"] = time.Now().Unix()
+				m["product_type"] = (*res)["product_type"]
+				m["user_id"] = userId
+				if !isSys {
+					status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
+					if len(*status) > 1 {
+						return
+					}
+					order_id := util.Mysql.Insert(dbname, m)
+					if order_id != -1 {
+						this.ServeJson(map[string]interface{}{
+							"invoice_status": 1,
+						})
+					}
+				} else {
+					query := map[string]interface{}{}
+					query["user_id"] = userId
+					query["order_code"] = order_code
+					query["invoice_changed"] = 1
+					ok := util.Mysql.Update(dbname, query, m)
+					if ok {
+						this.ServeJson(map[string]interface{}{
+							"invoice_status": 1,
+						})
+					}
+				}
+				InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
+				return
+			}
+		} else {
+			if phone == (*res)["phone"] && e_mail == (*res)["mail"] && id_num == (*res)["taxpayer_identnum"] && company_name == (*res)["company_name"] && (*res)["invoice_type"] == "单位" {
+				emailHtml := emailHtml_gs
+				emailHtmls := fmt.Sprintf(emailHtml, (*res)["company_name"], (*res)["taxpayer_identnum"], (*res)["phone"], e_mail)
+				html := fmt.Sprintf(email_format, order_code, (*res)["url"], emailHtmls)
+				m := make(map[string]interface{})
+				m["order_code"] = order_code
+				m["invoice_changed"] = 1
+				m["invoice_code"] = (*res)["invoice_code"]
+				m["invoice_number"] = (*res)["invoice_number"]
+				m["url"] = (*res)["url"]
+				m["invoice_serialnum"] = (*res)["invoice_serialnum"]
+				m["invoice_status"] = 1
+				m["billing_time"] = time.Now().Unix()
+				m["mail"] = (*res)["mail"]
+				m["phone"] = (*res)["phone"]
+				m["invoice_type"] = (*res)["invoice_type"]
+				m["company_name"] = (*res)["company_name"]
+				m["taxpayer_identnum"] = (*res)["taxpayer_identnum"]
+				m["create_time"] = time.Now().Unix()
+				m["product_type"] = (*res)["product_type"]
+				m["user_id"] = userId
+				if !isSys {
+					status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
+					if len(*status) > 1 {
+						return
+					}
+					order_id := util.Mysql.Insert(dbname, m)
+					if order_id != -1 {
+						this.ServeJson(map[string]interface{}{
+							"invoice_status": 1,
+						})
+					}
+				} else {
+					query := map[string]interface{}{}
+					query["user_id"] = userId
+					query["order_code"] = order_code
+					query["invoice_changed"] = 1
+					ok := util.Mysql.Update(dbname, query, m)
+					if ok {
+						this.ServeJson(map[string]interface{}{
+							"invoice_status": 1,
+						})
+					}
+				}
+				InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
+				return
+			}
+		}
+		invoice_status := 0
+		dataexport_data := make(map[string]interface{})
+		if invoice_type == "个人" {
+			dataexport_data["applyBill_type"] = 0
+			dataexport_data["applyBill_taxnum"] = ""
+			dataexport_data["applybill_company"] = ""
+		} else {
+			dataexport_data["applyBill_type"] = 1
+			dataexport_data["applyBill_taxnum"] = id_num
+			dataexport_data["applybill_company"] = company_name
+		}
+		dataexport_data["user_mail"] = e_mail
+		util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId}, dataexport_data)
+		data := make(map[string]interface{})
+		data["order_code"] = order_code
+		data["mail"] = e_mail
+		data["phone"] = phone
+		data["invoice_type"] = invoice_type
+		data["company_name"] = company_name
+		data["taxpayer_identnum"] = id_num
+		data["invoice_changed"] = 1
+		data["create_time"] = time.Now().Unix()
+		data["user_id"] = userId
+		data["invoice_status"] = invoice_status
+		data["product_type"] = (*res)["product_type"]
+		if !isSys {
+			status := util.Mysql.Find(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
+			if len(*status) == 0 {
+				if id := util.Mysql.Insert(dbname, data); id > 0 {
+					invoice_status = 1
+				}
+			} else {
+				invoice_status = 1
+			}
+		} else {
+			if ok := util.Mysql.Update(dbname, map[string]interface{}{
+				"order_code":      order_code,
+				"user_id":         userId,
+				"invoice_changed": 1,
+			}, data); ok {
+				invoice_status = 1
+			}
+		}
+		if !config.InvoiceConfig.Third_party_switch {
+			this.ServeJson(map[string]interface{}{
+				"invoice_status": invoice_status,
+			})
+			return
+		}
+		var orders = []map[string]interface{}{}
+		var items = []map[string]interface{}{}
+		prices := qutil.Float64All((*order_res)["order_money"]) / float64(100)
+		price := strconv.FormatFloat(prices, 'f', -1, 64)
+		item := map[string]interface{}{
+			"name":        (*order_res)["product_type"],
+			"code":        config.InvoiceConfig.Code,
+			"yhzcbs":      config.InvoiceConfig.Tax_policy,
+			"lineType":    config.InvoiceConfig.Invoice_nature,
+			"taxRate":     config.InvoiceConfig.Tax_rate,
+			"taxPrice":    price,
+			"totalAmount": price,
+			"quantity":    "1",
+			"phone":       phone,
+			"billDate":    NowFormat(Date_Full_Layout), //单据日期  格式:yyyy-MM-dd HH:mm:ss
+		}
+		items = append(items, item)
+		order := map[string]interface{}{
+			"billNo": order_code,
+			"items":  items,
+		}
+		orders = append(orders, order)
+		client := &http.Client{}
+		body := map[string]interface{}{
+			"Swno":      order_code,
+			"custType":  "03",
+			"orders":    orders,
+			"custTaxNo": id_num,
+			"yfphm":     (*res)["invoice_number"],
+			"yfpdm":     (*res)["invoice_code"],
+			"changed":   "1",
+			"phone":     phone,
+			"redcode":   (*res)["invoice_serialnum"],
+		}
+		if invoice_type == "单位" {
+			body["custName"] = company_name
+		} else {
+			body["custName"] = invoice_type
+		}
+		b, _ := json.Marshal(body)
+		buffer := bytes.NewBuffer(b)
+		request, err := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/Replace", buffer)
+		if err == nil {
+			var invoice_status = 0
+			invoice_res := &InvoiceInfo{}
+			response, err1 := client.Do(request)
+			if err1 != nil {
+				invoice_status = -1
+			} else {
+				res, err := ioutil.ReadAll(response.Body)
+				defer response.Body.Close()
+				if err != nil {
+					invoice_status = -1
+				} else {
+					resMap := qutil.ObjToMap(string(res))
+					if *resMap != nil {
+						if qutil.IntAll((*resMap)["code"]) == 1 {
+							invoice_status = -1
+						}
+					}
+					err := json.Unmarshal(res, invoice_res)
+					if err != nil {
+						log.Println("序列化出错", err)
+					} else {
+						if invoice_res.data["path"] != nil {
+							invoice_status = 1
+						}
+						if invoice_res == nil {
+							invoice_status = -1
+						}
+					}
+				}
+			}
+			updata_status := true
+			if invoice_status == -1 {
+				if !delReplaceInvoice(map[string]interface{}{"order_code": order_code, "invoice_changed": 1}) {
+					log.Printf("delete replace invoice err: %s", order_code)
+				}
+			} else {
+				updata_status = util.Mysql.Update(dbname, map[string]interface{}{"order_code": order_code, "invoice_changed": 1}, map[string]interface{}{
+					"invoice_serialnum": invoice_res.data["swno"],
+					"invoice_code":      invoice_res.data["fpdm"],
+					"invoice_number":    invoice_res.data["fphm"],
+					"url":               invoice_res.data["path"],
+					"invoice_status":    invoice_status,
+				})
+			}
+			if updata_status {
+				this.ServeJson(map[string]interface{}{
+					"invoice_status": invoice_status,
+				})
+			} else {
+				this.ServeJson(map[string]interface{}{
+					"invoice_status": 0,
+				})
+			}
+		} else {
+			go func() {
+				//删除该错误发票信息
+				// util.Mysql.Update(dbname, map[string]interface{}{"order_code": order_code, "invoice_changed": 1}, map[string]interface{}{
+				// 	"invoice_status": -1,
+				// })
+				if !delReplaceInvoice(map[string]interface{}{"order_code": order_code, "invoice_changed": 1}) {
+					log.Printf("delete go func replace invoice err: %s", order_code)
+				}
+			}()
 
-            this.ServeJson(map[string]interface{}{
-                "invoice_status": -1,
-            })
-        }
-    }
+			this.ServeJson(map[string]interface{}{
+				"invoice_status": -1,
+			})
+		}
+	}
 
 }
 
 // 新换票
 func (this *Invoice) NewReplaceinvoice() {
-    //红冲开关
-    if !config.InvoiceConfig.Red_invoice_switch {
-        this.ServeJson(map[string]interface{}{
-            "invoice_status": -1,
-            "invoice_msg":    config.InvoiceConfig.Red_invoice_msg,
-        })
-        return
-    }
-    invoice_type := this.GetString("invoice_type")
-    phone := this.GetString("phone")
-    e_mail := this.GetString("mail")
-    company_name := this.GetString("company_name")
-    id_num := strings.ToUpper(this.GetString("taxpayer_identnum")) //纳税人识别号
-    invoice_status := 0
-    //userId := qutil.ObjToString(this.GetSession("userId"))  支持扫描换票
-    //order_code := this.GetString("order_code")
-    sid := encrypt.SE.Decode4Hex(this.GetString("sid"))
-    oRes := util.Mysql.FindOne(dbname, map[string]interface{}{"id": sid, "invoie_changed": 0}, "", "") //仅线上开发票可换票
-    if oRes != nil && len(*oRes) > 0 &&
-        ((*oRes)["invoicing_entity"] == nil || qutil.InterfaceToStr((*oRes)["invoicing_entity"]) == config.InvoiceConfig.SigningSubject) {
-        var (
-            qSql    string
-            errCode []string
-            //saveData []map[string]interface{}
-            resArr []map[string]interface{}
-        )
-        if qutil.IntAll((*oRes)["invoice_status"]) == -2 {
-            this.ServeJson(map[string]interface{}{
-                "invoice_status": -2,
-            })
-            return
-        }
-        if invoice_order_code := qutil.InterfaceToStr((*oRes)["invoice_order_code"]); len(strings.Split(invoice_order_code, ",")) > 1 {
-            qSql = fmt.Sprintf(`SELECT * FROM invoice WHERE invoice_order_code = '%s' `, qutil.InterfaceToStr((*oRes)["invoice_order_code"]))
-            res1 := util.Mysql.SelectBySql(qSql)
-            if res1 != nil && len(*res1) > 0 {
-                resArr = *res1
-            }
-        } else { //多订单联合开票
-            resArr = append(resArr, *oRes)
-        }
-        var isMail bool
-        tm := time.Now()
-        for _, res := range resArr {
-            if res["only_Identifying"] == nil { //无唯一id 允许换票一次 生成唯一id
-                newUuid := uuid.New()
-                res["only_Identifying"] = newUuid
-                util.Mysql.Update(dbname, map[string]interface{}{"id": res["id"]}, map[string]interface{}{"only_Identifying": newUuid})
-            } else if util.Mysql.Count(dbname, map[string]interface{}{
-                "order_code":       res["order_code"],
-                "user_id":          res["user_id"],
-                "only_Identifying": res["only_Identifying"],
-            }) > 1 {
-                continue
-            }
-            res["phone"] = this.GetString("phone")
-            res["mail"] = this.GetString("mail")
-            res["invoice_content"] = this.GetString("invoice_content")
-            res["company_phone"] = this.GetString("company_phone")
-            res["taxpayer_identnum"] = this.GetString("taxpayer_identnum")
-            res["operable_time"] = FormatDate(&tm, Date_Full_Layout)
-            res["remark"] = this.GetString("remark")
-            res["invoice_variety"] = this.GetString("invoice_variety")
-            res["bank_account"] = this.GetString("bank_account")
-            res["company_address"] = this.GetString("company_address")
-            res["bank_name"] = this.GetString("bank_name")
-            res["recipient"] = this.GetString("recipient")
-            res["delivery_address"] = this.GetString("delivery_address")
-            res["product_type"] = this.GetString("bank_name")
-            data := res
-            delete(data, "id")
-            switch IsEdit(res, phone, e_mail, id_num, company_name, invoice_type) {
-            case true:
-                var html string
-                if invoice_type == "个人" {
-                    emailHtml := emailHtml_gr
-                    emailHtmls := fmt.Sprintf(emailHtml, phone, e_mail)
-                    html = fmt.Sprintf(email_format, res["order_code"], res["url"], emailHtmls)
-                } else {
-                    emailHtml := emailHtml_gs
-                    emailHtmls := fmt.Sprintf(emailHtml, company_name, id_num, phone, e_mail)
-                    html = fmt.Sprintf(email_format, res["order_code"], res["url"], emailHtmls)
-                }
-                data["invoice_changed"] = 1
-                data["invoice_status"] = 1
-                data["billing_time"] = tm.Unix()
-                data["create_time"] = tm.Unix()
-                order_id := util.Mysql.Insert(dbname, data)
-                if order_id == -1 {
-                    errCode = append(errCode, fmt.Sprintf("%s_%s", res["order_code"], res["invoice_order_code"]))
-                }
-                if !isMail { //成功发邮件
-                    isMail = true
-                    InvoiceSendMail(res["mail"].(string), html, "电子发票")
-                }
-            case false:
-                if util.Mysql.Count(dbname, map[string]interface{}{
-                    "order_code":       res["order_code"],
-                    "user_id":          res["user_id"],
-                    "only_Identifying": res["only_Identifying"],
-                }) > 1 {
-                    continue
-                }
-                dataexport_data := make(map[string]interface{})
-                if invoice_type == "个人" {
-                    dataexport_data["applyBill_type"] = 0
-                    dataexport_data["applyBill_taxnum"] = ""
-                    dataexport_data["applybill_company"] = ""
-                } else {
-                    dataexport_data["applyBill_type"] = 1
-                    dataexport_data["applyBill_taxnum"] = id_num
-                    dataexport_data["applybill_company"] = company_name
-                }
-                dataexport_data["user_mail"] = e_mail
-                util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": res["order_code"]}, dataexport_data)
-                data["mail"] = e_mail
-                data["phone"] = phone
-                data["invoice_type"] = invoice_type
-                data["company_name"] = company_name
-                data["taxpayer_identnum"] = id_num
-                data["invoice_changed"] = 1
-                data["create_time"] = time.Now().Unix()
-                data["invoice_status"] = invoice_status
-                order_id := util.Mysql.Insert(dbname, data)
-                if order_id == -1 {
-                    errCode = append(errCode, fmt.Sprintf("%s_%s", res["order_code"], res["invoice_order_code"]))
-                }
-            }
-        }
-        log.Println("换票错误信息:", errCode)
-        if !config.InvoiceConfig.Third_party_switch {
-            this.ServeJson(map[string]interface{}{
-                "invoice_status": invoice_status,
-            })
-            return
-        }
-    } else {
-        if qutil.IntAll((*oRes)["invoice_status"]) < 0 {
-            this.ServeJson(map[string]interface{}{
-                "invoice_status": invoice_status,
-            })
-            return
-        }
-    }
+	//红冲开关
+	if !config.InvoiceConfig.Red_invoice_switch {
+		this.ServeJson(map[string]interface{}{
+			"invoice_status": -1,
+			"invoice_msg":    config.InvoiceConfig.Red_invoice_msg,
+		})
+		return
+	}
+	invoice_type := this.GetString("invoice_type")
+	phone := this.GetString("phone")
+	e_mail := this.GetString("mail")
+	company_name := this.GetString("company_name")
+	id_num := strings.ToUpper(this.GetString("taxpayer_identnum")) //纳税人识别号
+	invoiceContent := this.GetString("invoiceContent")
+	remark := this.GetString("remark")
+	invoiceVariety := this.GetString("invoice_variety")
+	invoice_status := 0
+	//userId := qutil.ObjToString(this.GetSession("userId"))  支持扫描换票
+	//order_code := this.GetString("order_code")
+	sid := encrypt.SE.Decode4Hex(this.GetString("sid"))
+	oRes := util.Mysql.FindOne(dbname, map[string]interface{}{"id": sid, "invoice_changed": 0}, "", "") //仅线上开发票可换票
+	if oRes != nil && len(*oRes) > 0 &&
+		((*oRes)["invoicing_entity"] == nil || qutil.InterfaceToStr((*oRes)["invoicing_entity"]) == config.InvoiceConfig.SigningSubject) {
+		var (
+			qSql    string
+			errCode []string
+			//saveData []map[string]interface{}
+			resArr []map[string]interface{}
+		)
+		if qutil.IntAll((*oRes)["invoice_status"]) == -2 {
+			this.ServeJson(map[string]interface{}{
+				"invoice_status": -2,
+			})
+			return
+		}
+		if invoice_order_code := qutil.InterfaceToStr((*oRes)["invoice_order_code"]); len(strings.Split(invoice_order_code, ",")) > 1 {
+			qSql = fmt.Sprintf(`SELECT * FROM invoice WHERE invoice_order_code = '%s' `, qutil.InterfaceToStr((*oRes)["invoice_order_code"]))
+			res1 := util.Mysql.SelectBySql(qSql)
+			if res1 != nil && len(*res1) > 0 {
+				resArr = *res1
+			}
+		} else { //多订单联合开票
+			resArr = append(resArr, *oRes)
+		}
+		var isMail bool
+		tm := time.Now()
+		for _, res := range resArr {
+			if res["only_Identifying"] == nil { //无唯一id 允许换票一次 生成唯一id
+				newUuid := uuid.New()
+				res["only_Identifying"] = newUuid
+				util.Mysql.Update(dbname, map[string]interface{}{"id": res["id"]}, map[string]interface{}{"only_Identifying": newUuid})
+			} else if util.Mysql.Count(dbname, map[string]interface{}{
+				"order_code":       res["order_code"],
+				"user_id":          res["user_id"],
+				"only_Identifying": res["only_Identifying"],
+			}) > 1 {
+				continue
+			}
+			res["phone"] = phone
+			res["mail"] = e_mail
+			res["invoice_content"] = invoiceContent
+			res["company_phone"] = this.GetString("company_phone")
+			res["taxpayer_identnum"] = id_num
+			res["operable_time"] = FormatDate(&tm, Date_Full_Layout)
+			res["remark"] = remark
+			res["invoice_variety"] = invoiceVariety
+			res["bank_account"] = this.GetString("bank_account")
+			res["company_address"] = this.GetString("company_address")
+			res["bank_name"] = this.GetString("bank_name")
+			res["recipient"] = this.GetString("recipient")
+			res["delivery_address"] = this.GetString("delivery_address")
+			res["company_name"] = company_name
+			res["invoice_type"] = invoice_type
+			data := res
+			delete(data, "id")
+			switch IsEdit(res, phone, e_mail, id_num, company_name, invoice_type, invoiceContent, remark, invoiceVariety) {
+			case true:
+				var html string
+				if invoice_type == "个人" {
+					emailHtml := emailHtml_gr
+					emailHtmls := fmt.Sprintf(emailHtml, phone, e_mail)
+					html = fmt.Sprintf(email_format, res["order_code"], res["url"], emailHtmls)
+				} else {
+					emailHtml := emailHtml_gs
+					emailHtmls := fmt.Sprintf(emailHtml, company_name, id_num, phone, e_mail)
+					html = fmt.Sprintf(email_format, res["order_code"], res["url"], emailHtmls)
+				}
+				data["invoice_changed"] = 1
+				data["invoice_status"] = 1
+				data["billing_time"] = tm.Unix()
+				data["create_time"] = tm.Unix()
+				order_id := util.Mysql.Insert(dbname, data)
+				if order_id == -1 {
+					errCode = append(errCode, fmt.Sprintf("%s_%s", res["order_code"], res["invoice_order_code"]))
+				}
+				if !isMail { //成功发邮件
+					isMail = true
+					InvoiceSendMail(res["mail"].(string), html, "电子发票")
+				}
+			case false:
+				if util.Mysql.Count(dbname, map[string]interface{}{
+					"order_code":       res["order_code"],
+					"user_id":          res["user_id"],
+					"only_Identifying": res["only_Identifying"],
+				}) > 1 {
+					continue
+				}
+				dataexport_data := make(map[string]interface{})
+				if invoice_type == "个人" {
+					dataexport_data["applyBill_type"] = 0
+					dataexport_data["applyBill_taxnum"] = ""
+					dataexport_data["applybill_company"] = ""
+				} else {
+					dataexport_data["applyBill_type"] = 1
+					dataexport_data["applyBill_taxnum"] = id_num
+					dataexport_data["applybill_company"] = company_name
+				}
+				dataexport_data["user_mail"] = e_mail
+				util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": res["order_code"]}, dataexport_data)
+				data["mail"] = e_mail
+				data["phone"] = phone
+				data["invoice_type"] = invoice_type
+				data["company_name"] = company_name
+				data["taxpayer_identnum"] = id_num
+				data["invoice_changed"] = 1
+				data["create_time"] = time.Now().Unix()
+				data["invoice_status"] = invoice_status
+				order_id := util.Mysql.Insert(dbname, data)
+				if order_id == -1 {
+					errCode = append(errCode, fmt.Sprintf("%s_%s", res["order_code"], res["invoice_order_code"]))
+				}
+			}
+		}
+		log.Println("换票错误信息:", errCode)
+		if !config.InvoiceConfig.Third_party_switch {
+			this.ServeJson(map[string]interface{}{
+				"invoice_status": invoice_status,
+			})
+			return
+		}
+	} else {
+		this.ServeJson(map[string]interface{}{
+			"invoice_status": -1,
+		})
+		return
+	}
 
 }
 
-func IsEdit(res map[string]interface{}, phone, e_mail, id_num, company_name, invoice_type string) bool {
-    if invoice_type == "个人" {
-        if phone == res["phone"] && e_mail == res["mail"] && res["invoice_type"] == "个人" {
-            return true
-        }
-    } else {
-        if phone == res["phone"] && e_mail == res["mail"] && id_num == res["taxpayer_identnum"] && company_name == res["company_name"] && res["invoice_type"] == "单位" {
-            return true
-        }
-    }
-    return false
+func IsEdit(res map[string]interface{}, phone, e_mail, id_num, company_name, invoice_type, invoiceContent, remark, invoiceVariety string) bool {
+	if invoice_type == "个人" {
+		if phone == res["phone"] && e_mail == res["mail"] && res["invoice_type"] == "个人" {
+			return true
+		}
+	} else {
+		if phone == res["phone"] && e_mail == res["mail"] && id_num == res["taxpayer_identnum"] &&
+			company_name == res["company_name"] && res["invoice_type"] == "单位" &&
+			res["invoice_content"] == invoiceContent && res["remark"] == remark && res["invoice_variety"] == invoiceVariety {
+			return true
+		}
+	}
+	return false
 }
 
 // 退票
 func (this *Invoice) Refundinvoice() {
-    if !config.InvoiceConfig.Third_party_switch {
-        this.ServeJson(map[string]interface{}{
-            "invoice_status": -1,
-            "invoice_msg":    config.InvoiceConfig.Red_invoice_msg,
-        })
-        return
-    }
-    var refund_flag = -1
-    userid := this.GetSession("userId")
-    invoice_serialnum := this.GetString("invoice_serialnum") //发票流水号
-    if invoice_serialnum != "" {
-        query := make(map[string]interface{})
-        query["invoice_serialnum"] = invoice_serialnum
-        query["user_id"] = userid
-        res := util.Mysql.FindOne(dbname, query, "fpdm,fphm,invoice_serialnum", "")
-        if res != nil {
-            req_ := make(map[string]interface{})
-            req_["fpdm"] = (*res)["fpdm"]
-            req_["fphm"] = (*res)["fphm"]
-            req_["redcode"] = (*res)["invoice_serialnum"]
-            b, _ := json.Marshal(req_)
-            buffer := bytes.NewBuffer(b)
-            request, _ := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/RedSubmit", buffer)
-            client := &http.Client{}
-            response, err := client.Do(request)
-            if err == nil {
-                res, _ := ioutil.ReadAll(response.Body)
-                defer response.Body.Close()
-                result := map[string]interface{}{}
-                err := json.Unmarshal(res, &result)
-                if err != nil {
-                    log.Println("json序列化错误")
-                } else {
-                    if result["code"].(string) == "0" {
-                        refund_flag = 0
-                    } else if result["code"].(string) == "1" {
-                        refund_flag = 1
-                    } else {
-                        refund_flag = 2
-                    }
-                }
-                go util.Mysql.Update(dbname, query, map[string]interface{}{"refund_flag": refund_flag})
-            }
+	if !config.InvoiceConfig.Third_party_switch {
+		this.ServeJson(map[string]interface{}{
+			"invoice_status": -1,
+			"invoice_msg":    config.InvoiceConfig.Red_invoice_msg,
+		})
+		return
+	}
+	var refund_flag = -1
+	userid := this.GetSession("userId")
+	invoice_serialnum := this.GetString("invoice_serialnum") //发票流水号
+	if invoice_serialnum != "" {
+		query := make(map[string]interface{})
+		query["invoice_serialnum"] = invoice_serialnum
+		query["user_id"] = userid
+		res := util.Mysql.FindOne(dbname, query, "fpdm,fphm,invoice_serialnum", "")
+		if res != nil {
+			req_ := make(map[string]interface{})
+			req_["fpdm"] = (*res)["fpdm"]
+			req_["fphm"] = (*res)["fphm"]
+			req_["redcode"] = (*res)["invoice_serialnum"]
+			b, _ := json.Marshal(req_)
+			buffer := bytes.NewBuffer(b)
+			request, _ := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/RedSubmit", buffer)
+			client := &http.Client{}
+			response, err := client.Do(request)
+			if err == nil {
+				res, _ := ioutil.ReadAll(response.Body)
+				defer response.Body.Close()
+				result := map[string]interface{}{}
+				err := json.Unmarshal(res, &result)
+				if err != nil {
+					log.Println("json序列化错误")
+				} else {
+					if result["code"].(string) == "0" {
+						refund_flag = 0
+					} else if result["code"].(string) == "1" {
+						refund_flag = 1
+					} else {
+						refund_flag = 2
+					}
+				}
+				go util.Mysql.Update(dbname, query, map[string]interface{}{"refund_flag": refund_flag})
+			}
 
-        }
-    }
+		}
+	}
 
 }
 
 func (this *Invoice) Invoiceinfo() {
-    userId := qutil.ObjToString(this.GetSession("userId"))
-    order_code := this.GetString("order_code")
-    data := make(map[string]interface{})
-    data["order_code"] = order_code
-    data["user_id"] = userId
-    countdowntime := config.Config.OrderCountdown.(string)
-    status := util.Mysql.FindOne("dataexport_order", data, "", "")
-    if *status != nil {
-        (*status)["source"] = LastInvoiceSource(qutil.InterfaceToStr((*status)["order_code"]))
-        //卡卷id加密
-        if (*status)["d_relation_id"] != "" {
-            (*status)["userLotteryId"] = encrypt.SE.Encode2Hex(qutil.ObjToString((*status)["d_relation_id"]))
-        }
-        (*status)["order_money"] = float64((*status)["order_money"].(int64)) / 100
-        if (*status)["discount_price"] != nil && (*status)["discount_price"].(int64) > 0 {
-            (*status)["discount_price"] = float64((*status)["discount_price"].(int64)) / 100
-        }
-        if (*status)["pay_money"] != nil && (*status)["pay_money"].(int64) > 0 {
-            (*status)["pay_money"] = float64((*status)["pay_money"].(int64)) / 100
-        }
-        delete((*status), "d_relation_id")
-        (*status)["countdown"] = countdowntime
-        this.ServeJson(map[string]interface{}{
-            "status": "success",
-            "data":   status,
-        })
-    } else {
-        (*status)["countdown"] = countdowntime
-        this.ServeJson(map[string]interface{}{
-            "status": "fail",
-            "data":   "",
-        })
-    }
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	order_code := this.GetString("order_code")
+	data := make(map[string]interface{})
+	data["order_code"] = order_code
+	data["user_id"] = userId
+	countdowntime := config.Config.OrderCountdown.(string)
+	status := util.Mysql.FindOne("dataexport_order", data, "", "")
+	if *status != nil {
+		(*status)["source"] = LastInvoiceSource(qutil.InterfaceToStr((*status)["order_code"]))
+		//卡卷id加密
+		if (*status)["d_relation_id"] != "" {
+			(*status)["userLotteryId"] = encrypt.SE.Encode2Hex(qutil.ObjToString((*status)["d_relation_id"]))
+		}
+		(*status)["order_money"] = float64((*status)["order_money"].(int64)) / 100
+		if (*status)["discount_price"] != nil && (*status)["discount_price"].(int64) > 0 {
+			(*status)["discount_price"] = float64((*status)["discount_price"].(int64)) / 100
+		}
+		if (*status)["pay_money"] != nil && (*status)["pay_money"].(int64) > 0 {
+			(*status)["pay_money"] = float64((*status)["pay_money"].(int64)) / 100
+		}
+		delete((*status), "d_relation_id")
+		(*status)["countdown"] = countdowntime
+		this.ServeJson(map[string]interface{}{
+			"status": "success",
+			"data":   status,
+		})
+	} else {
+		(*status)["countdown"] = countdowntime
+		this.ServeJson(map[string]interface{}{
+			"status": "fail",
+			"data":   "",
+		})
+	}
 
 }
 
 func InvoiceSendMail(target_mail, html, title string) {
-    for k, v := range config.GmailAuth {
-        if mail.GSendMail("剑鱼标讯", target_mail, "", "", title, html, "", "", v) {
-            log.Println(target_mail, fmt.Sprintf("使用%s发送邮件成功", v.User))
-            break
-        }
-        if k < len(config.GmailAuth)-1 {
-            log.Println(target_mail, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User))
-        } else {
-            log.Println(target_mail, fmt.Sprintf("使用%s发送邮件失败!", v.User))
-        }
-        time.Sleep(time.Second * 3)
-    }
+	for k, v := range config.GmailAuth {
+		if mail.GSendMail("剑鱼标讯", target_mail, "", "", title, html, "", "", v) {
+			log.Println(target_mail, fmt.Sprintf("使用%s发送邮件成功", v.User))
+			break
+		}
+		if k < len(config.GmailAuth)-1 {
+			log.Println(target_mail, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User))
+		} else {
+			log.Println(target_mail, fmt.Sprintf("使用%s发送邮件失败!", v.User))
+		}
+		time.Sleep(time.Second * 3)
+	}
 }
 
 // 查询订单最后开票状态
 func LastInvoiceSource(orderCode string) int64 {
-    orderData := util.Mysql.SelectBySql("select source  from  invoice   where   order_code  =? ORDER BY  create_time desc ", orderCode)
-    if orderData != nil && len(*orderData) > 0 {
-        return qutil.Int64All((*orderData)[0]["source"])
-    }
-    return 0
+	orderData := util.Mysql.SelectBySql("select source  from  invoice   where   order_code  =? ORDER BY  create_time desc ", orderCode)
+	if orderData != nil && len(*orderData) > 0 {
+		return qutil.Int64All((*orderData)[0]["source"])
+	}
+	return 0
 }
 
 // 是否可开票
 func IsAllowInvoice(res map[string]interface{}) bool {
-    filter := qutil.ObjToString(res["filter"].(string))
-    filter_map := map[string]interface{}{}
-    _ = json.Unmarshal([]byte(filter), &filter_map)
-    if res["order_status"] == 1 && filter_map["badge"] != "exchange" &&
-        //用户下单|| 代用户下单|| qmx下单 已全额回款 发票企业为剑鱼
-        (res["is_backstage_order"] == 0 || res["order_channel"] == "xdqd04" ||
-            (res["return_status"] == 1 && util.Mysql.Count("invoice", map[string]interface{}{
-                "order_code": res["order_code"],
-            }) == 0 && res["signing_subject"] == config.InvoiceConfig.SigningSubject)) {
-        return true
-    }
-    return false
+	filter := qutil.ObjToString(res["filter"].(string))
+	filter_map := map[string]interface{}{}
+	_ = json.Unmarshal([]byte(filter), &filter_map)
+	if qutil.IntAll(res["order_status"]) == 1 && qutil.InterfaceToStr(filter_map["badge"]) != "exchange" &&
+		//用户下单|| 代用户下单|| qmx下单 已全额回款 发票企业为剑鱼
+		(qutil.IntAll(res["is_backstage_order"]) == 0 || qutil.InterfaceToStr(res["order_channel"]) == "xdqd04" ||
+			(qutil.IntAll(res["return_status"]) == 1 && util.Mysql.Count("invoice", map[string]interface{}{
+				"order_code": res["order_code"],
+			}) == 0 && qutil.InterfaceToStr(res["signing_subject"]) == config.InvoiceConfig.SigningSubject)) {
+		return true
+	}
+	return false
 }
 
 func (this *Invoice) Available() {
-    u := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": this.GetString("order_code")}, "pay_time", "")
-    status := 0
-    if u != nil {
-        if pay_time, _ := (*u)["pay_time"].(string); pay_time != "" && config.InvoiceConfig.Switch_paymch.Time != "" {
-            p1, err1 := time.ParseInLocation(Date_Full_Layout, pay_time, time.Local)
-            p2, err2 := time.ParseInLocation(Date_Full_Layout, config.InvoiceConfig.Switch_paymch.Time, time.Local)
-            if err1 == nil && err2 == nil {
-                if config.InvoiceConfig.Switch_paymch.Model == 1 { //大于该时间点,不能开票
-                    if p1.Before(p2) {
-                        status = 1
-                    }
-                } else if config.InvoiceConfig.Switch_paymch.Model == 2 { //小于该时间点,不能开票
-                    if p1.After(p2) {
-                        status = 1
-                    }
-                } else { //无限制,都能开票
-                    status = 1
-                }
-            }
-        }
-    }
-    this.ServeJson(map[string]interface{}{
-        "status": status,
-    })
+	u := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": this.GetString("order_code")}, "pay_time", "")
+	status := 0
+	if u != nil {
+		if pay_time, _ := (*u)["pay_time"].(string); pay_time != "" && config.InvoiceConfig.Switch_paymch.Time != "" {
+			p1, err1 := time.ParseInLocation(Date_Full_Layout, pay_time, time.Local)
+			p2, err2 := time.ParseInLocation(Date_Full_Layout, config.InvoiceConfig.Switch_paymch.Time, time.Local)
+			if err1 == nil && err2 == nil {
+				if config.InvoiceConfig.Switch_paymch.Model == 1 { //大于该时间点,不能开票
+					if p1.Before(p2) {
+						status = 1
+					}
+				} else if config.InvoiceConfig.Switch_paymch.Model == 2 { //小于该时间点,不能开票
+					if p1.After(p2) {
+						status = 1
+					}
+				} else { //无限制,都能开票
+					status = 1
+				}
+			}
+		}
+	}
+	this.ServeJson(map[string]interface{}{
+		"status": status,
+	})
 }
 
 // 删除有问题的换开发票并记录
 func delReplaceInvoice(query map[string]interface{}) bool {
-    data := util.Mysql.FindOne(dbname, query, "", "")
-    if data != nil && len(*data) > 0 {
-        log.Printf("invoice replace delete data: %+v", data)
-    }
-    return util.Mysql.Delete(dbname, query)
+	data := util.Mysql.FindOne(dbname, query, "", "")
+	if data != nil && len(*data) > 0 {
+		log.Printf("invoice replace delete data: %+v", data)
+	}
+	return util.Mysql.Delete(dbname, query)
 }
 
 func InvoiceAmount(orderCode string) (invoicedMoney int64) {
-    invoicedInfo := util.Mysql.SelectBySql(fmt.Sprintf("SELECT invoice_order_money,only_Identifying FROM invoice WHERE order_code = '%s' and invoice_status>=0", orderCode))
-    if invoicedInfo != nil && len(*invoicedInfo) > 0 {
-        onlyMap := make(map[string]int64)
-        for _, m := range *invoicedInfo {
-            if m["only_Identifying"] != nil { //过滤换票过程中的数据
-                onlyMap[qutil.InterfaceToStr(m["only_Identifying"])] = qutil.Int64All(m["invoice_order_money"])
-            } else {
-                invoicedMoney += qutil.Int64All(m["invoice_order_money"])
-            }
-        }
-        if len(onlyMap) > 0 {
-            for _, i := range onlyMap {
-                invoicedMoney += i
-            }
-        }
-    }
-    return
+	invoicedInfo := util.Mysql.SelectBySql(fmt.Sprintf("SELECT invoice_order_money,only_Identifying FROM invoice WHERE order_code = '%s' and invoice_status>=0", orderCode))
+	if invoicedInfo != nil && len(*invoicedInfo) > 0 {
+		onlyMap := make(map[string]int64)
+		for _, m := range *invoicedInfo {
+			if m["only_Identifying"] != nil { //过滤换票过程中的数据
+				onlyMap[qutil.InterfaceToStr(m["only_Identifying"])] = qutil.Int64All(m["invoice_order_money"])
+			} else {
+				invoicedMoney += qutil.Int64All(m["invoice_order_money"])
+			}
+		}
+		if len(onlyMap) > 0 {
+			for _, i := range onlyMap {
+				invoicedMoney += i
+			}
+		}
+	}
+	return
 }
 
 // InvoiceSubmit 发票信息提交
 func (this *Invoice) InvoiceSubmit() {
-    if !R.CheckReqParam(this.ResponseWriter, this.Request, "invoice_variety", "invoiceContent", "invoice_type", "phone", "mail") {
-        this.ServeJson(NewResult("", errors.New("缺少参数")))
-        return
-    }
-    if this.GetString("invoice_type") == "单位" && !R.CheckReqParam(this.ResponseWriter, this.Request, "company_name", "taxpayer_identnum") {
-        this.ServeJson(NewResult("", errors.New("缺少参数")))
-        return
-    }
-    if !config.InvoiceConfig.Invoice_type[this.GetString("invoice_variety")] {
-        this.ServeJson(NewResult("", errors.New("发票类型有误")))
-        return
-    }
-    if this.GetString("invoice_type") != "个人" && this.GetString("invoice_type") != "单位" {
-        this.ServeJson(NewResult("", errors.New("发票抬头有误")))
-        return
-    }
-    now := time.Now()
-    again, _ := this.GetInteger("again")                       //是否是失败重新开票 0 首次提交  1 再此提交
-    oldOnlyIdentifying := this.GetString("oldOnlyIdentifying") //最后一次失败的发票信息唯一标识
-    data := map[string]interface{}{
-        "company_name":      this.GetString("company_name"),
-        "phone":             this.GetString("phone"),
-        "mail":              this.GetString("mail"),
-        "invoice_type":      this.GetString("invoice_type"),
-        "invoice_content":   this.GetString("invoiceContent"),
-        "invoice_status":    0,
-        "invoice_changed":   0,
-        "company_phone":     this.GetString("company_phone"),
-        "taxpayer_identnum": this.GetString("taxpayer_identnum"),
-        "create_time":       time.Now().Unix(),
-        "operable_time":     FormatDate(&now, Date_Full_Layout),
-        "invoicing_entity":  "北京剑鱼信息技术有限公司",
-        "remark":            this.GetString("remark"),
-        "invoice_variety":   this.GetString("invoice_variety"),
-        "bank_account":      this.GetString("bank_account"),
-        "company_address":   this.GetString("company_address"),
-        "bank_name":         this.GetString("bank_name"),
-        "recipient":         this.GetString("recipient"),
-        "delivery_address":  this.GetString("delivery_address"),
-    }
-    if again == 1 {
-        err := OpenInvoiceAgain(oldOnlyIdentifying, data)
-        if err != nil {
-            this.ServeJson(NewResult("", err))
-            return
-        }
-        this.ServeJson(NewResult("保存信息成功", nil))
-        return
-    }
-    source, _ := this.GetInteger("source")
-    switch source {
-    case 0: //用户端开票
-        userId := qutil.ObjToString(this.GetSession("userId"))
-        if userId == "" {
-            this.ServeJson(NewResult("", errors.New("userId为空")))
-            return
-        }
-        orderCode := this.GetString("order_code")
-        err := JyOpenInvoice(orderCode, userId, data)
-        if err != nil {
-            this.ServeJson(NewResult("", err))
-            return
-        }
-    case 1: //管理后台扫码开票
-        onlyIdentifying := encrypt.SE.DecodeString(this.GetString("onlyIdentifying"))
-        invoiceMoney := encrypt.SE.DecodeString(this.GetString("invoiceMoney"))
-        operator := encrypt.SE.Decode4HexByCheck(this.GetString("operator"))
-        if onlyIdentifying == "" || invoiceMoney == "" {
-            this.ServeJson(NewResult("", errors.New("传入参数不正确")))
-            return
-        }
-        err := AdminOpenInvoice(onlyIdentifying, invoiceMoney, operator, data)
-        if err != nil {
-            this.ServeJson(NewResult("", err))
-            return
-        }
-    }
-    this.ServeJson(NewResult("保存信息成功", nil))
+	if !R.CheckReqParam(this.ResponseWriter, this.Request, "invoice_variety", "invoiceContent", "invoice_type", "phone", "mail") {
+		this.ServeJson(NewResult("", errors.New("缺少参数")))
+		return
+	}
+	if this.GetString("invoice_type") == "单位" && !R.CheckReqParam(this.ResponseWriter, this.Request, "company_name", "taxpayer_identnum") {
+		this.ServeJson(NewResult("", errors.New("缺少参数")))
+		return
+	}
+	if !config.InvoiceConfig.Invoice_type[this.GetString("invoice_variety")] {
+		this.ServeJson(NewResult("", errors.New("发票类型有误")))
+		return
+	}
+	if this.GetString("invoice_type") != "个人" && this.GetString("invoice_type") != "单位" {
+		this.ServeJson(NewResult("", errors.New("发票抬头有误")))
+		return
+	}
+	now := time.Now()
+	again, _ := this.GetInteger("again")                       //是否是失败重新开票 0 首次提交  1 再此提交
+	oldOnlyIdentifying := this.GetString("oldOnlyIdentifying") //最后一次失败的发票信息唯一标识
+	data := map[string]interface{}{
+		"company_name":      this.GetString("company_name"),
+		"phone":             this.GetString("phone"),
+		"mail":              this.GetString("mail"),
+		"invoice_type":      this.GetString("invoice_type"),
+		"invoice_content":   this.GetString("invoiceContent"),
+		"invoice_status":    0,
+		"invoice_changed":   0,
+		"company_phone":     this.GetString("company_phone"),
+		"taxpayer_identnum": this.GetString("taxpayer_identnum"),
+		"create_time":       time.Now().Unix(),
+		"operable_time":     FormatDate(&now, Date_Full_Layout),
+		"invoicing_entity":  "北京剑鱼信息技术有限公司",
+		"remark":            this.GetString("remark"),
+		"invoice_variety":   this.GetString("invoice_variety"),
+		"bank_account":      this.GetString("bank_account"),
+		"company_address":   this.GetString("company_address"),
+		"bank_name":         this.GetString("bank_name"),
+		"recipient":         this.GetString("recipient"),
+		"delivery_address":  this.GetString("delivery_address"),
+	}
+	if again == 1 {
+		err := OpenInvoiceAgain(oldOnlyIdentifying, data)
+		if err != nil {
+			this.ServeJson(NewResult("", err))
+			return
+		}
+		this.ServeJson(NewResult("保存信息成功", nil))
+		return
+	}
+	source, _ := this.GetInteger("source")
+	switch source {
+	case 0: //用户端开票
+		userId := qutil.ObjToString(this.GetSession("userId"))
+		if userId == "" {
+			this.ServeJson(NewResult("", errors.New("userId为空")))
+			return
+		}
+		orderCode := this.GetString("order_code")
+		err := JyOpenInvoice(orderCode, userId, data)
+		if err != nil {
+			this.ServeJson(NewResult("", err))
+			return
+		}
+	case 1: //管理后台扫码开票
+		onlyIdentifying := encrypt.SE.DecodeString(this.GetString("onlyIdentifying"))
+		invoiceMoney := encrypt.SE.DecodeString(this.GetString("invoiceMoney"))
+		operator := encrypt.SE.Decode4HexByCheck(this.GetString("operator"))
+		if onlyIdentifying == "" || invoiceMoney == "" {
+			this.ServeJson(NewResult("", errors.New("传入参数不正确")))
+			return
+		}
+		err := AdminOpenInvoice(onlyIdentifying, invoiceMoney, operator, data)
+		if err != nil {
+			this.ServeJson(NewResult("", err))
+			return
+		}
+	}
+	this.ServeJson(NewResult("保存信息成功", nil))
 }
 
 func OpenInvoiceAgain(oldOnlyIdentifying string, data map[string]interface{}) error {
-    if oldOnlyIdentifying == "" {
-        return errors.New("缺少关键参数")
-    }
-    ok := InvoiceFailRecord(oldOnlyIdentifying)
-    if !ok {
-        return errors.New("插入失败记录出错")
-    }
-    if util.Mysql.Count("invoice_fail_record", map[string]interface{}{"only_Identifying": oldOnlyIdentifying}) >= config.InvoiceConfig.SubmitNum {
-        return errors.New("提交次数已达上限")
-    }
-    if !util.Mysql.Update("invoice", map[string]interface{}{"only_Identifying": oldOnlyIdentifying}, data) {
-        return errors.New("再次开票更新发票信息出错")
-    }
-    return nil
+	if oldOnlyIdentifying == "" {
+		return errors.New("缺少关键参数")
+	}
+	ok := InvoiceFailRecord(oldOnlyIdentifying)
+	if !ok {
+		return errors.New("插入失败记录出错")
+	}
+	if util.Mysql.Count("invoice_fail_record", map[string]interface{}{"only_Identifying": oldOnlyIdentifying}) >= config.InvoiceConfig.SubmitNum {
+		return errors.New("提交次数已达上限")
+	}
+	if !util.Mysql.Update("invoice", map[string]interface{}{"only_Identifying": oldOnlyIdentifying}, data) {
+		return errors.New("再次开票更新发票信息出错")
+	}
+	return nil
 }
 
 func JyOpenInvoice(orderCode, userId string, data map[string]interface{}) error {
-    onlyIdentifying := fmt.Sprintf("%s%s%s", "aa", time.Now().Format("150405"), qutil.GetRandom(4))
-    orderInfo := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": orderCode}, "product_type,user_mail,pay_money,create_time,signing_subject", "")
-    if orderInfo == nil {
-        return errors.New("订单不存在")
-    }
-    createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", qutil.ObjToString((*orderInfo)["create_time"]), time.Local)
-    if createTime.Unix() < config.InvoiceConfig.Order_createtime {
-        return errors.New("2024年之前的订单不在开票")
-    }
-    if qutil.ObjToString((*orderInfo)["signing_subject"]) == "h02" {
-        return errors.New("签约主体为拓普")
-    }
-    invoicedMoney := InvoiceAmount(orderCode) //已开票金额
-    invoiceMoney := qutil.Int64All((*orderInfo)["pay_money"]) - invoicedMoney
-    data["order_code"] = orderCode
-    data["invoice_order_code"] = orderCode
-    data["only_Identifying"] = onlyIdentifying
-    data["invoice_money"] = invoiceMoney
-    data["invoice_order_money"] = invoiceMoney
-    data["product_type"] = qutil.ObjToString((*orderInfo)["product_type"])
-    data["user_id"] = userId
-    data["source"] = 0
-    if !util.Mysql.ExecTx("用户端开发票", func(tx *sql.Tx) bool {
-        if util.Mysql.InsertByTx(tx, "invoice", data) <= 0 {
-            log.Println("插入invoice出错", orderCode)
-            return false
-        }
-        if !util.Mysql.UpdateByTx(tx, "dataexport_order", map[string]interface{}{
-            "order_code": orderCode,
-        }, map[string]interface{}{
-            "applybill_status": 1,
-        }) {
-            log.Println("更新dataexport_order出错", orderCode)
-            return false
-        }
-        return true
-    }) {
-        return errors.New("用户端开票插入数据出错")
-    }
-    return nil
+	onlyIdentifying := fmt.Sprintf("%s%s%s", "aa", time.Now().Format("150405"), qutil.GetRandom(4))
+	orderInfo := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": orderCode}, "product_type,user_mail,pay_money,create_time,signing_subject,applybill_status", "")
+	if orderInfo == nil {
+		return errors.New("订单不存在")
+	}
+	createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", qutil.ObjToString((*orderInfo)["create_time"]), time.Local)
+	if createTime.Unix() < config.InvoiceConfig.Order_createtime {
+		return errors.New("2024年之前的订单不在开票")
+	}
+	if qutil.ObjToString((*orderInfo)["signing_subject"]) == "h02" {
+		return errors.New("签约主体为拓普")
+	}
+	if qutil.IntAll((*orderInfo)["applybill_status"]) != 0 {
+		return errors.New("已提交发票信息")
+	}
+	invoicedMoney := InvoiceAmount(orderCode) //已开票金额
+	invoiceMoney := qutil.Int64All((*orderInfo)["pay_money"]) - invoicedMoney
+	data["order_code"] = orderCode
+	data["invoice_order_code"] = orderCode
+	data["only_Identifying"] = onlyIdentifying
+	data["invoice_money"] = invoiceMoney
+	data["invoice_order_money"] = invoiceMoney
+	data["product_type"] = qutil.ObjToString((*orderInfo)["product_type"])
+	data["user_id"] = userId
+	data["source"] = 0
+	if !util.Mysql.ExecTx("用户端开发票", func(tx *sql.Tx) bool {
+		if util.Mysql.InsertByTx(tx, "invoice", data) <= 0 {
+			log.Println("插入invoice出错", orderCode)
+			return false
+		}
+		if !util.Mysql.UpdateByTx(tx, "dataexport_order", map[string]interface{}{
+			"order_code": orderCode,
+		}, map[string]interface{}{
+			"applybill_status": 1,
+		}) {
+			log.Println("更新dataexport_order出错", orderCode)
+			return false
+		}
+		return true
+	}) {
+		return errors.New("用户端开票插入数据出错")
+	}
+	return nil
 }
 
 func AdminOpenInvoice(onlyIdentifying, invoiceMoney, operator string, data map[string]interface{}) error {
-    oldData := util.Mysql.FindOne("invoice", map[string]interface{}{
-        "only_Identifying": onlyIdentifying,
-    }, "id", "")
-    if oldData != nil {
-        return errors.New("该订单发票信息已经提交过申请")
-    }
-    orderArr := []string{}
-    mailOrderArr := []string{}
-    orderMap := map[string]interface{}{}
-    Allmoney := int64(0)
-    for _, v := range strings.Split(invoiceMoney, ",") {
-        invoiceMoneyArr := strings.Split(v, ":")
-        orderArr = append(orderArr, invoiceMoneyArr[0])
-        Allmoney += qutil.Int64All(invoiceMoneyArr[1])
-        orderMap[invoiceMoneyArr[0]] = invoiceMoneyArr[1]
-        prices := qutil.Float64All(invoiceMoneyArr[1]) / float64(100)
-        price := strconv.FormatFloat(prices, 'f', -1, 64)
-        mailOrderArr = append(mailOrderArr, fmt.Sprintf("%s(%s元)", invoiceMoneyArr[0], price))
+	oldData := util.Mysql.FindOne("invoice", map[string]interface{}{
+		"only_Identifying": onlyIdentifying,
+	}, "id", "")
+	if oldData != nil {
+		return errors.New("该订单发票信息已经提交过申请")
+	}
+	orderArr := []string{}
+	mailOrderArr := []string{}
+	orderMap := map[string]interface{}{}
+	Allmoney := int64(0)
+	for _, v := range strings.Split(invoiceMoney, ",") {
+		invoiceMoneyArr := strings.Split(v, ":")
+		orderArr = append(orderArr, invoiceMoneyArr[0])
+		Allmoney += qutil.Int64All(invoiceMoneyArr[1])
+		orderMap[invoiceMoneyArr[0]] = invoiceMoneyArr[1]
+		prices := qutil.Float64All(invoiceMoneyArr[1]) / float64(100)
+		price := strconv.FormatFloat(prices, 'f', -1, 64)
+		mailOrderArr = append(mailOrderArr, fmt.Sprintf("%s(%s元)", invoiceMoneyArr[0], price))
 
-    }
-    //提交时订单金额再做一次校验
-    for orderCode, money := range orderMap {
-        if ResidueMoney(orderCode) < qutil.Int64All(money) {
-            return errors.New("该订单发票信息已经提交过申请")
-        }
-    }
-    if !util.Mysql.ExecTx("发票信息保存", func(tx *sql.Tx) bool {
-        for orderCode, money := range orderMap {
-            orderInfo := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": orderCode}, "product_type,user_mail,user_id,create_time", "")
-            productType := ""
-            if orderInfo != nil {
-                productType = qutil.InterfaceToStr((*orderInfo)["product_type"])
-            }
-            createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", qutil.ObjToString((*orderInfo)["create_time"]), time.Local)
-            if createTime.Unix() < config.InvoiceConfig.Order_createtime {
-                log.Println("2024年之前的订单不在开票", orderCode)
-                return false
-            }
-            data["order_code"] = orderCode
-            data["invoice_order_code"] = strings.Join(orderArr, ",")
-            data["only_Identifying"] = onlyIdentifying
-            data["invoice_money"] = Allmoney
-            data["invoice_order_money"] = money
-            data["product_type"] = productType
-            data["user_id"] = qutil.ObjToString((*orderInfo)["user_id"])
-            data["operator"] = operator
-            data["source"] = 1
-            if util.Mysql.Insert("invoice", data) <= 0 {
-                log.Println("扫码开票插入invoice表出错", orderCode)
-                return false
-            }
-            //订单发票状态改成已申请
-            if !util.Mysql.Update("dataexport_order", map[string]interface{}{
-                "order_code": orderCode,
-            }, map[string]interface{}{
-                "applybill_status": 1,
-            }) {
-                log.Println("扫码开票更新dataexport_order表出错", orderCode)
-                return false
-            }
-        }
-        return true
-    }) {
-        return errors.New("发票信息保存失败")
-    }
-    return nil
+	}
+	//提交时订单金额再做一次校验
+	for orderCode, money := range orderMap {
+		if ResidueMoney(orderCode) < qutil.Int64All(money) {
+			return errors.New("该订单发票信息已经提交过申请")
+		}
+	}
+	if !util.Mysql.ExecTx("发票信息保存", func(tx *sql.Tx) bool {
+		for orderCode, money := range orderMap {
+			orderInfo := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": orderCode}, "product_type,user_mail,user_id,create_time", "")
+			productType := ""
+			if orderInfo != nil {
+				productType = qutil.InterfaceToStr((*orderInfo)["product_type"])
+			}
+			createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", qutil.ObjToString((*orderInfo)["create_time"]), time.Local)
+			if createTime.Unix() < config.InvoiceConfig.Order_createtime {
+				log.Println("2024年之前的订单不在开票", orderCode)
+				return false
+			}
+			data["order_code"] = orderCode
+			data["invoice_order_code"] = strings.Join(orderArr, ",")
+			data["only_Identifying"] = onlyIdentifying
+			data["invoice_money"] = Allmoney
+			data["invoice_order_money"] = money
+			data["product_type"] = productType
+			data["user_id"] = qutil.ObjToString((*orderInfo)["user_id"])
+			data["operator"] = operator
+			data["source"] = 1
+			if util.Mysql.Insert("invoice", data) <= 0 {
+				log.Println("扫码开票插入invoice表出错", orderCode)
+				return false
+			}
+			//订单发票状态改成已申请
+			if !util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"order_code": orderCode,
+			}, map[string]interface{}{
+				"applybill_status": 1,
+			}) {
+				log.Println("扫码开票更新dataexport_order表出错", orderCode)
+				return false
+			}
+		}
+		return true
+	}) {
+		return errors.New("发票信息保存失败")
+	}
+	return nil
 }
 
 func InvoiceFailRecord(oldOnlyIdentifying string) bool {
-    //开票失败再次提交
-    invoiceData := util.Mysql.Find("invoice", map[string]interface{}{"only_Identifying": oldOnlyIdentifying, "invoice_status": -1}, "", "", -1, -1)
-    if invoiceData == nil && len(*invoiceData) <= 0 {
-        log.Println("未找到开票记录", oldOnlyIdentifying)
-        return false
-    }
-    //插入开票失败记录表
-    ok := util.Mysql.ExecTx("插入开票失败记录表", func(tx *sql.Tx) bool {
-        for _, val := range *invoiceData {
-            delete(val, "id")
-            if util.Mysql.InsertByTx(tx, "invoice_fail_record", val) <= 0 {
-                return false
-            }
-        }
-        return true
-    })
-    return ok
+	//开票失败再次提交
+	invoiceData := util.Mysql.Find("invoice", map[string]interface{}{"only_Identifying": oldOnlyIdentifying, "invoice_status": -1}, "", "", -1, -1)
+	if invoiceData == nil && len(*invoiceData) <= 0 {
+		log.Println("未找到开票记录", oldOnlyIdentifying)
+		return false
+	}
+	//插入开票失败记录表
+	ok := util.Mysql.ExecTx("插入开票失败记录表", func(tx *sql.Tx) bool {
+		for _, val := range *invoiceData {
+			delete(val, "id")
+			if util.Mysql.InsertByTx(tx, "invoice_fail_record", val) <= 0 {
+				return false
+			}
+		}
+		return true
+	})
+	return ok
 }
 
 func (this *Invoice) GetCompanyCode() {
-    code := ""
-    companyInfo := util.Mysql.FindOne("entniche_info", map[string]interface{}{"name": this.GetString("companyName")}, "code", "")
-    if companyInfo != nil && len(*companyInfo) > 0 {
-        code = qutil.ObjToString((*companyInfo)["code"])
-    }
-    this.ServeJson(NewResult(map[string]interface{}{
-        "code": code,
-    }, nil))
-    return
+	code := ""
+	companyInfo := util.Mysql.FindOne("entniche_info", map[string]interface{}{"name": this.GetString("companyName")}, "code", "")
+	if companyInfo != nil && len(*companyInfo) > 0 {
+		code = qutil.ObjToString((*companyInfo)["code"])
+	}
+	this.ServeJson(NewResult(map[string]interface{}{
+		"code": code,
+	}, nil))
+	return
 }
 
 // 发票信息查询
 func (this *Invoice) InvoiceQuery() {
-    onlyIdentifying := encrypt.SE.DecodeString(this.GetString("onlyIdentifying"))
-    invoiceMoney := encrypt.SE.DecodeString(this.GetString("invoiceMoney"))
-    operator := ""
-    if onlyIdentifying == "" || invoiceMoney == "" {
-        this.ServeJson(NewResult("", errors.New("传入参数不正确")))
-        return
-    }
-    orderArr := []string{}
-    money := int64(0)
-    for _, v := range strings.Split(invoiceMoney, ",") {
-        invoiceMoneyArr := strings.Split(v, ":")
-        orderArr = append(orderArr, invoiceMoneyArr[0])
-        money += qutil.Int64All(invoiceMoneyArr[1])
-    }
-    invoiceOne := util.Mysql.FindOne("invoice", map[string]interface{}{
-        "only_Identifying": onlyIdentifying,
-    }, "id,invoice_changed,order_code, bank_account, company_phone,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", " create_time   DESC")
-    companyName := ""
-    if invoiceOne == nil {
-        //查询公司名称
-        querySQL := fmt.Sprintf("select company_name  from   dataexport_order  where order_code  in  (%s)   and  company_name!=''   ORDER BY  create_time   DESC LIMIT 1", fmt.Sprintf("\"%s\"", strings.Join(orderArr, "\",\"")))
-        orderArr := util.Mysql.SelectBySql(querySQL)
-        if orderArr != nil && len(*orderArr) > 0 {
-            companyName = qutil.ObjToString((*orderArr)[0]["company_name"])
-        }
-    } else {
-        switch qutil.IntAll((*invoiceOne)["invoice_status"]) {
-        case 1:
-            //是否换票
-            isJyInvoice := !strings.Contains(qutil.InterfaceToStr((*invoiceOne)["url"]), "/jyInvoice/") //非数电票
-            isChanged := util.Mysql.Count("invoice", map[string]interface{}{
-                "only_Identifying": onlyIdentifying,
-                "order_code":       (*invoiceOne)["order_code"],
-            }) > 1
-            (*invoiceOne)["changed"] = qutil.If(isJyInvoice || isChanged, true, false)
-        case -1: //失败支持重新提交否
-            (*invoiceOne)["isReopen"] = util.Mysql.Count("invoice_fail_record", map[string]interface{}{
-                "only_Identifying": (*invoiceOne)["only_Identifying"],
-                "order_code":       (*invoiceOne)["order_code"],
-            })+1 >= config.InvoiceConfig.SubmitNum
-        }
-    }
-    this.ServeJson(NewResult(map[string]interface{}{
-        "orderCodes":   strings.Join(orderArr, ","),
-        "money":        money,
-        "invoice":      &invoiceOne,
-        "operator":     operator,
-        "company_name": companyName,
-    }, nil))
+	onlyIdentifying := encrypt.SE.DecodeString(this.GetString("onlyIdentifying"))
+	invoiceMoney := encrypt.SE.DecodeString(this.GetString("invoiceMoney"))
+	operator := ""
+	if onlyIdentifying == "" || invoiceMoney == "" {
+		this.ServeJson(NewResult("", errors.New("传入参数不正确")))
+		return
+	}
+	orderArr := []string{}
+	money := int64(0)
+	for _, v := range strings.Split(invoiceMoney, ",") {
+		invoiceMoneyArr := strings.Split(v, ":")
+		orderArr = append(orderArr, invoiceMoneyArr[0])
+		money += qutil.Int64All(invoiceMoneyArr[1])
+	}
+	invoiceOne := util.Mysql.FindOne("invoice", map[string]interface{}{
+		"only_Identifying": onlyIdentifying,
+	}, "id,invoice_changed,order_code, bank_account, company_phone,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", " create_time   DESC")
+	companyName := ""
+	if invoiceOne == nil {
+		//查询公司名称
+		querySQL := fmt.Sprintf("select company_name  from   dataexport_order  where order_code  in  (%s)   and  company_name!=''   ORDER BY  create_time   DESC LIMIT 1", fmt.Sprintf("\"%s\"", strings.Join(orderArr, "\",\"")))
+		orderArr := util.Mysql.SelectBySql(querySQL)
+		if orderArr != nil && len(*orderArr) > 0 {
+			companyName = qutil.ObjToString((*orderArr)[0]["company_name"])
+		}
+	} else {
+		switch qutil.IntAll((*invoiceOne)["invoice_status"]) {
+		case 1:
+			//是否换票
+			isJyInvoice := !strings.Contains(qutil.InterfaceToStr((*invoiceOne)["url"]), "/jyInvoice/") //非数电票
+			isChanged := util.Mysql.Count("invoice", map[string]interface{}{
+				"only_Identifying": onlyIdentifying,
+				"order_code":       (*invoiceOne)["order_code"],
+			}) > 1
+			(*invoiceOne)["changed"] = qutil.If(isJyInvoice || isChanged, true, false)
+		case -1: //失败支持重新提交否
+			(*invoiceOne)["isReopen"] = util.Mysql.Count("invoice_fail_record", map[string]interface{}{
+				"only_Identifying": (*invoiceOne)["only_Identifying"],
+				"order_code":       (*invoiceOne)["order_code"],
+			})+1 >= config.InvoiceConfig.SubmitNum
+		}
+	}
+	this.ServeJson(NewResult(map[string]interface{}{
+		"orderCodes":   strings.Join(orderArr, ","),
+		"money":        money,
+		"invoice":      &invoiceOne,
+		"operator":     operator,
+		"company_name": companyName,
+	}, nil))
 }
 
 // GetUserId 获取用户id从订单中
 func GetUserId(orderCode string) (userId string) {
-    rs := util.Mysql.SelectBySql(fmt.Sprintf("select user_id from %s where order_code=?", "dataexport_order"), orderCode)
-    if rs != nil && len(*rs) > 0 {
-        userId = qutil.ObjToString((*rs)[0]["userId"])
-    }
-    return userId
+	rs := util.Mysql.SelectBySql(fmt.Sprintf("select user_id from %s where order_code=?", "dataexport_order"), orderCode)
+	if rs != nil && len(*rs) > 0 {
+		userId = qutil.ObjToString((*rs)[0]["userId"])
+	}
+	return userId
 }
 
 // 调航天金税接口
 func htjs(body map[string]interface{}, orderCode []string, invoiceType, companyName, taxpayerIdentnum, mail, phone string) {
-    invoice_status := 0
-    client := &http.Client{}
-    b, _ := json.Marshal(body)
-    buffer := bytes.NewBuffer(b)
-    request, _ := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/Add", buffer)
-    response, err := client.Do(request)
-    if err == nil {
-        res, err := ioutil.ReadAll(response.Body)
-        if err != nil {
-            invoice_status = -1
-        } else {
-            resMap := qutil.ObjToMap(string(res))
-            if *resMap != nil {
-                if qutil.IntAll((*resMap)["code"]) == 0 { //开票成功
-                    invoice_status = 1
-                } else if qutil.IntAll((*resMap)["code"]) == 2 { //开票中
-                    invoice_status = 0
-                } else { //开票失败
-                    invoice_status = -1
-                }
-            }
-            defer response.Body.Close()
-            resData := (*resMap)["data"].(map[string]interface{})
-            if invoice_status == 1 {
-                sendMail(invoiceType, strings.Join(orderCode, ","), companyName, taxpayerIdentnum, mail, phone, qutil.InterfaceToStr(resData["path"]))
-            }
-            for _, v := range orderCode {
-                util.Mysql.Update(dbname, map[string]interface{}{"order_code": v, "invoice_status": 0}, map[string]interface{}{
-                    "invoice_serialnum": resData["swno"],
-                    "invoice_code":      resData["fpdm"],
-                    "invoice_number":    resData["fphm"],
-                    "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)
-            }
-        }
-    }
+	invoice_status := 0
+	client := &http.Client{}
+	b, _ := json.Marshal(body)
+	buffer := bytes.NewBuffer(b)
+	request, _ := http.NewRequest("POST", config.InvoiceConfig.Invoice_interface_address+"/Invoice/Add", buffer)
+	response, err := client.Do(request)
+	if err == nil {
+		res, err := ioutil.ReadAll(response.Body)
+		if err != nil {
+			invoice_status = -1
+		} else {
+			resMap := qutil.ObjToMap(string(res))
+			if *resMap != nil {
+				if qutil.IntAll((*resMap)["code"]) == 0 { //开票成功
+					invoice_status = 1
+				} else if qutil.IntAll((*resMap)["code"]) == 2 { //开票中
+					invoice_status = 0
+				} else { //开票失败
+					invoice_status = -1
+				}
+			}
+			defer response.Body.Close()
+			resData := (*resMap)["data"].(map[string]interface{})
+			if invoice_status == 1 {
+				sendMail(invoiceType, strings.Join(orderCode, ","), companyName, taxpayerIdentnum, mail, phone, qutil.InterfaceToStr(resData["path"]))
+			}
+			for _, v := range orderCode {
+				util.Mysql.Update(dbname, map[string]interface{}{"order_code": v, "invoice_status": 0}, map[string]interface{}{
+					"invoice_serialnum": resData["swno"],
+					"invoice_code":      resData["fpdm"],
+					"invoice_number":    resData["fphm"],
+					"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)
+			}
+		}
+	}
 }
 
 // 判断是全额还是部分回款
 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
+	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, "电子发票")
-    }
+	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, "电子发票")
+	}
 }
 
 // 剩余金额
 func InvoicePrice(orderData map[string]interface{}) int64 {
-    residueMoney := int64(0)
-    if qutil.Int64All(orderData["applybill_status"]) == 2 {
-        return residueMoney
-    }
+	residueMoney := int64(0)
+	if qutil.Int64All(orderData["applybill_status"]) == 2 {
+		return residueMoney
+	}
 
-    return qutil.Int64All(orderData["pay_money"]) - InvoiceAmount(qutil.InterfaceToStr(orderData["order_code"]))
+	return qutil.Int64All(orderData["pay_money"]) - InvoiceAmount(qutil.InterfaceToStr(orderData["order_code"]))
 }
 
 // 订单剩余金额查询
 func ResidueMoney(orderCode string) int64 {
-    residueMoney := int64(0)
-    //订单信息查询
-    orderData := util.Mysql.SelectBySql("select  pay_money,applybill_status from  dataexport_order  where  order_code =?", orderCode)
-    if len(*orderData) == 0 || orderData == nil {
-        return residueMoney
-    }
-    return InvoicePrice((*orderData)[0])
+	residueMoney := int64(0)
+	//订单信息查询
+	orderData := util.Mysql.SelectBySql("select  pay_money,applybill_status from  dataexport_order  where  order_code =?", orderCode)
+	if len(*orderData) == 0 || orderData == nil {
+		return residueMoney
+	}
+	return InvoicePrice((*orderData)[0])
 
-    //发票信息查询
-    //invoiceData := util.Mysql.SelectBySql("select invoice_status,sum(invoice_order_money) as  money  from  invoice where  order_code=?  and  invoice_status>=0  GROUP BY  invoice_status", orderCode)
-    //if len(*orderData) == 0 || orderData == nil {
-    //} else {
-    //    //开过几次票
-    //    payMoney := qutil.Int64All((*orderData)[0]["pay_money"])
-    //    allMoney := int64(0)
-    //    for _, invoice := range *invoiceData {
-    //        invoice_status := qutil.Int64All(invoice["invoice_status"])
-    //        money := qutil.Int64All(invoice["money"])
-    //        if invoice_status == 0 {
-    //            return residueMoney
-    //        } else {
-    //            allMoney += money
-    //        }
-    //    }
-    //    residueMoney = payMoney - allMoney
-    //}
-    //return residueMoney
+	//发票信息查询
+	//invoiceData := util.Mysql.SelectBySql("select invoice_status,sum(invoice_order_money) as  money  from  invoice where  order_code=?  and  invoice_status>=0  GROUP BY  invoice_status", orderCode)
+	//if len(*orderData) == 0 || orderData == nil {
+	//} else {
+	//    //开过几次票
+	//    payMoney := qutil.Int64All((*orderData)[0]["pay_money"])
+	//    allMoney := int64(0)
+	//    for _, invoice := range *invoiceData {
+	//        invoice_status := qutil.Int64All(invoice["invoice_status"])
+	//        money := qutil.Int64All(invoice["money"])
+	//        if invoice_status == 0 {
+	//            return residueMoney
+	//        } else {
+	//            allMoney += money
+	//        }
+	//    }
+	//    residueMoney = payMoney - allMoney
+	//}
+	//return residueMoney
 }

+ 7 - 7
src/web/staticres/electronic_invoice/css/check_invoice.css

@@ -162,11 +162,11 @@
 #check_invoice .step .l:after {
   content: "";
   position: absolute;
-  right: -23px;
+  right: -22px;
   top: 0;
   width: 0;
   height: 0;
-  border-top: 19px solid transparent;
+  border-top: 20px solid transparent;
   border-left: 23px solid #2CB7CA;
   border-bottom: 19px solid transparent;
 }
@@ -200,7 +200,7 @@
   top: 0;
   width: 0;
   height: 0;
-  border-top: 19px solid transparent;
+  border-top: 20px solid transparent;
   border-left: 23px solid #fff;
   border-bottom: 19px solid transparent;
 }
@@ -208,12 +208,12 @@
 #check_invoice .step .c:after {
   content: "";
   position: absolute;
-  right: -23px;
+  right: -22px;
   top: 0;
   width: 0;
   height: 0;
-  border-top: 19px solid transparent;
-  border-left: 23px solid #BFBFBF;
+  border-top: 20px solid transparent;
+  border-left: 23px solid #2CB7CA;
   border-bottom: 19px solid transparent;
 }
 
@@ -290,7 +290,7 @@
   top: 0;
   width: 0;
   height: 0;
-  border-top: 19px solid transparent;
+  border-top: 20px solid transparent;
   border-left: 23px solid #fff;
   border-bottom: 19px solid transparent;
 }

+ 3 - 0
src/web/staticres/electronic_invoice/css/invoice.css

@@ -11,6 +11,9 @@ input::-webkit-inner-spin-button {
 input[type="number"] {
   -moz-appearance: textfield;
 }
+input::placeholder, textarea::placeholder{
+  color: #999999!important;
+}
 
 #invoice {
   line-height: 1;

+ 3 - 0
src/web/staticres/public-pc/css/header-nav-mini.css

@@ -147,6 +147,9 @@ a.j-s-button:hover {
 #public-nav {
     height: unset;
 }
+#public-nav.relative{
+  position: relative;
+}
 .fixed-header {
     position: fixed;
     top: 0;

+ 5 - 0
src/web/staticres/public-pc/js/header-nav-mini.js

@@ -140,6 +140,11 @@ var headerNavMini = {
       $('.go-to-workspace').hide()
     }
     this.changeHeaderPlaceholder()
+    // 导航栏置顶or不置顶  登录:置顶  未登录:不置顶
+    var noStickMeta = document.querySelector('meta[name="cancel-nav-sticky"]')
+    if (noStickMeta) {
+      this.headerFixed(login)
+    }
   },
   changeMenuActive: function (name) {
     this.headerNav.find('[name='+name+']').addClass('active')

+ 30 - 5
src/web/staticres/tags/css/no-login-detail.css

@@ -147,15 +147,18 @@
   width: 100%;
   margin: 20px 0;
 }
-.no-login-detail .bid-banner > img{
+.no-login-detail .bid-banner > a{
+  width: 100%;
+  display: block;
+}
+.no-login-detail .bid-banner img{
   display: inline-block;
   width: 100%;
   max-height: 64px;
-  object-fit: contain;
+  /* object-fit: contain; */
   cursor: pointer;
+  border-radius: 4px;
 }
-
-
 .no-login-detail .bid-content {
   margin-top: 20px;
   padding: 32px;
@@ -472,4 +475,26 @@
 }
 .no-login-detail ul li{
   float: unset!important;
-}
+}
+
+
+.fixed-bottom-banner {
+    position: fixed;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    display: flex;
+    justify-content: center;
+    width: 100%;
+    z-index: 999;
+}
+.advert-bottom-banner{
+    width: 100%;
+}
+.advert-bottom-banner img {
+    display: block;
+    /* object-fit: contain; */
+    cursor: pointer;
+    /* width: 1920px; */
+    width: 100%;
+}

+ 1 - 1
src/web/templates/areaPack/pc/page_order.html

@@ -221,7 +221,7 @@
                             $(".pay_num_p").css("display", "");
                             if (r.data.transaction_id) $(".pay_num").text(r.data.transaction_id);
                             //发票
-                            if (r.data.order.applybill_status === 0 && r.data.order.invoice_price) {
+                            if (r.data.order.is_can_invoice) {
                                 $(".openinvoice").css("display", "");
                             } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                 $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/frontRouter/pc/dataFile/sess/orderDetail.html

@@ -189,7 +189,7 @@
                             $(".pay_num_p").css("display", "");
                             if (r.data.transaction_id) $(".pay_num").text(r.data.transaction_id);
                             //发票
-                            if (r.data.order.applybill_status === 0 && r.data.order.billingMode === 1 && r.data.order.is_backstage_order === 0 && r.data.order.invoice_price) {
+                            if (r.data.order.is_can_invoice) {
                                 $(".openinvoice").css("display", "");
                             } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2 ) {
                                 $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/order/pc/bidfile/bidfileDetail.html

@@ -178,7 +178,7 @@
                             $(".pay_num_p").show();
                         }
                         //发票
-                        if (r.data.applybill_status === 0 && r.data.invoice_price) {
+                        if (r.data.is_can_invoice) {
                             $(".openinvoice").css("display", "");
                         } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                             $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/order/pc/buyerPortraitPack/detail.html

@@ -190,7 +190,7 @@
                             $(".pay_num_p").css("display", "");
                             if (r.data.transaction_id) $(".pay_num").text(r.data.transaction_id);
                             //发票
-                            if (r.data.order.applybill_status === 0 && r.data.order.invoice_price) {
+                            if (r.data.order.is_can_invoice) {
                                 $(".openinvoice").css("display", "");
                             } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                 $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/order/pc/datareport/detail.html

@@ -166,7 +166,7 @@
                         $(".pay_num_p").css("display", "");
                         if (r.data.orderInfo.paymentId) $(".pay_num").text(r.data.orderInfo.paymentId);
                         //发票
-                        if (r.data.orderInfo.applybillStatus === 0 && r.data.orderInfo.invoice_price) {
+                        if (r.data.orderInfo.is_can_invoice) {
                             $(".openinvoice").css("display", "");
                         } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                             $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/order/pc/filePack/detail.html

@@ -190,7 +190,7 @@
                             $(".pay_num_p").css("display", "");
                             if (r.data.transaction_id) $(".pay_num").text(r.data.transaction_id);
                             //发票
-                            if (r.data.order.applybill_status === 0 && r.data.order.invoice_price) {
+                            if (r.data.order.is_can_invoice) {
                                 $(".openinvoice").css("display", "");
                             } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                 $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/order/pc/integral/integralDetail.html

@@ -200,7 +200,7 @@
                             $(".pay_num_p").show();
                         }
                         //发票
-                        if (r.data.applybill_status === 0 && r.data.invoice_price) {
+                        if (r.data.is_can_invoice) {
                             $(".openinvoice").css("display", "");
                         } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                             $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/pc/aiPack_orderDetail.html

@@ -225,7 +225,7 @@
                         if (source===""){
                             if (r.data.is_backstage_order!==1){
                                 //发票
-                                if (r.data.applybill_status === 0 && r.data.invoice_price) {
+                                if (r.data.is_can_invoice) {
                                     $(".openinvoice").css("display", "");
                                 }  else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                     $(".lookinvoice").css("display", "").on("click", function () {

+ 3 - 3
src/web/templates/pc/check_invoice.html

@@ -75,9 +75,9 @@
         </div>
         <div class="w step clearfix" v-if="selectinvoice.invoice_status !== -1">
             <!-- 进行中 类名为 active  已完成 类名为 finish  未完成默认颜色-->
-            <div id="l" class="pro l" :class="{'active': selectinvoice.invoice_status === 0}">已完成</div>
-            <div id="c" class="pro c" :class="{'active': selectinvoice.invoice_status === 0}">财务处理</div>
-            <div id="r" class="pro r" :class="{'finish': selectinvoice.invoice_status === 1}">发票开具</div>
+            <div id="l" class="pro l" :class="{'active': selectinvoice.invoice_status === 0 || selectinvoice.invoice_status === 1}">已完成</div>
+            <div id="c" class="pro c" :class="{'active': selectinvoice.invoice_status === 0 || selectinvoice.invoice_status === 1}">财务处理</div>
+            <div id="r" class="pro r" :class="{'active': selectinvoice.invoice_status === 0 || selectinvoice.invoice_status === 1, 'finish': selectinvoice.invoice_status === 1}">发票开具</div>
             <div class="rules" data-toggle="modal" data-target="#ruleModal">开票规则</div>
         </div>
         <div class="w step invoice_fail_container" v-else>

+ 1 - 1
src/web/templates/pc/dataPack/packDetail.html

@@ -218,7 +218,7 @@
                             $(".pay_num_p").css("display", "");
                             if (r.data.transaction_id) $(".pay_num").text(r.data.transaction_id);
                             //发票 "item.applybill_status === 0 &&  && item.is_backstage_order === 0"
-                            if (r.data.order.applybill_status === 0 && r.data.order.invoice_price && r.data.order.billingMode === 1 && r.data.order.is_backstage_order === 0) {
+                            if (r.data.order.is_can_invoice) {
                                 $(".openinvoice").css("display", "");
                             } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                 $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 1
src/web/templates/pc/entniche_orderDetail.html

@@ -155,7 +155,7 @@
                         $(".pay_num_p").css("display", "");
                         if (r.data.prepay_id) $(".pay_num").text(r.data.prepay_id);
                         //发票
-                        if (r.data.applybill_status === 0 && r.data.invoice_price) {
+                        if (r.data.is_can_invoice) {
                             $(".openinvoice").css("display", "");
                         } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                             $(".lookinvoice").css("display", "").on("click", function () {

+ 115 - 30
src/web/templates/pc/invoice.html

@@ -69,7 +69,7 @@
     <!-- header -->
 	{{include "/common/pchead.html"}}
     <!-- main  START -->
-    <div class="invoice" id="invoice">
+    <div class="invoice" id="invoice" v-loading="loading">
         <div class="w invoice_crumb">
             <a href="javascript:;" data-type="work-bench" data-href="/front/swordfish/toMyOrder">我的订单</a><em> > </em>
             <a href="" class="active">开发票</a>
@@ -106,7 +106,7 @@
                       </el-card>
                     </el-form-item>
                     <el-form-item label="单位税号:" prop="taxpayer_identnum">
-                      <el-input @blur="validateForm" placeholder="请输入单位税号" v-model="ruleForm.taxpayer_identnum"></el-input>
+                      <el-input placeholder="请输入单位税号" v-model="ruleForm.taxpayer_identnum"></el-input>
                     </el-form-item>
                     <el-form-item style="min-height: 36px;height: auto;" label="单位地址:" :rules="[{ required: ruleForm.invoice_variety == '电子专用发票', message: '请输入单位地址', trigger: 'blur' }]" prop="company_address">
                       <el-input ref="company_address" :style="{height: addressHeight + 'px'}" type="textarea" :rows="1" placeholder="请输入单位地址" v-model="ruleForm.company_address"></el-input>
@@ -125,16 +125,16 @@
                     </el-form-item>
                   </div>
                   <el-form-item label="联系电话:" prop="phone">
-                    <el-input maxlength="11" @blur="validateForm" placeholder="请输入手机号" v-model="ruleForm.phone"></el-input>
+                    <el-input maxlength="11" placeholder="请输入手机号" v-model="ruleForm.phone"></el-input>
                   </el-form-item>
                   <el-form-item  label="电子邮箱:" prop="mail">
-                    <el-input @blur="validateForm" placeholder="邮箱用于接收电子发票" v-model="ruleForm.mail"></el-input>
+                    <el-input placeholder="邮箱用于接收电子发票" v-model="ruleForm.mail"></el-input>
                   </el-form-item>
                   <el-form-item style="min-height: 36px;height: auto;" v-if="ruleForm.invoice_type == '个人'" label="开票备注:">
                     <el-input ref="remark" :style="{height: remarkHeight + 'px'}" :rows="1" placeholder="非必填,此部分内容会展示在发票“备注”上,请按照贵司财务要求进行填写" type="textarea" v-model="ruleForm.remark"></el-input>
                   </el-form-item>
                   <el-form-item style="margin-top: 32px;">
-                    <el-button :disabled="!isFormValid" type="primary" @click="submitForm('ruleForm')">提交</el-button>
+                    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                     <el-button @click="resetForm('ruleForm')">取消</el-button>
                   </el-form-item>
                 </el-form>
@@ -246,14 +246,15 @@
               rules: {
                 phone: [
                   { required: true, message: '请输入手机号', trigger: 'blur' },
-                  { min: 11, max: 11, message: '手机号长度为11位', trigger: 'blur' }
+                  { validator: this.validatePhone, trigger: 'blur' }
                 ],
                 mail: [
-                  { required: true, message: '请输入邮箱地址', trigger: 'blur' },
-                  { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
+                  { validator: this.validateMail, trigger: 'blur' },
+                  { required: true, message: '请输入邮箱地址', trigger: 'blur' }
                 ],
                 company_name: [
-                  { required: true, message: '请输入单位名称', trigger: 'blur' }
+                  { required: true, message: '请输入单位名称', trigger: 'blur' },
+                  { validator: this.validateCompany, trigger: 'blur' }
                 ],
                 taxpayer_identnum: [
                   { required: true, message: '请输入纳税人识别号', trigger: 'blur' },
@@ -261,7 +262,8 @@
 
                 ],
                 company_address: [
-                  { required: true, message: '请输入单位地址', trigger: 'blur' }
+                  { required: true, message: '请输入单位地址', trigger: 'blur' },
+                  { validator: this.validateAddress, trigger: 'blur' }
                 ]
               },
               companyList: [],
@@ -272,7 +274,9 @@
               },
               addressHeight: 36,
               remarkHeight: 36,
-              isFormValid: false // 表单是否通过校验
+              isFormValid: [], // 表单校验结果
+              isValid: false,  // 表单是否通过校验
+              loading: false
             }
           },
           created () {
@@ -286,18 +290,17 @@
             this.setPageOver()
             this.invouceInfoEcho()
           },
-          mounted() {
-            setTimeout(() => {
-              this.validateForm()
-            }, 200)
-          },
           watch: {
             'ruleForm.invoice_variety': {
               handler (val) {
                 if (val === '电子专用发票') {
                   this.ruleForm.invoice_type = '单位'
+                  this.isFormValid = [false, false, false, false, false]
+                } else {
+                  this.isFormValid = [false, false, false, false]
                 }
-              }
+              },
+              immediate: true
             },
             'ruleForm.company_address': {
               handler() {
@@ -316,6 +319,13 @@
               }
             }
           },
+          computed: {
+            getValidateResult() {
+              console.info(this.isFormValid, 'isFormValid')
+              let hasFalse = this.isFormValid.includes(false);
+              return hasFalse
+            }
+          },
           methods: {
             // 查询是否可以开发票
             setPageOver () {
@@ -340,12 +350,6 @@
                 }
               })
             },
-            validateForm() {
-              this.$refs.ruleForm.validate(valid => {
-                // this.$refs.ruleForm.clearValidate();
-                this.isFormValid = valid
-              });
-            },
             getTextareaHeight(textareaEl) {
               textareaEl = textareaEl.querySelector('textarea');
               textareaEl.style.height = 'auto';
@@ -383,19 +387,85 @@
               this.urlParams.only_Identifying = only_Identifying
             },
             validateCode: (rule, value, callback) => {
+              const regCode = /(^[A-Za-z0-9]{15}$)|(^[A-Za-z0-9]{17,18}$)|(^[A-Za-z0-9]{20}$)/;
               if (!value) {
+                invoiceNode.setFormValidate(invoiceNode.isFormValid)
                 return callback(new Error('请输入纳税人识别号'))
               } else {
-                if (
-                  value.trim().length === 18 ||
-                  value.trim().length === 15 ||
-                  value.trim().length === 20
-                ) {
+                if (regCode.test(value)) {
+                  invoiceNode.isFormValid.push(true)
+                  return callback()
+                } else {
+                  invoiceNode.setFormValidate(invoiceNode.isFormValid)
+                  return callback(new Error('请输入正确的纳税人识别号'))
+                }
+              }
+            },
+            validatePhone: (rule, value, callback) => {
+              const regPhone = /^1[3-9]\d{9}$/;
+              if(!value) {
+                invoiceNode.setFormValidate(invoiceNode.isFormValid)
+                return callback(new Error('请输入手机号'));
+              } else {
+                if (regPhone.test(value)) {
+                  invoiceNode.isFormValid.push(true)
+                  return callback()
+                } else {
+                  invoiceNode.setFormValidate(invoiceNode.isFormValid)
+                  return callback(new Error('请输入正确的手机号'))
+                }
+              }
+            },
+            validateMail: (rule, value, callback) => {
+              console.info(rule, value,'isFormValid')
+              const regEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/
+              if(!value) {
+                invoiceNode.setFormValidate(invoiceNode.isFormValid)
+                return callback(new Error('请输入邮箱'))
+              } else {
+                if (regEmail.test(value.trim())) {
+                  invoiceNode.isFormValid.push(true)
                   return callback()
+                } else {
+                  invoiceNode.setFormValidate(invoiceNode.isFormValid)
+                  return callback(new Error('请输入正确的邮箱'))
                 }
-                return callback(new Error('请输入正确的纳税人识别号'))
               }
             },
+            validateCompany: (rule, value, callback) => {
+              const regCompany=/^[\u4e00-\u9fa5_a-zA-Z0-9_\(_\)_\uff08_\uff09\)]{2,50}$/;
+              if(!value) {
+                invoiceNode.setFormValidate(invoiceNode.isFormValid)
+                return callback(new Error('请输入公司名称'))
+              } else {
+                if (regCompany.test(value)) {
+                  invoiceNode.isFormValid.push(true)
+                  return callback()
+                } else {
+                  invoiceNode.setFormValidate(invoiceNode.isFormValid)
+                  return callback(new Error('请输入正确的公司名称'))
+                }
+              }
+            },
+            validateAddress: (rule, value, callback) => {
+              if (value.trim().length > 0) {
+                invoiceNode.isFormValid.push(true)
+                return callback()
+              } else {
+                invoiceNode.setFormValidate(invoiceNode.isFormValid)
+              }
+            },
+            setFormValidate (array) {
+              let data = Array.from(array)
+              console.info(data.length, 'array')
+              data.forEach((e, i) => {
+                if(e) {
+                  data.splice(i, 1)
+                  data.push(false)
+                }
+              });
+              this.isFormValid = data
+            },
             setHighLight(item) {
               const keyword = utils.replaceKeyword(item.name, this.ruleForm.company_name, '<span class="highlight-text">' + this.ruleForm.company_name + '</span>')
               return keyword
@@ -403,6 +473,7 @@
             submitForm(formName) {
               this.$refs[formName].validate((valid) => {
                 if (valid) {
+                  this.loading = true
                   const { order_code, invoice_content, invoice_type, invoice_variety, mail, phone, remark, company_name, taxpayer_identnum, company_address, company_phone, bank_name, bank_account } = this.ruleForm
                   let params = {
                     order_code: order_code, // 唯一标识
@@ -450,12 +521,27 @@
             },
             onConfirm(url, params) {
               this.ajaxComponent(url, params).then((res) => {
+                this.loading = false
                 if(res && res.error_code === 0) {
                   this.toastFn('提交成功', 2000)
+                  // 新窗口打开
+                  // 判断窗口是不是window.open打开的
+                  setTimeout(() => {
+                    if (window.opener && window.opener !== window) {
+                      window.close()
+                    } else {
+                        if (history.length <= 1) {
+                            window.close()
+                        }
+                        history.back()
+                    }
+                  }, 2000)
                 } else {
+                  this.loading = false
                   this.toastFn(res.error_msg || res.invoice_msg, 2000)
                 }
               }).catch(err => {
+                this.loading = false
                 this.toastFn('提交失败', 2000)
               })
             },
@@ -483,7 +569,6 @@
               setTimeout(() => {
                 this.companyList = []
               }, 200);
-              this.validateForm()
             },
             handleClick(item) {
               const { name, taxCode } = item

+ 1 - 1
src/web/templates/pc/medaratus_orderDetail.html

@@ -295,7 +295,7 @@
                             //发票
                             // 后台渠道为xdqd04(销售代下单)可以开发票,其他后台创建订单不可以开发票
                             if (r.data.order.is_backstage_order!==1 || r.data.order.order_channel === 'xdqd04'){
-                                if (r.data.order.applybill_status === 0 && r.data.order.invoice_price) {
+                                if (r.data.is_can_invoice) {
                                     $(".openinvoice").css("display", "");
                                 } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                     $(".lookinvoice").css("display", "").on("click", function () {

+ 1 - 6
src/web/templates/pc/member_orderDetail.html

@@ -354,14 +354,9 @@
                         }
                         if (source===""){
                             if(r.data.is_backstage_order!==1){ //发票
-                                if (r.data.applybill_status === 0 && r.data.invoice_price) {
+                                if (r.data.is_can_invoice) {
                                     $(".openinvoice").css("display", "").on("click", function () {
                                         // return false // 待可开发票时删除
-
-                                        if (window.isTransferPay) {
-                                            checkinvoice(2, '', '请联系客服开票<br>客服热线:400-108-6670')
-                                            return
-                                        }
                                         window.open("/front/order/invoice/" + orderCode, '_self');
                                     });
                                 }else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {

+ 3 - 3
src/web/templates/pc/myOrder.html

@@ -555,7 +555,7 @@
                       <p><a data-jy-track="click-hover" @click="goCancel(item)">取消订单</a></p>
                     </div>
                     <div v-if="item.order_status === 1 && item.filter.badge!='exchange'">
-                      <p><a v-if="item.applybill_status === 0 && (item.is_backstage_order === 0 || item.order_channel === 'xdqd04' ||  item.qmx_invoice ) && item.invoice_price" data-jy-track="click-hover"
+                      <p><a v-if="item.is_can_invoice" data-jy-track="click-hover"
                           @click="goInvoice(item)">开发票</a></p>
                       <p><a v-if="item.invoice_show" data-jy-track="click-hover" @click="goInvoice(item)">发票信息</a></p>
                     </div>
@@ -574,7 +574,7 @@
                     </div>
                     <div v-if="item.order_status === 1 && (item.filter.source || '') === ''&& item.filter.badge!='exchange'">
                       <!--                                        <div v-if="(item.filter.canInvoice !=undefined  && !item.filter.canInvoice)">-->
-                      <p><a v-if="item.applybill_status === 0 && item.invoice_price" data-jy-track="click-hover"
+                      <p><a v-if="item.is_can_invoice" data-jy-track="click-hover"
                           @click="goInvoice(item)">开发票</a></p>
                       <p><a v-if="item.invoice_show"
                           data-jy-track="click-hover" @click="goInvoice(item)">发票信息</a></p>
@@ -593,7 +593,7 @@
                     </p>
                     <!--已完成 && && item.filter.badge!='exchange' P307 权益码兑换 不开发票-->
                     <p v-if="item.order_status === 1 && item.filter.badge!='exchange'"><a
-                        v-if="item.billingMode === 1 && (item.is_backstage_order === 0 || item.order_channel === 'xdqd04' ||  item.qmx_invoice ) && item.invoice_price"
+                        v-if="item.is_can_invoice"
                         data-jy-track="click-hover" @click="goInvoice(item)">开发票</a></p>
                     <p v-if="item.order_status === 1"><a v-if="item.invoice_show" data-jy-track="click-hover" @click="goInvoice(item)">发票信息</a></p>
                     <!--已取消-->

+ 1 - 0
src/web/templates/pc/newIndex.html

@@ -9,6 +9,7 @@
   <meta name="format-detection" content="telephone=no" />
   <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
   <meta name="renderer" content="webkit" >
+  <meta name="cancel-nav-sticky" content="no-login" />
   <!-- pnc.html是pcbottom.html的依赖 -->
   {{include "/common/pnc.html"}}
   <link rel="canonical" href="https://www.jianyu360.cn">

+ 2 - 2
src/web/templates/pc/orderDetail.html

@@ -516,7 +516,7 @@
     $(function () {
         var orderStatus = {{ .T.o.order_status }};
         var invoiceStatus = {{ .T.o.applybill_status }}
-        var invoicePrice = {{ .T.o.invoice_price }}
+        var is_can_invoice = {{ .T.o.is_can_invoice }}
         var orderCode = {{.T.o.order_code}}
 
         if (orderStatus === 0) {
@@ -525,7 +525,7 @@
             $(".o_m_thead").removeClass("greenBg").addClass("redBg")
         } else if (orderStatus === 1) {
             $("#status_success").show();
-            if (invoiceStatus === 0 && invoicePrice) {
+            if (is_can_invoice) {
                 $(".openinvoice").show();
             } else if (invoiceStatus === 1 || invoiceStatus === 2) {
                 $(".lookinvoice").show().on("click", function () {

+ 1 - 1
src/web/templates/pc/subAccount_orderDetail.html

@@ -217,7 +217,7 @@
                         if (source===""){
                           //发票
                             if (r.data.is_backstage_order!==1){
-                                if (r.data.applybill_status === 0 && r.data.invoice_price) {
+                                if (r.data.is_can_invoice) {
                                     $(".openinvoice").css("display", "");
                                 } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                     $(".lookinvoice").css("display", "").on("click", function () {

+ 62 - 2
src/web/templates/pc/tags/detail.html

@@ -89,9 +89,16 @@
               </div>
             </div>
           </div>
+          {{$ad_1:=(Ad "pc-nologin-detail-middle" -1 .Host (cookie "SESSIONID"))}}
+          {{if $ad_1}}
           <div class="bid-banner">
-            <img id="login-banner-btn" class="login-node" src='{{Msg "seo" "cdn"}}/tags/images/login-banner.png?v={{Msg "seo" "version"}}' alt="loginBanner" />
+            {{range $ad := $ad_1}}
+            <a target="_blank" {{if $ad.S_link}}href="{{$ad.S_link}}"{{end}}>
+              <img id="login-banner-btn" src='{{$ad.S_pic}}' alt="{{$ad.S_picalt}}" />
+            </a>
+            {{end}}
           </div>
+          {{end}}
           {{if .T.canRead}}
           <div class="bid-content">
             <!-- 非<拟建项目>、<采购意向>基本信息表格 -->
@@ -323,7 +330,16 @@
     </div>
   </div>
 
-  {{include "/pc/tags/template/bottom-banner.html"}}
+    {{$ad_bottom:=(Ad "pc-nologin-detail-bottom" -1 .Host (cookie "SESSIONID"))}}
+    {{if $ad_bottom}}
+    <div class="fixed-bottom-banner advert-bottom-banner">
+      {{range $ad := $ad_bottom}}
+      <a class="advert-bottom-banner-link" target="_blank" {{if $ad.S_link}}href="{{$ad.S_link}}"{{end}}>
+        <img id="login-advert-bottom-btn" src='{{$ad.S_pic}}' alt="{{$ad.S_picalt}}" />
+      </a>
+      {{end}}
+    </div>
+    {{end}}
 	{{include "/common/pcbottom.html"}}
 
 
@@ -354,6 +370,50 @@
       } catch (e) {
         console.warn(e)
       }
+      $('.login-node').on('click', function () {
+          try {
+              if (!loginflag) {
+                  openLoginDig(false, 'reload')
+              }
+          } catch (error) {
+              openLoginDig(false, 'reload')
+          }
+      })
+
+      var memberTimer = setInterval(function () {
+          clearInterval(memberTimer)
+          adBottomFn()
+      }, 2000)
+      function adBottomFn () {
+          var top1 = 0;
+          var top2 = 0;
+          var timer = null;
+          $(document).scroll(function(){
+              clearTimeout(timer)
+              timer = setTimeout(isScrollEnd, 1000);
+              top1 = document.documentElement.scrollTop || document.body.scrollTop;
+              $('.fixed-bottom-banner').fadeOut()
+          })
+          function isScrollEnd() {
+              top2 = document.documentElement.scrollTop || document.body.scrollTop;
+              if(top1 == top2){
+                  $('.fixed-bottom-banner').fadeIn()
+              }
+          }
+      }
+      // 广告位链接如果是登录链接 则阻止a标签默认事件 在当前页打开登录弹框
+      $('.advert-bottom-banner-link').click(function(){
+        if (this.href.indexOf('?nol=1') > -1) {
+          openLoginDig(false, 'reload')
+          return false
+        }
+      })
+      $('.bid-banner > a').click(function(){
+        if (this.href.indexOf('?nol=1') > -1) {
+          openLoginDig(false, 'reload')
+          return false
+        }
+      })
     })
   </script>
   <!--百度统计start-->

+ 2 - 0
src/web/templates/pc/tags/index.html

@@ -6,6 +6,8 @@
     <meta name="renderer" content="webkit">
     <meta content="telephone=no" name="format-detection"/>
     <meta content="剑鱼标讯" theme="light" name="enable-header"/>
+    <!-- 未登录取消导航栏置顶效果meta标识 -->
+    <meta name="cancel-nav-sticky" content="no-login" />
     {{include "/common/pnc.html"}}
     <link href='{{Msg "seo" "cdn"}}/css/pc.css?v={{Msg "seo" "version"}}' rel="stylesheet" />
     <link href='{{Msg "seo" "cdn"}}/pccss/index.css?v={{Msg "seo" "version"}}' rel="stylesheet" />

+ 3 - 2
src/web/templates/pc/tags/template/bottom-banner.html

@@ -15,9 +15,10 @@
 }
 .advert-bottom-banner > img {
     display: block;
-    object-fit: contain;
+    /* object-fit: contain; */
     cursor: pointer;
-    width: 1920px;
+    /* width: 1920px; */
+    width: 100%;
 }
 </style>
 <div class="fixed-bottom-banner advert-bottom-banner">

+ 1 - 1
src/web/templates/pc/vip_orderDetail.html

@@ -302,7 +302,7 @@
                             //发票
                             // 后台渠道为xdqd04(销售代下单)可以开发票,其他后台创建订单不可以开发票
                             if (r.data.order.is_backstage_order!==1 || r.data.order.order_channel === 'xdqd04'){
-                                if (r.data.order.applybill_status === 0 && r.data.order.invoice_price) {
+                                if (r.data.order.is_can_invoice) {
                                     $(".openinvoice").css("display", "");
                                 } else if (r.data.applybill_status === 1 || r.data.applybill_status === 2) {
                                     $(".lookinvoice").css("display", "").on("click", function () {