From 0c24547b2159172e087b7f8194137b8f455cde53 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 7 Feb 2024 17:25:49 +0800 Subject: [PATCH] update --- ...es_public_platoon_free_punish_with_user.go | 27 +++++++++++ ...public_platoon_records_punish_with_user.go | 46 +++++++++++++++++++ ...public_platoon_records_punish_with_user.go | 7 +++ ...public_platoon_user_relation_commission.go | 27 +++++++++++ 4 files changed, 107 insertions(+) create mode 100644 db/db_one_circles_public_platoon_records_punish_with_user.go create mode 100644 db/model/one_circles_public_platoon_records_punish_with_user.go diff --git a/db/db_one_circles_public_platoon_free_punish_with_user.go b/db/db_one_circles_public_platoon_free_punish_with_user.go index 7249cb6..e0139a3 100644 --- a/db/db_one_circles_public_platoon_free_punish_with_user.go +++ b/db/db_one_circles_public_platoon_free_punish_with_user.go @@ -12,8 +12,35 @@ func FindAllOneCirclesPublicPlatoonFreePunishWithUser(Db *xorm.Engine) (resp map if err != nil { return nil, zhios_order_relate_logx.Error(err) } + resp = map[int]*model.OneCirclesPublicPlatoonFreePunishWithUser{} for _, v := range m { resp[v.Uid] = &v } return } + +// OneCirclesPublicPlatoonFreePunishWithUserInsert 插入单条数据 +func OneCirclesPublicPlatoonFreePunishWithUserInsert(Db *xorm.Engine, oneCirclesPublicPlatoonFreePunishWithUser *model.OneCirclesPublicPlatoonFreePunishWithUser) (int, error) { + _, err := Db.InsertOne(oneCirclesPublicPlatoonFreePunishWithUser) + if err != nil { + return 0, err + } + return oneCirclesPublicPlatoonFreePunishWithUser.Id, nil +} + +// OneCirclesPublicPlatoonFreePunishWithUserUpdate 更新记录 +func OneCirclesPublicPlatoonFreePunishWithUserUpdate(Db *xorm.Engine, id interface{}, oneCirclesPublicPlatoonFreePunishWithUser *model.OneCirclesPublicPlatoonFreePunishWithUser, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = Db.Where("id=?", id).Cols(forceColums...).Update(oneCirclesPublicPlatoonFreePunishWithUser) + } else { + affected, err = Db.Where("id=?", id).Update(oneCirclesPublicPlatoonFreePunishWithUser) + } + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/db/db_one_circles_public_platoon_records_punish_with_user.go b/db/db_one_circles_public_platoon_records_punish_with_user.go new file mode 100644 index 0000000..78067ac --- /dev/null +++ b/db/db_one_circles_public_platoon_records_punish_with_user.go @@ -0,0 +1,46 @@ +package db + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" + zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" + "xorm.io/xorm" +) + +func FindAllOneCirclesPublicPlatoonRecordsPunishWithUser(Db *xorm.Engine) (resp map[int]*model.OneCirclesPublicPlatoonRecordsPunishWithUser, err error) { + var m []model.OneCirclesPublicPlatoonRecordsPunishWithUser + err = Db.Where("1=1").Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + resp = map[int]*model.OneCirclesPublicPlatoonRecordsPunishWithUser{} + for _, v := range m { + resp[v.Uid] = &v + } + return +} + +// OneCirclesPublicPlatoonRecordsPunishWithUserInsert 插入单条数据 +func OneCirclesPublicPlatoonRecordsPunishWithUserInsert(Db *xorm.Engine, oneCirclesPublicPlatoonRecordsPunishWithUser *model.OneCirclesPublicPlatoonRecordsPunishWithUser) (int, error) { + _, err := Db.InsertOne(oneCirclesPublicPlatoonRecordsPunishWithUser) + if err != nil { + return 0, err + } + return oneCirclesPublicPlatoonRecordsPunishWithUser.Id, nil +} + +// OneCirclesPublicPlatoonRecordsPunishWithUserUpdate 更新记录 +func OneCirclesPublicPlatoonRecordsPunishWithUserUpdate(Db *xorm.Engine, id interface{}, oneCirclesPublicPlatoonRecordsPunishWithUser *model.OneCirclesPublicPlatoonRecordsPunishWithUser, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = Db.Where("id=?", id).Cols(forceColums...).Update(oneCirclesPublicPlatoonRecordsPunishWithUser) + } else { + affected, err = Db.Where("id=?", id).Update(oneCirclesPublicPlatoonRecordsPunishWithUser) + } + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/db/model/one_circles_public_platoon_records_punish_with_user.go b/db/model/one_circles_public_platoon_records_punish_with_user.go new file mode 100644 index 0000000..2f673d3 --- /dev/null +++ b/db/model/one_circles_public_platoon_records_punish_with_user.go @@ -0,0 +1,7 @@ +package model + +type OneCirclesPublicPlatoonRecordsPunishWithUser struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` + Date string `json:"date" xorm:"default '0000-00-00' comment('处罚日期') CHAR(50)"` +} diff --git a/rule/one_circles/one_circles_public_platoon_user_relation_commission.go b/rule/one_circles/one_circles_public_platoon_user_relation_commission.go index d9a5196..d84f586 100644 --- a/rule/one_circles/one_circles_public_platoon_user_relation_commission.go +++ b/rule/one_circles/one_circles_public_platoon_user_relation_commission.go @@ -857,11 +857,38 @@ func OneCirclesDealUserPublicPlatoonPunish(engine *xorm.Engine, masterId string) var list []model.OneCirclesGreenEnergySignIn err = engine.Where("start_time >= ?", startDate).And("uid = ?", user.Uid).Find(&list) if len(list) <= 0 && mapOneCirclesPublicPlatoonFreePunishWithUser[user.Uid] == nil { + var oneCirclesPublicPlatoonRecordsPunishWithUser model.OneCirclesPublicPlatoonRecordsPunishWithUser + has, err1 := engine.Where("uid = ?", user.Uid).Get(&oneCirclesPublicPlatoonRecordsPunishWithUser) + if err1 != nil { + return err1 + } + oneCirclesPublicPlatoonRecordsPunishWithUserDate, _ := time.ParseInLocation("2006-01-02", oneCirclesPublicPlatoonRecordsPunishWithUser.Date, time.Local) + if has && now.AddDate(0, 0, -7).After(oneCirclesPublicPlatoonRecordsPunishWithUserDate) { + //TODO::不进行重复处罚 + continue + } //进行处罚 err, _ = OneCirclesDealCommonWealthPunish(engine, user.Uid, "公排处罚") if err != nil { return err } + + //添加 one_circles_public_platoon_records_punish_with_user 记录 + if has { + oneCirclesPublicPlatoonRecordsPunishWithUser.Date = now.Format("2006-01-02") + _, err2 := db.OneCirclesPublicPlatoonRecordsPunishWithUserUpdate(engine, oneCirclesPublicPlatoonRecordsPunishWithUser.Id, &oneCirclesPublicPlatoonRecordsPunishWithUser, "date") + if err2 != nil { + return err2 + } + } else { + _, err2 := db.OneCirclesPublicPlatoonRecordsPunishWithUserInsert(engine, &model.OneCirclesPublicPlatoonRecordsPunishWithUser{ + Uid: user.Uid, + Date: now.Format("2006-01-02"), + }) + if err2 != nil { + return err2 + } + } } } page++