From e993981bb4d77386086b0a9c9b5d42fe4d364c35 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 4 Sep 2024 11:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_financial_dynamics.go | 59 +++++++++ app/md/md_financial_dynamics.go | 35 ++++++ app/md/md_settle_center.go | 4 + app/router/router.go | 21 ++-- app/svc/svc_financial_dynamics.go | 71 +++++++++++ app/svc/svc_settle_center.go | 2 + docs/docs.go | 203 ++++++++++++++++++++++++++++++ docs/swagger.json | 203 ++++++++++++++++++++++++++++++ docs/swagger.yaml | 137 ++++++++++++++++++++ go.mod | 2 +- 10 files changed, 728 insertions(+), 9 deletions(-) create mode 100644 app/hdl/hdl_financial_dynamics.go create mode 100644 app/md/md_financial_dynamics.go create mode 100644 app/svc/svc_financial_dynamics.go diff --git a/app/hdl/hdl_financial_dynamics.go b/app/hdl/hdl_financial_dynamics.go new file mode 100644 index 0000000..e4edd62 --- /dev/null +++ b/app/hdl/hdl_financial_dynamics.go @@ -0,0 +1,59 @@ +package hdl + +import ( + "applet/app/e" + "applet/app/lib/validate" + "applet/app/md" + "applet/app/svc" + "github.com/gin-gonic/gin" +) + +// FinancialDynamicsMediumTotal +// @Summary 媒体预付-统计 +// @Tags 资产动态------嘉俊 +// @Description 资产动态-媒体预付-统计 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.FinancialDynamicsMediumTotalReq true "请求参数" +// @Success 200 {object} md.FinancialDynamicsMediumTotalRes "具体看返回内容 这是data里面的数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/financialDynamics/medium/total [POST] +func FinancialDynamicsMediumTotal(c *gin.Context) { + var req md.FinancialDynamicsMediumTotalReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + res := svc.FinancialDynamicsMediumTotal(c, req) + e.OutSuc(c, res, nil) + return +} + +// FinancialDynamicsMediumList +// @Summary 媒体预付 +// @Tags 资产动态------嘉俊 +// @Description 资产动态-媒体预付 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.FinancialDynamicsMediumListReq true "请求参数" +// @Success 200 {object} md.FinancialDynamicsMediumListRes "具体看返回内容 这是data里面的数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/financialDynamics/medium/list [POST] +func FinancialDynamicsMediumList(c *gin.Context) { + var req md.FinancialDynamicsMediumListReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + res := svc.FinancialDynamicsMediumList(c, req) + e.OutSuc(c, res, nil) + return +} diff --git a/app/md/md_financial_dynamics.go b/app/md/md_financial_dynamics.go new file mode 100644 index 0000000..0cd6770 --- /dev/null +++ b/app/md/md_financial_dynamics.go @@ -0,0 +1,35 @@ +package md + +type FinancialDynamicsMediumListReq struct { + Limit string `json:"limit"` + Page string `json:"page" ` + StartTime string `json:"start_time" example:"2024-08-29 00:00:00"` + EndTime string `json:"end_time" ` +} +type FinancialDynamicsMediumTotalReq struct { + StartTime string `json:"start_time" example:"2024-08-29 00:00:00"` + EndTime string `json:"end_time" ` +} + +type FinancialDynamicsMediumListRes struct { + List []FinancialDynamicsMediumListData `json:"list" ` + Total int64 `json:"total"` + BusinessKind []SelectData `json:"business_kind"` + PayMethod []SelectData `json:"pay_method"` +} + +type FinancialDynamicsMediumListData struct { + Id string `json:"id"` + PayTime string `json:"pay_time" example:"支付时间"` + Amount string `json:"amount" example:"支付金额"` + PayMethod string `json:"pay_method" example:"支付方式 0对私 1对公"` + Certificate string `json:"certificate" example:"支付凭证"` + Memo string `json:"memo" example:"备注"` + BusinessKind string `json:"business_kind" example:"支付类型(1:广告合作)"` +} +type FinancialDynamicsMediumTotalRes struct { + BalanceAmount string `json:"balance_amount" example:"账户余额"` + AllAmount string `json:"all_amount" example:"预付总金额"` + UseAmount string `json:"use_amount" example:"已消耗金额"` + PayCount string `json:"pay_count" example:"预付次数"` +} diff --git a/app/md/md_settle_center.go b/app/md/md_settle_center.go index 10c93b0..d3403eb 100644 --- a/app/md/md_settle_center.go +++ b/app/md/md_settle_center.go @@ -9,6 +9,10 @@ var AccountSettleState = []SelectData{ var BusinessKind = []SelectData{ {Name: "广告合作", Value: "1"}, } +var PayMethod = []SelectData{ + {Name: "对私账户", Value: "0"}, + {Name: "对公账户", Value: "1"}, +} var InvoiceCate = []SelectData{ {Name: "电子发票", Value: "0"}, {Name: "纸质发票", Value: "1"}, diff --git a/app/router/router.go b/app/router/router.go index 2f26622..a5f73cf 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -64,14 +64,15 @@ func route(r *gin.RouterGroup) { r.POST("/qiniuyun/upload", hdl.ImgReqUpload) //七牛云上传 r.POST("/sms", hdl.Sms) //短信发送 } - r.Use(mw.Auth) // 以下接口需要JWT验证 - rRole(r.Group("/role")) //权限管理 - rIndex(r.Group("/index")) //首页 - rApplication(r.Group("/application")) //应用管理 - rAccount(r.Group("/account")) //账号中心 - rSettleCenter(r.Group("/settleCenter")) //结算中心 - rInvoiceCenter(r.Group("/invoiceCenter")) //发票中心 - rDataCenter(r.Group("/dataCenter")) //数据中心 + r.Use(mw.Auth) // 以下接口需要JWT验证 + rRole(r.Group("/role")) //权限管理 + rIndex(r.Group("/index")) //首页 + rApplication(r.Group("/application")) //应用管理 + rAccount(r.Group("/account")) //账号中心 + rSettleCenter(r.Group("/settleCenter")) //结算中心 + rInvoiceCenter(r.Group("/invoiceCenter")) //发票中心 + rDataCenter(r.Group("/dataCenter")) //数据中心 + rFinancialDynamics(r.Group("/financialDynamics")) //资产动态 } func rRole(r *gin.RouterGroup) { @@ -128,3 +129,7 @@ func rIndex(r *gin.RouterGroup) { r.GET("/total", hdl.IndexTotal) //首页-统计数据 r.POST("/app/list", hdl.IndexAppList) //首页-应用数据 } +func rFinancialDynamics(r *gin.RouterGroup) { + r.POST("/medium/total", hdl.FinancialDynamicsMediumTotal) //资产动态-媒体预付统计 + r.POST("/medium/list", hdl.FinancialDynamicsMediumList) //资产动态-媒体预付 +} diff --git a/app/svc/svc_financial_dynamics.go b/app/svc/svc_financial_dynamics.go new file mode 100644 index 0000000..603786a --- /dev/null +++ b/app/svc/svc_financial_dynamics.go @@ -0,0 +1,71 @@ +package svc + +import ( + "applet/app/md" + "applet/app/utils" + db "code.fnuoos.com/zhimeng/model.git/src" + "code.fnuoos.com/zhimeng/model.git/src/super/implement" + "fmt" + "github.com/gin-gonic/gin" +) + +func FinancialDynamicsMediumList(c *gin.Context, req md.FinancialDynamicsMediumListReq) md.FinancialDynamicsMediumListRes { + engine := db.Db + NewMediumFinancialDynamicsDb := implement.NewMediumFinancialDynamicsDb(engine) + user := GetUser(c) + list, total, _ := NewMediumFinancialDynamicsDb.FindMediumFinancialDynamics(c.GetString("mid"), utils.IntToStr(user.MediumId), req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) + data := make([]md.FinancialDynamicsMediumListData, 0) + if len(list) > 0 { + for _, v := range list { + var tmp = md.FinancialDynamicsMediumListData{ + Id: utils.IntToStr(v.Id), + PayTime: v.PayTime, + Amount: v.Amount, + PayMethod: utils.IntToStr(v.PayMethod), + Certificate: v.Certificate, + Memo: v.Memo, + BusinessKind: utils.IntToStr(v.BusinessKind), + } + data = append(data, tmp) + } + } + res := md.FinancialDynamicsMediumListRes{ + List: data, + Total: total, + PayMethod: md.PayMethod, + BusinessKind: md.BusinessKind, + } + return res +} +func FinancialDynamicsMediumTotal(c *gin.Context, req md.FinancialDynamicsMediumTotalReq) md.FinancialDynamicsMediumTotalRes { + engine := db.Db + sql := `select sum(amount) as amount,COUNT(*) as count from %s where %s` + where := "uuid=" + c.GetString("mid") + user := GetUser(c) + where += " and medium_id=" + utils.IntToStr(user.MediumId) + sql1 := fmt.Sprintf(sql, "medium_list", where) + res := md.FinancialDynamicsMediumTotalRes{ + BalanceAmount: "0.00", + AllAmount: "0.00", + UseAmount: "0.00", + PayCount: "0", + } + nativeString, _ := db.QueryNativeString(engine, sql1) + for _, v := range nativeString { + if utils.StrToFloat64(v["amount"]) > 0 { + res.BalanceAmount = v["amount"] + } + } + sql2 := fmt.Sprintf(sql, "medium_financial_dynamics", where) + nativeString2, _ := db.QueryNativeString(engine, sql2) + for _, v := range nativeString2 { + if utils.StrToFloat64(v["amount"]) > 0 { + res.AllAmount = v["amount"] + } + if utils.StrToFloat64(v["count"]) > 0 { + res.PayCount = v["count"] + } + } + res.UseAmount = utils.Float64ToStr(utils.StrToFloat64(res.AllAmount) - utils.StrToFloat64(res.BalanceAmount)) + return res +} diff --git a/app/svc/svc_settle_center.go b/app/svc/svc_settle_center.go index 650a1bc..fd375e1 100644 --- a/app/svc/svc_settle_center.go +++ b/app/svc/svc_settle_center.go @@ -128,6 +128,8 @@ func SettleCenterInvoiceSave(c *gin.Context, req md.InvoiceReq) { if invoice == nil { invoice = &model.MediumInvoice{ SettlementId: data.Id, + Uuid: utils.StrToInt(c.GetString("mid")), + MediumId: data.MediumId, CreateAt: time.Now().Format("2006-01-02 15:04:05"), UpdateAt: time.Now().Format("2006-01-02 15:04:05"), } diff --git a/docs/docs.go b/docs/docs.go index b1b723a..3e4526c 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -741,6 +741,100 @@ const docTemplate = `{ } } }, + "/api/financialDynamics/medium/list": { + "post": { + "description": "资产动态-媒体预付", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "资产动态------嘉俊" + ], + "summary": "媒体预付", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumListReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumListRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/financialDynamics/medium/total": { + "post": { + "description": "资产动态-媒体预付-统计", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "资产动态------嘉俊" + ], + "summary": "媒体预付-统计", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumTotalReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumTotalRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/index/app/list": { "post": { "description": "数据中心-数据明细", @@ -2566,6 +2660,115 @@ const docTemplate = `{ } } }, + "md.FinancialDynamicsMediumListData": { + "type": "object", + "properties": { + "amount": { + "type": "string", + "example": "支付金额" + }, + "business_kind": { + "type": "string", + "example": "支付类型(1:广告合作)" + }, + "certificate": { + "type": "string", + "example": "支付凭证" + }, + "id": { + "type": "string" + }, + "memo": { + "type": "string", + "example": "备注" + }, + "pay_method": { + "type": "string", + "example": "支付方式 0对私 1对公" + }, + "pay_time": { + "type": "string", + "example": "支付时间" + } + } + }, + "md.FinancialDynamicsMediumListReq": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "limit": { + "type": "string" + }, + "page": { + "type": "string" + }, + "start_time": { + "type": "string", + "example": "2024-08-29 00:00:00" + } + } + }, + "md.FinancialDynamicsMediumListRes": { + "type": "object", + "properties": { + "business_kind": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.FinancialDynamicsMediumListData" + } + }, + "pay_method": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "total": { + "type": "integer" + } + } + }, + "md.FinancialDynamicsMediumTotalReq": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "start_time": { + "type": "string", + "example": "2024-08-29 00:00:00" + } + } + }, + "md.FinancialDynamicsMediumTotalRes": { + "type": "object", + "properties": { + "all_amount": { + "type": "string", + "example": "预付总金额" + }, + "balance_amount": { + "type": "string", + "example": "账户余额" + }, + "pay_count": { + "type": "string", + "example": "预付次数" + }, + "use_amount": { + "type": "string", + "example": "已消耗金额" + } + } + }, "md.ImgReqUpload": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 0426a74..f517c0b 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -733,6 +733,100 @@ } } }, + "/api/financialDynamics/medium/list": { + "post": { + "description": "资产动态-媒体预付", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "资产动态------嘉俊" + ], + "summary": "媒体预付", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumListReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumListRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/financialDynamics/medium/total": { + "post": { + "description": "资产动态-媒体预付-统计", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "资产动态------嘉俊" + ], + "summary": "媒体预付-统计", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumTotalReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsMediumTotalRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/index/app/list": { "post": { "description": "数据中心-数据明细", @@ -2558,6 +2652,115 @@ } } }, + "md.FinancialDynamicsMediumListData": { + "type": "object", + "properties": { + "amount": { + "type": "string", + "example": "支付金额" + }, + "business_kind": { + "type": "string", + "example": "支付类型(1:广告合作)" + }, + "certificate": { + "type": "string", + "example": "支付凭证" + }, + "id": { + "type": "string" + }, + "memo": { + "type": "string", + "example": "备注" + }, + "pay_method": { + "type": "string", + "example": "支付方式 0对私 1对公" + }, + "pay_time": { + "type": "string", + "example": "支付时间" + } + } + }, + "md.FinancialDynamicsMediumListReq": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "limit": { + "type": "string" + }, + "page": { + "type": "string" + }, + "start_time": { + "type": "string", + "example": "2024-08-29 00:00:00" + } + } + }, + "md.FinancialDynamicsMediumListRes": { + "type": "object", + "properties": { + "business_kind": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.FinancialDynamicsMediumListData" + } + }, + "pay_method": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "total": { + "type": "integer" + } + } + }, + "md.FinancialDynamicsMediumTotalReq": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "start_time": { + "type": "string", + "example": "2024-08-29 00:00:00" + } + } + }, + "md.FinancialDynamicsMediumTotalRes": { + "type": "object", + "properties": { + "all_amount": { + "type": "string", + "example": "预付总金额" + }, + "balance_amount": { + "type": "string", + "example": "账户余额" + }, + "pay_count": { + "type": "string", + "example": "预付次数" + }, + "use_amount": { + "type": "string", + "example": "已消耗金额" + } + } + }, "md.ImgReqUpload": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 0413fbc..437e0ec 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -396,6 +396,81 @@ definitions: platform_name: type: string type: object + md.FinancialDynamicsMediumListData: + properties: + amount: + example: 支付金额 + type: string + business_kind: + example: 支付类型(1:广告合作) + type: string + certificate: + example: 支付凭证 + type: string + id: + type: string + memo: + example: 备注 + type: string + pay_method: + example: 支付方式 0对私 1对公 + type: string + pay_time: + example: 支付时间 + type: string + type: object + md.FinancialDynamicsMediumListReq: + properties: + end_time: + type: string + limit: + type: string + page: + type: string + start_time: + example: "2024-08-29 00:00:00" + type: string + type: object + md.FinancialDynamicsMediumListRes: + properties: + business_kind: + items: + $ref: '#/definitions/md.SelectData' + type: array + list: + items: + $ref: '#/definitions/md.FinancialDynamicsMediumListData' + type: array + pay_method: + items: + $ref: '#/definitions/md.SelectData' + type: array + total: + type: integer + type: object + md.FinancialDynamicsMediumTotalReq: + properties: + end_time: + type: string + start_time: + example: "2024-08-29 00:00:00" + type: string + type: object + md.FinancialDynamicsMediumTotalRes: + properties: + all_amount: + example: 预付总金额 + type: string + balance_amount: + example: 账户余额 + type: string + pay_count: + example: 预付次数 + type: string + use_amount: + example: 已消耗金额 + type: string + type: object md.ImgReqUpload: properties: dir: @@ -1391,6 +1466,68 @@ paths: summary: 数据图表 tags: - 数据中心------嘉俊 + /api/financialDynamics/medium/list: + post: + consumes: + - application/json + description: 资产动态-媒体预付 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.FinancialDynamicsMediumListReq' + produces: + - application/json + responses: + "200": + description: 具体看返回内容 这是data里面的数据 + schema: + $ref: '#/definitions/md.FinancialDynamicsMediumListRes' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 媒体预付 + tags: + - 资产动态------嘉俊 + /api/financialDynamics/medium/total: + post: + consumes: + - application/json + description: 资产动态-媒体预付-统计 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.FinancialDynamicsMediumTotalReq' + produces: + - application/json + responses: + "200": + description: 具体看返回内容 这是data里面的数据 + schema: + $ref: '#/definitions/md.FinancialDynamicsMediumTotalRes' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 媒体预付-统计 + tags: + - 资产动态------嘉俊 /api/index/app/list: post: consumes: diff --git a/go.mod b/go.mod index 45c1a48..12a9484 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ go 1.18 // require ( - code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240902065422-a58ca385e5a0 + code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240904023523-1b174457882d github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/boombuler/barcode v1.0.1 github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5