|
@@ -24,7 +24,6 @@ type Invoice struct {
|
|
|
*xweb.Action
|
|
|
addinvoice xweb.Mapper `xweb:"/invoice/add"` //开发票
|
|
|
invoiceswitch xweb.Mapper `xweb:"/invoice/switch"` //发票开关
|
|
|
- invoiceecho xweb.Mapper `xweb:"/invoice/echo"` //发票回显
|
|
|
showinvoice xweb.Mapper `xweb:"/invoice/show"` //查看发票
|
|
|
callbackinvoice xweb.Mapper `xweb:"/invoice/callback"` //开发票回调
|
|
|
replaceinvoice xweb.Mapper `xweb:"/invoice/replace"` //换发票
|
|
@@ -119,20 +118,23 @@ func (this *Invoice) Invoiceswitch() {
|
|
|
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
|
|
|
}
|
|
|
- var product_name string
|
|
|
- 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", "")
|
|
|
- if u != nil {
|
|
|
- product_name = (*u)["product_type"].(string)
|
|
|
- }
|
|
|
- data["product_type"] = product_name
|
|
|
+ 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
|
|
@@ -141,15 +143,20 @@ func (this *Invoice) Invoiceswitch() {
|
|
|
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 {
|
|
|
- data["invoice_changed"] = 0
|
|
|
- data["invoice_status"] = 0
|
|
|
- util.Mysql.Insert(dbname, data)
|
|
|
+ //更新 "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 {
|
|
|
- util.Mysql.Update(dbname, map[string]interface{}{
|
|
|
+ req := map[string]interface{}{
|
|
|
"order_code": order_code,
|
|
|
"user_id": userId,
|
|
|
"invoice_changed": 0,
|
|
|
- }, data)
|
|
|
+ }
|
|
|
+ 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{}{
|
|
@@ -159,19 +166,6 @@ func (this *Invoice) Invoiceswitch() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (this *Invoice) Invoiceecho() {
|
|
|
- order_code := this.GetString("order_code")
|
|
|
- if userId := qutil.ObjToString(this.GetSession("userId")); userId != "" {
|
|
|
- u := util.Mysql.FindOne(dbname, map[string]interface{}{"user_id": userId, "order_code": order_code}, "invoice_type,mail,taxpayer_identnum,company_name,phone,url", "create_time desc")
|
|
|
- if u != nil {
|
|
|
- this.ServeJson(map[string]interface{}{
|
|
|
- "status": "success",
|
|
|
- "data": *u,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func (this *Invoice) Addinvoice() error {
|
|
|
defer qutil.Catch()
|
|
|
userId := qutil.ObjToString(this.GetSession("userId"))
|