修改了关联时间字段
This commit is contained in:
parent
fc835fbc6d
commit
b2c1f0ee44
@ -69,7 +69,7 @@ func UserCouponExpire(msg amqp091.Delivery) {
|
||||
|
||||
// 检测优惠卷过期时间
|
||||
now := time.Now()
|
||||
validEndTime := time.Time(userCoupon.ValidEndTime)
|
||||
validEndTime := time.Time(*userCoupon.ValidEndTime)
|
||||
diffTime := validEndTime.Sub(now)
|
||||
if diffTime >= 60*time.Second {
|
||||
// 重新添加入队列
|
||||
|
||||
@ -63,7 +63,9 @@ func UserMemberExpire(msg amqp091.Delivery) {
|
||||
|
||||
// 检测会员过期时间
|
||||
now := time.Now()
|
||||
diffTime := user.MemberExpireDate.Sub(now)
|
||||
memberExpireDate := time.Time(*user.MemberExpireDate)
|
||||
|
||||
diffTime := memberExpireDate.Sub(now)
|
||||
if diffTime >= 60*time.Second {
|
||||
// 重新添加入队列
|
||||
data := make(map[string]interface{})
|
||||
|
||||
@ -82,9 +82,12 @@ func (r *Login) LoginPhone(c *gin.Context) {
|
||||
Avatar: avatar,
|
||||
IsMember: 0,
|
||||
MemberExpireDate: nil,
|
||||
LoginAt: model.LocalTime(time.Now()),
|
||||
LoginIp: loginIp,
|
||||
}
|
||||
|
||||
loginAt := model.LocalTime(time.Now())
|
||||
user.LoginAt = &loginAt
|
||||
|
||||
user, err := userDao.AddUser(tx, user)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
@ -195,9 +198,12 @@ func (r *Login) LoginWx(c *gin.Context) {
|
||||
Avatar: avatar,
|
||||
IsMember: 0,
|
||||
MemberExpireDate: nil,
|
||||
LoginAt: model.LocalTime(time.Now()),
|
||||
LoginIp: loginIp,
|
||||
}
|
||||
|
||||
loginAt := model.LocalTime(time.Now())
|
||||
user.LoginAt = &loginAt
|
||||
|
||||
user, err = userDao.AddUser(tx, user)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
@ -248,14 +248,6 @@ func (b *OrderMember) GetOrderMemberPayStatus(c *gin.Context) {
|
||||
|
||||
// 处理有效期
|
||||
if g.PayStatus == 2 {
|
||||
// 获取单项配置
|
||||
systemMemberDao := dao.SystemMemberDao{}
|
||||
systemMember, err := systemMemberDao.GetSystemMemberById(orderMember.SystemMemberId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("内部错误", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(orderMember.UserId)
|
||||
@ -264,17 +256,10 @@ func (b *OrderMember) GetOrderMemberPayStatus(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取有效期
|
||||
var validTime time.Time
|
||||
if user.MemberExpireDate != nil {
|
||||
validTime = user.MemberExpireDate.Add(time.Duration(systemMember.MemberDays) * 24 * time.Hour)
|
||||
} else {
|
||||
now := time.Now()
|
||||
validTime = now.Add(time.Duration(systemMember.MemberDays) * 24 * time.Hour)
|
||||
// 加载到期时间
|
||||
g.LoadValidDate(user.MemberExpireDate)
|
||||
}
|
||||
|
||||
// 加载到期时间
|
||||
g.LoadValidDate(&validTime)
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
|
||||
@ -367,24 +367,5 @@ func (b *OrderSingle) GetOrderSinglePayStatus(c *gin.Context) {
|
||||
// 处理返回值
|
||||
g := dto.GetOrderSinglePayStatus(orderSingle)
|
||||
|
||||
// 处理有效期
|
||||
if g.PayStatus == 2 {
|
||||
// 获取单项配置
|
||||
systemSingleDao := dao.SystemSingleDao{}
|
||||
|
||||
maps = make(map[string]interface{})
|
||||
systemSingle, err := systemSingleDao.GetSystemSingle(maps)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("内部错误", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取有效期
|
||||
validTime := orderSingle.PayTime.Add(time.Duration(systemSingle.ValidDays) * 24 * time.Hour)
|
||||
|
||||
// 加载到期时间
|
||||
g.LoadValidDate(&validTime)
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
@ -133,8 +133,8 @@ func (r *Question) GetQuestion(c *gin.Context) {
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
// GetQuestionBuyStatus 获取问题购买状态
|
||||
func (r *Question) GetQuestionBuyStatus(c *gin.Context) {
|
||||
// GetQuestionUnlockStatus 获取问题解锁状态
|
||||
func (r *Question) GetQuestionUnlockStatus(c *gin.Context) {
|
||||
// 购买状态(0:否 1:是)
|
||||
var status int
|
||||
userId := c.GetInt64("UserId")
|
||||
@ -228,9 +228,10 @@ func (r *Question) GetQuestionBuyStatus(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 判断是否还在有效期内
|
||||
payTime := time.Time(*single.PayTime)
|
||||
validTime := payTime.Add(time.Duration(systemSingle.ValidDays) * 24 * time.Hour)
|
||||
now := time.Now()
|
||||
ValidTime := single.PayTime.Add(time.Duration(systemSingle.ValidDays) * 24 * time.Hour)
|
||||
if ValidTime.Before(now) {
|
||||
if validTime.Before(now) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ func UserCouponExpire() {
|
||||
|
||||
for _, userCoupon := range userCoupons {
|
||||
// 计算过期时间
|
||||
validEndTime := time.Time(userCoupon.ValidEndTime)
|
||||
validEndTime := time.Time(*userCoupon.ValidEndTime)
|
||||
|
||||
delay := validEndTime.Sub(time.Now())
|
||||
if delay < 5*time.Second {
|
||||
|
||||
@ -19,7 +19,7 @@ func UserMemberExpire() {
|
||||
|
||||
for _, user := range users {
|
||||
// 计算过期时间
|
||||
validEndTime := user.MemberExpireDate
|
||||
validEndTime := time.Time(*user.MemberExpireDate)
|
||||
|
||||
delay := validEndTime.Sub(time.Now())
|
||||
if delay < 5*time.Second {
|
||||
|
||||
@ -4,29 +4,28 @@ import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
"hepa-calc-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WxDto struct {
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
Token string `json:"token"` // token
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *model.LocalTime `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
Token string `json:"token"` // token
|
||||
}
|
||||
|
||||
type MobileDto struct {
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
Token string `json:"token"` // token
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *model.LocalTime `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
Token string `json:"token"` // token
|
||||
}
|
||||
|
||||
// LoginWxDto 微信登陆
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/app"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
|
||||
"hepa-calc-api/api/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderMemberDto 订单-会员
|
||||
@ -17,7 +16,7 @@ type OrderMemberDto struct {
|
||||
IsDelete int `json:"is_delete"` // 用户删除状态(0:否 1:是)
|
||||
PayChannel int `json:"pay_channel"` // 支付渠道(1:h5支付 2:app支付 3:会员支付)
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PayTime *time.Time `json:"pay_time"` // 支付时间
|
||||
PayTime *model.LocalTime `json:"pay_time"` // 支付时间
|
||||
RefundStatus int `json:"refund_status"` // 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
OrderNo string `json:"order_no"` // 系统订单编号
|
||||
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||
@ -25,7 +24,7 @@ type OrderMemberDto struct {
|
||||
CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
CancelStatus int `json:"cancel_status"` // 取消状态(0:否 1:是)
|
||||
CancelTime *time.Time `json:"cancel_time"` // 订单取消时间
|
||||
CancelTime *model.LocalTime `json:"cancel_time"` // 订单取消时间
|
||||
CancelRemarks string `json:"cancel_remarks"` // 取消订单备注
|
||||
OrderRemarks string `json:"order_remarks"` // 订单备注
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
@ -48,9 +47,9 @@ type OrderMemberPayDto struct {
|
||||
|
||||
// OrderMemberPayStatusDto 会员订单支付状态
|
||||
type OrderMemberPayStatusDto struct {
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
ValidDate model.LocalTime `json:"valid_date"` // 到期时间
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
ValidDate *model.LocalTime `json:"valid_date"` // 到期时间
|
||||
}
|
||||
|
||||
// GetOrderMemberListDto 列表
|
||||
@ -126,9 +125,9 @@ func (r *OrderMemberDto) LoadSystemMember(m *model.SystemMember) *OrderMemberDto
|
||||
}
|
||||
|
||||
// LoadValidDate 加载到期时间
|
||||
func (r *OrderMemberPayStatusDto) LoadValidDate(m *time.Time) *OrderMemberPayStatusDto {
|
||||
func (r *OrderMemberPayStatusDto) LoadValidDate(m *model.LocalTime) *OrderMemberPayStatusDto {
|
||||
if m != nil {
|
||||
r.ValidDate = model.LocalTime(*m)
|
||||
r.ValidDate = m
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@ -5,32 +5,32 @@ import (
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/app"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
|
||||
"hepa-calc-api/api/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderSingleDto 订单-单项
|
||||
type OrderSingleDto struct {
|
||||
OrderId string `json:"order_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
QuestionId string `json:"question_id"` // 问题id
|
||||
OrderStatus int `json:"order_status"` // 订单状态(1:待支付 2:已完成 3:已取消)
|
||||
IsDelete int `json:"is_delete"` // 用户删除状态(0:否 1:是)
|
||||
PayChannel int `json:"pay_channel"` // 支付渠道(1:h5支付 2:app支付 3:会员支付)
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PayTime *time.Time `json:"pay_time"` // 支付时间
|
||||
RefundStatus int `json:"refund_status"` // 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
OrderNo string `json:"order_no"` // 系统订单编号
|
||||
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||
AmountTotal float64 `json:"amount_total"` // 订单金额
|
||||
CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
CancelStatus int `json:"cancel_status"` // 取消状态(0:否 1:是)
|
||||
CancelTime *time.Time `json:"cancel_time"` // 订单取消时间
|
||||
CancelRemarks string `json:"cancel_remarks"` // 取消订单备注
|
||||
OrderRemarks string `json:"order_remarks"` // 订单备注
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
Question *QuestionDto `json:"question"` // 问题
|
||||
OrderId string `json:"order_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
QuestionId string `json:"question_id"` // 问题id
|
||||
OrderStatus int `json:"order_status"` // 订单状态(1:待支付 2:已完成 3:已取消)
|
||||
IsDelete int `json:"is_delete"` // 用户删除状态(0:否 1:是)
|
||||
PayChannel int `json:"pay_channel"` // 支付渠道(1:h5支付 2:app支付 3:会员支付)
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PayTime *model.LocalTime `json:"pay_time"` // 支付时间
|
||||
RefundStatus int `json:"refund_status"` // 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
OrderNo string `json:"order_no"` // 系统订单编号
|
||||
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||
AmountTotal float64 `json:"amount_total"` // 订单金额
|
||||
CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
CancelStatus int `json:"cancel_status"` // 取消状态(0:否 1:是)
|
||||
CancelTime *model.LocalTime `json:"cancel_time"` // 订单取消时间
|
||||
CancelRemarks string `json:"cancel_remarks"` // 取消订单备注
|
||||
ValidDate *model.LocalTime `json:"valid_date"` // 到期时间
|
||||
OrderRemarks string `json:"order_remarks"` // 订单备注
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
Question *QuestionDto `json:"question"` // 问题
|
||||
}
|
||||
|
||||
// OrderSinglePayDto 单项订单支付数据
|
||||
@ -48,9 +48,9 @@ type OrderSinglePayDto struct {
|
||||
|
||||
// OrderSinglePayStatusDto 单项订单支付状态
|
||||
type OrderSinglePayStatusDto struct {
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
ValidDate model.LocalTime `json:"valid_date"` // 到期时间
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
ValidDate *model.LocalTime `json:"valid_date"` // 到期时间
|
||||
}
|
||||
|
||||
// GetOrderSingleListDto 列表
|
||||
@ -78,6 +78,7 @@ func GetOrderSingleListDto(m []*model.OrderSingle) []*OrderSingleDto {
|
||||
CancelStatus: v.CancelStatus,
|
||||
CancelTime: v.CancelTime,
|
||||
CancelRemarks: v.CancelRemarks,
|
||||
ValidDate: v.ValidDate,
|
||||
OrderRemarks: v.OrderRemarks,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
@ -114,6 +115,7 @@ func GetOrderSinglePayStatus(m *model.OrderSingle) *OrderSinglePayStatusDto {
|
||||
return &OrderSinglePayStatusDto{
|
||||
PayStatus: m.PayStatus,
|
||||
PaymentAmountTotal: m.PaymentAmountTotal,
|
||||
ValidDate: m.ValidDate,
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,11 +126,3 @@ func (r *OrderSingleDto) LoadQuestion(m *model.Question) *OrderSingleDto {
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadValidDate 加载到期时间
|
||||
func (r *OrderSinglePayStatusDto) LoadValidDate(m *time.Time) *OrderSinglePayStatusDto {
|
||||
if m != nil {
|
||||
r.ValidDate = model.LocalTime(*m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@ -30,6 +30,13 @@ type QuestionDto struct {
|
||||
BuyCount int `json:"buy_count"` // 被购买数量
|
||||
}
|
||||
|
||||
// QuestionBuyStatusDto 获取问题解锁状态
|
||||
type QuestionBuyStatusDto struct {
|
||||
QuestionId string `json:"buy_status"` // 解锁状态(0:否 1:是)
|
||||
QuestionTitle *int `json:"buy_mode"` // 解锁方式(1:单项有效期 2:会员)
|
||||
ValidDate *time.Time `json:"valid_date"` // 到期时间
|
||||
}
|
||||
|
||||
// GetQuestionDto 详情-问题
|
||||
func GetQuestionDto(m *model.Question) *QuestionDto {
|
||||
return &QuestionDto{
|
||||
|
||||
@ -3,18 +3,17 @@ package dto
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SystemMemberDto 配置-会员配置
|
||||
type SystemMemberDto struct {
|
||||
SystemMemberId string `json:"system_member_id"` // 主键id
|
||||
MemberDays uint `json:"member_days"` // 会员天数
|
||||
Price float64 `json:"price"` // 价格(原价)
|
||||
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
|
||||
DiscountEndTime *time.Time `json:"discount_end_time"` // 优惠截止时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
SystemMemberId string `json:"system_member_id"` // 主键id
|
||||
MemberDays uint `json:"member_days"` // 会员天数
|
||||
Price float64 `json:"price"` // 价格(原价)
|
||||
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
|
||||
DiscountEndTime *model.LocalTime `json:"discount_end_time"` // 优惠截止时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetSystemMemberListDto 列表
|
||||
|
||||
@ -4,27 +4,26 @@ import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
"hepa-calc-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserDto 用户表
|
||||
type UserDto struct {
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
UserStatus int `json:"user_status"` // 状态(1:正常 2:禁用)
|
||||
RegisterSource int `json:"register_source"` // 注册来源(1:app注册 2:公众号注册)
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
UnionId string `json:"union_id"` // 微信开放平台标识
|
||||
Age *uint `json:"age"` // 年龄
|
||||
Sex uint `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
LoginAt model.LocalTime `json:"login_at"` // 登陆时间
|
||||
LoginIp string `json:"login_ip"` // 登陆ip
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
UserStatus int `json:"user_status"` // 状态(1:正常 2:禁用)
|
||||
RegisterSource int `json:"register_source"` // 注册来源(1:app注册 2:公众号注册)
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
UnionId string `json:"union_id"` // 微信开放平台标识
|
||||
Age *uint `json:"age"` // 年龄
|
||||
Sex uint `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *model.LocalTime `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
LoginAt *model.LocalTime `json:"login_at"` // 登陆时间
|
||||
LoginIp string `json:"login_ip"` // 登陆ip
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserDto 详情-问题
|
||||
|
||||
@ -6,17 +6,17 @@ import (
|
||||
)
|
||||
|
||||
type UserCouponDto struct {
|
||||
UserCouponId string `json:"user_coupon_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
CouponId string `json:"coupon_id"` // 优惠券id
|
||||
UserCouponStatus int `json:"user_coupon_status"` // 状态(0:未使用 1:已使用 3:已过期)
|
||||
IsWindows int `json:"is_windows"` // 是否已弹窗(0:否 1:是)
|
||||
CouponUseDate model.LocalTime `json:"coupon_use_date"` // 使用时间
|
||||
ValidStartTime model.LocalTime `json:"valid_start_time"` // 有效开始时间
|
||||
ValidEndTime model.LocalTime `json:"valid_end_time"` // 过期时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
Coupon *CouponDto `json:"coupon"` // 优惠卷
|
||||
UserCouponId string `json:"user_coupon_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
CouponId string `json:"coupon_id"` // 优惠券id
|
||||
UserCouponStatus int `json:"user_coupon_status"` // 状态(0:未使用 1:已使用 3:已过期)
|
||||
IsWindows int `json:"is_windows"` // 是否已弹窗(0:否 1:是)
|
||||
CouponUseDate *model.LocalTime `json:"coupon_use_date"` // 使用时间
|
||||
ValidStartTime *model.LocalTime `json:"valid_start_time"` // 有效开始时间
|
||||
ValidEndTime *model.LocalTime `json:"valid_end_time"` // 过期时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
Coupon *CouponDto `json:"coupon"` // 优惠卷
|
||||
}
|
||||
|
||||
// GetUserCouponDto 用户优惠卷详情
|
||||
|
||||
@ -15,7 +15,7 @@ type OrderMember struct {
|
||||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:用户删除状态(0:否 1:是)" json:"is_delete"`
|
||||
PayChannel int `gorm:"column:pay_channel;type:tinyint(1);comment:支付渠道(1:h5支付 2:app支付 3:会员支付);NOT NULL" json:"pay_channel"`
|
||||
PayStatus int `gorm:"column:pay_status;type:tinyint(1);default:1;comment:支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款);NOT NULL" json:"pay_status"`
|
||||
PayTime *time.Time `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||||
PayTime *LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||||
RefundStatus int `gorm:"column:refund_status;type:tinyint(1);default:0;comment:订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款);NOT NULL" json:"refund_status"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(30);comment:系统订单编号;NOT NULL" json:"order_no"`
|
||||
EscrowTradeNo string `gorm:"column:escrow_trade_no;type:varchar(100);comment:第三方支付流水号;NOT NULL" json:"escrow_trade_no"`
|
||||
@ -23,7 +23,7 @@ type OrderMember struct {
|
||||
CouponAmountTotal float64 `gorm:"column:coupon_amount_total;type:decimal(10,2);default:0.00;comment:优惠卷总金额" json:"coupon_amount_total"`
|
||||
PaymentAmountTotal float64 `gorm:"column:payment_amount_total;type:decimal(10,2);default:0.00;comment:实际付款金额" json:"payment_amount_total"`
|
||||
CancelStatus int `gorm:"column:cancel_status;type:tinyint(1);default:0;comment:取消状态(0:否 1:是)" json:"cancel_status"`
|
||||
CancelTime *time.Time `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
||||
CancelTime *LocalTime `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
||||
CancelRemarks string `gorm:"column:cancel_remarks;type:varchar(255);comment:取消订单备注" json:"cancel_remarks"`
|
||||
OrderRemarks string `gorm:"column:order_remarks;type:varchar(255);comment:订单备注" json:"order_remarks"`
|
||||
Model
|
||||
|
||||
@ -15,7 +15,7 @@ type OrderSingle struct {
|
||||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:用户删除状态(0:否 1:是)" json:"is_delete"`
|
||||
PayChannel int `gorm:"column:pay_channel;type:tinyint(1);comment:支付渠道(1:h5支付 2:app支付 3:会员支付);NOT NULL" json:"pay_channel"`
|
||||
PayStatus int `gorm:"column:pay_status;type:tinyint(1);default:1;comment:支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款);NOT NULL" json:"pay_status"`
|
||||
PayTime *time.Time `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||||
PayTime *LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||||
RefundStatus int `gorm:"column:refund_status;type:tinyint(1);default:0;comment:订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款);NOT NULL" json:"refund_status"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(30);comment:系统订单编号;NOT NULL" json:"order_no"`
|
||||
EscrowTradeNo string `gorm:"column:escrow_trade_no;type:varchar(100);comment:第三方支付流水号;NOT NULL" json:"escrow_trade_no"`
|
||||
@ -23,8 +23,9 @@ type OrderSingle struct {
|
||||
CouponAmountTotal float64 `gorm:"column:coupon_amount_total;type:decimal(10,2);default:0.00;comment:优惠卷总金额" json:"coupon_amount_total"`
|
||||
PaymentAmountTotal float64 `gorm:"column:payment_amount_total;type:decimal(10,2);default:0.00;comment:实际付款金额" json:"payment_amount_total"`
|
||||
CancelStatus int `gorm:"column:cancel_status;type:tinyint(1);default:0;comment:取消状态(0:否 1:是)" json:"cancel_status"`
|
||||
CancelTime *time.Time `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
||||
CancelTime *LocalTime `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
||||
CancelRemarks string `gorm:"column:cancel_remarks;type:varchar(255);comment:取消订单备注" json:"cancel_remarks"`
|
||||
ValidDate *LocalTime `gorm:"column:valid_date;type:datetime;comment:到期时间" json:"valid_date"`
|
||||
OrderRemarks string `gorm:"column:order_remarks;type:varchar(255);comment:订单备注" json:"order_remarks"`
|
||||
Answer string `gorm:"column:answer;type:varchar(500);comment:算一算答案" json:"answer"`
|
||||
Model
|
||||
|
||||
@ -12,7 +12,7 @@ type SystemMember struct {
|
||||
MemberDays uint `gorm:"column:member_days;type:int(10) unsigned;default:0;comment:会员天数" json:"member_days"`
|
||||
Price float64 `gorm:"column:price;type:decimal(10,2);default:0.00;comment:价格(原价)" json:"price"`
|
||||
DiscountPrice *float64 `gorm:"column:discount_price;type:decimal(10,2);comment:优惠价格" json:"discount_price"`
|
||||
DiscountEndTime *time.Time `gorm:"column:discount_end_time;type:datetime;comment:优惠截止时间" json:"discount_end_time"`
|
||||
DiscountEndTime *LocalTime `gorm:"column:discount_end_time;type:datetime;comment:优惠截止时间" json:"discount_end_time"`
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
@ -19,8 +19,8 @@ type User struct {
|
||||
Sex int `gorm:"column:sex;type:tinyint(1) unsigned;default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
|
||||
IsMember int `gorm:"column:is_member;type:tinyint(1);default:0;comment:是否会员(0:否 1:是)" json:"is_member"`
|
||||
MemberExpireDate *time.Time `gorm:"column:member_expire_date;type:datetime;comment:会员到期时间(非会员时为null)" json:"member_expire_date"`
|
||||
LoginAt LocalTime `gorm:"column:login_at;type:datetime;comment:登陆时间" json:"login_at"`
|
||||
MemberExpireDate *LocalTime `gorm:"column:member_expire_date;type:datetime;comment:会员到期时间(非会员时为null)" json:"member_expire_date"`
|
||||
LoginAt *LocalTime `gorm:"column:login_at;type:datetime;comment:登陆时间" json:"login_at"`
|
||||
LoginIp string `gorm:"column:login_ip;type:varchar(255);comment:登陆ip" json:"login_ip"`
|
||||
Model
|
||||
}
|
||||
|
||||
@ -7,14 +7,14 @@ import (
|
||||
)
|
||||
|
||||
type UserCoupon struct {
|
||||
UserCouponId int64 `gorm:"column:user_coupon_id;type:bigint(19);primary_key;comment:主键id" json:"user_coupon_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||
CouponId int64 `gorm:"column:coupon_id;type:bigint(19);comment:优惠卷id;NOT NULL" json:"coupon_id"`
|
||||
UserCouponStatus int `gorm:"column:user_coupon_status;type:tinyint(1);default:0;comment:状态(0:未使用 1:已使用 3:已过期)" json:"user_coupon_status"`
|
||||
IsWindows int `gorm:"column:is_windows;type:tinyint(1);default:0;comment:是否已弹窗(0:否 1:是)" json:"is_windows"`
|
||||
CouponUseDate LocalTime `gorm:"column:coupon_use_date;type:datetime;comment:使用时间" json:"coupon_use_date"`
|
||||
ValidStartTime LocalTime `gorm:"column:valid_start_time;type:datetime;comment:有效使用时间" json:"valid_start_time"`
|
||||
ValidEndTime LocalTime `gorm:"column:valid_end_time;type:datetime;comment:过期使用时间" json:"valid_end_time"`
|
||||
UserCouponId int64 `gorm:"column:user_coupon_id;type:bigint(19);primary_key;comment:主键id" json:"user_coupon_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||
CouponId int64 `gorm:"column:coupon_id;type:bigint(19);comment:优惠卷id;NOT NULL" json:"coupon_id"`
|
||||
UserCouponStatus int `gorm:"column:user_coupon_status;type:tinyint(1);default:0;comment:状态(0:未使用 1:已使用 3:已过期)" json:"user_coupon_status"`
|
||||
IsWindows int `gorm:"column:is_windows;type:tinyint(1);default:0;comment:是否已弹窗(0:否 1:是)" json:"is_windows"`
|
||||
CouponUseDate *LocalTime `gorm:"column:coupon_use_date;type:datetime;comment:使用时间" json:"coupon_use_date"`
|
||||
ValidStartTime *LocalTime `gorm:"column:valid_start_time;type:datetime;comment:有效使用时间" json:"valid_start_time"`
|
||||
ValidEndTime *LocalTime `gorm:"column:valid_end_time;type:datetime;comment:过期使用时间" json:"valid_end_time"`
|
||||
Model
|
||||
Coupon *Coupon `gorm:"foreignKey:CouponId;references:coupon_id" json:"coupon"`
|
||||
}
|
||||
|
||||
@ -141,8 +141,8 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 获取问题详情
|
||||
questionGroup.GET("/:question_id", api.Question.GetQuestion)
|
||||
|
||||
// 获取问题购买状态
|
||||
questionGroup.GET("/buy/status/:question_id", api.Question.GetQuestionBuyStatus)
|
||||
// 获取问题解锁状态
|
||||
questionGroup.GET("/unlock/status/:question_id", api.Question.GetQuestionUnlockStatus)
|
||||
|
||||
// 点击次数
|
||||
clickGroup := questionGroup.Group("/click")
|
||||
|
||||
@ -56,7 +56,8 @@ func (r *OrderMemberService) AddOrderMember(tx *gorm.DB, UserId, SystemMemberId
|
||||
if user.IsMember == 1 {
|
||||
now := time.Now()
|
||||
|
||||
diff := user.MemberExpireDate.Sub(now)
|
||||
memberExpireDate := time.Time(*user.MemberExpireDate)
|
||||
diff := memberExpireDate.Sub(now)
|
||||
// 将差值转换为天数
|
||||
diffDays := int(diff.Hours() / 24)
|
||||
totalDays := diffDays + int(systemMember.MemberDays)
|
||||
@ -70,7 +71,7 @@ func (r *OrderMemberService) AddOrderMember(tx *gorm.DB, UserId, SystemMemberId
|
||||
var paymentAmountTotal float64 // 实际付款金额
|
||||
var orderStatus int // 订单状态(1:待支付 2:已完成 3:已取消)
|
||||
var payStatus int // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
var payTime *time.Time // 支付时间
|
||||
var payTime *model.LocalTime // 支付时间
|
||||
var escrowTradeNo string // 第三方支付流水号
|
||||
|
||||
// 获取会员购买价格
|
||||
|
||||
@ -59,7 +59,7 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
|
||||
var paymentAmountTotal float64 // 实际付款金额
|
||||
var orderStatus int // 订单状态(1:待支付 2:已完成 3:已取消)
|
||||
var payStatus int // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
var payTime *time.Time // 支付时间
|
||||
var payTime *model.LocalTime // 支付时间
|
||||
var escrowTradeNo string // 第三方支付流水号
|
||||
|
||||
// 获取问题最终价格
|
||||
@ -98,7 +98,7 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
|
||||
orderStatus = 2 // 订单状态(1:待支付 2:已完成 3:已取消)
|
||||
payStatus = 2 // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
|
||||
now := time.Now()
|
||||
now := model.LocalTime(time.Now())
|
||||
payTime = &now // 支付时间
|
||||
|
||||
escrowTradeNo = "GD" + global.Snowflake.Generate().String() // 第三方支付流水号
|
||||
|
||||
@ -66,7 +66,8 @@ func (r *UserService) CheckUserMember(user *model.User) bool {
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
if user.MemberExpireDate.Before(now) {
|
||||
t := time.Time(*user.MemberExpireDate)
|
||||
if t.Before(now) {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -109,7 +110,8 @@ func (r *UserService) AddUserMemberValidDate(tx *gorm.DB, user *model.User, d in
|
||||
if user.MemberExpireDate == nil {
|
||||
userData["is_member"] = time.Now().Format("2006-01-02 15:04:05")
|
||||
} else {
|
||||
userData["is_member"] = user.MemberExpireDate.Add(time.Duration(d) * 24 * time.Hour)
|
||||
t := time.Time(*user.MemberExpireDate)
|
||||
userData["is_member"] = t.Add(time.Duration(d) * 24 * time.Hour)
|
||||
}
|
||||
|
||||
userDao := dao.UserDao{}
|
||||
|
||||
@ -26,7 +26,7 @@ func (r *UserCouponService) CheckUserCoupon(m *model.UserCoupon, id int64, order
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
validEndTime := time.Time(m.ValidEndTime)
|
||||
validEndTime := time.Time(*m.ValidEndTime)
|
||||
if validEndTime.Before(now) {
|
||||
return false, errors.New("优惠卷已过期,无法使用")
|
||||
}
|
||||
@ -101,7 +101,7 @@ func (r *UserCouponService) ReturnUserCoupon(tx *gorm.DB, userCouponId int64) bo
|
||||
|
||||
// 检测优惠卷过期时间。判断是否需要退还
|
||||
now := time.Now()
|
||||
validEndTime := time.Time(userCoupon.ValidEndTime)
|
||||
validEndTime := time.Time(*userCoupon.ValidEndTime)
|
||||
if validEndTime.Before(now) {
|
||||
userCouponData["user_coupon_status"] = 3
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user