|
@@ -156,17 +156,22 @@ func handelWatering(engine *xorm.Engine, req md.DealUserWatersKindForWateringReq |
|
|
_ = zhios_order_relate_logx.Error(err) |
|
|
_ = 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() |
|
|
now := time.Now() |
|
|
|
|
|
|
|
|
//1、查找 happy_orchard_user_waters 数据 |
|
|
//1、查找 happy_orchard_user_waters 数据 |
|
|
happyOrchardUserWatersSess := implement.NewHappyOrchardUserWatersSess(session) |
|
|
happyOrchardUserWatersSess := implement.NewHappyOrchardUserWatersSess(session) |
|
|
happyOrchardUserWaters, err := happyOrchardUserWatersSess.GetHappyOrchardUserWatersSess(req.Uid) |
|
|
happyOrchardUserWaters, err := happyOrchardUserWatersSess.GetHappyOrchardUserWatersSess(req.Uid) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
_ = session.Rollback() |
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if happyOrchardUserWaters == nil { |
|
|
if happyOrchardUserWaters == nil { |
|
|
_ = session.Rollback() |
|
|
|
|
|
return errors.New("用户数据不存在") |
|
|
return errors.New("用户数据不存在") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -174,17 +179,14 @@ func handelWatering(engine *xorm.Engine, req md.DealUserWatersKindForWateringReq |
|
|
beforeWaterNums := happyOrchardUserWaters.WaterNums |
|
|
beforeWaterNums := happyOrchardUserWaters.WaterNums |
|
|
happyOrchardUserWaters.WaterNums -= basicSetting.WateringEveryTimeWaterDroplet |
|
|
happyOrchardUserWaters.WaterNums -= basicSetting.WateringEveryTimeWaterDroplet |
|
|
if happyOrchardUserWaters.WaterNums < 0 { |
|
|
if happyOrchardUserWaters.WaterNums < 0 { |
|
|
_ = session.Rollback() |
|
|
|
|
|
return errors.New("用户水滴不够") |
|
|
return errors.New("用户水滴不够") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//3、更新 happy_orchard_user_waters 数据 |
|
|
//3、更新 happy_orchard_user_waters 数据 |
|
|
_, err = happyOrchardUserWatersSess.UpdateHappyOrchardUserWatersBySess(req.Uid, happyOrchardUserWaters, "water_nums") |
|
|
_, err = happyOrchardUserWatersSess.UpdateHappyOrchardUserWatersBySess(req.Uid, happyOrchardUserWaters, "water_nums") |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//4、新增 happy_orchard_user_waters_log 数据 |
|
|
//4、新增 happy_orchard_user_waters_log 数据 |
|
|
happyOrchardUserWatersLogDb := implement.NewHappyOrchardUserWatersLogDb(engine) |
|
|
happyOrchardUserWatersLogDb := implement.NewHappyOrchardUserWatersLogDb(engine) |
|
|
_, err = happyOrchardUserWatersLogDb.InsertHappyOrchardUserWatersLogBySess(session, &models.HappyOrchardUserWatersLog{ |
|
|
_, 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"), |
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
}) |
|
|
}) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return session.Commit() |
|
|
|
|
|
|
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func handelSevenDaysSign(engine *xorm.Engine, req md.DealUserWatersKindForSevenDaysSignReq, basicSetting models.HappyOrchardBasicSetting) (err error) { |
|
|
func handelSevenDaysSign(engine *xorm.Engine, req md.DealUserWatersKindForSevenDaysSignReq, basicSetting models.HappyOrchardBasicSetting) (err error) { |
|
|