From 8d1a7ae9edb5e9686cc68cdd5da0f36ce24f2c99 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Mon, 29 Apr 2024 18:51:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/model/subsidy_total.go | 15 ++++++++------- rule/consume_integral_settlement.go | 8 +++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/db/model/subsidy_total.go b/db/model/subsidy_total.go index 6be68ab..ef538cb 100644 --- a/db/model/subsidy_total.go +++ b/db/model/subsidy_total.go @@ -1,11 +1,12 @@ package model type SubsidyTotal struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - Date int `json:"date" xorm:"default 0 INT(11)"` - DayPayAmount string `json:"day_pay_amount" xorm:"default 0.000000 DECIMAL(20,6)"` - NowAmount string `json:"now_amount" xorm:"default 0.000000 DECIMAL(20,6)"` - DayIntegral string `json:"day_integral" xorm:"default 0.000000 DECIMAL(20,6)"` - AllAmount string `json:"all_amount" xorm:"default 0.000000 DECIMAL(20,6)"` - AllIntegral string `json:"all_integral" xorm:"default 0.000000 DECIMAL(20,6)"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Date int `json:"date" xorm:"default 0 INT(11)"` + DayPayAmount string `json:"day_pay_amount" xorm:"default 0.000000 DECIMAL(20,6)"` + NowAmount string `json:"now_amount" xorm:"default 0.000000 DECIMAL(20,6)"` + DayIntegral string `json:"day_integral" xorm:"default 0.000000 DECIMAL(20,6)"` + AllAmount string `json:"all_amount" xorm:"default 0.000000 DECIMAL(20,6)"` + AllIntegral string `json:"all_integral" xorm:"default 0.000000 DECIMAL(20,6)"` + AllIntegralAmount string `json:"all_integral_amount" xorm:"default 0.000000 DECIMAL(20,6)"` } diff --git a/rule/consume_integral_settlement.go b/rule/consume_integral_settlement.go index 45b3ae3..5892eb3 100644 --- a/rule/consume_integral_settlement.go +++ b/rule/consume_integral_settlement.go @@ -281,7 +281,12 @@ func Total(sess *xorm.Session, date, dayPayAmount string) error { if len(queryNativeStringAllIntegral) > 0 { AllIntegral = queryNativeStringAllIntegral[0]["amount"] } - + sqlAllIntegralAmount := "SELECT SUM(amount) as amount FROM subsidy_with_user where kind(1,2) and is_give=0 " + queryNativeStringAllIntegralAmount, _ := db.QueryNativeStringSess(sess, sqlAllIntegralAmount) + AllIntegralAmount := "0" + if len(queryNativeStringAllIntegralAmount) > 0 { + AllIntegralAmount = queryNativeStringAllIntegralAmount[0]["amount"] + } var data model.SubsidyTotal sess.Where("date=?", date1).Get(&data) if data.Id == 0 { @@ -296,6 +301,7 @@ func Total(sess *xorm.Session, date, dayPayAmount string) error { data.DayIntegral = DayIntegral data.AllAmount = AllAmount data.AllIntegral = AllIntegral + data.AllIntegralAmount = AllIntegralAmount update, err := sess.Where("id=?", data.Id).Update(&data) if update == 0 || err != nil { return errors.New("失败") From a0418928b27fec4c4e4a0d28de9a797a257ba9e4 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 30 Apr 2024 09:03:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/consume_integral_settlement.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rule/consume_integral_settlement.go b/rule/consume_integral_settlement.go index 5892eb3..28f2fce 100644 --- a/rule/consume_integral_settlement.go +++ b/rule/consume_integral_settlement.go @@ -262,7 +262,7 @@ func Total(sess *xorm.Session, date, dayPayAmount string) error { amount = queryNativeString[0]["amount"] } date1 := strings.ReplaceAll(date, "-", "") - sql2 := "SELECT SUM(integral_num) as amount FROM subsidy_with_user where kind(1,2) and is_give=0 and date='" + date + "'" + sql2 := "SELECT SUM(integral_num) as amount FROM subsidy_with_user where kind in(1,2) and is_give=0 and date='" + date + "'" queryNativeString2, _ := db.QueryNativeStringSess(sess, sql2) DayIntegral := "0" if len(queryNativeString2) > 0 { @@ -275,13 +275,13 @@ func Total(sess *xorm.Session, date, dayPayAmount string) error { if len(queryNativeStringAll) > 0 { AllAmount = queryNativeStringAll[0]["amount"] } - sqlAllIntegral := "SELECT SUM(integral_num) as amount FROM subsidy_with_user where kind(1,2) and is_give=0 " + sqlAllIntegral := "SELECT SUM(integral_num) as amount FROM subsidy_with_user where kind in(1,2) and is_give=0 " queryNativeStringAllIntegral, _ := db.QueryNativeStringSess(sess, sqlAllIntegral) AllIntegral := "0" if len(queryNativeStringAllIntegral) > 0 { AllIntegral = queryNativeStringAllIntegral[0]["amount"] } - sqlAllIntegralAmount := "SELECT SUM(amount) as amount FROM subsidy_with_user where kind(1,2) and is_give=0 " + sqlAllIntegralAmount := "SELECT SUM(amount) as amount FROM subsidy_with_user where kind in(1,2) and is_give=0 " queryNativeStringAllIntegralAmount, _ := db.QueryNativeStringSess(sess, sqlAllIntegralAmount) AllIntegralAmount := "0" if len(queryNativeStringAllIntegralAmount) > 0 {