|
@@ -17,11 +17,23 @@ import (
|
|
|
func CreatePricingStrategy(ctx context.Context, req *http_model.AddPricingRequest) (string, string, error) {
|
|
|
db := GetReadDB(ctx)
|
|
|
project_type, fee_form, platform, fans_low, fans_up, service_charge, base_offer := req.ProjectType, req.ManuscriptForm, req.Platform, req.FansLow, req.FansHigh, req.PlatformFee, req.BaseOffer
|
|
|
- var IsExclusive gorm_model.InfoPricingStrategy
|
|
|
+ var IsExclusive, IsExclusive2, IsExclusive3, IsExclusive1 gorm_model.InfoPricingStrategy
|
|
|
err := db.Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_low, fans_up).First(&IsExclusive).Error
|
|
|
if err == nil {
|
|
|
return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", "", nil
|
|
|
}
|
|
|
+ err = db.Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_low, fans_low).First(&IsExclusive1).Error
|
|
|
+ if err == nil {
|
|
|
+ return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", "", nil
|
|
|
+ }
|
|
|
+ err = db.Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_up, fans_up).First(&IsExclusive2).Error
|
|
|
+ if err == nil {
|
|
|
+ return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", "", nil
|
|
|
+ }
|
|
|
+ err = db.Where(" fee_form = ? && platform = ? && fans_low >= ? && fans_up <= ?", fee_form, platform, fans_low, fans_up).First(&IsExclusive3).Error
|
|
|
+ if err == nil {
|
|
|
+ return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", "", nil
|
|
|
+ }
|
|
|
var newStrategy gorm_model.InfoPricingStrategy
|
|
|
var strategyInfo gorm_model.InfoPricingStrategy
|
|
|
getMonth := time.Now().Format("01") //获取月
|
|
@@ -107,10 +119,22 @@ func ModifyPricing(ctx context.Context, req *http_model.ModifyPricingRequest) (s
|
|
|
strategyId := req.StrategyId
|
|
|
db = db.Model(gorm_model.InfoPricingStrategy{}).Where("strategyId = ?", strategyId)
|
|
|
project_type, fee_form, platform, fans_low, fans_up, service_charge, base_offer := req.ProjectType, req.FeeForm, req.Platform, req.FansLow, req.FansHigh, req.PlatformFee, req.BaseOffer
|
|
|
- var IsExclusive gorm_model.InfoPricingStrategy
|
|
|
+ var IsExclusive, IsExclusive2, IsExclusive3, IsExclusive1 gorm_model.InfoPricingStrategy
|
|
|
err := db.Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_low, fans_up).First(&IsExclusive).Error
|
|
|
if err == nil {
|
|
|
- return "要修改策略与已经运行的策略互斥,请修改相关字段", nil
|
|
|
+ return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", nil
|
|
|
+ }
|
|
|
+ err = db.Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_low, fans_low).First(&IsExclusive1).Error
|
|
|
+ if err == nil {
|
|
|
+ return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", nil
|
|
|
+ }
|
|
|
+ err = db.Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_up, fans_up).First(&IsExclusive2).Error
|
|
|
+ if err == nil {
|
|
|
+ return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", nil
|
|
|
+ }
|
|
|
+ err = db.Where(" fee_form = ? && platform = ? && fans_low >= ? && fans_up <= ?", fee_form, platform, fans_low, fans_up).First(&IsExclusive3).Error
|
|
|
+ if err == nil {
|
|
|
+ return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", nil
|
|
|
}
|
|
|
err = db.Updates(map[string]interface{}{
|
|
|
"project_type": project_type, "base_offer": base_offer, "fee_form": fee_form,
|
|
@@ -1604,3 +1628,53 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func GetHours(ctx context.Context) (*http_model.Hours, error) {
|
|
|
+ db := GetReadDB(ctx)
|
|
|
+ infoAuto := gorm_model.InfoAutoTask{}
|
|
|
+ err := db.Model(gorm_model.InfoAutoTask{}).Last(&infoAuto).Error
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ Hours := http_model.Hours{}
|
|
|
+ Hours.DraftDefaultInPic = infoAuto.DraftDefaultInPic
|
|
|
+ Hours.DraftDefaultInMv = infoAuto.DraftDefaultInMv
|
|
|
+ Hours.ScriptDefault = infoAuto.ScriptDefault
|
|
|
+ Hours.Invalid = infoAuto.Invalid
|
|
|
+ Hours.LinkBreach = infoAuto.LinkBreach
|
|
|
+ Hours.CaseClose = infoAuto.CaseClose
|
|
|
+ Hours.CaseCloseDefault = infoAuto.CaseCloseDefault
|
|
|
+ Hours.ReviewInMv = infoAuto.ReviewInMv
|
|
|
+ Hours.ReviewUnlimited = infoAuto.ReviewUnlimited
|
|
|
+ Hours.PostReview = infoAuto.Postreview
|
|
|
+ Hours.SignInVirtual = infoAuto.SignInVirtual
|
|
|
+ Hours.SignInOffline = infoAuto.SignInOffline
|
|
|
+ return &Hours, err
|
|
|
+}
|
|
|
+
|
|
|
+func GetPercents(ctx context.Context) (*http_model.Percents, error) {
|
|
|
+ db := GetReadDB(ctx)
|
|
|
+ percentsInfo := gorm_model.InfoAutoDefaultHandle{}
|
|
|
+ err := db.Model(gorm_model.InfoAutoDefaultHandle{}).Last(&percentsInfo).Error
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ Percents := http_model.Percents{}
|
|
|
+ Percents.DataReplaceNotUpload = percentsInfo.DataReplaceNotUpload
|
|
|
+ Percents.DataReplaceTimeOut = percentsInfo.DataReplaceTimeOut
|
|
|
+ Percents.DataOtherTimeOut = percentsInfo.DataOtherTimeOut
|
|
|
+ Percents.DataOtherNotUpload = percentsInfo.DataOtherNotUpload
|
|
|
+ Percents.LinkReplaceTimeOut = percentsInfo.LinkReplaceTimeOut
|
|
|
+ Percents.LinkReplaceNotUpload = percentsInfo.LinkReplaceNotUpload
|
|
|
+ Percents.LinkOtherTimeOut = percentsInfo.LinkOtherTimeOut
|
|
|
+ Percents.LinkOtherNotUpload = percentsInfo.LinkOtherNotUpload
|
|
|
+ Percents.ScriptReplaceTimeOut = percentsInfo.ScriptReplaceTimeOut
|
|
|
+ Percents.ScriptReplaceNotUpload = percentsInfo.ScriptReplaceNotUpload
|
|
|
+ Percents.ScriptOtherNotUpload = percentsInfo.ScriptOtherNotUpload
|
|
|
+ Percents.ScriptOtherTimeOut = percentsInfo.ScriptOtherTimeOut
|
|
|
+ Percents.SketchReplaceTimeOut = percentsInfo.SketchReplaceTimeOut
|
|
|
+ Percents.SketchOtherNotUpload = percentsInfo.SketchOtherNotUpload
|
|
|
+ Percents.SketchOtherTimeOut = percentsInfo.SketchOtherTimeOut
|
|
|
+ Percents.SketchReplaceNotUpload = percentsInfo.SketchReplaceNotUpload
|
|
|
+ return &Percents, err
|
|
|
+}
|