From f692c34ffb336bdaf028e81a25bce57e94ba4ae4 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 4 Dec 2024 17:22:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E6=96=B9=E6=B3=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/egg_energy/home_page_start_sign_in.go | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/rule/egg_energy/home_page_start_sign_in.go b/rule/egg_energy/home_page_start_sign_in.go index 452bd46..07f13f9 100644 --- a/rule/egg_energy/home_page_start_sign_in.go +++ b/rule/egg_energy/home_page_start_sign_in.go @@ -2,6 +2,7 @@ package egg_energy import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" @@ -91,7 +92,35 @@ func HomePageStartSignIn(engine *xorm.Engine, req md.HomePageStartSignInReq) err })) return errors.New("非签到时间," + "请求账号:" + req.Phone + ",请求时间:" + now.Format("2006-01-02 15:04:05") + ",签到时间:" + eggSignIn.EndTime) } - + //2、新增 `egg_sign_in` 记录 + endTime := now.Add(time.Hour * time.Duration(oneRoundDuration)).Format("2006-01-02 15:04:05") + _, err = engine.Insert(&model.EggSignIn{ + Uid: req.UID, + StartTime: now.Format("2006-01-02 15:04:05"), + EndTime: endTime, + IsCompleted: 0, + }) + if err != nil { + return err + } + //3、新增 `egg_energy_user_activity` 记录 + var m model.EggEnergyUserActivity + has, err := engine.Where("uid =? and date =?", req.UID, now.Format("2006-01-02")).Get(&m) + if err != nil { + return err + } + if !has { + affected, err1 := engine.Insert(&model.EggEnergyUserActivity{ + Uid: int(req.UID), + Date: now.Format("2006-01-02"), + }) + if err1 != nil { + return err1 + } + if affected <= 0 { + return errors.New("插入活跃记录失败") + } + } ch, err := rabbit.Cfg.Pool.GetChannel() if err != nil { return err