Browse Source

更新

master
huangjiajun 7 months ago
parent
commit
f5f0660300
1 changed files with 9 additions and 9 deletions
  1. +9
    -9
      rule/micro_applications/happy_orchard_user_waters.go

+ 9
- 9
rule/micro_applications/happy_orchard_user_waters.go View File

@@ -156,17 +156,22 @@ func handelWatering(engine *xorm.Engine, req md.DealUserWatersKindForWateringReq
_ = zhios_order_relate_logx.Error(err)
}
}()
err = CommWatering(engine, session, req, basicSetting)
if err != nil {
_ = session.Rollback()
return
}
return session.Commit()
}
func CommWatering(engine *xorm.Engine, session *xorm.Session, req md.DealUserWatersKindForWateringReq, basicSetting models.HappyOrchardBasicSetting) (err error) {
now := time.Now()

//1、查找 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("用户数据不存在")
}

@@ -174,17 +179,14 @@ func handelWatering(engine *xorm.Engine, req md.DealUserWatersKindForWateringReq
beforeWaterNums := happyOrchardUserWaters.WaterNums
happyOrchardUserWaters.WaterNums -= basicSetting.WateringEveryTimeWaterDroplet
if happyOrchardUserWaters.WaterNums < 0 {
_ = session.Rollback()
return errors.New("用户水滴不够")
}

//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{
@@ -198,11 +200,9 @@ func handelWatering(engine *xorm.Engine, req md.DealUserWatersKindForWateringReq
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
if err != nil {
_ = session.Rollback()
return err
}

return session.Commit()
return nil
}

func handelSevenDaysSign(engine *xorm.Engine, req md.DealUserWatersKindForSevenDaysSignReq, basicSetting models.HappyOrchardBasicSetting) (err error) {


Loading…
Cancel
Save