Эх сурвалжийг харах

wip:pdf下载包价格调整

wangkaiyue 1 жил өмнө
parent
commit
62c6b8b494

+ 18 - 1
src/jfw/modules/subscribepay/src/config.yaml

@@ -21,4 +21,21 @@ pdfCreateServer:
     winner: https://jybx2-webtest.jydev.jianyu360.com/page_big_pc/report/pdf/ent?pid=%s #企业画像报告
     winner: https://jybx2-webtest.jydev.jianyu360.com/page_big_pc/report/pdf/ent?pid=%s #企业画像报告
     buyer: https://jybx2-webtest.jydev.jianyu360.com/page_big_pc/report/pdf/prop?pid=%s #采购单位报告
     buyer: https://jybx2-webtest.jydev.jianyu360.com/page_big_pc/report/pdf/prop?pid=%s #采购单位报告
     analysis: https://jybx2-webtest.jydev.jianyu360.com/page_big_pc/report/pdf/market?pid=%s #定制化分析报告
     analysis: https://jybx2-webtest.jydev.jianyu360.com/page_big_pc/report/pdf/market?pid=%s #定制化分析报告
-
+pdfPackPrice:
+  企业中标分析报告下载包:
+    - num: 5
+      price: 49900
+    - num: 10
+      price: 79900
+    - num: 20
+      price: 138900
+  业主采购分析报告下载包:
+    - num: 5
+      price: 49900
+    - num: 10
+      price: 79900
+    - num: 20
+      price: 138900
+  市场分析定制报告下载包:
+    - num: 1
+      price: 199900

+ 3 - 14
src/jfw/modules/subscribepay/src/entity/commodity.go

@@ -935,20 +935,9 @@ func GetExtend(productCode int64, types string, id string) map[int64]map[string]
 		}
 		}
 	case PDFPACK_SOURCENAME:
 	case PDFPACK_SOURCENAME:
 		data = map[string]interface{}{
 		data = map[string]interface{}{
-			"validityYear": 3,   //有效期限
-			"priceUnit":    "元", //价格单位  元/分...
-			"specsUnit":    "个", //产品单位  天/条..,
-		}
-		switch id {
-		case PDFPACK_WINNER:
-			data["originalPrice"] = 2000
-			data["discountPrice"] = 1000
-		case PDFPACK_BUYER:
-			data["originalPrice"] = 2000
-			data["discountPrice"] = 1000
-		case PDFPACK_MARKET:
-			data["originalPrice"] = 2000
-			data["discountPrice"] = 1000
+			"validityYear": 3, //有效期限
+			//"priceUnit":    "元", //价格单位  元/分...
+			"specsUnit": "个", //产品单位  天/条..,
 		}
 		}
 	}
 	}
 	retData := map[int64]map[string]interface{}{}
 	retData := map[int64]map[string]interface{}{}

+ 27 - 16
src/jfw/modules/subscribepay/src/entity/pdfExportPack.go

@@ -13,7 +13,6 @@ import (
 	"github.com/gogf/gf/v2/util/gconv"
 	"github.com/gogf/gf/v2/util/gconv"
 	"github.com/google/uuid"
 	"github.com/google/uuid"
 	"io"
 	"io"
-	"jy/src/jfw/modules/subscribepay/src/config"
 	"jy/src/jfw/modules/subscribepay/src/util"
 	"jy/src/jfw/modules/subscribepay/src/util"
 	"log"
 	"log"
 	"net"
 	"net"
@@ -37,7 +36,7 @@ const (
 )
 )
 
 
 var (
 var (
-	pdfPackPriceMap = map[string]*PdfPackDetail{}
+	pdfPackPriceMap = map[string]map[int]int{}
 	JyPdfExportPack pdfExportPackStruct
 	JyPdfExportPack pdfExportPackStruct
 	ClientPool      chan *http.Client
 	ClientPool      chan *http.Client
 
 
@@ -115,20 +114,23 @@ type (
 )
 )
 
 
 func init() {
 func init() {
-	for _, pack := range config.ExConf.Packs_showList {
-		pdfPackPriceMap[fmt.Sprintf("%s_%d", "normal", pack.PackNum)] = &PdfPackDetail{
-			PackType:  1,
-			PackNum:   pack.PackNum,
-			ValidYear: 3, //默认全为两年
-			Price:     int(config.ExConf.UnitPrice_normal*config.ExConf.Discount*pack.Normal_discount*100) * pack.PackNum,
-		}
-		pdfPackPriceMap[fmt.Sprintf("%s_%d", "senior", pack.PackNum)] = &PdfPackDetail{
-			PackType:  2,
-			PackNum:   pack.PackNum,
-			ValidYear: 3, //默认全为两年
-			Price:     int(config.ExConf.UnitPrice_senior*config.ExConf.Discount*pack.Senior_discount*100) * pack.PackNum,
+	type priceSpe struct {
+		Num   int `json:"num"`
+		Price int `json:"price"`
+	}
+	for productName, detail := range g.Cfg().MustGet(context.TODO(), "pdfPackPrice").Map() {
+		var (
+			arr     []priceSpe
+			mapping = map[int]int{}
+		)
+		if gconv.Struct(detail, &arr) == nil {
+			for _, spe := range arr {
+				mapping[spe.Num] = spe.Price
+			}
 		}
 		}
+		pdfPackPriceMap[productName] = mapping
 	}
 	}
+	g.Dump(pdfPackPriceMap)
 }
 }
 
 
 // PayCallBack 支付完成回调
 // PayCallBack 支付完成回调
@@ -201,13 +203,22 @@ func (this *pdfExportPackStruct) GetPdfPackDetail(packId string) (PdfPackDetail,
 	if err != nil {
 	if err != nil {
 		return PdfPackDetail{}, err
 		return PdfPackDetail{}, err
 	}
 	}
+	productPricesMap, ok := pdfPackPriceMap[productType]
+	if !ok || productPricesMap == nil || len(productPricesMap) == 0 {
+		return PdfPackDetail{}, fmt.Errorf("未知产品类型")
+	}
+	price, ok := productPricesMap[num]
+	if !ok || price == 0 {
+		return PdfPackDetail{}, fmt.Errorf("未知规格")
+	}
+
 	//TODO:获取计价
 	//TODO:获取计价
 	return PdfPackDetail{
 	return PdfPackDetail{
 		PackType:      packType,
 		PackType:      packType,
 		PackNum:       num,
 		PackNum:       num,
 		ValidYear:     3,
 		ValidYear:     3,
-		Price:         num * 1000,
-		OriginalPrice: num * 2000,
+		Price:         price,
+		OriginalPrice: price,
 	}, nil
 	}, nil
 }
 }