feat(pet): 添加宠物交易功能 - 新增ModPrise接口用于修改宠物售价 - 新增BuyPet接口用于购买宠物 - 修改Pet模型中SalePrice字段类型为float32 - 实现宠物购买逻辑,包括价格验证、余额检查和交易处理 - 更新查询条件以支持宠物交易状态筛选 ```
This commit is contained in:
@@ -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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user