Browse Source

wip:初始化提交

wangkaiyue 1 year ago
parent
commit
e975c71b0f

+ 1 - 1
internal/controller/callback.go

@@ -50,7 +50,7 @@ func CallBack(r *ghttp.Request) {
 				service.JyInvoiceManager.ReleasePool() //可进行下次开票请求
 				g.Log().Infof(ctx, "发票冲红结束")
 			default:
-				g.Log().Infof(ctx, "未知回调任务退出 %d", qData)
+				g.Log().Infof(ctx, "未知回调任务退出 %+v", qData)
 			}
 		default:
 			g.Log().Infof(ctx, "未设置消息回调:%s", callType)

+ 1 - 1
internal/service/invoiceCallback.go

@@ -56,7 +56,7 @@ func InvoicingCallBackLogic(r *ghttp.Request) error {
 	case 7:
 		g.Log().Info(r.Context(), "非数电票试点纳税人,未核定数电票票种,不允许开票或其他原因")
 	default:
-		g.Log().Info(r.Context(), "InvoicingCallBackLogic tType:%d", tType)
+		g.Log().Infof(r.Context(), "InvoicingCallBackLogic tType:%d", tType)
 	}
 	return nil
 }

+ 116 - 0
internal/service/tripartiteTaxCode.go

@@ -0,0 +1,116 @@
+package service
+
+import (
+	"context"
+	"fmt"
+	"github.com/gogf/gf/v2/errors/gerror"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+)
+
+type Billitem struct {
+	Name    string `json:"name"`    //税收分类名称(接口中获取)
+	Ssflbm  string `json:"ssflbm"`  //税收分类编码(接口中获取)
+	Thirdid string `json:"thirdid"` //开票项id 自己定义的唯一id
+}
+
+// GetTaxList 返回内容 allTaxCode.json
+func (t *TripartiteAuth) GetTaxList() error {
+	err := CommonDoPost("/index_taxcode/getTaxCodeList",
+		t.GetFormHeaderWithToken(),
+		nil,
+		func(i interface{}) error {
+			g.Dump(i)
+			return nil
+		})
+	if err != nil {
+		return gerror.Wrap(err, "Demo")
+	}
+	return nil
+}
+
+// AddTaxCode 开票项增加
+func (t *TripartiteAuth) AddTaxCode(items []Billitem) error {
+	type AddTaxCodeParam struct {
+		TaxNum    string     `json:"taxNum"`
+		Tel       string     `json:"tel"`
+		BillItems []Billitem `json:"billitems"`
+	}
+
+	var (
+		ctx   = context.Background()
+		param = AddTaxCodeParam{
+			TaxNum:    g.Cfg().MustGet(ctx, "company.taxNum").String(),
+			Tel:       g.Cfg().MustGet(ctx, "company.tel").String(),
+			BillItems: items,
+		}
+	)
+	err := CommonDoPost("/index_taxcode/addTaxCode",
+		t.GetJsonHeaderWithToken(),
+		gconv.Map(gconv.String(param)),
+		nil)
+	if err != nil {
+		return gerror.Wrap(err, "Demo")
+	}
+	return err
+}
+
+// GetSuccessTaxCodeList 查询已维护的开票项
+func (t *TripartiteAuth) GetSuccessTaxCodeList() ([]map[string]interface{}, error) {
+	type (
+		billItem struct {
+			Code string `json:"code"`
+			Name string `json:"name"`
+			Uuid string `json:"uuid"`
+		}
+	)
+	var (
+		ctx       = context.Background()
+		billItems []billItem
+	)
+	err := CommonDoPost("/index_taxcode/getCompanyTaxCodeList",
+		t.GetFormHeaderWithToken(),
+		g.MapStrAny{
+			"taxNum": g.Cfg().MustGet(ctx, "company.taxNum"),
+		},
+		func(i interface{}) error {
+			return gconv.Struct(i, &billItems)
+		})
+	if err != nil {
+		return nil, gerror.Wrap(err, "查询已维护的开票项异常")
+	}
+	return gconv.Maps(billItems), nil
+}
+
+// DelTaxCode 删除开票项
+func (t *TripartiteAuth) DelTaxCode(uuid string) error {
+	type (
+		delItem struct {
+			UUid string `json:"uuid"`
+		}
+
+		AddTaxCodeParam struct {
+			TaxNum    string    `json:"taxNum"`
+			Tel       string    `json:"tel"`
+			BillItems []delItem `json:"billitems"`
+		}
+	)
+
+	var (
+		ctx   = context.Background()
+		param = AddTaxCodeParam{
+			TaxNum:    g.Cfg().MustGet(ctx, "company.taxNum").String(),
+			Tel:       g.Cfg().MustGet(ctx, "company.tel").String(),
+			BillItems: []delItem{{UUid: uuid}},
+		}
+	)
+	fmt.Println(gconv.String(param))
+	err := CommonDoPost("/index_taxcode/delTaxCode",
+		t.GetJsonHeaderWithToken(),
+		gconv.Map(gconv.String(param)),
+		nil)
+	if err != nil {
+		return gerror.Wrap(err, "删除开票项异常")
+	}
+	return err
+}