123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- package product
- import (
- "context"
- "fmt"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/util/gconv"
- "strings"
- )
- type (
- JyBigProductFilter struct {
- ComboId int `json:"comboId"`
- BuyAccountCount int `json:"buyAccountCount"` //购买数量
- GiftAccountCount int `json:"giftAccountCount"` //赠送数量
- FreeAccountCount int `json:"freeAccountCount"` //免费数量
- Count int `json:"count"` //招投标次数免费数量
- BuyCycle int `json:"buy_cycle"` //购买周期
- BuyType int `json:"buy_type"` //购买周期 类型 1天 2月 3年 4季度
- GiftCycle int `json:"give_cycle"` //赠送周期
- GiftType int `json:"give_type"` //赠送周期 类型 1天 2月 3年 4季度
- ServiceIds []string `json:"serviceIds"` //服务id
- SupServiceIds []string `json:"supServiceIds"`
- FinalAccountCount int `json:"finalAccountCount"` //当前套餐最终
- FinalAreaCount int `json:"finalAreaCount"`
- }
- )
- func GetBigFilter(data map[string]interface{}) (g.Map, string, error) {
- var (
- bigFilter g.Map
- bigCode string
- )
- filter := gconv.Map(data["filter"])
- if filter["comboId"] != nil {
- bigFilter["comboId"] = gconv.Int(filter["comboId"])
- } else {
- //1:专业版;2:智慧版;3:商机版;4:试用版 5:试用版 6:商机版2.0 7:专家版2.0 30190:商机版2.0(单省版)
- bigFilter["comboId"] = gconv.Int(filter["level"])
- }
- switch bigFilter["comboId"] {
- case 0:
- bigCode = "dyh001"
- case 6:
- bigCode = "dyh002"
- case 7:
- bigCode = "dyh003"
- case 30190:
- bigCode = "dyh004"
- }
- ctx := context.Background()
- bigFilter["finalAreaCount"] = -1
- if gconv.Int(filter["areaCount"]) > 0 {
- bigFilter["finalAreaCount"] = gconv.Int(filter["areaCount"])
- }
- switch gconv.String(data["product_type"]) {
- case "大会员", "大会员-子账号":
- bigFilter["buy_cycle"] = gconv.Int(filter["cycle"])
- if gconv.Int(filter["level"]) == 4 || gconv.Int(filter["cycleType"]) == 1 {
- bigFilter["buy_type"] = 1
- } else if gconv.Int(filter["cycleType"]) == 0 {
- bigFilter["buy_type"] = 2
- } else {
- bigFilter["buy_type"] = 3
- }
- bigFilter["buyAccountCount"] = gconv.Int(data["buy_count"]) //购买账号数
- if gconv.Int(filter["pay_sub_num"]) > 0 { //老订单购买的付费账号
- bigFilter["buyAccountCount"] = gconv.Int(bigFilter["buyAccountCount"]) + gconv.Int(filter["pay_sub_num"])
- }
- bigFilter["freeAccountCount"] = gconv.Int(filter["free_sub_num"])
- bigFilter["finalAccountCount"] = gconv.Int(bigFilter["buyAccountCount"]) + gconv.Int(bigFilter["freeAccountCount"])
- switch gconv.Int(filter["createType"]) {
- case 2:
- if supServiceId := gconv.String(filter["new_serverArr"]); supServiceId != "" {
- bigFilter["supServiceIds"] = strings.Split(supServiceId, ",")
- bigFilter["serviceIds"] = strings.Split(gconv.String(filter["serversId"]), ",")
- } else {
- bigFilter["supServiceIds"] = strings.Split(gconv.String(filter["serversId"]), ",")
- ids, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT ROUP_CONCAT(DISTINCT s_serviceid ORDER BY s_serviceid SEPARATOR ',') AS concatenated_ids FROM bigmember_service_user WHERE s_userid ='%s'`, gconv.String(data["user_id"])))
- if !ids.IsEmpty() {
- bigFilter["serviceIds"] = strings.Split(gconv.String(ids.Map()["concatenated_ids"]), ",")
- }
- }
- }
- case "大会员-AI中标预测包", "大会员-招标文件解读":
- bigFilter["buyAccountCount"] = gconv.Int(filter["count"])
- case "大会员-补充包": //补充服务为原有服务 增加份数
- bigFilter["serviceIds"] = strings.Split(gconv.String(filter["serversId"]), ",")
- var supIds []string
- for _, m := range gconv.Maps(filter["supplys"]) { //补充服务id
- supIds = append(supIds, gconv.String(m["id"]))
- }
- bigFilter["supServiceIds"] = supIds
- }
- return bigFilter, bigCode, nil
- }
|