bindbox-game/internal/api/user/address_share_submit_public.go
邹方成 45815bfb7d chore: 清理无用文件与优化代码结构
refactor(utils): 修复密码哈希比较逻辑错误
feat(user): 新增按状态筛选优惠券接口
docs: 添加虚拟发货与任务中心相关文档
fix(wechat): 修正Code2Session上下文传递问题
test: 补充订单折扣与积分转换测试用例
build: 更新配置文件与构建脚本
style: 清理多余的空行与注释
2025-12-18 17:35:55 +08:00

53 lines
1.9 KiB
Go

package app
import (
"net/http"
"bindbox-game/internal/code"
"bindbox-game/internal/pkg/core"
)
type addressShareSubmitRequest struct {
ShareToken string `json:"share_token"`
Name string `json:"name"`
Mobile string `json:"mobile"`
Province string `json:"province"`
City string `json:"city"`
District string `json:"district"`
Address string `json:"address"`
}
type addressShareSubmitResponse struct {
AddressID int64 `json:"address_id"`
}
// SubmitAddressShare 提交共享地址(公域)
// @Summary 提交共享地址
// @Description 被邀请者使用分享令牌提交收件信息;服务端校验令牌有效并创建待发货记录(极简方案)
// @Tags APP端.用户
// @Accept json
// @Produce json
// @Param RequestBody body addressShareSubmitRequest true "请求参数:令牌与地址信息"
// @Success 200 {object} addressShareSubmitResponse
// @Failure 400 {object} code.Failure "令牌无效/已处理/资产不可用"
// @Router /api/app/address-share/submit [post]
func (h *handler) SubmitAddressShare() core.HandlerFunc {
return func(ctx core.Context) {
req := new(addressShareSubmitRequest)
rsp := new(addressShareSubmitResponse)
if err := ctx.ShouldBindJSON(req); err != nil || req.ShareToken == "" || req.Name == "" || req.Mobile == "" || req.Province == "" || req.City == "" || req.District == "" || req.Address == "" {
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "参数错误"))
return
}
var submitUserID *int64
ip := ctx.Request().RemoteAddr
addrID, err := h.user.SubmitAddressShare(ctx.RequestContext(), req.ShareToken, req.Name, req.Mobile, req.Province, req.City, req.District, req.Address, submitUserID, &ip)
if err != nil {
ctx.AbortWithError(core.Error(http.StatusBadRequest, 10024, err.Error()))
return
}
rsp.AddressID = addrID
ctx.Payload(rsp)
}
}