diff --git a/app/admin/apis/market/marketing.go b/app/admin/apis/market/marketing.go index a647d2b..fe66f34 100644 --- a/app/admin/apis/market/marketing.go +++ b/app/admin/apis/market/marketing.go @@ -111,6 +111,41 @@ func ErpMarketingCouponEdit(c *gin.Context) { return } +// ErpMarketingCouponDetail 优惠券详情 +// @Summary 优惠券详情 +// @Tags 营销管理,V1.4.4 +// @Produce json +// @Accept json +// @Param request body models.ErpMarketingCouponDetailReq true "优惠券详情模型" +// @Success 200 {object} models.ErpCoupon +// @Router /api/v1/marketing/coupon/detail [post] +func ErpMarketingCouponDetail(c *gin.Context) { + req := &model.ErpMarketingCouponDetailReq{} + if err := c.ShouldBindJSON(&req); err != nil { + logger.Error("ShouldBindJSON err:", logger.Field("err", err)) + app.Error(c, http.StatusBadRequest, errors.New("para err"), "参数错误") + return + } + + err := tools.Validate(req) //必填参数校验 + if err != nil { + app.Error(c, http.StatusBadRequest, err, err.Error()) + return + } + + // 查询订单信息 + var erpCoupon model.ErpCoupon + err = orm.Eloquent.Table("erp_coupon").Where("id=?", req.ErpCouponId).Find(&erpCoupon).Error + if err != nil { + logger.Error("query erp_coupon err:", logger.Field("err", err)) + app.Error(c, http.StatusInternalServerError, err, err.Error()) + return + } + + app.OK(c, erpCoupon, "OK") + return +} + // ErpMarketingCouponDelete 删除优惠券 // @Summary 删除优惠券 // @Tags 营销管理,V1.4.4 diff --git a/app/admin/models/marketing.go b/app/admin/models/marketing.go index 31555c4..7c10306 100644 --- a/app/admin/models/marketing.go +++ b/app/admin/models/marketing.go @@ -127,6 +127,11 @@ type ErpMarketingCouponEditReq struct { Limit uint32 `json:"limit"` // 优惠券叠加限制 0-不限制;1-仅限原价购买时使用 } +// ErpMarketingCouponDetailReq 优惠券详情入参 +type ErpMarketingCouponDetailReq struct { + ErpCouponId uint32 `json:"erp_coupon_id" validate:"required"` // 优惠券id +} + // ErpMarketingCouponDeleteReq 删除优惠券入参 type ErpMarketingCouponDeleteReq struct { ErpCouponId uint32 `json:"erp_coupon_id" validate:"required"` // 优惠券id diff --git a/app/admin/router/marketing.go b/app/admin/router/marketing.go index 3e6a640..6d45602 100644 --- a/app/admin/router/marketing.go +++ b/app/admin/router/marketing.go @@ -13,6 +13,7 @@ func registerMarketingManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJ r.POST("coupon/list", market.ErpMarketingCouponList) // 优惠券列表 r.POST("coupon/create", market.ErpMarketingCouponCreate) // 新增优惠券 r.POST("coupon/edit", market.ErpMarketingCouponEdit) // 编辑优惠券 + r.POST("coupon/detail", market.ErpMarketingCouponDetail) // 优惠券详情 r.POST("coupon/delete", market.ErpMarketingCouponDelete) // 删除优惠券 r.POST("coupon/start", market.ErpMarketingCouponStart) // 启动优惠券发放 r.POST("coupon/data", market.ErpMarketingCouponData) // 优惠券数据 diff --git a/docs/docs.go b/docs/docs.go index b1d251b..8fbb551 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -4381,6 +4381,39 @@ const docTemplate = `{ } } }, + "/api/v1/marketing/coupon/detail": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "营销管理,V1.4.4" + ], + "summary": "优惠券详情", + "parameters": [ + { + "description": "优惠券详情模型", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.ErpMarketingCouponDetailReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.ErpCoupon" + } + } + } + } + }, "/api/v1/marketing/coupon/edit": { "post": { "consumes": [ @@ -9736,6 +9769,18 @@ const docTemplate = `{ } } }, + "models.ErpMarketingCouponDetailReq": { + "type": "object", + "required": [ + "erp_coupon_id" + ], + "properties": { + "erp_coupon_id": { + "description": "优惠券id", + "type": "integer" + } + } + }, "models.ErpMarketingCouponEditReq": { "type": "object", "required": [ diff --git a/docs/swagger.json b/docs/swagger.json index 35249b0..1c8e819 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -4370,6 +4370,39 @@ } } }, + "/api/v1/marketing/coupon/detail": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "营销管理,V1.4.4" + ], + "summary": "优惠券详情", + "parameters": [ + { + "description": "优惠券详情模型", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.ErpMarketingCouponDetailReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.ErpCoupon" + } + } + } + } + }, "/api/v1/marketing/coupon/edit": { "post": { "consumes": [ @@ -9725,6 +9758,18 @@ } } }, + "models.ErpMarketingCouponDetailReq": { + "type": "object", + "required": [ + "erp_coupon_id" + ], + "properties": { + "erp_coupon_id": { + "description": "优惠券id", + "type": "integer" + } + } + }, "models.ErpMarketingCouponEditReq": { "type": "object", "required": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d83611c..6b32715 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -2255,6 +2255,14 @@ definitions: required: - erp_coupon_id type: object + models.ErpMarketingCouponDetailReq: + properties: + erp_coupon_id: + description: 优惠券id + type: integer + required: + - erp_coupon_id + type: object models.ErpMarketingCouponEditReq: properties: active_date: @@ -11709,6 +11717,27 @@ paths: summary: 删除优惠券 tags: - 营销管理,V1.4.4 + /api/v1/marketing/coupon/detail: + post: + consumes: + - application/json + parameters: + - description: 优惠券详情模型 + in: body + name: request + required: true + schema: + $ref: '#/definitions/models.ErpMarketingCouponDetailReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/models.ErpCoupon' + summary: 优惠券详情 + tags: + - 营销管理,V1.4.4 /api/v1/marketing/coupon/edit: post: consumes: