huangjiajun 3 settimane fa
parent
commit
d1115392a2
5 ha cambiato i file con 231 aggiunte e 8 eliminazioni
  1. +220
    -0
      app/hdl/hdl_settle_center_medium.go
  2. +2
    -0
      app/md/md_finance_center.go
  3. +4
    -4
      app/router/router.go
  4. +4
    -3
      app/svc/svc_finance_center_agent.go
  5. +1
    -1
      app/svc/svc_finance_center_medium.go

+ 220
- 0
app/hdl/hdl_settle_center_medium.go Vedi File

@@ -5,7 +5,19 @@ import (
"applet/app/lib/validate"
"applet/app/md"
"applet/app/svc"
"applet/app/utils"
db "code.fnuoos.com/zhimeng/model.git/src"
"code.fnuoos.com/zhimeng/model.git/src/super/implement"
"fmt"
"github.com/boombuler/barcode"
"github.com/boombuler/barcode/code128"
"github.com/gin-gonic/gin"
"github.com/jung-kurt/gofpdf"
"image/jpeg"
"net/url"
"os"
"strings"
"time"
)

// SettleCenterMediumList
@@ -80,3 +92,211 @@ func SettleCenterMediumDetail(c *gin.Context) {
e.OutSuc(c, res, nil)
return
}
func SettleCenterSettleFileDown(c *gin.Context) {
path := "/data/advertisement-pdf"
id := c.Query("id")
engine := db.Db
NewMediumSettlementDb := implement.NewMediumSettlementDb(engine)
data, _ := NewMediumSettlementDb.GetMediumSettlementById(utils.StrToInt(id))
NewMediumListDb := implement.NewMediumListDb(engine)
medium, _ := NewMediumListDb.GetMediumList(data.MediumId)
// 创建一个新的PDF文件
pdf := gofpdf.New("P", "mm", "A4", "")
// 添加一页
pdf.AddPage()
// 设置文本颜色(参数为RGB值)
pdf.SetTextColor(0, 0, 0)
// 换行
pdf.Ln(-1)
// 引入中文字体,需要相应的字体文件

pdf.AddUTF8Font("SourceHanSansCN-Light", "", path+"/_0000000000_2024103011290507244911708.ttf")
// 引入中文字体后设置中文字体和字号
left := 15.0
pdf.Image(path+"/_0000000000_2024103011210157735330925.png", left, 25, 50, 15, false, "PNG", 0, "")
pdf.SetFont("SourceHanSansCN-Light", "", 10)
pdf.Text(130, 40, "杭州激活鸟网络科技有限公司")
//// 生成EAN-13条形码
num := "jihuoniao-Ads-" + time.Now().Format("20060102") + "-" + utils.IntToStr(data.Id)
cs, _ := code128.Encode(num)
// 创建一个要输出数据的文件

file, _ := os.Create(path + "/" + num + ".jpg")
defer file.Close()
// 设置图片像素大小
qrCode, _ := barcode.Scale(cs, 350, 100)
// 将code128的条形码编码为png图片
jpeg.Encode(file, qrCode, nil)
pdf.Image(path+"/"+num+".jpg", left, 50, 170, 30, false, "JPEG", 0, "")
pdf.SetFont("SourceHanSansCN-Light", "", 28)
pdf.Text(left, 95, "激活鸟 · 变现中心结算对账单")
pdf.SetFont("SourceHanSansCN-Light", "", 12)
pdf.Text(left, 105, "结 算 单 号 : "+num)
pdf.Text(left, 115, "制 表 日 期 : "+time.Now().Format("2006/01/02"))
date := ""
if data.StartDate != "0000-00-00" && data.StartDate != "" {
date = strings.ReplaceAll(data.StartDate, "-", ".")
}
if data.EndDate != "0000-00-00" && data.EndDate != "" {
date += " - " + strings.ReplaceAll(data.EndDate, "-", ".")
}
pdf.Text(left, 125, "结 算 日 期 : "+date)
pdf.Text(left, 135, "客 户 名 称 : "+medium.CompanyName)
// 定义表格内容
pdf.SetFont("SourceHanSansCN-Light", "", 12)
table := []string{
"业务类型", "基础收益(元)", "其他调整(元)", "实际结算总计(元)",
"广告合作", utils.Float64ToStr(float64(data.BasicIncome) / 100), utils.Float64ToStr(float64(data.OtherIncome) / 100), utils.Float64ToStr(float64(data.BasicIncome+data.OtherIncome) / 100),
}
// 定义表格列数
col := 4
// 定义单元格位置
cellWidth := 10.0 * 4
cellHeight := 8.0
x := left
y := 140.0
for i := 0; i < len(table); {
pdf.SetXY(x, y)
if i == col {
cellHeight = 13
}
for j := 0; j < col; j++ {
if i < len(table) {
// 循环绘制单元格并输入内容
pdf.CellFormat(cellWidth, cellHeight, table[i], "1", 0, "C", false, 0, "")
}
i++
}
y = y + cellHeight
}
pdf.SetFont("SourceHanSansCN-Light", "", 12)
pdf.Text(100, 170, "实际结算总计(元):")
pdf.Text(160, 170, utils.Float64ToStr(float64(data.BasicIncome+data.OtherIncome)/100))
pdf.Text(210/2-20, 190, "数据确认回执栏")
pdf.Line(left, 193, 180, 194)
pdf.Text(left, 200, "数据确认")
pdf.Text(left, 210, "公司(盖章或手印):")
pdf.Text(left, 220, "授权人代表签字:")
pdf.Text(left, 230, "日期:")

// 保存PDF文件
pdfName := num + ".pdf"
err := pdf.OutputFileAndClose(path + "/" + pdfName)
if err != nil {
fmt.Println(err)
return
}
c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Disposition", "attachment; filename="+url.QueryEscape(pdfName))
c.Header("Content-Transfer-Encoding", "binary")
c.File(path + "/" + pdfName)
os.Remove(path + "/" + pdfName)
file.Close()
err = os.Remove(path + "/" + num + ".jpg")
fmt.Println(err)
return
}
func AgentSettleCenterSettleFileDown(c *gin.Context) {
path := "/data/advertisement-pdf"
id := c.Query("id")
engine := db.Db
NewMediumSettlementDb := implement.NewAgentSettlementDb(engine)
data, _ := NewMediumSettlementDb.GetAgentSettlementById(utils.StrToInt(id))
NewMediumListDb := implement.NewAgentListDb(engine)
medium, _ := NewMediumListDb.GetAgentList(data.AgentId)
// 创建一个新的PDF文件
pdf := gofpdf.New("P", "mm", "A4", "")
// 添加一页
pdf.AddPage()
// 设置文本颜色(参数为RGB值)
pdf.SetTextColor(0, 0, 0)
// 换行
pdf.Ln(-1)
// 引入中文字体,需要相应的字体文件

pdf.AddUTF8Font("SourceHanSansCN-Light", "", path+"/_0000000000_2024103011290507244911708.ttf")
// 引入中文字体后设置中文字体和字号
left := 15.0
pdf.Image(path+"/_0000000000_2024103011210157735330925.png", left, 25, 50, 15, false, "PNG", 0, "")
pdf.SetFont("SourceHanSansCN-Light", "", 10)
pdf.Text(130, 40, "杭州激活鸟网络科技有限公司")
//// 生成EAN-13条形码
num := "jihuoniao-Ads-agent-" + time.Now().Format("20060102") + "-" + utils.IntToStr(data.Id)
cs, _ := code128.Encode(num)
// 创建一个要输出数据的文件

file, _ := os.Create(path + "/" + num + ".jpg")
defer file.Close()
// 设置图片像素大小
qrCode, _ := barcode.Scale(cs, 350, 100)
// 将code128的条形码编码为png图片
jpeg.Encode(file, qrCode, nil)
pdf.Image(path+"/"+num+".jpg", left, 50, 170, 30, false, "JPEG", 0, "")
pdf.SetFont("SourceHanSansCN-Light", "", 28)
pdf.Text(left, 95, "激活鸟 · 变现中心结算对账单")
pdf.SetFont("SourceHanSansCN-Light", "", 12)
pdf.Text(left, 105, "结 算 单 号 : "+num)
pdf.Text(left, 115, "制 表 日 期 : "+time.Now().Format("2006/01/02"))
date := ""
if data.StartDate != "0000-00-00" && data.StartDate != "" {
date = strings.ReplaceAll(data.StartDate, "-", ".")
}
if data.EndDate != "0000-00-00" && data.EndDate != "" {
date += " - " + strings.ReplaceAll(data.EndDate, "-", ".")
}
pdf.Text(left, 125, "结 算 日 期 : "+date)
pdf.Text(left, 135, "客 户 名 称 : "+medium.CompanyName)
// 定义表格内容
pdf.SetFont("SourceHanSansCN-Light", "", 12)
table := []string{
"业务类型", "基础收益(元)", "其他调整(元)", "实际结算总计(元)",
"广告合作", utils.Float64ToStr(float64(data.BasicIncome) / 100), utils.Float64ToStr(float64(data.OtherIncome) / 100), utils.Float64ToStr(float64(data.BasicIncome+data.OtherIncome) / 100),
}
// 定义表格列数
col := 4
// 定义单元格位置
cellWidth := 10.0 * 4
cellHeight := 8.0
x := left
y := 140.0
for i := 0; i < len(table); {
pdf.SetXY(x, y)
if i == col {
cellHeight = 13
}
for j := 0; j < col; j++ {
if i < len(table) {
// 循环绘制单元格并输入内容
pdf.CellFormat(cellWidth, cellHeight, table[i], "1", 0, "C", false, 0, "")
}
i++
}
y = y + cellHeight
}
pdf.SetFont("SourceHanSansCN-Light", "", 12)
pdf.Text(100, 170, "实际结算总计(元):")
pdf.Text(160, 170, utils.Float64ToStr(float64(data.BasicIncome+data.OtherIncome)/100))
pdf.Text(210/2-20, 190, "数据确认回执栏")
pdf.Line(left, 193, 180, 194)
pdf.Text(left, 200, "数据确认")
pdf.Text(left, 210, "公司(盖章或手印):")
pdf.Text(left, 220, "授权人代表签字:")
pdf.Text(left, 230, "日期:")

// 保存PDF文件
pdfName := num + ".pdf"
err := pdf.OutputFileAndClose(path + "/" + pdfName)
if err != nil {
fmt.Println(err)
return
}
c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Disposition", "attachment; filename="+url.QueryEscape(pdfName))
c.Header("Content-Transfer-Encoding", "binary")
c.File(path + "/" + pdfName)
os.Remove(path + "/" + pdfName)
file.Close()
err = os.Remove(path + "/" + num + ".jpg")
fmt.Println(err)
return
}

+ 2
- 0
app/md/md_finance_center.go Vedi File

@@ -113,6 +113,7 @@ type FinanceCenterDataDetail struct {
OtherIncome string `json:"other_income" example:"其他调整"`
PayState string `json:"pay_state" example:"结算单支付状态(0:未开始 1:待审核发票 2:发票审核中 3:发票审核拒绝 4:付款中 5:已付款)"`
State string `json:"state" example:"结算单状态(0:未开始 1:核算中 2:待签订 3:完成签订)"`
DownUrl string `json:"down_url"`
}
type FinanceCenterDataAgentDetail struct {
TimeStr string `json:"time_str" example:"业务时间"`
@@ -126,6 +127,7 @@ type FinanceCenterDataAgentDetail struct {
OtherIncome string `json:"other_income" example:"其他调整"`
PayState string `json:"pay_state" example:"结算单支付状态(0:未开始 1:待审核发票 2:发票审核中 3:发票审核拒绝 4:付款中 5:已付款)"`
State string `json:"state" example:"结算单状态(0:未开始 1:核算中 2:待签订 3:完成签订)"`
DownUrl string `json:"down_url"`
}
type Invoice struct {
Type string `json:"type"`


+ 4
- 4
app/router/router.go Vedi File

@@ -76,8 +76,10 @@ func route(r *gin.RouterGroup) {
r.GET("/getAuthToken", hdl.GetAuthToken)

r.GET("/authorize", hdl.AppletAuthorize)
r.POST("/qiniuyun/callback", hdl.FileImgCallback) // 七牛云回调
r.Use(mw.DB) // 以下接口需要用到数据库
r.POST("/qiniuyun/callback", hdl.FileImgCallback) // 七牛云回调
r.GET("/medium/settle/file/down", hdl.SettleCenterSettleFileDown) //结算中心-结算报表-结算单下载
r.GET("/agent/settle/file/down", hdl.AgentSettleCenterSettleFileDown) //结算中心-结算报表-结算单下载
r.Use(mw.DB) // 以下接口需要用到数据库
{
r.POST("/login", hdl.Login)
r.GET("/base", hdl.LoginBase)
@@ -280,7 +282,6 @@ func rFinanceCenter(r *gin.RouterGroup) {
r.POST("/medium/invoice/save", hdl.FinanceCenterMediumInvoiceSave) // 财务中心-媒体详情-发票审核
r.POST("/medium/other/income/save", hdl.FinanceCenterMediumOtherIncomeSave) // 财务中心-媒体详情-其他收益调整
r.POST("/medium/pay/save", hdl.FinanceCenterMediumPaySave) // 财务中心-媒体详情-确认支付
r.POST("/medium/check/save", hdl.FinanceCenterMediumCheckSave) // 财务中心-媒体详情-确认支付

r.POST("/platform/list", hdl.FinanceCenterPlatformList) // 财务中心-平台报表

@@ -290,7 +291,6 @@ func rFinanceCenter(r *gin.RouterGroup) {
r.POST("/agent/invoice/save", hdl.FinanceCenterAgentInvoiceSave) // 财务中心-代理详情-发票审核
r.POST("/agent/other/income/save", hdl.FinanceCenterAgentOtherIncomeSave) // 财务中心-代理详情-其他收益调整
r.POST("/agent/pay/save", hdl.FinanceCenterAgentPaySave) // 财务中心-代理详情-确认支付
r.POST("/agent/check/save", hdl.FinanceCenterAgentCheckSave) // 财务中心-媒体详情-确认支付

}



+ 4
- 3
app/svc/svc_finance_center_agent.go Vedi File

@@ -78,11 +78,11 @@ func FinanceCenterAgentCheckSave(c *gin.Context, req md.CommDetailReq) {
engine := db.Db
NewAgentSettlementDb := implement.NewAgentSettlementDb(engine)
data, _ := NewAgentSettlementDb.GetAgentSettlementById(utils.StrToInt(req.Id))
if data.State > 1 {
e.OutErr(c, 400, e.NewErr(400, "不能再调整"))
if data.State >= 2 {
e.OutErr(c, 400, e.NewErr(400, "已推送给代理,不能再调整"))
return
}
data.State = 1
data.State = 2
engine.Where("id=?", data.Id).Cols("state").Update(data)
e.OutSuc(c, "success", nil)
return
@@ -145,6 +145,7 @@ func FinanceCenterAgentDetail(c *gin.Context, req md.CommDetailReq) md.FinanceCe
if tmpAgent["account"] != "" {
tmp.Account = tmpAgent["account"]
}
tmp.DownUrl = "http://" + c.Request.Host + "/api/medium/settle/file/down?id=" + utils.IntToStr(data.Id)

res := md.FinanceCenterDataAgentDetailRes{
Data: tmp,


+ 1
- 1
app/svc/svc_finance_center_medium.go Vedi File

@@ -148,7 +148,7 @@ func FinanceCenterMediumDetail(c *gin.Context, req md.CommDetailReq) md.FinanceC
if tmpMedium["account"] != "" {
tmp.Account = tmpMedium["account"]
}
tmp.DownUrl = "http://" + c.Request.Host + "/api/agent/settle/file/down?id=" + utils.IntToStr(data.Id)
res := md.FinanceCenterDataDetailRes{
Data: tmp,
InvoiceCate: md.InvoiceCate,


Caricamento…
Annulla
Salva