DengBiao преди 8 месеца
родител
ревизия
0c24547b21
променени са 4 файла, в които са добавени 107 реда и са изтрити 0 реда
  1. +27
    -0
      db/db_one_circles_public_platoon_free_punish_with_user.go
  2. +46
    -0
      db/db_one_circles_public_platoon_records_punish_with_user.go
  3. +7
    -0
      db/model/one_circles_public_platoon_records_punish_with_user.go
  4. +27
    -0
      rule/one_circles/one_circles_public_platoon_user_relation_commission.go

+ 27
- 0
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
}

+ 46
- 0
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
}

+ 7
- 0
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)"`
}

+ 27
- 0
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++


Зареждане…
Отказ
Запис