12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package consts
- import (
- "context"
- "fmt"
- "github.com/gogf/gf/v2/errors/gerror"
- "github.com/gogf/gf/v2/frame/g"
- "strings"
- "time"
- )
- var (
- ServiceAddress = g.Cfg().MustGet(context.Background(), "tripartite.service").String()
- )
- var (
- LoginOutErr = gerror.New("请重新获取授权")
- AuthTimeOut = gerror.New("验证超时")
- WaitTimeOut = gerror.New("等待超时")
- InvoiceStartTime time.Time
- taxCodeItem []*TaxCodeItem
- )
- func init() {
- var (
- err error
- ctx context.Context
- )
- InvoiceStartTime, err = time.ParseInLocation(DateFormat_Short, g.Cfg().MustGet(ctx, "invoiceStartTime", "2024-04-23").String(), time.Local)
- if err != nil {
- g.Log().Panic(ctx, "发票开始时间异常")
- }
- if err := g.Cfg().MustGet(ctx, "taxCodeList").Struct(&taxCodeItem); err != nil {
- g.Log().Panic(ctx, "获取维护的开票项异常")
- }
- fmt.Println(taxCodeItem)
- }
- const (
- DateFormat_Full = "2006-01-02 15:04:05"
- DateFormat_Short = "2006-01-02"
- )
- type TaxCodeItem struct {
- Name string
- Code string
- }
- // GetTaxCodeByName 获取开票项
- func GetTaxCodeByName(name string) string {
- if name == "" {
- return taxCodeItem[0].Code
- }
- if splitArr := strings.SplitN(name, "-", 2); len(splitArr) == 2 {
- for _, item := range taxCodeItem {
- if item.Name == splitArr[1] {
- return item.Code
- }
- }
- }
- return taxCodeItem[0].Code
- }
|