|
|
@@ -38,6 +38,7 @@ func ZhiosOrderTotalSecond(queue md.MqQueue) { |
|
|
|
err = handleZhiosOrderTotalSecond(res.Body) |
|
|
|
//_ = res.Reject(false) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("===================统计", err.Error()) |
|
|
|
_ = res.Reject(false) |
|
|
|
//TODO::重新推回队列末尾,避免造成队列堵塞 |
|
|
|
var msg *md.ZhiosOrderBuckle |
|
|
@@ -73,7 +74,6 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
fmt.Println("===with", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
fmt.Println(tmpString) |
|
|
|
err = json.Unmarshal([]byte(tmpString), &canalMsg) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("===with", err.Error()) |
|
|
@@ -130,19 +130,20 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if has == 0 { |
|
|
|
sess.Rollback() |
|
|
|
return errors.New("失败") |
|
|
|
return errors.New("失败1") |
|
|
|
} |
|
|
|
} |
|
|
|
isupdate := 0 |
|
|
|
before := userStatistics.Amount |
|
|
|
if ordData.State == 4 && ordData.IsTotal == 1 { |
|
|
|
isupdate = 1 |
|
|
|
isTotal = 2 |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 6) |
|
|
|
} |
|
|
|
if ordData.State != 4 && ordData.IsTotal == 0 { |
|
|
|
isupdate = 1 |
|
|
|
isTotal = 1 |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 6) |
|
|
|
} |
|
|
|
update, err := sess.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics) |
|
|
|
if err != nil { |
|
|
@@ -151,7 +152,9 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if update == 0 && isupdate == 1 { |
|
|
|
sess.Rollback() |
|
|
|
return errors.New("失败") |
|
|
|
fmt.Println("================zhe", before, utils.SerializeStr(userStatistics)) |
|
|
|
fmt.Println("================zhe", utils.SerializeStr(ordData)) |
|
|
|
return errors.New("失败2") |
|
|
|
} |
|
|
|
if v.CreateAt > 1711086661 { |
|
|
|
var userStatistics1 model.UserDayAmount |
|
|
@@ -168,17 +171,17 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if has == 0 { |
|
|
|
sess.Rollback() |
|
|
|
return errors.New("失败") |
|
|
|
return errors.New("失败3") |
|
|
|
} |
|
|
|
} |
|
|
|
isupdate1 := 0 |
|
|
|
if ordData.State == 4 && ordData.IsTotal == 1 { |
|
|
|
isupdate1 = 1 |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 6) |
|
|
|
} |
|
|
|
if ordData.State != 4 && ordData.IsTotal == 0 { |
|
|
|
isupdate1 = 1 |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 6) |
|
|
|
} |
|
|
|
update1, err1 := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) |
|
|
|
if err1 != nil { |
|
|
@@ -187,7 +190,7 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if update1 == 0 && isupdate1 == 1 { |
|
|
|
sess.Rollback() |
|
|
|
return errors.New("失败") |
|
|
|
return errors.New("失败4") |
|
|
|
} |
|
|
|
} |
|
|
|
var userStatistics1 model.UserWaitAmount |
|
|
@@ -203,17 +206,17 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if has == 0 { |
|
|
|
sess.Rollback() |
|
|
|
return errors.New("失败") |
|
|
|
return errors.New("失败5") |
|
|
|
} |
|
|
|
} |
|
|
|
isupdate1 := 0 |
|
|
|
if ordData.State == 4 && ordData.IsTotal == 1 { |
|
|
|
isupdate1 = 1 |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 6) |
|
|
|
} |
|
|
|
if ordData.State != 4 && ordData.IsTotal == 0 { |
|
|
|
isupdate1 = 1 |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 6) |
|
|
|
} |
|
|
|
update1, err1 := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) |
|
|
|
if err1 != nil { |
|
|
@@ -222,7 +225,7 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if update1 == 0 && isupdate1 == 1 { |
|
|
|
sess.Rollback() |
|
|
|
return errors.New("失败") |
|
|
|
return errors.New("失败6") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -257,15 +260,15 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if ordData.State == 4 && (ordData.IsTotal == 1 || ordData.IsTotal == 3) { |
|
|
|
isTotal = 2 |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-utils.StrToFloat64(v.AfterAmount), 4) |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-utils.StrToFloat64(v.AfterAmount), 6) |
|
|
|
} |
|
|
|
if ordData.State != 4 && (ordData.IsTotal == 0) { |
|
|
|
isTotal = 3 |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)+utils.StrToFloat64(v.AfterAmount), 4) |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)+utils.StrToFloat64(v.AfterAmount), 6) |
|
|
|
} |
|
|
|
if ordData.State != 4 && (ordData.IsTotal == 1) { |
|
|
|
isTotal = 3 |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-utils.StrToFloat64(v.Amount), 4) |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-utils.StrToFloat64(v.Amount), 6) |
|
|
|
} |
|
|
|
_, err := sess.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics) |
|
|
|
if err != nil { |
|
|
@@ -285,20 +288,20 @@ func handleZhiosOrderTotalSecond(msg []byte) error { |
|
|
|
} |
|
|
|
if has == 0 { |
|
|
|
sess.Rollback() |
|
|
|
return errors.New("失败") |
|
|
|
return errors.New("失败a") |
|
|
|
} |
|
|
|
} |
|
|
|
if ordData.State == 4 && (ordData.IsTotal == 1 || ordData.IsTotal == 3) { |
|
|
|
isTotal = 2 |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.AfterAmount), 4) |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.AfterAmount), 6) |
|
|
|
} |
|
|
|
if ordData.State != 4 && (ordData.IsTotal == 0) { |
|
|
|
isTotal = 3 |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+utils.StrToFloat64(v.AfterAmount), 4) |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+utils.StrToFloat64(v.AfterAmount), 6) |
|
|
|
} |
|
|
|
if ordData.State != 4 && (ordData.IsTotal == 1) { |
|
|
|
isTotal = 3 |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.Amount), 4) |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.Amount), 6) |
|
|
|
} |
|
|
|
_, err = sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics) |
|
|
|
if err != nil { |
|
|
|