diff --git a/db/db_second_newcomers_free.go b/db/db_second_newcomers_free.go new file mode 100644 index 0000000..91ef1ba --- /dev/null +++ b/db/db_second_newcomers_free.go @@ -0,0 +1,14 @@ +package db + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" + "xorm.io/xorm" +) + +func SecondGetAllPriceTypeList(Db *xorm.Engine) ([]model.SecondNewcomersFreePriceType, error) { + var priceType []model.SecondNewcomersFreePriceType + if err := Db.Find(&priceType); err != nil { + return nil, err + } + return priceType, nil +} diff --git a/db/model/second_newcomers_free_price_type.go b/db/model/second_newcomers_free_price_type.go new file mode 100644 index 0000000..db06178 --- /dev/null +++ b/db/model/second_newcomers_free_price_type.go @@ -0,0 +1,19 @@ +package model + +type SecondNewcomersFreePriceType struct { + Id int `json:"id" xorm:"not null pk autoincr INT(10)"` + PriceName string `json:"price_name" xorm:"not null comment('价格类型') VARCHAR(255)"` + NeedQuan int `json:"need_quan" xorm:"not null default 0 comment('需要的福利券') INT(11)"` + CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` + UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` + IsShow int `json:"is_show" xorm:"not null default 1 comment('是否开启') TINYINT(1)"` + IsDel int `json:"is_del" xorm:"not null default 0 INT(11)"` + Auth string `json:"auth" xorm:"not null comment('权限') TEXT"` + NeedUseQuan int `json:"need_use_quan" xorm:"default 1 comment('是否需要使用免单券 0否 1是') INT(1)"` + NeedLimitBuy int `json:"need_limit_buy" xorm:"default 0 comment('是否限购') INT(1)"` + LimitBuyCondition string `json:"limit_buy_condition" xorm:"default '' comment('限购条件') VARCHAR(255)"` + CommissionId string `json:"commission_id" xorm:"default '' VARCHAR(255)"` + LimitStr string `json:"limit_str" xorm:"default '' VARCHAR(255)"` + BuyStr string `json:"buy_str" xorm:"default '' VARCHAR(255)"` + CommissionData string `json:"commission_data" xorm:"default '' VARCHAR(500)"` +} diff --git a/svc/get_plan_cfg.go b/svc/get_plan_cfg.go index 42bdac0..2ba9ad5 100644 --- a/svc/get_plan_cfg.go +++ b/svc/get_plan_cfg.go @@ -34,6 +34,32 @@ func GetAllPlan(eg *xorm.Engine, dbName string) (map[string]*model.PlanReward, m for _, v := range pvds { plan[v.Pvd] = v } + list, _ := db.SecondGetAllPriceTypeList(eg) + for _, v := range list { + var oneRewardPlan map[string]string + err := json.Unmarshal([]byte(v.CommissionData), &oneRewardPlan) + if err == nil { + var tmp = &model.PlanReward{ + Id: 0, + Pvd: "seFree_" + zhios_order_relate_utils.IntToStr(v.Id), + PvdRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["pvd_rate"]) / 100, + SysRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["sys_rate"]) / 100, + RegionRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["region_rate"]) / 100, + GlobalRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["global_rate"]) / 100, + SettleMode: zhios_order_relate_utils.StrToInt(oneRewardPlan["settle_mode"]), + PlanCommissionId: zhios_order_relate_utils.StrToInt(oneRewardPlan["plan_commission_id"]), + PlanSettleId: zhios_order_relate_utils.StrToInt(oneRewardPlan["plan_settle_id"]), + State: 1, + Source: 1, + IntegralOpen: zhios_order_relate_utils.StrToInt(oneRewardPlan["integral_open"]), + MerchantRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["merchant_rate"]) / 100, + PushHandRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["push_hand_rate"]) / 100, + OrderBeforeRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["order_before_rate"]) / 100, + } + plan[tmp.Pvd] = tmp + } + } + commission := make(map[int]*model.PlanCommission, 0) commissions := db.DbsPlanCommissionByIds(eg) for _, v := range commissions {