```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(pet): 添加宠物交易功能

- 新增ModPrise接口用于修改宠物售价
- 新增BuyPet接口用于购买宠物
- 修改Pet模型中SalePrice字段类型为float32
- 实现宠物购买逻辑,包括价格验证、余额检查和交易处理
- 更新查询条件以支持宠物交易状态筛选
```
This commit is contained in:
昔念
2026-03-10 22:20:36 +08:00
parent 69350bb79e
commit 6792e0e79a
3 changed files with 75 additions and 11 deletions

View File

@@ -84,3 +84,34 @@ type PetLevelRes struct {
//ID
ID int `json:"id"`
}
type PriseReq struct {
g.Meta `path:"/modpirse" method:"POST"`
Ctime uint32 `json:"catch_time"`
Price float32 `json:"sale_price"`
}
func (c *PetBagController) ModPrise(ctx context.Context, req *PriseReq) (res *cool.BaseRes, err error) {
admin := cool.GetAdmin(ctx)
res = &cool.BaseRes{}
service.NewPetService(uint32(admin.UserId)).UPdatePrice(req.Ctime, req.Price)
return
}
type BuyPetReq struct {
g.Meta `path:"/buy" method:"POST"`
Cid uint32 `json:"id"`
}
func (c *PetBagController) BuyPet(ctx context.Context, req *BuyPetReq) (res *cool.BaseRes, err error) {
admin := cool.GetAdmin(ctx)
res = &cool.BaseRes{}
service.NewPetService(uint32(admin.UserId)).BuyPet(req.Cid)
return
}