diff --git a/db/db_user_small_public_platoon_relation.go b/db/db_user_small_public_platoon_relation.go index 5db0008..49e5043 100644 --- a/db/db_user_small_public_platoon_relation.go +++ b/db/db_user_small_public_platoon_relation.go @@ -92,10 +92,10 @@ func UserSmallPublicPlatoonRelationFindByEmptyPosition(Db *xorm.Engine) (*model. return &m, nil } -func UserSmallPublicPlatoonRelationGetOneByPid(Db *xorm.Engine, pid string, params map[string]interface{}) (*model.UserSmallPublicPlatoonRelation, error) { +func UserSmallPublicPlatoonRelationGetOneByPid(Db *xorm.Engine, recommendUid string, params map[string]interface{}) (*model.UserSmallPublicPlatoonRelation, error) { var m model.UserSmallPublicPlatoonRelation var query = fmt.Sprintf("%s =?", params["key"]) - if has, err := Db.Where("pid = ?", pid).And(query, params["value"]).Get(&m); err != nil || has == false { + if has, err := Db.Where("recommend_uid = ?", recommendUid).And(query, params["value"]).Get(&m); err != nil || has == false { return nil, zhios_order_relate_logx.Error(err) } return &m, nil diff --git a/rule/public_platoon_relate_commission.go b/rule/public_platoon_relate_commission.go index c561677..dc2ed8a 100644 --- a/rule/public_platoon_relate_commission.go +++ b/rule/public_platoon_relate_commission.go @@ -135,10 +135,10 @@ 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) + // 3、插入 user_public_platoon_relation 记录 if userPublicPlatoonSetting.SettleDay == 0 { userPublicPlatoonSetting.SettleDay = 30 } - // 3、插入 user_public_platoon_relation 记录 now := time.Now() userPublicPlatoonRelation.Uid = uid userPublicPlatoonRelation.FatherUid = fatherUid @@ -240,6 +240,8 @@ func UpdateWaitForSettlementDate(engine *xorm.Engine, userIds []string) (err err settleDay := 30 if userPublicPlatoonSetting != nil && userPublicPlatoonSetting.SettleDay == 0 { settleDay = 30 + } else { + settleDay = userPublicPlatoonSetting.SettleDay } //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, ",") + ")" diff --git a/rule/small_public_platoon_relate_commission.go b/rule/small_public_platoon_relate_commission.go index edf9de0..c847885 100644 --- a/rule/small_public_platoon_relate_commission.go +++ b/rule/small_public_platoon_relate_commission.go @@ -49,6 +49,9 @@ func AddSmallPublicPlatoonRelateCommission(engine *xorm.Engine, AddSmallPublicPl } if userSmallPublicPlatoonRelation != nil { userSmallPublicPlatoonRelation.Uid = zhios_order_relate_utils.StrToInt(param.Uid) + uniqueIdentifier := strings.Split(userSmallPublicPlatoonRelation.UniqueIdentifier, "-") + uniqueIdentifier[1] = param.Uid + userSmallPublicPlatoonRelation.UniqueIdentifier = strings.Join(uniqueIdentifier, "-") updateAffected, err := db.UserSmallPublicPlatoonRelationUpdate(engine.NewSession(), userSmallPublicPlatoonRelation.Id, userSmallPublicPlatoonRelation) if err != nil { return nil, err @@ -76,6 +79,9 @@ func AddSmallPublicPlatoonRelateCommission(engine *xorm.Engine, AddSmallPublicPl } if userSmallPublicPlatoonRelation != nil { userSmallPublicPlatoonRelation.Uid = zhios_order_relate_utils.StrToInt(param.Uid) + uniqueIdentifier := strings.Split(userSmallPublicPlatoonRelation.UniqueIdentifier, "-") + uniqueIdentifier[1] = param.Uid + userSmallPublicPlatoonRelation.UniqueIdentifier = strings.Join(uniqueIdentifier, "-") updateAffected, err := db.UserSmallPublicPlatoonRelationUpdate(engine.NewSession(), userSmallPublicPlatoonRelation.Id, userSmallPublicPlatoonRelation) if err != nil { return nil, err @@ -310,6 +316,9 @@ func naturalSmallPublicPlatoon(engine *xorm.Engine, uid int, originalPosition *i 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) // 3、插入 user_public_platoon_relation 记录 + if userPublicPlatoonSetting.SettleDay == 0 { + userPublicPlatoonSetting.SettleDay = 30 + } now := time.Now() userPublicPlatoonRelation.Uid = uid userPublicPlatoonRelation.FatherUid = fatherUid @@ -318,7 +327,7 @@ func naturalSmallPublicPlatoon(engine *xorm.Engine, uid int, originalPosition *i 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 @@ -410,9 +419,23 @@ func smallFindWaitForDealUsers(engine *xorm.Engine, page, pageSize int) (err err // SmallUpdateWaitForSettlementDate 改变 `wait_for_settlement_date` 待结算时间 func SmallUpdateWaitForSettlementDate(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 + } else { + settleDay = userPublicPlatoonSetting.SettleDay + } //Todo:: 将 user_public_platoon_relation 中 wait_for_settlement_date 设置为 30天后 sql := "update user_small_public_platoon_relation 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