From 9f86c73636ace7d8295c0b5d24c46c76f431f9d1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 4 Dec 2024 10:10:50 +0800 Subject: [PATCH] 1 --- db/db_second_newcomers_free.go | 7 ++++++ db/model/four_newcomers_free_price_type.go | 19 +++++++++++++++ svc/get_plan_cfg.go | 27 ++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 db/model/four_newcomers_free_price_type.go diff --git a/db/db_second_newcomers_free.go b/db/db_second_newcomers_free.go index e478471..a30e7b3 100644 --- a/db/db_second_newcomers_free.go +++ b/db/db_second_newcomers_free.go @@ -19,3 +19,10 @@ func MoreGetAllPriceTypeList(Db *xorm.Engine) ([]model.MoreNewcomersFreePriceTyp } return priceType, nil } +func FourGetAllPriceTypeList(Db *xorm.Engine) ([]model.FourNewcomersFreePriceType, error) { + var priceType []model.FourNewcomersFreePriceType + if err := Db.Find(&priceType); err != nil { + return nil, err + } + return priceType, nil +} diff --git a/db/model/four_newcomers_free_price_type.go b/db/model/four_newcomers_free_price_type.go new file mode 100644 index 0000000..43afd9c --- /dev/null +++ b/db/model/four_newcomers_free_price_type.go @@ -0,0 +1,19 @@ +package model + +type FourNewcomersFreePriceType 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 f86204f..461a0d8 100644 --- a/svc/get_plan_cfg.go +++ b/svc/get_plan_cfg.go @@ -89,6 +89,33 @@ func GetAllPlan(eg *xorm.Engine, dbName string) (map[string]*model.PlanReward, m plan[tmp.Pvd] = tmp } } + fourList, _ := db.FourGetAllPriceTypeList(eg) + for _, v := range fourList { + var oneRewardPlan map[string]string + err := json.Unmarshal([]byte(v.CommissionData), &oneRewardPlan) + if err == nil { + var tmp = &model.PlanReward{ + Id: 0, + Pvd: "fourFree_" + 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, + StoreSubsidyRate: zhios_order_relate_utils.StrToFloat64(oneRewardPlan["store_subsidy_rate"]), + RedPacketRate: zhios_order_relate_utils.StrToFloat64(oneRewardPlan["red_packet_rate"]), + 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 {