diff --git a/db/db_second_newcomers_free.go b/db/db_second_newcomers_free.go index 91ef1ba..e478471 100644 --- a/db/db_second_newcomers_free.go +++ b/db/db_second_newcomers_free.go @@ -12,3 +12,10 @@ func SecondGetAllPriceTypeList(Db *xorm.Engine) ([]model.SecondNewcomersFreePric } return priceType, nil } +func MoreGetAllPriceTypeList(Db *xorm.Engine) ([]model.MoreNewcomersFreePriceType, error) { + var priceType []model.MoreNewcomersFreePriceType + if err := Db.Find(&priceType); err != nil { + return nil, err + } + return priceType, nil +} diff --git a/db/model/more_newcomers_free_price_type.go b/db/model/more_newcomers_free_price_type.go new file mode 100644 index 0000000..7a1e7d3 --- /dev/null +++ b/db/model/more_newcomers_free_price_type.go @@ -0,0 +1,17 @@ +package model + +type MoreNewcomersFreePriceType 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)"` + NeedUseQuan int `json:"need_use_quan" xorm:"not null default 1 INT(1)"` + NeedLimitBuy int `json:"need_limit_buy" xorm:"not null default 0 INT(1)"` + Auth string `json:"auth" xorm:"not null comment('权限') TEXT"` + LimitBuyCondition string `json:"limit_buy_condition" xorm:"not null comment('限购条件') TEXT"` + CommissionId string `json:"commission_id" 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 e674712..97034fe 100644 --- a/svc/get_plan_cfg.go +++ b/svc/get_plan_cfg.go @@ -60,7 +60,31 @@ func GetAllPlan(eg *xorm.Engine, dbName string) (map[string]*model.PlanReward, m plan[tmp.Pvd] = tmp } } - + moreList, _ := db.MoreGetAllPriceTypeList(eg) + for _, v := range moreList { + var oneRewardPlan map[string]string + err := json.Unmarshal([]byte(v.CommissionData), &oneRewardPlan) + if err == nil { + var tmp = &model.PlanReward{ + Id: 0, + Pvd: "moreFree_" + 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 { @@ -271,6 +295,31 @@ func PlanOpts(eg *xorm.Engine) map[string]*comm_plan.PlanOpt { allRewardPlan = append(allRewardPlan, tmp) } } + moreList, _ := db.MoreGetAllPriceTypeList(eg) + for _, v := range moreList { + var oneRewardPlan map[string]string + err := json.Unmarshal([]byte(v.CommissionData), &oneRewardPlan) + if err == nil { + var tmp = &model.PlanReward{ + Id: 0, + Pvd: "moreFree_" + 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, + } + allRewardPlan = append(allRewardPlan, tmp) + } + } opts := map[string]*comm_plan.PlanOpt{} for _, v := range allRewardPlan { if _, ok := commissionPlans[v.PlanCommissionId]; ok && v.State == 1 && v.PlanCommissionId > 0 {