Prechádzať zdrojové kódy

wip:增加测试账号

wangshan 1 rok pred
rodič
commit
f037bb7659

+ 1 - 0
rpc/partnerlib/etc/interface.yaml

@@ -3,6 +3,7 @@ Docin:
   Host: https://t.docin.com
   AppId: QHXKW0Z4JPM0GZXK
   AppSecret: tYLwu4fk7BQsS8WgP2g3o1BZv5Mxm2Ta
+  TestAccount: 20240101001
   DocList:
     Name: 文档列表接口
     Pathname: /api/jianyu/getProducts.do

+ 3 - 0
rpc/partnerlib/init/init.go

@@ -4,6 +4,7 @@ import (
 	"app.yhyue.com/moapp/jy_docs/rpc/partnerlib/internal/config"
 	"app.yhyue.com/moapp/jy_docs/services/partner"
 	jyDocsRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"flag"
 	"github.com/zeromicro/go-zero/core/conf"
 )
@@ -31,6 +32,8 @@ func init() {
 		jyDocsRpcUtil.InitMongo(C.Mongo)
 		jyDocsRpcUtil.InitOss(C.FileSystemConf)
 	}
+	//初始化 订单编码池
+	jy.OrderCodePoolInit()
 	//初始化 分类对应关系
 	go partner.InitDocClass()
 }

+ 1 - 0
rpc/partnerlib/internal/config/interface.go

@@ -6,6 +6,7 @@ type InterfaceInfo struct {
 		Host        string
 		AppId       string
 		AppSecret   string
+		TestAccount int64
 		DocList     BaseInfo
 		UpdateList  BaseInfo
 		DocDownload BaseInfo

+ 2 - 2
rpc/partnerlib/service/service.go

@@ -86,14 +86,14 @@ func (h *HH) HttpFunc() (body []byte, err error, isJson bool) {
 	// 使用 Do 方法处理请求
 	resp, _err := client.Do(req)
 	if _err != nil {
-		err = fmt.Errorf("failed to create client:%v", http.StatusInternalServerError)
+		err = fmt.Errorf("failed to create client:%v,err:%s", http.StatusInternalServerError, _err.Error())
 		return
 	}
 	defer resp.Body.Close()
 	body, err = io.ReadAll(resp.Body)
 	isJson = strings.Contains(strings.ToLower(resp.Header.Get("Content-Type")), "text/json")
 	if err != nil {
-		log.Println("Failed to read response body", http.StatusInternalServerError)
+		log.Println(fmt.Sprintf("Failed to read response body:%v,err:%s", http.StatusInternalServerError, err.Error()))
 		return
 	}
 	return

+ 6 - 1
rpc/partnerlib/service/userBuy.go

@@ -24,13 +24,18 @@ func UBHandle(in *partnerlib.UserBuyVipRequest) (res *partnerlib.UBVRes, err err
 	var (
 		b       []byte
 		docInfo = partner.DocsFindOne(in.DocId)
+		userId  = in.PositionId
 	)
+	//测试账号
+	if IC.I.Docin.TestAccount > 0 {
+		userId = IC.I.Docin.TestAccount
+	}
 	if docInfo.Id != "" {
 		orderCode := util.GetOrderCode()
 		h := NewHH(IC.I.Docin.Name, IC.I.Docin.Host, IC.I.Docin.BuyRecord.Name, IC.I.Docin.BuyRecord.Pathname, IC.I.Docin.BuyRecord.Method, map[string]interface{}{
 			"orderNo":   orderCode,
 			"productId": in.DocId,
-			"userId":    in.PositionId,
+			"userId":    userId,
 			"price":     docInfo.Price,
 			"priceVip":  docInfo.PriceVip,
 			"type":      in.Type,