|
- 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
- }
|