Ver código fonte

update

master
dengbiao 7 meses atrás
pai
commit
d69a103291
3 arquivos alterados com 71 adições e 0 exclusões
  1. +3
    -0
      rule/micro_applications/enum/happy_orchard.go
  2. +65
    -0
      rule/micro_applications/happy_orchard_user_waters.go
  3. +3
    -0
      rule/micro_applications/md/happy_orchard.go

+ 3
- 0
rule/micro_applications/enum/happy_orchard.go Ver arquivo

@@ -91,6 +91,7 @@ const (
DealUserWatersKindForBrowsingInterface = "browsing_interface"
DealUserWatersKindForPlayGoldenEggGame = "play_golden_egg_game"
DealUserWatersKindForPlayRaffleGame = "play_raffle_game"
DealUserWatersKindForUpgradeReward = "upgrade_reward"
)

func (kind DealUserWatersKind) String() string {
@@ -113,6 +114,8 @@ func (kind DealUserWatersKind) String() string {
return "玩金蛋奖励"
case DealUserWatersKindForPlayRaffleGame:
return "玩抽奖游戏奖励"
case DealUserWatersKindForUpgradeReward:
return "升级奖励"
default:
return "未知"
}


+ 65
- 0
rule/micro_applications/happy_orchard_user_waters.go Ver arquivo

@@ -131,6 +131,17 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
return
}
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
@@ -637,6 +648,60 @@ func handelBrowsingInterface(engine *xorm.Engine, req md.DealUserWatersKindForBr
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) {
now := time.Now()
today := now.Format("2006-01-02")


+ 3
- 0
rule/micro_applications/md/happy_orchard.go Ver arquivo

@@ -70,3 +70,6 @@ type DealUserWatersKindForPlayGoldenEggGame struct {
type DealUserWatersKindForPlayRaffleGame struct {
Uid int `json:"uid"` //用户id
}
type DealUserWatersKindForUpgradeRewardReq struct {
Uid int `json:"uid"` //用户id
}

Carregando…
Cancelar
Salvar