package enterprise import ( "errors" "git.u8t.cn/open/goutil" "github.com/tidwall/gjson" ) const ( ApprovalProfitAmountTypeCost = "消耗" ApprovalProfitAmountTypeProfit = "利润" ApprovalProfitAmountTypeAward = "奖励" ) type ApprovalProfitCreate struct { SpNo string `json:"sp_no"` //申请单号,相同的单号数据将会被替换 Month string `json:"month"` //业绩对应月份 Username string `json:"username"` //业绩对应责任人 AmountType string `json:"amount_type"` //业绩类型 Amount string `json:"amount"` //业绩金额 单位元 Description string `json:"description"` //业绩描述 AppId string `json:"app_id"` //业绩对应的业务ID } type ApprovalProfit struct { Enterprise } func NewApprovalProfit(baseUrl, token string) *ApprovalProfit { return &ApprovalProfit{ Enterprise: Enterprise{ baseUrl: baseUrl, token: token, }, } } func (e *ApprovalProfit) Create(req *ApprovalProfitCreate) error { var reqBody string reqBody = goutil.EncodeJSON(req) reqUrl := e.GetBaseUrl() + "/ext/approval/profit" body, err := goutil.HttpPost(reqUrl, e.GetHeader(), []byte(reqBody)) if err != nil { return err } g := gjson.ParseBytes(body) if g.Get("code").Int() != 0 { return errors.New(string(body)) } return nil }