123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- package controllers
- import (
- "ERP_storage/Nats"
- "ERP_storage/Nats/NatsServer"
- "ERP_storage/conf"
- "ERP_storage/dto"
- "ERP_storage/logs"
- "ERP_storage/models/Account"
- models "ERP_storage/models/ContractReview"
- "ERP_storage/services"
- "encoding/json"
- "fmt"
- natslibs "gogs.baozhida.cn/zoie/ERP_libs/Nats"
- userlibs "gogs.baozhida.cn/zoie/ERP_libs/User"
- "gogs.baozhida.cn/zoie/ERP_libs/lib"
- beego "github.com/beego/beego/v2/server/web"
- "github.com/xuri/excelize/v2"
- "math"
- "os"
- "strconv"
- )
- type ContractReviewController struct {
- beego.Controller
- User userlibs.User
- }
- func (c *ContractReviewController) Prepare() {
- c.User = *Account.User_r
- }
- // 服务类型
- func (c *ContractReviewController) ServiceType_List() {
- s := services.ServiceType{}
- reqData := dto.ServiceTypePageReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- R_List, R_cnt := s.GetPage(&reqData)
- var r_jsons lib.R_JSONS
- r_jsons.Num = R_cnt
- r_jsons.Data = R_List
- r_jsons.Page = reqData.Page
- r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(reqData.PageSize)))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) ServiceType_Add() {
- s := services.ServiceType{}
- reqData := dto.ServiceTypeInsertReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- Id, err := s.Insert(&reqData)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "服务类型", "添加", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) ServiceType_Edit() {
- s := services.ServiceType{}
- reqData := dto.ServiceTypeUpdateReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if err := s.Update(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "服务类型", "修改", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) ServiceType_Del() {
- s := services.ServiceType{}
- reqData := dto.ServiceTypeDeleteReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if err := s.Delete(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "服务类型", "删除", strconv.Itoa(reqData.T_id))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 服务内容
- func (c *ContractReviewController) ServiceItem_List() {
- s := services.ServiceItem{}
- reqData := dto.ServiceItemPageReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- R_List, R_cnt := s.GetPage(&reqData)
- var r_jsons lib.R_JSONS
- r_jsons.Num = R_cnt
- r_jsons.Data = R_List
- r_jsons.Page = reqData.Page
- r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(reqData.PageSize)))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) ServiceItem_Add() {
- s := services.ServiceItem{}
- reqData := dto.ServiceItemInsertReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- Id, err := s.Insert(&reqData)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "服务内容", "添加", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) ServiceItem_Edit() {
- s := services.ServiceItem{}
- reqData := dto.ServiceItemUpdateReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if err := s.Update(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "服务内容", "修改", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) ServiceItem_Del() {
- s := services.ServiceItem{}
- reqData := dto.ServiceItemDeleteReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if err := s.Delete(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "服务内容", "删除", strconv.Itoa(reqData.T_id))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 合同评审-用户
- func (c *ContractReviewController) List() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewPageReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- userList, _ := NatsServer.Read_User_List_All()
- Account.Read_User_All_Map(userList)
- reqData.T_submit = c.User.T_uuid
- R_List, R_cnt := s.GetPage(&reqData)
- var r_jsons lib.R_JSONS
- r_jsons.Num = R_cnt
- r_jsons.Data = R_List
- r_jsons.Page = reqData.Page
- r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(reqData.PageSize)))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- // 合同评审-财务
- func (c *ContractReviewController) Finance_List() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewPageReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- userList, _ := NatsServer.Read_User_List_All()
- Account.Read_User_All_Map(userList)
- R_List, R_cnt := s.GetFinancePage(&reqData)
- var r_jsons lib.R_JSONS
- r_jsons.Num = R_cnt
- r_jsons.Data = R_List
- r_jsons.Page = reqData.Page
- r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(reqData.PageSize)))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- // 合同评审-财务
- func (c *ContractReviewController) Manager_List() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewPageReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- userList, _ := NatsServer.Read_User_List_All()
- Account.Read_User_All_Map(userList)
- R_List, R_cnt := s.GetManagerPage(&reqData)
- var r_jsons lib.R_JSONS
- r_jsons.Num = R_cnt
- r_jsons.Data = R_List
- r_jsons.Page = reqData.Page
- r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(reqData.PageSize)))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- // 负责人列表
- func (c *ContractReviewController) Submit_User_List() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewSubmitUserPageReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- userList, _ := NatsServer.Read_User_List_All()
- Account.Read_User_All_Map(userList)
- R_List, R_cnt := s.GetSubmitUserPage(&reqData)
- var r_jsons lib.R_JSONS
- r_jsons.Num = R_cnt
- r_jsons.Data = R_List
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) Add() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewInsertReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := json.Unmarshal([]byte(reqData.ServiceItems), &reqData.ServiceItemList); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "服务内容 参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- reqData.T_submit = c.User.T_uuid
- Id, err := s.Insert(&reqData)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "合同评审", "添加", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) Edit() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewUpdateReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := json.Unmarshal([]byte(reqData.ServiceItems), &reqData.ServiceItemList); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "服务内容 参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if err := s.Update(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "合同评审", "修改", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 提交审核
- func (c *ContractReviewController) Submit_Audit() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewGetReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if err := s.SubmitAudit(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "合同评审", "提交审核", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 财务审核
- func (c *ContractReviewController) Finance_Audit() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewAuditReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if !(reqData.T_audit == 3 || reqData.T_audit == 4) {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "状态参数错误"}
- c.ServeJSON()
- return
- }
- if err := s.FinanceAudit(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "合同评审", "财务审核", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 管理员审核
- func (c *ContractReviewController) Manager_Audit() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewAuditReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if !(reqData.T_audit == 5 || reqData.T_audit == 6) {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "状态参数错误"}
- c.ServeJSON()
- return
- }
- if err := s.ManagerAudit(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "合同评审", "总经理审核", reqData)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) Del() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewDeleteReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- if err := s.Delete(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- NatsServer.AddUserLogs(c.User.T_uuid, "合同评审", "删除", strconv.Itoa(reqData.T_id))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- func (c *ContractReviewController) Stock_Detail_Excel() {
- s := services.ContractReview{}
- reqData := dto.ContractReviewPageReq{}
- if err := c.ParseForm(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "参数错误"}
- c.ServeJSON()
- return
- }
- if err := Validate(&reqData); err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
- c.ServeJSON()
- return
- }
- userList, _ := NatsServer.Read_User_List_All()
- Account.Read_User_All_Map(userList)
- reqData.PageSize = 9999
- R_List, _ := s.GetFinancePage(&reqData)
- filename := fmt.Sprintf("合同评审统计表(%s)", lib.GetRandstring(6, "0123456789", 0))
- f := excelize.NewFile() // 设置单元格的值
- Style1, _ := f.NewStyle(
- &excelize.Style{
- Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
- Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
- })
- Style2, _ := f.NewStyle(
- &excelize.Style{
- Font: &excelize.Font{Bold: true, Size: 10, Family: "宋体"},
- Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
- Border: []excelize.Border{
- {Type: "left", Color: "000000", Style: 1},
- {Type: "top", Color: "000000", Style: 1},
- {Type: "bottom", Color: "000000", Style: 1},
- {Type: "right", Color: "000000", Style: 1},
- },
- })
- f.MergeCell("Sheet1", "A1", "I1")
- f.SetRowStyle("Sheet1", 1, 1, Style1)
- f.SetCellValue("Sheet1", "A1", fmt.Sprintf("宝智达科技合同评审统计表"))
- f.SetRowHeight("Sheet1", 1, 30)
- // 这里设置表头
- f.SetCellStyle("Sheet1", "A2", "I2", Style2)
- f.SetRowHeight("Sheet1", 2, 20)
- f.SetCellValue("Sheet1", "A2", "序号")
- f.SetCellValue("Sheet1", "B2", "状态")
- f.SetCellValue("Sheet1", "C2", "项目名称")
- f.SetCellValue("Sheet1", "D2", "项目地址")
- f.SetCellValue("Sheet1", "E2", "项目负责人")
- f.SetCellValue("Sheet1", "F2", "预计签约时间")
- f.SetCellValue("Sheet1", "G2", "总金额")
- f.SetCellValue("Sheet1", "H2", "最终优惠金额")
- f.SetCellValue("Sheet1", "I2", "是否有居间费")
- f.SetCellValue("Sheet1", "J2", "居间费金额")
- // 设置列宽
- f.SetColWidth("Sheet1", "A", "A", 10)
- f.SetColWidth("Sheet1", "B", "B", 10)
- f.SetColWidth("Sheet1", "C", "D", 15)
- f.SetColWidth("Sheet1", "D", "D", 20)
- f.SetColWidth("Sheet1", "E", "E", 12)
- f.SetColWidth("Sheet1", "F", "F", 12)
- f.SetColWidth("Sheet1", "G", "H", 10)
- f.SetColWidth("Sheet1", "I", "I", 12)
- f.SetColWidth("Sheet1", "J", "J", 10)
- line := 2
- // 循环写入数据
- for _, v := range R_List {
- line++
- f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), line-2)
- f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), models.Get_T_audit_name(v.T_audit))
- f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.T_name)
- f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.T_address)
- f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), v.T_submit_name)
- f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), v.T_predict_sign_time)
- f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.T_money)
- f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), v.T_discount_money)
- T_have_brokerage_fee_str := "否"
- if v.T_have_brokerage_fee == true {
- T_have_brokerage_fee_str = "是"
- }
- f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), T_have_brokerage_fee_str)
- f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), v.T_brokerage_fee_money)
- }
- Style4, _ := f.NewStyle(
- &excelize.Style{
- Font: &excelize.Font{Size: 10, Family: "宋体"},
- Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
- Border: []excelize.Border{
- {Type: "left", Color: "000000", Style: 1},
- {Type: "top", Color: "000000", Style: 1},
- {Type: "bottom", Color: "000000", Style: 1},
- {Type: "right", Color: "000000", Style: 1},
- },
- })
- f.SetCellStyle("Sheet1", "A2", fmt.Sprintf("I%d", line), Style4)
- // 保存文件
- if err := f.SaveAs("ofile/" + filename + ".xlsx"); err != nil {
- fmt.Println(err)
- }
- var url string
- //// 上传 OSS
- nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
- url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+filename+".xlsx", "ofile/"+filename+".xlsx")
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
- c.ServeJSON()
- return
- }
- //删除目录
- err := os.Remove("ofile/" + filename + ".xlsx")
- if err != nil {
- logs.Error(lib.FuncName(), err)
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
- c.ServeJSON()
- return
- }
|