Browse Source

校验商户号是否存在

tuoling805 1 year ago
parent
commit
5d6a86391c
1 changed files with 4 additions and 0 deletions
  1. 4 0
      services/aiser/ai.go

+ 4 - 0
services/aiser/ai.go

@@ -2,6 +2,7 @@ package aiser
 
 import (
 	"encoding/json"
+	"errors"
 	"eta/eta_api/utils"
 	"io/ioutil"
 	"net/http"
@@ -23,6 +24,9 @@ func ChatAutoMsg(prompt string) (result string, err error) {
 	//提交请求
 	reqest, err := http.NewRequest("POST", chatUrl, strings.NewReader(string(postData)))
 	businessCode := utils.BusinessCode
+	if businessCode == "" {
+		return businessCode, errors.New("未获取到商户号")
+	}
 	nonce := utils.GetRandStringNoSpecialChar(16)
 	timestamp := time.Now().Format(utils.FormatDateTimeUnSpace)
 	signature := utils.GetSign(nonce, timestamp, utils.EtaAppid, utils.EtaSecret)