Browse Source

2023-05-22

zoie 1 year ago
parent
commit
f72ec608c3
4 changed files with 35 additions and 19 deletions
  1. 18 18
      controllers/Salary.go
  2. 1 0
      go.mod
  3. 2 0
      go.sum
  4. 14 1
      models/Salary/Salary.go

+ 18 - 18
controllers/Salary.go

@@ -96,7 +96,7 @@ func (c *SalaryController) Salary_Get() {
 				c.ServeJSON()
 				return
 			}
-			salary_new.T_State = 1
+			salary_new.T_State = 3
 			c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: salary_new}
 			c.ServeJSON()
 			return
@@ -119,7 +119,7 @@ func (c *SalaryController) Salary_User_Get() {
 		T_date = time.Now().AddDate(0, -1, 0).Format("2006-01")
 	}
 
-	salary, err := Salary.Read_Salary_ByT_uuid_T_date(c.User.T_uuid, T_date)
+	salary, err := Salary.Read_Salary_ByT_date(c.User.T_uuid, T_date)
 	if err != nil {
 		if err.Error() == orm.ErrNoRows.Error() {
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "暂无当月数据!"}
@@ -458,22 +458,22 @@ func (c *SalaryController) Salary_Excel() {
 	//f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line), total)
 
 	// 函数统计
-	f.SetCellFormula("Sheet1", fmt.Sprintf("E%d", line), fmt.Sprintf("SUM(E4,E%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("F%d", line), fmt.Sprintf("SUM(F4,F%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("G%d", line), fmt.Sprintf("SUM(G4,G%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("J%d", line), fmt.Sprintf("SUM(J4,J%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("K%d", line), fmt.Sprintf("SUM(K4,K%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("L%d", line), fmt.Sprintf("SUM(L4,L%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("M%d", line), fmt.Sprintf("SUM(M4,M%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("N%d", line), fmt.Sprintf("SUM(N4,N%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("O%d", line), fmt.Sprintf("SUM(O4,O%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("P%d", line), fmt.Sprintf("SUM(P4,P%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("Q%d", line), fmt.Sprintf("SUM(Q4,Q%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("R%d", line), fmt.Sprintf("SUM(R4,R%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("S%d", line), fmt.Sprintf("SUM(S4,S%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("T%d", line), fmt.Sprintf("SUM(T4,T%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("U%d", line), fmt.Sprintf("SUM(U4,U%d)", line-1))
-	f.SetCellFormula("Sheet1", fmt.Sprintf("V%d", line), fmt.Sprintf("SUM(V4,V%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("E%d", line), fmt.Sprintf("SUM(E4:E%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("F%d", line), fmt.Sprintf("SUM(F4:F%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("G%d", line), fmt.Sprintf("SUM(G4:G%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("J%d", line), fmt.Sprintf("SUM(J4:J%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("K%d", line), fmt.Sprintf("SUM(K4:K%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("L%d", line), fmt.Sprintf("SUM(L4:L%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("M%d", line), fmt.Sprintf("SUM(M4:M%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("N%d", line), fmt.Sprintf("SUM(N4:N%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("O%d", line), fmt.Sprintf("SUM(O4:O%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("P%d", line), fmt.Sprintf("SUM(P4:P%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("Q%d", line), fmt.Sprintf("SUM(Q4:Q%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("R%d", line), fmt.Sprintf("SUM(R4:R%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("S%d", line), fmt.Sprintf("SUM(S4:S%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("T%d", line), fmt.Sprintf("SUM(T4:T%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("U%d", line), fmt.Sprintf("SUM(U4:U%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("V%d", line), fmt.Sprintf("SUM(V4:V%d)", line-1))
 
 	Style4, _ := f.NewStyle(
 		&excelize.Style{

+ 1 - 0
go.mod

@@ -17,6 +17,7 @@ require (
 )
 
 require (
+	baliance.com/gooxml v1.0.1 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect
 	github.com/cespare/xxhash/v2 v2.1.2 // indirect
 	github.com/golang/protobuf v1.5.2 // indirect

+ 2 - 0
go.sum

@@ -1,3 +1,5 @@
+baliance.com/gooxml v1.0.1 h1:fG5lmxmjEVFfbKQ2NuyCuU3hMuuOb5avh5a38SZNO1o=
+baliance.com/gooxml v1.0.1/go.mod h1:+gpUgmkAF4zCtwOFPNRLDAvpVRWoKs5EeQTSv/HYFnw=
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=

+ 14 - 1
models/Salary/Salary.go

@@ -31,7 +31,7 @@ type Salary struct {
 	T_housing_fund            float32 `orm:"digits(12);decimals(2)"` // 需缴住房公积金
 	T_tax                     float32 `orm:"digits(12);decimals(2)"` // 需缴个人所得税
 	T_remark                  string  `orm:"type(text);null"`
-	T_State                   int     `orm:"size(20);default(1)"` //  1 未发送 2 已发送
+	T_State                   int     `orm:"size(20);default(1)"` //  1 未发送 2 已发送 3-未提交
 
 	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
 	UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"`     //auto_now 每次 model 保存时都会对时间自动更新
@@ -147,6 +147,19 @@ func Read_Salary_ByT_uuid_T_date(T_uuid, T_date string) (r Salary, err error) {
 	return r, err
 }
 
+func Read_Salary_ByT_date(T_uuid, T_date string) (r Salary, err error) {
+	o := orm.NewOrm()
+	qs := o.QueryTable(new(Salary))
+	//r = Salary{T_uid: T_uuid, T_date: T_date}
+	//err = o.Read(&r, "T_uid", "T_date")
+	err = qs.Filter("T_uid", T_uuid).Filter("T_date", T_date).Filter("T_State", 2).One(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return r, err
+	}
+	return r, err
+}
+
 // 添加
 func Add_Salary(m Salary) (id int, err error) {
 	o := orm.NewOrm()