🎨 优化文章和支付回调,新增返回分享用接口

This commit is contained in:
2025-10-08 16:41:50 +08:00
parent f0ea189553
commit d593476c51
9 changed files with 94 additions and 83 deletions

View File

@@ -176,17 +176,17 @@ func (s *OrderService) BalancePay(p request.BalancePay) error {
}
// 计算会员的过期时间
if user.VipExpireTime != "" {
expireTime, _ := time.Parse("2006-01-02", user.VipExpireTime)
expireTime, _ := time.Parse("2006-01-02 15:04:05", user.VipExpireTime)
if expireTime.After(time.Now()) {
// 如果会员未过期,则在原有的基础上增加时间
user.VipExpireTime = expireTime.AddDate(0, 0, int(vipInfo.Expiration)).Format("2006-01-02")
user.VipExpireTime = expireTime.AddDate(0, 0, int(vipInfo.Expiration)).Format("2006-01-02 15:04:05")
} else {
// 如果会员已过期,则从当前时间开始计算
user.VipExpireTime = time.Now().AddDate(0, 0, int(vipInfo.Expiration)).Format("2006-01-02")
user.VipExpireTime = time.Now().AddDate(0, 0, int(vipInfo.Expiration)).Format("2006-01-02 15:04:05")
}
} else {
// 如果没有会员时间,则从当前时间开始计算
user.VipExpireTime = time.Now().AddDate(0, 0, int(vipInfo.Expiration)).Format("2006-01-02")
user.VipExpireTime = time.Now().AddDate(0, 0, int(vipInfo.Expiration)).Format("2006-01-02 15:04:05")
}
// 更新用户的会员状态
@@ -216,8 +216,8 @@ func (s *OrderService) BalancePay(p request.BalancePay) error {
teacherVipId, _ := strconv.ParseUint(id, 10, 64)
teacherVip.TeacherVipId = uint(teacherVipId)
teacherVip.UserId = uint(order.UserId)
teacherVip.ExpireAt = time.Now().AddDate(0, 1, 0).Format("2006-01-02") // 会员有效期一个月
teacherVip.IsExpire = 1 // 设置为未过期
teacherVip.ExpireAt = time.Now().AddDate(0, 1, 0).Format("2006-01-02 15:04:05") // 会员有效期一个月
teacherVip.IsExpire = 1 // 设置为未过期
err = global.GVA_DB.Create(&teacherVip).Error
if err != nil {
global.GVA_LOG.Error("购买讲师会员回调处理失败:", zap.Error(err))