diff --git a/api/controller/UserCoupon.go b/api/controller/UserCoupon.go index 8ab6984..d5b85e9 100644 --- a/api/controller/UserCoupon.go +++ b/api/controller/UserCoupon.go @@ -166,3 +166,34 @@ func (b *UserCoupon) GetUserUsableMemberCoupon(c *gin.Context) { responses.OkWithData(userCoupon, c) } + +// PutUserCouponUnnotified 修改还未弹窗的优惠卷 +func (b *UserCoupon) PutUserCouponUnnotified(c *gin.Context) { + userId := c.GetInt64("UserId") + + // 获取数据 + userCouponDao := dao.UserCouponDao{} + maps := make(map[string]interface{}) + maps["user_id"] = userId + userCoupon, _ := userCouponDao.GetUserCoupon(maps) + if userCoupon == nil { + responses.OkWithData(nil, c) + return + } + + // 开始事务 + tx := global.Db.Begin() + defer func() { + if r := recover(); r != nil { + tx.Rollback() + } + }() + + maps = make(map[string]interface{}) + maps["is_windows"] = 1 + _ = userCouponDao.EditUserCouponById(tx, userCoupon.UserCouponId, maps) + + tx.Commit() + + responses.Ok(c) +} diff --git a/api/router/router.go b/api/router/router.go index f5bf4f6..ad9fca2 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -246,6 +246,9 @@ func privateRouter(r *gin.Engine, api controller.Api) { // 获取还未弹窗的优惠卷 couponGroup.GET("/unnotified", api.UserCoupon.GetUserCouponUnnotified) + // 修改还未弹窗的优惠卷 + couponGroup.PUT("/unnotified/:user_coupon_id", api.UserCoupon.PutUserCouponUnnotified) + usableGroup := couponGroup.Group("/usable") { // 获取患者可使用优惠卷-单项