优化阅读页跳转逻辑,优先传递章节中间ID(mid),以提升分享功能的一致性。更新相关页面以支持新逻辑,确保用户体验流畅。增加退款功能的相关处理,支持订单退款及退款原因的记录,增强订单管理的灵活性。
This commit is contained in:
@@ -39,14 +39,14 @@ func UserAddressesGet(c *gin.Context) {
|
||||
// UserAddressesPost POST /api/user/addresses
|
||||
func UserAddressesPost(c *gin.Context) {
|
||||
var body struct {
|
||||
UserID string `json:"userId" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
District string `json:"district"`
|
||||
Detail string `json:"detail" binding:"required"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
UserID string `json:"userId" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
District string `json:"district"`
|
||||
Detail string `json:"detail" binding:"required"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&body); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"success": false, "message": "缺少必填项:userId, name, phone, detail"})
|
||||
@@ -107,12 +107,24 @@ func UserAddressesByID(c *gin.Context) {
|
||||
}
|
||||
_ = c.ShouldBindJSON(&body)
|
||||
updates := make(map[string]interface{})
|
||||
if body.Name != nil { updates["name"] = *body.Name }
|
||||
if body.Phone != nil { updates["phone"] = *body.Phone }
|
||||
if body.Province != nil { updates["province"] = *body.Province }
|
||||
if body.City != nil { updates["city"] = *body.City }
|
||||
if body.District != nil { updates["district"] = *body.District }
|
||||
if body.Detail != nil { updates["detail"] = *body.Detail }
|
||||
if body.Name != nil {
|
||||
updates["name"] = *body.Name
|
||||
}
|
||||
if body.Phone != nil {
|
||||
updates["phone"] = *body.Phone
|
||||
}
|
||||
if body.Province != nil {
|
||||
updates["province"] = *body.Province
|
||||
}
|
||||
if body.City != nil {
|
||||
updates["city"] = *body.City
|
||||
}
|
||||
if body.District != nil {
|
||||
updates["district"] = *body.District
|
||||
}
|
||||
if body.Detail != nil {
|
||||
updates["detail"] = *body.Detail
|
||||
}
|
||||
if body.IsDefault != nil {
|
||||
updates["is_default"] = *body.IsDefault
|
||||
if *body.IsDefault {
|
||||
@@ -240,10 +252,18 @@ func UserProfilePost(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
updates := make(map[string]interface{})
|
||||
if body.Nickname != nil { updates["nickname"] = *body.Nickname }
|
||||
if body.Avatar != nil { updates["avatar"] = *body.Avatar }
|
||||
if body.Phone != nil { updates["phone"] = *body.Phone }
|
||||
if body.WechatID != nil { updates["wechat_id"] = *body.WechatID }
|
||||
if body.Nickname != nil {
|
||||
updates["nickname"] = *body.Nickname
|
||||
}
|
||||
if body.Avatar != nil {
|
||||
updates["avatar"] = *body.Avatar
|
||||
}
|
||||
if body.Phone != nil {
|
||||
updates["phone"] = *body.Phone
|
||||
}
|
||||
if body.WechatID != nil {
|
||||
updates["wechat_id"] = *body.WechatID
|
||||
}
|
||||
if len(updates) == 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "没有需要更新的字段"})
|
||||
return
|
||||
@@ -310,14 +330,14 @@ func UserPurchaseStatus(c *gin.Context) {
|
||||
"hasReferrer": hasReferrer,
|
||||
"matchCount": matchQuota.PurchasedTotal,
|
||||
"matchQuota": gin.H{
|
||||
"purchasedTotal": matchQuota.PurchasedTotal,
|
||||
"purchasedTotal": matchQuota.PurchasedTotal,
|
||||
"purchasedUsed": matchQuota.PurchasedUsed,
|
||||
"matchesUsedToday": matchQuota.MatchesUsedToday,
|
||||
"freeRemainToday": matchQuota.FreeRemainToday,
|
||||
"purchasedRemain": matchQuota.PurchasedRemain,
|
||||
"remainToday": matchQuota.RemainToday,
|
||||
},
|
||||
"earnings": earnings,
|
||||
"earnings": earnings,
|
||||
"pendingEarnings": pendingEarnings,
|
||||
}})
|
||||
}
|
||||
@@ -449,10 +469,10 @@ func UserTrackGet(c *gin.Context) {
|
||||
// UserTrackPost POST /api/user/track 记录行为(GORM)
|
||||
func UserTrackPost(c *gin.Context) {
|
||||
var body struct {
|
||||
UserID string `json:"userId"`
|
||||
Phone string `json:"phone"`
|
||||
Action string `json:"action"`
|
||||
Target string `json:"target"`
|
||||
UserID string `json:"userId"`
|
||||
Phone string `json:"phone"`
|
||||
Action string `json:"action"`
|
||||
Target string `json:"target"`
|
||||
ExtraData interface{} `json:"extraData"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&body); err != nil {
|
||||
@@ -509,10 +529,18 @@ func UserUpdate(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
updates := make(map[string]interface{})
|
||||
if body.Nickname != nil { updates["nickname"] = *body.Nickname }
|
||||
if body.Avatar != nil { updates["avatar"] = *body.Avatar }
|
||||
if body.Phone != nil { updates["phone"] = *body.Phone }
|
||||
if body.Wechat != nil { updates["wechat_id"] = *body.Wechat }
|
||||
if body.Nickname != nil {
|
||||
updates["nickname"] = *body.Nickname
|
||||
}
|
||||
if body.Avatar != nil {
|
||||
updates["avatar"] = *body.Avatar
|
||||
}
|
||||
if body.Phone != nil {
|
||||
updates["phone"] = *body.Phone
|
||||
}
|
||||
if body.Wechat != nil {
|
||||
updates["wechat_id"] = *body.Wechat
|
||||
}
|
||||
if len(updates) == 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"success": false, "message": "没有需要更新的字段"})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user