refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package app
|
||
|
||
import (
|
||
"net/http"
|
||
|
||
"bindbox-game/internal/code"
|
||
"bindbox-game/internal/pkg/core"
|
||
)
|
||
|
||
type requestShippingRequest struct {
|
||
InventoryID int64 `json:"inventory_id"`
|
||
}
|
||
|
||
type requestShippingResponse struct {
|
||
AddressID int64 `json:"address_id"`
|
||
}
|
||
|
||
// RequestShipping 申请发货(使用默认地址)
|
||
// @Summary 申请发货
|
||
// @Description 用户已有默认地址时,申请对指定资产发货;幂等校验已存在发货记录时返回已处理
|
||
// @Tags APP端.用户
|
||
// @Accept json
|
||
// @Produce json
|
||
// @Param user_id path integer true "用户ID"
|
||
// @Security LoginVerifyToken
|
||
// @Param RequestBody body requestShippingRequest true "请求参数:资产ID"
|
||
// @Success 200 {object} requestShippingResponse
|
||
// @Failure 400 {object} code.Failure "参数错误/未设置默认地址/已处理"
|
||
// @Router /api/app/users/{user_id}/inventory/request-shipping [post]
|
||
func (h *handler) RequestShipping() core.HandlerFunc {
|
||
return func(ctx core.Context) {
|
||
req := new(requestShippingRequest)
|
||
rsp := new(requestShippingResponse)
|
||
if err := ctx.ShouldBindJSON(req); err != nil || req.InventoryID == 0 {
|
||
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "参数错误"))
|
||
return
|
||
}
|
||
userID := int64(ctx.SessionUserInfo().Id)
|
||
addrID, err := h.user.RequestShipping(ctx.RequestContext(), userID, req.InventoryID)
|
||
if err != nil {
|
||
ctx.AbortWithError(core.Error(http.StatusBadRequest, 10022, err.Error()))
|
||
return
|
||
}
|
||
rsp.AddressID = addrID
|
||
ctx.Payload(rsp)
|
||
}
|
||
}
|