|
|
@@ -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 |
|
|
|