huangjiajun пре 5 месеци
родитељ
комит
f5f0660300
1 измењених фајлова са 9 додато и 9 уклоњено
  1. +9
    -9
      rule/micro_applications/happy_orchard_user_waters.go

+ 9
- 9
rule/micro_applications/happy_orchard_user_waters.go Прегледај датотеку

@@ -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…
Откажи
Сачувај