fix: 修复宠物购买重复订单问题
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-03-14 10:27:26 +08:00
committed by cnb
parent 30dba8fee3
commit 4e1fdd6a22

View File

@@ -123,10 +123,15 @@ func (s *PetService) BuyPet(pid uint32) error {
if err != nil {
return err
}
_, err = tx.Model(s.Model).Where("catch_time", tt.CatchTime).Delete()
res, err := tx.Model(s.Model).Where("id", tt.ID).Delete()
if err != nil {
return err
}
cd, _ := res.RowsAffected()
if cd == 0 {
return fmt.Errorf("重复订单")
}
_, err = tx.Model(basemodel.BaseSysUser{}).Where("id", tt.PlayerID).Increment("free_gold", int64(tt.SalePrice)*98)
if err != nil {
return err