|
@@ -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
|
|
}
|
|
}
|
|
|
|
|