|
@@ -131,6 +131,17 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
break |
|
|
break |
|
|
|
|
|
case enum.DealUserWatersKindForUpgradeReward: |
|
|
|
|
|
var req *md.DealUserWatersKindForUpgradeRewardReq |
|
|
|
|
|
err = json.Unmarshal(zhios_order_relate_utils.Serialize(args), &req) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
err = handelUpgradeReward(engine, *req, *happyOrchardBasicSetting) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
break |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return |
|
|
return |
|
@@ -637,6 +648,60 @@ func handelBrowsingInterface(engine *xorm.Engine, req md.DealUserWatersKindForBr |
|
|
return session.Commit() |
|
|
return session.Commit() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func handelUpgradeReward(engine *xorm.Engine, req md.DealUserWatersKindForUpgradeRewardReq, basicSetting models.HappyOrchardBasicSetting) (err error) { |
|
|
|
|
|
now := time.Now() |
|
|
|
|
|
|
|
|
|
|
|
//1、获取基础设置中的 "升级奖励" 数据 |
|
|
|
|
|
rewardWatersValue := basicSetting.UpgradeRewardWaterDroplet //奖励水滴值 |
|
|
|
|
|
|
|
|
|
|
|
session := engine.NewSession() |
|
|
|
|
|
session.Begin() |
|
|
|
|
|
defer func() { |
|
|
|
|
|
session.Close() |
|
|
|
|
|
if err := recover(); err != nil { |
|
|
|
|
|
_ = zhios_order_relate_logx.Error(err) |
|
|
|
|
|
} |
|
|
|
|
|
}() |
|
|
|
|
|
//2、查找 happy_orchard_user_waters 数据 |
|
|
|
|
|
happyOrchardUserWatersSess := implement.NewHappyOrchardUserWatersSess(session) |
|
|
|
|
|
happyOrchardUserWaters, err := happyOrchardUserWatersSess.GetHappyOrchardUserWatersSess(req.Uid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if happyOrchardUserWaters == nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return errors.New("用户数据不存在") |
|
|
|
|
|
} |
|
|
|
|
|
beforeWaterNums := happyOrchardUserWaters.WaterNums |
|
|
|
|
|
happyOrchardUserWaters.WaterNums += rewardWatersValue |
|
|
|
|
|
|
|
|
|
|
|
//3、更新 happy_orchard_user_waters 数据 |
|
|
|
|
|
_, err = happyOrchardUserWatersSess.UpdateHappyOrchardUserWatersBySess(req.Uid, happyOrchardUserWaters, "water_nums") |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//4、新增 happy_orchard_user_waters_log 数据 |
|
|
|
|
|
happyOrchardUserWatersLogDb := implement.NewHappyOrchardUserWatersLogDb(engine) |
|
|
|
|
|
_, err = happyOrchardUserWatersLogDb.InsertHappyOrchardUserWatersLogBySess(session, &models.HappyOrchardUserWatersLog{ |
|
|
|
|
|
Uid: req.Uid, |
|
|
|
|
|
WaterNums: basicSetting.WateringEveryTimeWaterDroplet, |
|
|
|
|
|
Title: enum.DealUserWatersKind(enum.DealUserWatersKindForUpgradeReward).String(), |
|
|
|
|
|
Kind: 1, |
|
|
|
|
|
BeforeWaterNums: beforeWaterNums, |
|
|
|
|
|
AfterWaterNums: happyOrchardUserWaters.WaterNums, |
|
|
|
|
|
CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
return session.Commit() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func handelPlayGoldenEggGame(engine *xorm.Engine, req md.DealUserWatersKindForPlayGoldenEggGame, basicSetting models.HappyOrchardBasicSetting) (err error) { |
|
|
func handelPlayGoldenEggGame(engine *xorm.Engine, req md.DealUserWatersKindForPlayGoldenEggGame, basicSetting models.HappyOrchardBasicSetting) (err error) { |
|
|
now := time.Now() |
|
|
now := time.Now() |
|
|
today := now.Format("2006-01-02") |
|
|
today := now.Format("2006-01-02") |
|
|