1
This commit is contained in:
55
business/model/dao/invoice_dao.go
Normal file
55
business/model/dao/invoice_dao.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetInvoiceInfo(db *DaoDB, vendorOrderId string) (*model.InvoiceMsg, error) {
|
||||
data := &model.InvoiceMsg{}
|
||||
sql := ` SELECT * FROM invoice_msg WHERE order_id = ? `
|
||||
err := GetRow(db, data, sql, []interface{}{vendorOrderId}...)
|
||||
return data, err
|
||||
}
|
||||
|
||||
func GetStoreInvoiceList(storeID int, startTime, endTime time.Time, status string, offset, pageSize int) (info *model.PagedInfo, err error) {
|
||||
parameter := []interface{}{}
|
||||
sql := ` SELECT * FROM invoice_msg WHERE 1=1 `
|
||||
if storeID != 0 {
|
||||
sql += ` AND store_id = ? `
|
||||
parameter = append(parameter, storeID)
|
||||
}
|
||||
if !utils.IsTimeZero(startTime) {
|
||||
sql += ` AND created_at >= ? `
|
||||
parameter = append(parameter, startTime)
|
||||
}
|
||||
if !utils.IsTimeZero(endTime) {
|
||||
sql += ` AND created_at <= ? `
|
||||
parameter = append(parameter, endTime)
|
||||
}
|
||||
if status != "" {
|
||||
switch status {
|
||||
case "1": // 未回复
|
||||
sql += ` AND invoice_url = ""`
|
||||
case "2": // 已回复
|
||||
sql += ` AND invoice_url <> ""`
|
||||
}
|
||||
}
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
parameter = append(parameter, jxutils.FormalizePageSize(pageSize), offset)
|
||||
db := GetDB()
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
data := make([]*model.InvoiceMsg, 0, 0)
|
||||
if err = GetRowsTx(txDB, &data, sql, parameter...); err == nil {
|
||||
pagedInfo := &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount2(db, txDB),
|
||||
Data: data,
|
||||
}
|
||||
return pagedInfo, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
31
business/model/invoice_msg.go
Normal file
31
business/model/invoice_msg.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package model
|
||||
|
||||
type InvoiceMsg struct {
|
||||
ModelIDCUL
|
||||
OrderId string `orm:"column(order_id);size(32)" json:"order_id"` // 订单ID
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid
|
||||
VendorID int `orm:"column(vendor_id);size(2)" json:"vendorID"` // 平台ID
|
||||
InvoiceTaskId string `orm:"column(invoice_task_id);size(64)" json:"invoiceTaskId"` // 任务ID
|
||||
PushType int `orm:"column(push_type);size(2)" json:"pushType"` // 消息类型,1-开发票,3-催发票
|
||||
InvoiceTitle string `orm:"column(invoice_title);size(256)" json:"invoiceTitle"` // 发票抬头,为用户填写的开发票的抬头。
|
||||
TaxpayerId string `orm:"column(taxpayer_id);size(32)" json:"taxpayerId"` // 纳税人识别号
|
||||
NeedInvoiceByCategory int `orm:"column(need_category);size(2)" json:"needCategory"` // 是否需要按大类开票:1-需要按大类开票;2-需要商品明细开票;如果用户端没有选择,默认是按照明细开票
|
||||
CompanyAddress string `orm:"column(company_address);size(256)" json:"companyAddress"` // 公司地址
|
||||
CompanyPhone string `orm:"column(company_phone);size(16)" json:"companyPhone"` // 公司电话
|
||||
AccountBank string `orm:"column(account_bank);size(64)" json:"accountBank"` // 开户银行
|
||||
AccountNumber string `orm:"column(account_number);size(32)" json:"accountNumber"` // 开户账号
|
||||
Email string `orm:"column(email);size(64)" json:"email"` // 邮箱
|
||||
InvoiceAmount int64 `orm:"column(invoice_amount);size(16)" json:"invoiceAmount"` // 商家开票金额,单位分
|
||||
InvoiceUrl string `orm:"column(invoice_url);size(512)" json:"invoiceUrl"` // 发票文件链接
|
||||
InvoiceId string `orm:"column(invoice_id);size(32)" json:"invoiceId"` // 发票号码
|
||||
}
|
||||
|
||||
func (o *InvoiceMsg) TableUnique() [][]string {
|
||||
return [][]string{}
|
||||
}
|
||||
func (o *InvoiceMsg) TableIndex() [][]string {
|
||||
return [][]string{
|
||||
[]string{"CreatedAt", "StoreID"},
|
||||
[]string{"OrderId"},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user