diff --git a/db/model/user_public_platoon_setting.go b/db/model/user_public_platoon_setting.go index d363d23..dbb1bf4 100644 --- a/db/model/user_public_platoon_setting.go +++ b/db/model/user_public_platoon_setting.go @@ -16,4 +16,5 @@ type UserPublicPlatoonSetting struct { SystemPunishTask string `json:"system_punish_task" xorm:"comment('处罚任务条件') TEXT"` RewardTask string `json:"reward_task" xorm:"comment('奖励任务条件') TEXT"` SystemPunishReplace int `json:"system_punish_replace" xorm:"default 0 comment('是否位置滑落 被新用户替换 0否 1是') INT(1)"` + SettleDay int `json:"settle_day" xorm:"not null default 30 comment('结算天数') INT(11)"` } diff --git a/rule/public_platoon_relate_commission.go b/rule/public_platoon_relate_commission.go index 47d9f7e..1ece6c1 100644 --- a/rule/public_platoon_relate_commission.go +++ b/rule/public_platoon_relate_commission.go @@ -135,7 +135,9 @@ func publicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPlatoon //唯一标识符(父级id-uid-等级-位置) var uniqueIdentifier = zhios_order_relate_utils.IntToStr(pid) + "-" + zhios_order_relate_utils.IntToStr(uid) + "-" + zhios_order_relate_utils.IntToStr(int(level)) + "-" + zhios_order_relate_utils.IntToStr(position) - + if userPublicPlatoonSetting.SettleDay == 0 { + userPublicPlatoonSetting.SettleDay = 30 + } // 3、插入 user_public_platoon_relation 记录 now := time.Now() userPublicPlatoonRelation.Uid = uid @@ -145,7 +147,7 @@ func publicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPlatoon userPublicPlatoonRelation.Level = int(level) userPublicPlatoonRelation.Position = position userPublicPlatoonRelation.UniqueIdentifier = uniqueIdentifier - userPublicPlatoonRelation.WaitForSettlementDate = now.AddDate(0, 0, 30).Format("2006-01-02") + userPublicPlatoonRelation.WaitForSettlementDate = now.AddDate(0, 0, userPublicPlatoonSetting.SettleDay).Format("2006-01-02") userPublicPlatoonRelation.JoinAt = now userPublicPlatoonRelation.CreateAt = now userPublicPlatoonRelation.UpdateAt = now @@ -227,9 +229,21 @@ func FindWaitForDealUsers(engine *xorm.Engine, page, pageSize int) (err error, r // UpdateWaitForSettlementDate 改变 `wait_for_settlement_date` 待结算时间 func UpdateWaitForSettlementDate(engine *xorm.Engine, userIds []string) (err error) { + //查找 `user_public_platoon_setting` 基础设置 + userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{ + "key": "is_open", + "value": 1, + }) + if err != nil { + return err + } + settleDay := 30 + if userPublicPlatoonSetting != nil && userPublicPlatoonSetting.SettleDay == 0 { + settleDay = 30 + } //Todo:: 将 user_public_platoon_relation 中 wait_for_settlement_date 设置为 30天后 sql := "update user_public_platoon_amount set wait_for_settlement_date = ? where uid in (" + strings.Join(userIds, ",") + ")" - waitForSettlementDate := time.Now().AddDate(0, 0, 30).Format("2006-01-02") + waitForSettlementDate := time.Now().AddDate(0, 0, settleDay).Format("2006-01-02") _, err = engine.Exec(sql, waitForSettlementDate) if err != nil { return