Commit 3fbf4730 authored by hujiebin's avatar hujiebin

Update charge_max.go

parent 98e4087e
......@@ -25,8 +25,6 @@ func ats25(a interface{}) string {
}
func main() {
d := GetLastChargeTime(644741)
println(d)
type ChargeMaxUid struct {
UserId uint64
Dollar int64
......@@ -86,7 +84,7 @@ func GetUserById25(id uint64) (model.User, error) {
func GetUserMonthMaxCharge(uid uint64) float64 {
var dollar int64
if err := mysql.ProdReadOnlyDB.Raw("select max(dollar)\nFROM (\nSELECT\n\tuser_id,\n\tDATE_FORMAT(created_time,\"%Y-%m\") as d,\n\tSUM(price) as dollar\nFROM\n\t`pay_order`\nWHERE\n\t`status` = '2'\nAND `type` = '0'\nAND created_time >= \"2022-07-01\"\nAND user_id = ?\nGROUP BY user_id,d \nUNION ALL \nSELECT\n\treceiver_id user_id,\n\tDATE_FORMAT(created_time, \"%Y-%m\") AS d,\n\tSUM(dollar) AS dollar\nFROM\n\t`dealer_transfer_detail`\nWHERE\n\tcreated_time >= \"2022-07-01\"\nAND receiver_id = ?\nGROUP BY\n\treceiver_id,\n\td\n) t", uid, uid).Scan(&dollar).Error; err != nil {
if err := mysql.ProdReadOnlyDB.Raw("select MAX(dollar) FROM\n(\nselect d,SUM(dollar) as dollar FROM (\nSELECT\n\tuser_id,\n\tDATE_FORMAT(created_time,\"%Y-%m\") as d,\n\tSUM(price) as dollar\nFROM\n\t`pay_order`\nWHERE\n\t`status` = '2'\nAND `type` = '0'\nAND created_time >= \"2022-07-01\"\nAND user_id = ?\nGROUP BY user_id,d \nUNION ALL \nSELECT\n\treceiver_id user_id,\n\tDATE_FORMAT(created_time, \"%Y-%m\") AS d,\n\tSUM(dollar) AS dollar\nFROM\n\t`dealer_transfer_detail`\nWHERE\n\tcreated_time >= \"2022-07-01\"\nAND receiver_id = ?\nGROUP BY\n\treceiver_id,\n\td\n) t GROUP BY d\n) t2", uid, uid).Scan(&dollar).Error; err != nil {
panic(err)
}
return float64(dollar) / 100
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment