|
@@ -1,19 +1,28 @@
|
|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
+ "ERP_storage/Nats"
|
|
|
"ERP_storage/Nats/NatsServer"
|
|
|
"ERP_storage/conf"
|
|
|
+ "ERP_storage/logs"
|
|
|
"ERP_storage/models/Account"
|
|
|
"ERP_storage/models/Basic"
|
|
|
"ERP_storage/models/Contract"
|
|
|
"ERP_storage/models/Percentage"
|
|
|
- "ERP_storage/models/Stock"
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/adapter/orm"
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
|
+ "github.com/go-resty/resty/v2"
|
|
|
+ "github.com/robfig/cron/v3"
|
|
|
+ "github.com/xuri/excelize/v2"
|
|
|
+ natslibs "gogs.baozhida.cn/zoie/ERP_libs/Nats"
|
|
|
userlibs "gogs.baozhida.cn/zoie/ERP_libs/User"
|
|
|
"gogs.baozhida.cn/zoie/ERP_libs/lib"
|
|
|
"math"
|
|
|
+ "os"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type PercentageController struct {
|
|
@@ -22,7 +31,9 @@ type PercentageController struct {
|
|
|
}
|
|
|
|
|
|
func (c *PercentageController) Prepare() {
|
|
|
- c.User = *Account.User_r
|
|
|
+ if Account.User_r != nil {
|
|
|
+ c.User = *Account.User_r
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 财务管理列表
|
|
@@ -42,14 +53,22 @@ func (c *PercentageController) Percentage_List() {
|
|
|
T_name := c.GetString("T_name")
|
|
|
T_uuid := c.GetString("T_uuid")
|
|
|
T_state, _ := c.GetInt("T_state")
|
|
|
+ T_type, _ := c.GetInt("T_type")
|
|
|
+ T_start_date := c.GetString("T_start_date") // 开始时间
|
|
|
+ T_end_date := c.GetString("T_end_date") // 结束时间
|
|
|
+
|
|
|
+ var T_company_list []string
|
|
|
+ if len(T_name) > 0 {
|
|
|
+ T_company_list = Percentage.Read_VerifyCompany_T_uuid_ListByT_name(T_name)
|
|
|
+ }
|
|
|
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
|
Account.Read_User_All_Map(userList)
|
|
|
- Contract.Read_Contract_All_Map()
|
|
|
- Contract.Read_VerifyContract_All_Map()
|
|
|
+ Percentage.Read_VerifyCompany_All_Map()
|
|
|
|
|
|
PercentageDao := Percentage.NewPercentage(orm.NewOrm())
|
|
|
- R_List, R_cnt := PercentageDao.Read_Percentage_List(T_name, T_uuid, T_state, page, page_z)
|
|
|
+ R_List, R_cnt := PercentageDao.Read_Percentage_List(T_name, T_uuid, T_start_date, T_end_date,
|
|
|
+ T_company_list, T_state, T_type, page, page_z)
|
|
|
|
|
|
var r_jsons lib.R_JSONS
|
|
|
r_jsons.Num = R_cnt
|
|
@@ -77,14 +96,19 @@ func (c *PercentageController) Percentage_User_List() {
|
|
|
// 查询
|
|
|
T_name := c.GetString("T_name")
|
|
|
T_state, _ := c.GetInt("T_state")
|
|
|
+ T_start_date := c.GetString("T_start_date") // 开始时间
|
|
|
+ T_end_date := c.GetString("T_end_date") // 结束时间
|
|
|
+ var T_company_list []string
|
|
|
+ if len(T_name) > 0 {
|
|
|
+ T_company_list = Percentage.Read_VerifyCompany_T_uuid_ListByT_name(T_name)
|
|
|
+ }
|
|
|
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
|
Account.Read_User_All_Map(userList)
|
|
|
- Contract.Read_Contract_All_Map()
|
|
|
Contract.Read_VerifyContract_All_Map()
|
|
|
|
|
|
PercentageDao := Percentage.NewPercentage(orm.NewOrm())
|
|
|
- R_List, R_cnt := PercentageDao.Read_Percentage_User_List(c.User.T_uuid, T_name, T_state, page, page_z)
|
|
|
+ R_List, R_cnt := PercentageDao.Read_Percentage_User_List(c.User.T_uuid, T_name, T_start_date, T_end_date, T_company_list, T_state, page, page_z)
|
|
|
|
|
|
var r_jsons lib.R_JSONS
|
|
|
r_jsons.Num = R_cnt
|
|
@@ -97,113 +121,546 @@ func (c *PercentageController) Percentage_User_List() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func (c *PercentageController) Percentage_Get() {
|
|
|
+func (c *PercentageController) Percentage_Export() {
|
|
|
|
|
|
// 查询
|
|
|
- T_id, _ := c.GetInt("T_id")
|
|
|
- o := orm.NewOrm()
|
|
|
- PercentageDao := Percentage.NewPercentage(o)
|
|
|
- ContractDao := Contract.NewContract(o)
|
|
|
- DeviceDao := Stock.NewDevice(o)
|
|
|
- contractProductDao := Contract.NewContractProduct(o)
|
|
|
- percentage, err := PercentageDao.Read_Percentage_ById(T_id)
|
|
|
- if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
+ T_name := c.GetString("T_name")
|
|
|
+ T_uuid := c.GetString("T_uuid")
|
|
|
+ T_start_date := c.GetString("T_start_date") // 开始时间
|
|
|
+ T_end_date := c.GetString("T_end_date") // 结束时间
|
|
|
+ T_state, _ := c.GetInt("T_state")
|
|
|
+ T_type, _ := c.GetInt("T_type") // 提成类型
|
|
|
+ userList, _ := NatsServer.Read_User_List_All()
|
|
|
+ Account.Read_User_All_Map(userList)
|
|
|
+ Percentage.Read_VerifyCompany_All_Map()
|
|
|
+ Basic.Read_VerifyItem_All_Map()
|
|
|
+ PercentageDao := Percentage.NewPercentage(orm.NewOrm())
|
|
|
+ percentageList, _ := PercentageDao.Read_Percentage_List_For_Excel(T_name, T_uuid, T_start_date, T_end_date, []string{}, T_state, T_type)
|
|
|
+ dataInterval := fmt.Sprintf("%s - %s", T_start_date, T_end_date)
|
|
|
+ if dataInterval == " - " {
|
|
|
+ dataInterval = ""
|
|
|
+ }
|
|
|
+ f := excelize.NewFile() // 设置单元格的值
|
|
|
+ Style1, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 20, Family: "宋体"},
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
+ })
|
|
|
+
|
|
|
+ Style2, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
+ 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", "AC1")
|
|
|
+ f.SetRowStyle("Sheet1", 1, 1, Style1)
|
|
|
+ f.SetRowHeight("Sheet1", 1, 50)
|
|
|
+ f.SetCellValue("Sheet1", "A1", fmt.Sprintf("%s提成统计表", dataInterval))
|
|
|
+
|
|
|
+ //Style3, _ := 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.SetCellStyle("Sheet1", "A2", "G4", Style2)
|
|
|
+ f.SetRowHeight("Sheet1", 2, 20)
|
|
|
+ f.SetRowHeight("Sheet1", 4, 20)
|
|
|
+
|
|
|
+ // 这里设置表头
|
|
|
+ f.MergeCell("Sheet1", "A2", "A4")
|
|
|
+ f.MergeCell("Sheet1", "B2", "B4")
|
|
|
+ f.MergeCell("Sheet1", "C2", "C4")
|
|
|
+ f.MergeCell("Sheet1", "D2", "D4")
|
|
|
+ f.MergeCell("Sheet1", "E2", "E4")
|
|
|
+ f.MergeCell("Sheet1", "F2", "F4")
|
|
|
+ f.MergeCell("Sheet1", "G2", "G4")
|
|
|
+
|
|
|
+ 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.MergeCell("Sheet1", "H2", "S2")
|
|
|
+ f.SetCellValue("Sheet1", "H2", "验证实施")
|
|
|
+
|
|
|
+ f.MergeCell("Sheet1", "T2", "AC2")
|
|
|
+ f.SetCellValue("Sheet1", "T2", "报告编写")
|
|
|
+
|
|
|
+ verifyItemList, _ := Basic.Read_VerifyItem_List(0, "", 0, 9999)
|
|
|
+ for _, item := range verifyItemList {
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("%s3", item.T_cell), item.T_name)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("%s4", item.T_cell), item.T_price)
|
|
|
+ }
|
|
|
+
|
|
|
+ f.MergeCell("Sheet1", "S3", "S4")
|
|
|
+ f.SetCellValue("Sheet1", "S3", "合计")
|
|
|
+
|
|
|
+ f.MergeCell("Sheet1", "AC3", "AC4")
|
|
|
+ f.SetCellValue("Sheet1", "AC3", "合计")
|
|
|
+ // 设置列宽
|
|
|
+ f.SetColWidth("Sheet1", "A", "A", 5)
|
|
|
+ f.SetColWidth("Sheet1", "B", "G", 16)
|
|
|
+ f.SetColWidth("Sheet1", "E", "G", 10)
|
|
|
+ f.SetColWidth("Sheet1", "H", "AC", 10)
|
|
|
+
|
|
|
+ // 冻结1-3行
|
|
|
+ f.SetPanes("Sheet1", &excelize.Panes{
|
|
|
+ Freeze: true,
|
|
|
+ Split: false,
|
|
|
+ XSplit: 2,
|
|
|
+ YSplit: 4,
|
|
|
+ TopLeftCell: "A1",
|
|
|
+ ActivePane: "topRight",
|
|
|
+ })
|
|
|
+
|
|
|
+ // 过滤器
|
|
|
+ f.AutoFilter("Sheet1", "A4:G4", nil)
|
|
|
+
|
|
|
+ // 循环写入数据
|
|
|
+ line := 5
|
|
|
+ for i, percentage := range percentageList {
|
|
|
+
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), percentage.T_verifyCompany.T_name)
|
|
|
+
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), percentage.T_device_type+percentage.T_verify_type)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), percentage.T_task_name)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), percentage.T_uuid_name)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), percentage.T_reporting_pass_time[:10])
|
|
|
+
|
|
|
+ verifyItem := Basic.Read_VerifyItem_Get(percentage.T_verify_item)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("%s%d", verifyItem.T_cell, line), verifyItem.T_price)
|
|
|
+ var verifyType string
|
|
|
+ if percentage.T_type == Percentage.SchemeType {
|
|
|
+ verifyType = "验证实施"
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("S%d", line), verifyItem.T_price)
|
|
|
+
|
|
|
+ } else if percentage.T_type == Percentage.ReportingType {
|
|
|
+ verifyType = "报告编写"
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("AC%d", line), verifyItem.T_price)
|
|
|
+
|
|
|
+ }
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), verifyType)
|
|
|
+ line++
|
|
|
+ }
|
|
|
+ // 函数统计
|
|
|
+ //f.SetCellFormula("Sheet1", fmt.Sprintf("S%d", line), fmt.Sprintf("SUM(S5:S%d)", line-1))
|
|
|
+ //f.SetCellFormula("Sheet1", fmt.Sprintf("AC%d", line), fmt.Sprintf("SUM(AC5:AC%d)", line-1))
|
|
|
+
|
|
|
+ Style4, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Size: 11, 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},
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ // 黄色填充
|
|
|
+ StyleYellowFill, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#FFFF00"}, Pattern: 1},
|
|
|
+ })
|
|
|
+ // 黄色填充
|
|
|
+ StyleYellowFill1, _ := 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#FFFF00"}, Pattern: 1},
|
|
|
+ })
|
|
|
+ // 绿色填充
|
|
|
+ StyleGreenFill, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#92D050"}, Pattern: 1},
|
|
|
+ })
|
|
|
+ StyleGreenFill1, _ := 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#92D050"}, Pattern: 1},
|
|
|
+ })
|
|
|
+
|
|
|
+ f.SetCellStyle("Sheet1", "A5", fmt.Sprintf("AC%d", line-1), Style4)
|
|
|
+
|
|
|
+ f.SetCellStyle("Sheet1", "H2", "S4", StyleYellowFill)
|
|
|
+ f.SetCellStyle("Sheet1", "S5", fmt.Sprintf("S%d", line-1), StyleYellowFill1)
|
|
|
+ f.SetCellStyle("Sheet1", "T2", "AC4", StyleGreenFill)
|
|
|
+ f.SetCellStyle("Sheet1", "AC5", fmt.Sprintf("AC%d", line-1), StyleGreenFill1)
|
|
|
+ filename := fmt.Sprintf("%s提成统计表(%s)", dataInterval, lib.GetRandstring(6, "0123456789", 0))
|
|
|
+ // 保存文件
|
|
|
+ if err := f.SaveAs("ofile/" + filename + ".xlsx"); err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传 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
|
|
|
}
|
|
|
- contract, err := ContractDao.Read_Contract_ByT_number(percentage.T_number)
|
|
|
+ //删除目录
|
|
|
+ err := os.Remove("ofile/" + filename + ".xlsx")
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同不存在!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
+ logs.Error(lib.FuncName(), err)
|
|
|
}
|
|
|
- productList := contractProductDao.Read_ContractProduct_List(contract.T_number)
|
|
|
|
|
|
- var pList []Contract.ContractProduct_R
|
|
|
- for _, v := range productList {
|
|
|
- p := Contract.ContractProductToContractProduct_R(v)
|
|
|
- p.T_device_list, _ = DeviceDao.Read_DeviceSn_List(contract.T_number, v.T_product_id, "", "")
|
|
|
- pList = append(pList, p)
|
|
|
- }
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
+func (c *PercentageController) Percentage_User_Export() {
|
|
|
|
|
|
+ // 查询
|
|
|
+ T_name := c.GetString("T_name") // 关键字
|
|
|
+ T_start_date := c.GetString("T_start_date") // 开始时间
|
|
|
+ T_end_date := c.GetString("T_end_date") // 结束时间
|
|
|
+ T_state, _ := c.GetInt("T_state")
|
|
|
+ T_type, _ := c.GetInt("T_type") // 提成类型
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
|
Account.Read_User_All_Map(userList)
|
|
|
- Contract.Read_VerifyContract_All_Map()
|
|
|
+ Percentage.Read_VerifyCompany_All_Map()
|
|
|
Basic.Read_VerifyItem_All_Map()
|
|
|
+ PercentageDao := Percentage.NewPercentage(orm.NewOrm())
|
|
|
+ percentageList, _ := PercentageDao.Read_Percentage_List_For_Excel(T_name, c.User.T_uuid, T_start_date, T_end_date, []string{}, T_state, T_type)
|
|
|
+ dataInterval := fmt.Sprintf("%s - %s", T_start_date, T_end_date)
|
|
|
+ if dataInterval == " - " {
|
|
|
+ dataInterval = ""
|
|
|
+ }
|
|
|
+ f := excelize.NewFile() // 设置单元格的值
|
|
|
+ Style1, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 20, Family: "宋体"},
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
+ })
|
|
|
+
|
|
|
+ Style2, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
+ 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", "AC1")
|
|
|
+ f.SetRowStyle("Sheet1", 1, 1, Style1)
|
|
|
+ f.SetRowHeight("Sheet1", 1, 50)
|
|
|
+ f.SetCellValue("Sheet1", "A1", fmt.Sprintf("%s提成统计表", dataInterval))
|
|
|
+
|
|
|
+ //Style3, _ := 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.SetCellStyle("Sheet1", "A2", "G4", Style2)
|
|
|
+ f.SetRowHeight("Sheet1", 2, 20)
|
|
|
+ f.SetRowHeight("Sheet1", 4, 20)
|
|
|
+
|
|
|
+ // 这里设置表头
|
|
|
+ f.MergeCell("Sheet1", "A2", "A4")
|
|
|
+ f.MergeCell("Sheet1", "B2", "B4")
|
|
|
+ f.MergeCell("Sheet1", "C2", "C4")
|
|
|
+ f.MergeCell("Sheet1", "D2", "D4")
|
|
|
+ f.MergeCell("Sheet1", "E2", "E4")
|
|
|
+ f.MergeCell("Sheet1", "F2", "F4")
|
|
|
+ f.MergeCell("Sheet1", "G2", "G4")
|
|
|
+
|
|
|
+ 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.MergeCell("Sheet1", "H2", "S2")
|
|
|
+ f.SetCellValue("Sheet1", "H2", "验证实施")
|
|
|
+
|
|
|
+ f.MergeCell("Sheet1", "T2", "AC2")
|
|
|
+ f.SetCellValue("Sheet1", "T2", "报告编写")
|
|
|
+
|
|
|
+ verifyItemList, _ := Basic.Read_VerifyItem_List(0, "", 0, 9999)
|
|
|
+ for _, item := range verifyItemList {
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("%s3", item.T_cell), item.T_name)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("%s4", item.T_cell), item.T_price)
|
|
|
+ }
|
|
|
+
|
|
|
+ f.MergeCell("Sheet1", "S3", "S4")
|
|
|
+ f.SetCellValue("Sheet1", "S3", "合计")
|
|
|
+
|
|
|
+ f.MergeCell("Sheet1", "AC3", "AC4")
|
|
|
+ f.SetCellValue("Sheet1", "AC3", "合计")
|
|
|
+ // 设置列宽
|
|
|
+ f.SetColWidth("Sheet1", "A", "A", 5)
|
|
|
+ f.SetColWidth("Sheet1", "B", "G", 16)
|
|
|
+ f.SetColWidth("Sheet1", "E", "G", 10)
|
|
|
+ f.SetColWidth("Sheet1", "H", "AC", 10)
|
|
|
+
|
|
|
+ // 冻结1-3行
|
|
|
+ f.SetPanes("Sheet1", &excelize.Panes{
|
|
|
+ Freeze: true,
|
|
|
+ Split: false,
|
|
|
+ XSplit: 2,
|
|
|
+ YSplit: 4,
|
|
|
+ TopLeftCell: "A1",
|
|
|
+ ActivePane: "topRight",
|
|
|
+ })
|
|
|
+
|
|
|
+ // 过滤器
|
|
|
+ f.AutoFilter("Sheet1", "A4:G4", nil)
|
|
|
+
|
|
|
+ // 循环写入数据
|
|
|
+ line := 5
|
|
|
+ for i, percentage := range percentageList {
|
|
|
+
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), percentage.T_verifyCompany.T_name)
|
|
|
+
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), percentage.T_device_type+percentage.T_verify_type)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), percentage.T_task_name)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), percentage.T_uuid_name)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), percentage.T_reporting_pass_time[:10])
|
|
|
+
|
|
|
+ verifyItem := Basic.Read_VerifyItem_Get(percentage.T_verify_item)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("%s%d", verifyItem.T_cell, line), verifyItem.T_price)
|
|
|
+ var verifyType string
|
|
|
+ if percentage.T_type == Percentage.SchemeType {
|
|
|
+ verifyType = "验证实施"
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("S%d", line), verifyItem.T_price)
|
|
|
+
|
|
|
+ } else if percentage.T_type == Percentage.ReportingType {
|
|
|
+ verifyType = "报告编写"
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("AC%d", line), verifyItem.T_price)
|
|
|
+
|
|
|
+ }
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), verifyType)
|
|
|
+ line++
|
|
|
+ }
|
|
|
+ // 函数统计
|
|
|
+ //f.SetCellFormula("Sheet1", fmt.Sprintf("S%d", line), fmt.Sprintf("SUM(S5:S%d)", line-1))
|
|
|
+ //f.SetCellFormula("Sheet1", fmt.Sprintf("AC%d", line), fmt.Sprintf("SUM(AC5:AC%d)", line-1))
|
|
|
+
|
|
|
+ Style4, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Size: 11, 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},
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ // 黄色填充
|
|
|
+ StyleYellowFill, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#FFFF00"}, Pattern: 1},
|
|
|
+ })
|
|
|
+ // 黄色填充
|
|
|
+ StyleYellowFill1, _ := 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#FFFF00"}, Pattern: 1},
|
|
|
+ })
|
|
|
+ // 绿色填充
|
|
|
+ StyleGreenFill, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#92D050"}, Pattern: 1},
|
|
|
+ })
|
|
|
+ StyleGreenFill1, _ := 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},
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{Type: "pattern", Color: []string{"#92D050"}, Pattern: 1},
|
|
|
+ })
|
|
|
+
|
|
|
+ f.SetCellStyle("Sheet1", "A5", fmt.Sprintf("AC%d", line-1), Style4)
|
|
|
+
|
|
|
+ f.SetCellStyle("Sheet1", "H2", "S4", StyleYellowFill)
|
|
|
+ f.SetCellStyle("Sheet1", "S5", fmt.Sprintf("S%d", line-1), StyleYellowFill1)
|
|
|
+ f.SetCellStyle("Sheet1", "T2", "AC4", StyleGreenFill)
|
|
|
+ f.SetCellStyle("Sheet1", "AC5", fmt.Sprintf("AC%d", line-1), StyleGreenFill1)
|
|
|
+ filename := fmt.Sprintf("%s提成统计表(%s)", dataInterval, lib.GetRandstring(6, "0123456789", 0))
|
|
|
+ // 保存文件
|
|
|
+ if err := f.SaveAs("ofile/" + filename + ".xlsx"); err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传 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: Percentage.PercentageToPercentage_Detail(percentage, contract, pList)}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func (c *PercentageController) Percentage_Add() {
|
|
|
-
|
|
|
- T_number := c.GetString("T_number")
|
|
|
- T_uuid := c.GetString("T_uuid")
|
|
|
- T_money, _ := c.GetFloat("T_money") // 总价
|
|
|
- T_type, _ := c.GetInt("T_type") // 类型
|
|
|
- T_item := c.GetString("T_item")
|
|
|
+func (c *PercentageController) Percentage_Get() {
|
|
|
|
|
|
- if len(T_item) == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "提成明细不能为空"}
|
|
|
+ // 查询
|
|
|
+ T_id, _ := c.GetInt("T_id")
|
|
|
+ o := orm.NewOrm()
|
|
|
+ PercentageDao := Percentage.NewPercentage(o)
|
|
|
+ percentage, err := PercentageDao.Read_Percentage_ById(T_id)
|
|
|
+ if err != nil {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
+ Percentage.Read_VerifyCompany_All_Map()
|
|
|
|
|
|
- var_ := Percentage.Percentage{
|
|
|
- T_number: T_number,
|
|
|
- T_uuid: T_uuid,
|
|
|
- T_money: float32(T_money),
|
|
|
- T_type: T_type, //类型 1-验证实施 2-报告编写
|
|
|
- T_State: 6, // 6-未提交审核
|
|
|
- T_submit: c.User.T_uuid,
|
|
|
- T_item: T_item,
|
|
|
- }
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Percentage.PercentageToPercentage_Detail(percentage)}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
|
|
|
- o := orm.NewOrm()
|
|
|
- ContractDao := Contract.NewContract(o)
|
|
|
- _, err := ContractDao.Read_Contract_ByT_number(T_number)
|
|
|
- if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同不存在!"}
|
|
|
+func (c *PercentageController) Percentage_Add() {
|
|
|
+
|
|
|
+ T_device_type := c.GetString("T_device_type") // 提成类型
|
|
|
+ T_verify_type := c.GetString("T_verify_type") // 验证类型
|
|
|
+ T_company_uuid := c.GetString("T_company_uuid") // 公司id
|
|
|
+ T_type, _ := c.GetInt("T_type") // 类型 1-验证实施 2-报告编写
|
|
|
+
|
|
|
+ company, is := Percentage.Read_VerifyCompany(T_company_uuid)
|
|
|
+ if !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询公司信息失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- Basic.Read_VerifyItem_All_Map()
|
|
|
|
|
|
- o.Begin()
|
|
|
- PercentageDao := Percentage.NewPercentage(o)
|
|
|
-
|
|
|
- var T_type_str string
|
|
|
- if T_type == 1 {
|
|
|
- T_type_str = "验证实施"
|
|
|
+ var verifyItemMap map[string]Basic.VerifyItem
|
|
|
+ verifyItemSchemeMap, verifyItemReportingMap := GetVerifyItemMap()
|
|
|
+ if T_type == Percentage.SchemeType {
|
|
|
+ verifyItemMap = verifyItemSchemeMap
|
|
|
}
|
|
|
- if T_type == 2 {
|
|
|
- T_type_str = "报告编写"
|
|
|
+ if T_type == Percentage.ReportingType {
|
|
|
+ verifyItemMap = verifyItemReportingMap
|
|
|
}
|
|
|
- _, err = PercentageDao.Read_Percentage_ByT_number_T_type(T_number, T_type)
|
|
|
- if err == nil {
|
|
|
- o.Rollback()
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("该合同已提交过%s提成申请", T_type_str)}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
+
|
|
|
+ var_ := Percentage.Percentage{
|
|
|
+ T_Distributor_id: company.T_Distributor_id,
|
|
|
+ T_device_type: T_device_type,
|
|
|
+ T_verify_type: T_verify_type,
|
|
|
+ T_uuid: c.User.T_uuid,
|
|
|
+ T_company_uuid: T_company_uuid,
|
|
|
+ T_money: verifyItemMap[T_device_type].T_price,
|
|
|
+ T_type: T_type, //类型 1-验证实施 2-报告编写
|
|
|
+ T_State: 6, // 6-未提交审核
|
|
|
+ T_verify_item: verifyItemMap[T_device_type].Id,
|
|
|
}
|
|
|
- var_.T_item_price = Percentage.Generate_VerifyItem_Price(var_.T_item)
|
|
|
- var_.T_item = "|" + var_.T_item
|
|
|
|
|
|
- _, err = PercentageDao.Add_Percentage(var_)
|
|
|
+ o := orm.NewOrm()
|
|
|
+
|
|
|
+ PercentageDao := Percentage.NewPercentage(o)
|
|
|
+
|
|
|
+ id, err := PercentageDao.Add_Percentage(var_)
|
|
|
if err != nil {
|
|
|
- o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- o.Commit()
|
|
|
-
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "添加", var_)
|
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -211,7 +668,6 @@ func (c *PercentageController) Percentage_Add() {
|
|
|
func (c *PercentageController) Percentage_Approval() {
|
|
|
|
|
|
T_id, _ := c.GetInt("T_id")
|
|
|
- T_item := c.GetString("T_item")
|
|
|
T_state, _ := c.GetInt("T_state")
|
|
|
T_approval_money, _ := c.GetFloat("T_approval_money")
|
|
|
T_approval_opinion := c.GetString("T_approval_opinion")
|
|
@@ -247,12 +703,8 @@ func (c *PercentageController) Percentage_Approval() {
|
|
|
if T_state == 2 || T_state == 3 {
|
|
|
percentage.T_State = T_state
|
|
|
}
|
|
|
- if len(T_item) > 0 {
|
|
|
- percentage.T_item = T_item
|
|
|
- percentage.T_item_price = Percentage.Generate_VerifyItem_Price(percentage.T_item)
|
|
|
- }
|
|
|
|
|
|
- err = PercentageDao.Update_Percentage(percentage, "T_State", "T_approval_opinion", "T_approval_money", "T_item", "T_item_price")
|
|
|
+ err = PercentageDao.Update_Percentage(percentage, "T_State", "T_approval_opinion", "T_approval_money")
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
@@ -260,10 +712,10 @@ func (c *PercentageController) Percentage_Approval() {
|
|
|
return
|
|
|
}
|
|
|
if T_state == Percentage.AuditPass {
|
|
|
- NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)审核已通过", percentage.T_number), conf.MyPercentageUrl)
|
|
|
+ NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)审核已通过", percentage.T_task_id), conf.MyPercentageUrl)
|
|
|
}
|
|
|
if T_state == Percentage.AuditUnPass {
|
|
|
- NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)审核未通过", percentage.T_number), conf.MyPercentageUrl)
|
|
|
+ NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)审核未通过", percentage.T_task_id), conf.MyPercentageUrl)
|
|
|
}
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "审核", percentage)
|
|
|
|
|
@@ -274,36 +726,29 @@ func (c *PercentageController) Percentage_Approval() {
|
|
|
|
|
|
func (c *PercentageController) Percentage_Edit() {
|
|
|
T_id, _ := c.GetInt("T_id")
|
|
|
- T_number := c.GetString("T_number")
|
|
|
- T_uuid := c.GetString("T_uuid")
|
|
|
- T_money, _ := c.GetFloat("T_money") // 总价
|
|
|
- T_type, _ := c.GetInt("T_type") // 优惠价
|
|
|
- T_item := c.GetString("T_item")
|
|
|
-
|
|
|
- if len(T_item) == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "提成明细不能为空"}
|
|
|
+ T_device_type := c.GetString("T_device_type") // 提成类型
|
|
|
+ T_verify_type := c.GetString("T_verify_type") // 验证类型
|
|
|
+ T_company_uuid := c.GetString("T_company_uuid") // 公司id
|
|
|
+ T_type, _ := c.GetInt("T_type") // 类型 1-验证实施 2-报告编写
|
|
|
+
|
|
|
+ company, is := Percentage.Read_VerifyCompany(T_company_uuid)
|
|
|
+ if !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询公司信息失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- var T_type_str string
|
|
|
- if T_type == 1 {
|
|
|
- T_type_str = "验证实施"
|
|
|
+ var verifyItemMap map[string]Basic.VerifyItem
|
|
|
+ verifyItemSchemeMap, verifyItemReportingMap := GetVerifyItemMap()
|
|
|
+ if T_type == Percentage.SchemeType {
|
|
|
+ verifyItemMap = verifyItemSchemeMap
|
|
|
}
|
|
|
- if T_type == 2 {
|
|
|
- T_type_str = "报告编写"
|
|
|
+ if T_type == Percentage.ReportingType {
|
|
|
+ verifyItemMap = verifyItemReportingMap
|
|
|
}
|
|
|
|
|
|
o := orm.NewOrm()
|
|
|
- ContractDao := Contract.NewContract(o)
|
|
|
- _, err := ContractDao.Read_Contract_ByT_number(T_number)
|
|
|
- if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同不存在!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
|
-
|
|
|
percentage, err := PercentageDao.Read_Percentage_ById(T_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
@@ -311,18 +756,6 @@ func (c *PercentageController) Percentage_Edit() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- percentage1, err := PercentageDao.Read_Percentage_ByT_number_T_type(T_number, T_type)
|
|
|
- if err != nil && err.Error() != orm.ErrNoRows.Error() {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- if percentage1.Id > 0 && percentage1.Id != percentage.Id {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("该合同已提交过%s提成申请", T_type_str)}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
// 1-待审核 2-审核通过 3-审核不通过 4-部分打款 5-全部打款 6-未提交审核 合同状态为未通过,修改之后将状态更改为待审核
|
|
|
if percentage.T_State == Percentage.AuditPass || percentage.T_State == Percentage.RemitPart || percentage.T_State == Percentage.RemitAll {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("状态为%s,禁止修改!", Percentage.Read_Audit_Get(percentage.T_State))}
|
|
@@ -330,24 +763,25 @@ func (c *PercentageController) Percentage_Edit() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if len(T_number) > 0 {
|
|
|
- percentage.T_number = T_number
|
|
|
+ if len(T_company_uuid) > 0 {
|
|
|
+ percentage.T_company_uuid = T_company_uuid
|
|
|
+ percentage.T_Distributor_id = company.T_Distributor_id
|
|
|
}
|
|
|
- if len(T_uuid) > 0 {
|
|
|
- percentage.T_uuid = T_uuid
|
|
|
+ if len(T_device_type) > 0 {
|
|
|
+ percentage.T_device_type = T_device_type
|
|
|
}
|
|
|
- if T_money > 0 {
|
|
|
- percentage.T_money = float32(T_money)
|
|
|
+ if len(T_verify_type) > 0 {
|
|
|
+ percentage.T_verify_type = T_verify_type
|
|
|
}
|
|
|
+
|
|
|
if T_type > 0 {
|
|
|
percentage.T_type = T_type
|
|
|
}
|
|
|
- if len(T_item) > 0 {
|
|
|
- percentage.T_item = "|" + T_item
|
|
|
- percentage.T_item_price = Percentage.Generate_VerifyItem_Price(T_item)
|
|
|
- }
|
|
|
|
|
|
- err = PercentageDao.Update_Percentage(percentage, "T_number", "T_uuid", "T_money", "T_type", "T_item", "T_item_price")
|
|
|
+ percentage.T_money = verifyItemMap[percentage.T_device_type].T_price
|
|
|
+ percentage.T_verify_item = verifyItemMap[percentage.T_device_type].Id
|
|
|
+
|
|
|
+ err = PercentageDao.Update_Percentage(percentage, "T_company_uuid", "T_Distributor_id", "T_device_type", "T_verify_type", "T_type", "T_money", "T_verify_item")
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
|
c.ServeJSON()
|
|
@@ -424,7 +858,7 @@ func (c *PercentageController) Percentage_Admin_Del() {
|
|
|
// 打款
|
|
|
func (c *PercentageController) Percentage_Remit() {
|
|
|
T_id, _ := c.GetInt("T_id")
|
|
|
- T_remit := c.GetString("T_remit")
|
|
|
+ //T_remit := c.GetString("T_remit")
|
|
|
|
|
|
o := orm.NewOrm()
|
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
@@ -437,44 +871,45 @@ func (c *PercentageController) Percentage_Remit() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 1-待审核 2-审核通过 3-审核不通过 4-部分打款 5-全部打款 合同状态为未通过,修改之后将状态更改为待审核
|
|
|
+ // 1-待审核 2-审核通过 3-审核不通过 5-已打款 合同状态为未通过,修改之后将状态更改为待审核
|
|
|
if percentage.T_State == 1 || percentage.T_State == 3 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "当前状态不可添加打款信息!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "当前状态不可提交打款!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if len(T_remit) == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "打款明细不能为空"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
+ //if len(T_remit) == 0 {
|
|
|
+ // c.Data["json"] = lib.JSONS{Code: 202, Msg: "打款明细不能为空"}
|
|
|
+ // c.ServeJSON()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+
|
|
|
+ //if len(T_remit) > 0 {
|
|
|
+ // percentage.T_remit = T_remit
|
|
|
+ //}
|
|
|
+ //_, money := Percentage.PercentageToPercentageRemit_R(T_remit)
|
|
|
+ //// 部分打款
|
|
|
+ //if percentage.T_approval_money > money && money > 0 {
|
|
|
+ // percentage.T_State = 4
|
|
|
+ //}
|
|
|
+ //// 全部打款
|
|
|
+ //if percentage.T_approval_money == money && money > 0 {
|
|
|
+ // percentage.T_State = 5
|
|
|
+ //}
|
|
|
+ percentage.T_State = 5
|
|
|
|
|
|
- if len(T_remit) > 0 {
|
|
|
- percentage.T_remit = T_remit
|
|
|
- }
|
|
|
- _, money := Percentage.PercentageToPercentageRemit_R(T_remit)
|
|
|
- // 部分打款
|
|
|
- if percentage.T_approval_money > money && money > 0 {
|
|
|
- percentage.T_State = 4
|
|
|
- }
|
|
|
- // 全部打款
|
|
|
- if percentage.T_approval_money == money && money > 0 {
|
|
|
- percentage.T_State = 5
|
|
|
- }
|
|
|
-
|
|
|
- err = PercentageDao.Update_Percentage(percentage, "T_remit", "T_State")
|
|
|
+ err = PercentageDao.Update_Percentage(percentage, "T_State")
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if percentage.T_State == 4 {
|
|
|
- NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)已部分打款", percentage.T_number), conf.MyPercentageUrl)
|
|
|
- }
|
|
|
+ //if percentage.T_State == 4 {
|
|
|
+ // NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)已部分打款", percentage.T_task_id), conf.MyPercentageUrl)
|
|
|
+ //}
|
|
|
if percentage.T_State == 5 {
|
|
|
- NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)已全部打款", percentage.T_number), conf.MyPercentageUrl)
|
|
|
+ NatsServer.AddNews(percentage.T_uuid, fmt.Sprintf("【提成申请】您提交的提成申请(%s)已打款", percentage.T_task_id), conf.MyPercentageUrl)
|
|
|
}
|
|
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "修改", percentage)
|
|
@@ -585,10 +1020,344 @@ func (c *PercentageController) Percentage_Submit_Audit() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- NatsServer.AddNews(conf.FinanceUuid, fmt.Sprintf("【提成申请】您有一条提成申请(%s)待审核", percentage.T_number), conf.PercentageApprovalUrl)
|
|
|
+ NatsServer.AddNews(conf.FinanceUuid, fmt.Sprintf("【提成申请】您有一条提成申请(%s)待审核", percentage.T_task_id), conf.PercentageApprovalUrl)
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "审核", percentage)
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
+func (c *PercentageController) Percentage_SyncVerify() {
|
|
|
+
|
|
|
+ SyncVerifyPercentage(false)
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func Cron_Percentage() {
|
|
|
+
|
|
|
+ //创建一个定时任务对象
|
|
|
+ c := cron.New(cron.WithSeconds())
|
|
|
+ //给对象增加定时任务
|
|
|
+ //c.AddFunc("0 */1 * * * ?", Cron_SyncColdVerifyCompany)
|
|
|
+ c.AddFunc("@daily", Cron_SyncColdVerifyCompany)
|
|
|
+ //c.AddFunc("0 */1 * * * ?", Cron_SyncVerifyPercentage)
|
|
|
+ c.AddFunc("@daily", Cron_SyncVerifyPercentage)
|
|
|
+
|
|
|
+ //启动定时任务
|
|
|
+ c.Start()
|
|
|
+ defer c.Stop()
|
|
|
+
|
|
|
+ //查询语句,阻塞,让main函数不退出,保持程序运行
|
|
|
+ select {}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func Cron_SyncColdVerifyCompany() {
|
|
|
+ url := "/openapi/company/list"
|
|
|
+ signature, timestamp := lib.GenColdVerifySignature()
|
|
|
+ client := resty.New()
|
|
|
+ resp, err := client.R().SetFormData(map[string]string{
|
|
|
+ "CreateDate": "",
|
|
|
+ "X-API-KEY": lib.ColdVerify_OpenApi_Key,
|
|
|
+ "X-API-SIGNATURE": signature,
|
|
|
+ "X-API-TIMESTAMP": timestamp,
|
|
|
+ }).Post(conf.ColdVerify_OpenApi_Host + url)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("请求冷链验证公司列表接口失败!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ type R_JSONS struct {
|
|
|
+ //必须的大写开头
|
|
|
+ Data []Percentage.VerifyCompany
|
|
|
+ Code int64
|
|
|
+ Msg string
|
|
|
+ }
|
|
|
+ var res R_JSONS
|
|
|
+ if err = json.Unmarshal(resp.Body(), &res); err != nil {
|
|
|
+ logs.Error("请求冷链验证公司列表接口失败!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, company := range res.Data {
|
|
|
+ c, is := Percentage.Read_VerifyCompany(company.T_uuid)
|
|
|
+ if is {
|
|
|
+ if c.T_name != company.T_name || c.T_Distributor_name != company.T_Distributor_name {
|
|
|
+ c.T_name = company.T_name
|
|
|
+ c.T_Distributor_name = company.T_Distributor_name
|
|
|
+ Percentage.Update_VerifyCompany(c, "T_name", "T_Distributor_name")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Percentage.Add_VerifyCompany(company)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// 读取冷链验证任务,同步到提成
|
|
|
+// 定时统计前一天审核通过的任务
|
|
|
+func Cron_SyncVerifyPercentage() {
|
|
|
+ SyncVerifyPercentage(true)
|
|
|
+}
|
|
|
+
|
|
|
+func SyncVerifyPercentage(isCron bool) {
|
|
|
+ url := "/openapi/task/list"
|
|
|
+ signature, timestamp := lib.GenColdVerifySignature()
|
|
|
+ client := resty.New()
|
|
|
+ var createDate string
|
|
|
+ if isCron {
|
|
|
+ createDate = time.Now().Add(-time.Hour * 24).Format("2006-01-02")
|
|
|
+ }
|
|
|
+ client.SetTimeout(30 * time.Second)
|
|
|
+ client.SetRetryCount(3).SetRetryWaitTime(1 * time.Second)
|
|
|
+ resp, err := client.R().SetFormData(map[string]string{
|
|
|
+ "CreateDate": createDate,
|
|
|
+ "X-API-KEY": lib.ColdVerify_OpenApi_Key,
|
|
|
+ "X-API-SIGNATURE": signature,
|
|
|
+ "X-API-TIMESTAMP": timestamp,
|
|
|
+ }).Post(conf.ColdVerify_OpenApi_Host + url)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("请求冷链验证任务列表接口失败!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ type R_JSONS struct {
|
|
|
+ //必须的大写开头
|
|
|
+ Data []Percentage.VerifyTask
|
|
|
+ Code int64
|
|
|
+ Msg string
|
|
|
+ }
|
|
|
+ var res R_JSONS
|
|
|
+ if err = json.Unmarshal(resp.Body(), &res); err != nil {
|
|
|
+ logs.Error("请求冷链验证任务列表接口失败!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ verifyItemSchemeMap, verifyItemReportingMap := GetVerifyItemMap()
|
|
|
+ coldVerifyUUIDMap := GetColdVerifyUUIDMap()
|
|
|
+
|
|
|
+ PercentageDao := Percentage.NewPercentage(orm.NewOrm())
|
|
|
+ for _, task := range res.Data {
|
|
|
+ // 自动同步报告提成
|
|
|
+ _, err = PercentageDao.Read_Percentage_ByT_T_task_id_T_type(task.T_task_id, Percentage.ReportingType)
|
|
|
+ if err != nil && err.Error() == orm.ErrNoRows.Error() {
|
|
|
+ verifyItem := GetPercentageMoney(task.T_device_type, task.T_verify_type, verifyItemReportingMap)
|
|
|
+ // 添加报告提成
|
|
|
+ percentage := Percentage.Percentage{
|
|
|
+ T_Distributor_id: task.T_Distributor_id,
|
|
|
+ T_task_id: task.T_task_id,
|
|
|
+ T_task_int_id: task.Id,
|
|
|
+ T_device_type: task.T_device_type,
|
|
|
+ T_verify_type: task.T_verify_type,
|
|
|
+ T_company_uuid: task.T_uuid,
|
|
|
+ T_task_name: task.T_name,
|
|
|
+ T_uuid: coldVerifyUUIDMap[task.T_reporting],
|
|
|
+ T_money: verifyItem.T_price,
|
|
|
+ T_type: Percentage.ReportingType,
|
|
|
+ T_State: 1,
|
|
|
+ T_verify_item: verifyItem.Id,
|
|
|
+ T_reporting_pass_time: task.T_reporting_pass_time,
|
|
|
+ }
|
|
|
+ _, err = PercentageDao.Add_Percentage(percentage)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 由经销商id的任务 只有报告,不需要同步实施提成
|
|
|
+ if len(task.T_Distributor_id) > 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自动同步实施提成
|
|
|
+ _, err = PercentageDao.Read_Percentage_ByT_T_task_id_T_type(task.T_task_id, Percentage.SchemeType)
|
|
|
+ if err != nil && err.Error() == orm.ErrNoRows.Error() {
|
|
|
+ verifyItem := GetPercentageMoney(task.T_device_type, task.T_verify_type, verifyItemSchemeMap)
|
|
|
+ // 添加报告提成
|
|
|
+ percentage := Percentage.Percentage{
|
|
|
+ T_Distributor_id: task.T_Distributor_id,
|
|
|
+ T_task_id: task.T_task_id,
|
|
|
+ T_task_int_id: task.Id,
|
|
|
+ T_device_type: task.T_device_type,
|
|
|
+ T_verify_type: task.T_verify_type,
|
|
|
+ T_company_uuid: task.T_uuid,
|
|
|
+ T_task_name: task.T_name,
|
|
|
+ T_uuid: coldVerifyUUIDMap[task.T_scheme],
|
|
|
+ T_money: verifyItem.T_price,
|
|
|
+ T_type: Percentage.SchemeType,
|
|
|
+ T_State: 1,
|
|
|
+ T_verify_item: verifyItem.Id,
|
|
|
+ T_reporting_pass_time: task.T_reporting_pass_time,
|
|
|
+ }
|
|
|
+ _, err = PercentageDao.Add_Percentage(percentage)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetVerifyItemMap() (map[string]Basic.VerifyItem, map[string]Basic.VerifyItem) {
|
|
|
+ verifyItemList, _ := Basic.Read_VerifyItem_List(0, "", 0, 999)
|
|
|
+ var verifyItemSchemeMap = make(map[string]Basic.VerifyItem) // 实施
|
|
|
+ var verifyItemReportingMap = make(map[string]Basic.VerifyItem) // 实施
|
|
|
+ for _, item := range verifyItemList {
|
|
|
+ if item.T_type == Percentage.SchemeType {
|
|
|
+ verifyItemSchemeMap[item.T_name] = item
|
|
|
+ }
|
|
|
+ if item.T_type == Percentage.ReportingType {
|
|
|
+ verifyItemReportingMap[item.T_name] = item
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return verifyItemSchemeMap, verifyItemReportingMap
|
|
|
+}
|
|
|
+
|
|
|
+func GetColdVerifyUUIDMap() (uuidMap map[string]string) {
|
|
|
+ uuidMap = make(map[string]string)
|
|
|
+ userList, _ := NatsServer.Read_User_List_All()
|
|
|
+ for _, user := range userList {
|
|
|
+ uuidMap[user.T_verify_cold_uuid] = user.T_uuid
|
|
|
+ }
|
|
|
+ return uuidMap
|
|
|
+}
|
|
|
+
|
|
|
+// 获取实施提成金额
|
|
|
+func GetPercentageMoney(T_device_type, T_verify_type string, verifyItemMap map[string]Basic.VerifyItem) (money Basic.VerifyItem) {
|
|
|
+ if strings.Contains(T_device_type, "箱") {
|
|
|
+ return verifyItemMap["保温箱"]
|
|
|
+ }
|
|
|
+ if strings.Contains(T_device_type, "车") {
|
|
|
+ if strings.Contains(T_verify_type, "空载") {
|
|
|
+ return verifyItemMap["冷藏车(空载)"]
|
|
|
+ } else {
|
|
|
+ return verifyItemMap["冷藏车(满载)"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(T_device_type, "柜") {
|
|
|
+ if strings.Contains(T_verify_type, "空载") {
|
|
|
+ return verifyItemMap["冷库(空载)"]
|
|
|
+ } else {
|
|
|
+ return verifyItemMap["冷库(满载)"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(T_device_type, "库") {
|
|
|
+ if strings.Contains(T_verify_type, "空载") {
|
|
|
+ return verifyItemMap["冷库(空载)"]
|
|
|
+ } else {
|
|
|
+ return verifyItemMap["冷库(满载)"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(T_device_type, "系统验证") {
|
|
|
+ return verifyItemMap["系统验证"]
|
|
|
+ }
|
|
|
+ if strings.Contains(T_device_type, "位置") {
|
|
|
+ return verifyItemMap["位置"]
|
|
|
+ }
|
|
|
+ return Basic.VerifyItem{}
|
|
|
+}
|
|
|
+
|
|
|
+func (c *PercentageController) VerifyCompany_List() {
|
|
|
+
|
|
|
+ // 分页参数 初始化
|
|
|
+ page, _ := c.GetInt("page")
|
|
|
+ if page < 1 {
|
|
|
+ page = 1
|
|
|
+ }
|
|
|
+ page_z, _ := c.GetInt("page_z")
|
|
|
+ if page_z < 1 {
|
|
|
+ page_z = conf.Page_size
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询
|
|
|
+ T_name := c.GetString("T_name")
|
|
|
+ T_state, _ := c.GetInt("T_state")
|
|
|
+
|
|
|
+ R_List, R_cnt := Percentage.Read_VerifyCompany_List(T_name, T_state, page, page_z)
|
|
|
+
|
|
|
+ var r_jsons lib.R_JSONS
|
|
|
+ r_jsons.Num = R_cnt
|
|
|
+ r_jsons.Data = R_List
|
|
|
+ r_jsons.Page = page
|
|
|
+ r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (c *PercentageController) VerifyCompany_Add() {
|
|
|
+
|
|
|
+ T_name := c.GetString("T_name")
|
|
|
+ T_State, _ := c.GetInt("T_State") // 总价
|
|
|
+
|
|
|
+ var_ := Percentage.VerifyCompany{
|
|
|
+ T_name: T_name,
|
|
|
+ T_State: T_State,
|
|
|
+ }
|
|
|
+
|
|
|
+ if _, is := Percentage.Read_VerifyCompanyByT_name(T_name); is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "公司名称重复!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ Id, is := Percentage.Add_VerifyCompany(var_)
|
|
|
+ if !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "验证公司", "添加", var_)
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
+func (c *PercentageController) VerifyCompany_Edit() {
|
|
|
+
|
|
|
+ T_uuid := c.GetString("T_uuid")
|
|
|
+ T_State, _ := c.GetInt("T_State") // 总价
|
|
|
+
|
|
|
+ company, is := Percentage.Read_VerifyCompany(T_uuid)
|
|
|
+ if !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询验证公司失败"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if T_State > 0 {
|
|
|
+ company.T_State = T_State
|
|
|
+ if !Percentage.Update_VerifyCompany(company, "T_State") {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改验证公司失败"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "验证公司", "修改", company)
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: company.T_uuid}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
+func (c *PercentageController) VerifyCompany_Del() {
|
|
|
+
|
|
|
+ T_uuid := c.GetString("T_uuid")
|
|
|
+
|
|
|
+ company, is := Percentage.Read_VerifyCompany(T_uuid)
|
|
|
+ if !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询验证公司失败"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if !Percentage.Delete_VerifyCompany(company) {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除验证公司失败"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "验证公司", "删除", company.T_uuid)
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: company.T_uuid}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|