|
|
@@ -122,6 +122,9 @@ func (c *Client) QueryPersonalSignAuthRecords(openUserID, status string) ([]Auth
|
|
|
return nil, err
|
|
|
}
|
|
|
if err := resp.err(); err != nil {
|
|
|
+ if IsPersonalSignAuthRecordNotFound(err) {
|
|
|
+ return []AuthRecord{}, nil
|
|
|
+ }
|
|
|
return nil, err
|
|
|
}
|
|
|
out := make([]AuthRecord, 0, len(resp.Result))
|
|
|
@@ -152,12 +155,31 @@ func (c *Client) PersonalSignAuthRecordForCompany(openUserID string, company App
|
|
|
if err != nil {
|
|
|
return nil, false, err
|
|
|
}
|
|
|
+ if rec, ok := findAuthRecordForCompany(records, company, status); ok {
|
|
|
+ return rec, true, nil
|
|
|
+ }
|
|
|
+ if status != "" {
|
|
|
+ all, err := c.QueryPersonalSignAuthRecords(openUserID, "")
|
|
|
+ if err != nil {
|
|
|
+ return nil, false, err
|
|
|
+ }
|
|
|
+ if rec, ok := findAuthRecordForCompany(all, company, status); ok {
|
|
|
+ return rec, true, nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil, false, nil
|
|
|
+}
|
|
|
+
|
|
|
+func findAuthRecordForCompany(records []AuthRecord, company ApplyCompanyParams, wantStatus string) (*AuthRecord, bool) {
|
|
|
for i := range records {
|
|
|
+ if wantStatus != "" && records[i].Status != wantStatus {
|
|
|
+ continue
|
|
|
+ }
|
|
|
if authRecordMatchesCompany(&records[i], company) {
|
|
|
- return &records[i], true, nil
|
|
|
+ return &records[i], true
|
|
|
}
|
|
|
}
|
|
|
- return nil, false, nil
|
|
|
+ return nil, false
|
|
|
}
|
|
|
|
|
|
func authRecordMatchesCompany(rec *AuthRecord, company ApplyCompanyParams) bool {
|