|
@@ -450,24 +450,21 @@ func (this *Invoice) ShowinvoiceList() {
|
|
"ris": config.InvoiceConfig.Red_invoice_switch,
|
|
"ris": config.InvoiceConfig.Red_invoice_switch,
|
|
"rim": config.InvoiceConfig.Red_invoice_msg,
|
|
"rim": config.InvoiceConfig.Red_invoice_msg,
|
|
}
|
|
}
|
|
- invoices := 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 submit_num>= 0 ORDER BY create_time DESC`, order_code))
|
|
|
|
- if invoices != nil && len(*invoices) > 0 {
|
|
|
|
|
|
+ invoices := ShowList(order_code)
|
|
|
|
+ if invoices != nil && len(invoices) > 0 {
|
|
isIos := util.IsMobileIOS(this.Request.UserAgent())
|
|
isIos := util.IsMobileIOS(this.Request.UserAgent())
|
|
var invoiceData []map[string]interface{}
|
|
var invoiceData []map[string]interface{}
|
|
- for _, data := range *invoices {
|
|
|
|
- delete(data, "user_id")
|
|
|
|
- isJyInvoice := !strings.Contains(qutil.InterfaceToStr(data["url"]), "/jyInvoice/") //非数电票
|
|
|
|
|
|
+ for _, data := range invoices {
|
|
//是否换过票
|
|
//是否换过票
|
|
isChanged := qutil.IntAll(data["isChanged"]) > 1
|
|
isChanged := qutil.IntAll(data["isChanged"]) > 1
|
|
if isChanged && data["invoice_changed"] == 0 { //换过票的 只展示换票后的数据
|
|
if isChanged && data["invoice_changed"] == 0 { //换过票的 只展示换票后的数据
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- data["changed"] = qutil.If(isJyInvoice || isChanged, true, false)
|
|
|
|
- //data["status"] = "processing"
|
|
|
|
|
|
+ delete(data, "user_id")
|
|
|
|
+ isJyInvoice := !strings.Contains(qutil.InterfaceToStr(data["url"]), "/jyInvoice/") //非数电票
|
|
|
|
+ isJyEntity := data["invoicing_entity"] != nil && qutil.InterfaceToStr(data["invoicing_entity"]) != config.Config.SigningSubject
|
|
|
|
+ data["changed"] = qutil.If(isJyInvoice || isChanged || isJyEntity, true, false)
|
|
if url := qutil.InterfaceToStr(data["url"]); url != "" {
|
|
if url := qutil.InterfaceToStr(data["url"]); url != "" {
|
|
- //data["status"] = "success"
|
|
|
|
//ios 移动端
|
|
//ios 移动端
|
|
if isIos {
|
|
if isIos {
|
|
//国家税务局-增值税电子发票公共服务平台
|
|
//国家税务局-增值税电子发票公共服务平台
|
|
@@ -478,7 +475,10 @@ func (this *Invoice) ShowinvoiceList() {
|
|
}
|
|
}
|
|
var isReopen bool
|
|
var isReopen bool
|
|
if data["invoice_status"] == -1 {
|
|
if data["invoice_status"] == -1 {
|
|
- isReopen = qutil.IntAll(data["submit_num"])+1 >= config.Config.SubmitNum
|
|
|
|
|
|
+ isReopen = util.Mysql.Count("invoice_fail_record", map[string]interface{}{
|
|
|
|
+ "only_Identifying": data["only_Identifying"],
|
|
|
|
+ "order_code": order_code,
|
|
|
|
+ })+1 >= config.Config.SubmitNum
|
|
}
|
|
}
|
|
data["isReopen"] = isReopen
|
|
data["isReopen"] = isReopen
|
|
invoiceData = append(invoiceData, data)
|
|
invoiceData = append(invoiceData, data)
|
|
@@ -504,20 +504,23 @@ func (this *Invoice) ShowinvoiceList() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func ShowList(order_code string) []map[string]interface{} {
|
|
|
|
+ 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
|
|
|
|
+}
|
|
|
|
+
|
|
func (this *Invoice) NewInvoiceShow() {
|
|
func (this *Invoice) NewInvoiceShow() {
|
|
stype := this.GetString("stype")
|
|
stype := this.GetString("stype")
|
|
code := this.GetString("code")
|
|
code := this.GetString("code")
|
|
data := make(map[string]interface{})
|
|
data := make(map[string]interface{})
|
|
switch stype {
|
|
switch stype {
|
|
case "1": //订单回显金额
|
|
case "1": //订单回显金额
|
|
- res := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
|
|
|
|
- "order_code": code,
|
|
|
|
- }, "order_status,applybill_status,order_code,user_mail,applybill_type,applybill_company,user_phone,applybill_taxnum", "")
|
|
|
|
- if res != nil {
|
|
|
|
- if pay_money := qutil.Int64All((*res)["pay_money"]) - InvoiceAmount(qutil.InterfaceToStr((*res)["order_code"])); pay_money > 0 {
|
|
|
|
- data["pay_money"] = pay_money
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ data["pay_money"] = ResidueMoney(code)
|
|
case "2": //发票信息回显
|
|
case "2": //发票信息回显
|
|
invoice := util.Mysql.FindOne("invoice", map[string]interface{}{"id": code}, "id,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", "")
|
|
invoice := util.Mysql.FindOne("invoice", map[string]interface{}{"id": code}, "id,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", "")
|
|
data["invoice"] = invoice
|
|
data["invoice"] = invoice
|
|
@@ -1110,7 +1113,8 @@ func (this *Invoice) NewReplaceinvoice() {
|
|
//order_code := this.GetString("order_code")
|
|
//order_code := this.GetString("order_code")
|
|
sid := this.GetString("sid")
|
|
sid := this.GetString("sid")
|
|
oRes := util.Mysql.FindOne(dbname, map[string]interface{}{"id": sid, "invoie_changed": 0}, "", "") //仅线上开发票可换票
|
|
oRes := util.Mysql.FindOne(dbname, map[string]interface{}{"id": sid, "invoie_changed": 0}, "", "") //仅线上开发票可换票
|
|
- if oRes != nil && len(*oRes) > 0 {
|
|
|
|
|
|
+ if oRes != nil && len(*oRes) > 0 &&
|
|
|
|
+ ((*oRes)["invoicing_entity"] == nil || qutil.InterfaceToStr((*oRes)["invoicing_entity"]) == config.Config.SigningSubject) {
|
|
var (
|
|
var (
|
|
qSql string
|
|
qSql string
|
|
errCode []string
|
|
errCode []string
|
|
@@ -1124,7 +1128,7 @@ func (this *Invoice) NewReplaceinvoice() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if invoice_order_code := qutil.InterfaceToStr((*oRes)["invoice_order_code"]); len(strings.Split(invoice_order_code, ",")) > 1 {
|
|
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' and submit_num >= 0`, qutil.InterfaceToStr((*oRes)["invoice_order_code"]))
|
|
|
|
|
|
+ qSql = fmt.Sprintf(`SELECT * FROM invoice WHERE invoice_order_code = '%s' `, qutil.InterfaceToStr((*oRes)["invoice_order_code"]))
|
|
res1 := util.Mysql.SelectBySql(qSql)
|
|
res1 := util.Mysql.SelectBySql(qSql)
|
|
if res1 != nil && len(*res1) > 0 {
|
|
if res1 != nil && len(*res1) > 0 {
|
|
resArr = *res1
|
|
resArr = *res1
|
|
@@ -1642,7 +1646,7 @@ func (this *Invoice) InvoiceQuery() {
|
|
}
|
|
}
|
|
invoiceOne := util.Mysql.FindOne("invoice", map[string]interface{}{
|
|
invoiceOne := util.Mysql.FindOne("invoice", map[string]interface{}{
|
|
"only_Identifying": onlyIdentifying,
|
|
"only_Identifying": onlyIdentifying,
|
|
- }, "id,invoice_changed, 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")
|
|
|
|
|
|
+ }, "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 := ""
|
|
companyName := ""
|
|
if invoiceOne == nil {
|
|
if invoiceOne == nil {
|
|
//查询公司名称
|
|
//查询公司名称
|
|
@@ -1651,6 +1655,22 @@ func (this *Invoice) InvoiceQuery() {
|
|
if orderArr != nil && len(*orderArr) > 0 {
|
|
if orderArr != nil && len(*orderArr) > 0 {
|
|
companyName = qutil.ObjToString((*orderArr)[0]["company_name"])
|
|
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.Config.SubmitNum
|
|
|
|
+ }
|
|
}
|
|
}
|
|
this.ServeJson(NewResult(map[string]interface{}{
|
|
this.ServeJson(NewResult(map[string]interface{}{
|
|
"orderCodes": strings.Join(orderArr, ","),
|
|
"orderCodes": strings.Join(orderArr, ","),
|