diff --git a/app/hdl/hdl_financial_dynamics.go b/app/hdl/hdl_financial_dynamics.go new file mode 100644 index 0000000..fad23d7 --- /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" +) + +// FinancialDynamicsAgentTotal +// @Summary 代理预付-统计 +// @Tags 资产动态------嘉俊 +// @Description 资产动态-代理预付-统计 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.FinancialDynamicsAgentTotalReq true "请求参数" +// @Success 200 {object} md.FinancialDynamicsAgentTotalRes "具体看返回内容 这是data里面的数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/financialDynamics/agent/total [POST] +func FinancialDynamicsAgentTotal(c *gin.Context) { + var req md.FinancialDynamicsAgentTotalReq + 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.FinancialDynamicsAgentTotal(c, req) + e.OutSuc(c, res, nil) + return +} + +// FinancialDynamicsAgentList +// @Summary 代理预付 +// @Tags 资产动态------嘉俊 +// @Description 资产动态-代理预付 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.FinancialDynamicsAgentListReq true "请求参数" +// @Success 200 {object} md.FinancialDynamicsAgentListRes "具体看返回内容 这是data里面的数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/financialDynamics/agent/list [POST] +func FinancialDynamicsAgentList(c *gin.Context) { + var req md.FinancialDynamicsAgentListReq + 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.FinancialDynamicsAgentList(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..7fa5439 --- /dev/null +++ b/app/md/md_financial_dynamics.go @@ -0,0 +1,35 @@ +package md + +type FinancialDynamicsAgentListReq 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 FinancialDynamicsAgentTotalReq struct { + StartTime string `json:"start_time" example:"2024-08-29 00:00:00"` + EndTime string `json:"end_time" ` +} + +type FinancialDynamicsAgentListRes struct { + List []FinancialDynamicsAgentListData `json:"list" ` + Total int64 `json:"total"` + BusinessKind []SelectData `json:"business_kind"` + PayMethod []SelectData `json:"pay_method"` +} + +type FinancialDynamicsAgentListData 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 FinancialDynamicsAgentTotalRes 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 8b92a5f..21508ec 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 ef92aee..2e6a47a 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -64,14 +64,14 @@ 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")) //权限管理 - rMedium(r.Group("/medium")) //媒体中心 - rAccount(r.Group("/account")) //账号中心 - rIndex(r.Group("/index")) //首页 - rDataCenter(r.Group("/dataCenter")) //数据中心 - rSettleCenter(r.Group("/settleCenter")) //结算中心 - + r.Use(mw.Auth) // 以下接口需要JWT验证 + rRole(r.Group("/role")) //权限管理 + rMedium(r.Group("/medium")) //媒体中心 + rAccount(r.Group("/account")) //账号中心 + rIndex(r.Group("/index")) //首页 + rDataCenter(r.Group("/dataCenter")) //数据中心 + rSettleCenter(r.Group("/settleCenter")) //结算中心 + rFinancialDynamics(r.Group("/financialDynamics")) //资产动态 } func rRole(r *gin.RouterGroup) { @@ -128,3 +128,7 @@ func rSettleCenter(r *gin.RouterGroup) { r.POST("/agent/settle/file/save", hdl.SettleCenterSettleFileSave) //结算中心-渠道个人结算报表-结算单上传 r.POST("/agent/invoice/save", hdl.SettleCenterInvoiceSave) //结算中心-渠道个人结算报表-发票上传 } +func rFinancialDynamics(r *gin.RouterGroup) { + r.POST("/agent/total", hdl.FinancialDynamicsAgentTotal) //资产动态-代理预付统计 + r.POST("/agent/list", hdl.FinancialDynamicsAgentList) //资产动态-代理预付 +} diff --git a/app/svc/svc_financial_dynamics.go b/app/svc/svc_financial_dynamics.go new file mode 100644 index 0000000..dedcad7 --- /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 FinancialDynamicsAgentList(c *gin.Context, req md.FinancialDynamicsAgentListReq) md.FinancialDynamicsAgentListRes { + engine := db.Db + NewAgentFinancialDynamicsDb := implement.NewAgentFinancialDynamicsDb(engine) + user := GetUser(c) + list, total, _ := NewAgentFinancialDynamicsDb.FindAgentFinancialDynamics(c.GetString("mid"), utils.IntToStr(user.AgentId), req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) + data := make([]md.FinancialDynamicsAgentListData, 0) + if len(list) > 0 { + for _, v := range list { + var tmp = md.FinancialDynamicsAgentListData{ + 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.FinancialDynamicsAgentListRes{ + List: data, + Total: total, + PayMethod: md.PayMethod, + BusinessKind: md.BusinessKind, + } + return res +} +func FinancialDynamicsAgentTotal(c *gin.Context, req md.FinancialDynamicsAgentTotalReq) md.FinancialDynamicsAgentTotalRes { + 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 agent_id=" + utils.IntToStr(user.AgentId) + sql1 := fmt.Sprintf(sql, "agent_list", where) + res := md.FinancialDynamicsAgentTotalRes{ + 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, "agent_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 b742c5b..224a199 100644 --- a/app/svc/svc_settle_center.go +++ b/app/svc/svc_settle_center.go @@ -172,6 +172,8 @@ func SettleCenterInvoiceSave(c *gin.Context, req md.InvoiceReq) { if invoice == nil { invoice = &model.AgentInvoice{ SettlementId: data.Id, + Uuid: utils.StrToInt(c.GetString("mid")), + AgentId: data.AgentId, 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 bbb9ae1..839b65c 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -741,6 +741,100 @@ const docTemplate = `{ } } }, + "/api/financialDynamics/agent/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.FinancialDynamicsAgentListReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsAgentListRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/financialDynamics/agent/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.FinancialDynamicsAgentTotalReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsAgentTotalRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/index/app/list": { "post": { "description": "数据中心-数据明细", @@ -2567,6 +2661,115 @@ const docTemplate = `{ } } }, + "md.FinancialDynamicsAgentListData": { + "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.FinancialDynamicsAgentListReq": { + "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.FinancialDynamicsAgentListRes": { + "type": "object", + "properties": { + "business_kind": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.FinancialDynamicsAgentListData" + } + }, + "pay_method": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "total": { + "type": "integer" + } + } + }, + "md.FinancialDynamicsAgentTotalReq": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "start_time": { + "type": "string", + "example": "2024-08-29 00:00:00" + } + } + }, + "md.FinancialDynamicsAgentTotalRes": { + "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 abb3d1f..7c366d8 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -733,6 +733,100 @@ } } }, + "/api/financialDynamics/agent/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.FinancialDynamicsAgentListReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsAgentListRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/financialDynamics/agent/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.FinancialDynamicsAgentTotalReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容 这是data里面的数据", + "schema": { + "$ref": "#/definitions/md.FinancialDynamicsAgentTotalRes" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/index/app/list": { "post": { "description": "数据中心-数据明细", @@ -2559,6 +2653,115 @@ } } }, + "md.FinancialDynamicsAgentListData": { + "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.FinancialDynamicsAgentListReq": { + "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.FinancialDynamicsAgentListRes": { + "type": "object", + "properties": { + "business_kind": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.FinancialDynamicsAgentListData" + } + }, + "pay_method": { + "type": "array", + "items": { + "$ref": "#/definitions/md.SelectData" + } + }, + "total": { + "type": "integer" + } + } + }, + "md.FinancialDynamicsAgentTotalReq": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "start_time": { + "type": "string", + "example": "2024-08-29 00:00:00" + } + } + }, + "md.FinancialDynamicsAgentTotalRes": { + "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 07d6f9b..b7bf9b6 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -399,6 +399,81 @@ definitions: platform_name: type: string type: object + md.FinancialDynamicsAgentListData: + 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.FinancialDynamicsAgentListReq: + 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.FinancialDynamicsAgentListRes: + properties: + business_kind: + items: + $ref: '#/definitions/md.SelectData' + type: array + list: + items: + $ref: '#/definitions/md.FinancialDynamicsAgentListData' + type: array + pay_method: + items: + $ref: '#/definitions/md.SelectData' + type: array + total: + type: integer + type: object + md.FinancialDynamicsAgentTotalReq: + properties: + end_time: + type: string + start_time: + example: "2024-08-29 00:00:00" + type: string + type: object + md.FinancialDynamicsAgentTotalRes: + 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: @@ -1337,6 +1412,68 @@ paths: summary: 筛选条件 tags: - 数据中心------嘉俊 + /api/financialDynamics/agent/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.FinancialDynamicsAgentListReq' + produces: + - application/json + responses: + "200": + description: 具体看返回内容 这是data里面的数据 + schema: + $ref: '#/definitions/md.FinancialDynamicsAgentListRes' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 代理预付 + tags: + - 资产动态------嘉俊 + /api/financialDynamics/agent/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.FinancialDynamicsAgentTotalReq' + produces: + - application/json + responses: + "200": + description: 具体看返回内容 这是data里面的数据 + schema: + $ref: '#/definitions/md.FinancialDynamicsAgentTotalRes' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 代理预付-统计 + tags: + - 资产动态------嘉俊 /api/index/app/list: post: consumes: diff --git a/go.mod b/go.mod index 32f70ee..7b727ae 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( ) 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/360EntSecGroup-Skylar/excelize v1.4.1 )