|
- 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"
- "encoding/json"
- "github.com/gin-gonic/gin"
- )
-
- func InvoiceCenterList(c *gin.Context, req md.InvoiceCenterDataReq) md.InvoiceCenterDataRes {
- user := GetUser(c)
- engine := db.Db
- NewMediumInvoiceDb := implement.NewMediumInvoiceDb(engine)
- MediumList, total, _ := NewMediumInvoiceDb.FindMediumInvoiceList(c.GetString("mid"), req.Type, utils.IntToStr(user.MediumId), utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
- data := make([]md.InvoiceCenterDataData, 0)
- if len(MediumList) > 0 {
- for _, v := range MediumList {
- var tmp = md.InvoiceCenterDataData{
- Id: utils.IntToStr(v.MediumInvoice.Id),
- TimeStr: v.MediumInvoice.UpdateAt,
- Month: v.StartDate,
- Count: utils.IntToStr(v.MediumInvoice.Count),
- Amount: utils.Float64ToStr(float64(v.MediumSettlement.OtherIncome+v.MediumSettlement.BasicIncome) / 100),
- State: utils.IntToStr(v.MediumInvoice.State),
- }
- data = append(data, tmp)
- }
- }
- res := md.InvoiceCenterDataRes{
- List: data,
- Total: total,
- State: md.InvoiceState,
- }
- return res
- }
- func InvoiceCenterDetail(c *gin.Context, req md.CommDetailReq) md.InvoiceCenterDataDetailRes {
- engine := db.Db
- NewMediumInvoiceDb := implement.NewMediumInvoiceDb(engine)
- data, _ := NewMediumInvoiceDb.GetMediumInvoiceById(utils.StrToInt(req.Id))
- file := make([]md.InvoiceFile, 0)
- json.Unmarshal([]byte(data.File), &file)
- tmp := md.InvoiceCenterDataDetailData{
- TimeStr: data.UpdateAt,
- State: utils.IntToStr(data.State),
- Count: utils.IntToStr(data.Count),
- File: file,
- }
- res := md.InvoiceCenterDataDetailRes{
- Data: tmp,
- State: md.InvoiceState,
- }
- return res
- }
|