增加了微信支付

This commit is contained in:
2024-07-25 14:39:57 +08:00
parent 8c84ed3656
commit a525a67a01
29 changed files with 1173 additions and 149 deletions
+32 -3
View File
@@ -2,10 +2,13 @@ package dto
import (
"fmt"
"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 订单-单项
// OrderMemberDto 订单-会员
type OrderMemberDto struct {
OrderId string `json:"order_id"` // 主键id
UserId string `json:"user_id"` // 用户id
@@ -14,7 +17,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 model.LocalTime `json:"pay_time"` // 支付时间
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"` // 第三方支付流水号
@@ -22,7 +25,7 @@ type OrderMemberDto struct {
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"` // 订单取消时间
CancelTime *time.Time `json:"cancel_time"` // 订单取消时间
CancelRemarks string `json:"cancel_remarks"` // 取消订单备注
OrderRemarks string `json:"order_remarks"` // 订单备注
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
@@ -30,6 +33,19 @@ type OrderMemberDto struct {
SystemMember *SystemMemberDto `json:"system_member"` // 会员
}
// OrderMemberPayDto 会员订单支付数据
type OrderMemberPayDto struct {
OrderId string `json:"order_id"` // 主键id
SystemMemberId string `json:"system_member_id"` // 会员id
OrderNo string `json:"order_no"` // 系统订单编号
AmountTotal float64 `json:"amount_total"` // 订单金额
CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
PrepayJsapi *jsapi.PrepayWithRequestPaymentResponse `json:"prepay_jsapi"` // 预支付交易数据-jsapi
PrepayApp *app.PrepayWithRequestPaymentResponse `json:"prepay_app"` // 预支付交易数据-app
}
// GetOrderMemberListDto 列表
func GetOrderMemberListDto(m []*model.OrderMember) []*OrderMemberDto {
// 处理返回值
@@ -73,6 +89,19 @@ func GetOrderMemberListDto(m []*model.OrderMember) []*OrderMemberDto {
return responses
}
// GetOrderMemberPayDto 获取单项订单支付数据
func GetOrderMemberPayDto(m *model.OrderMember) *OrderMemberPayDto {
return &OrderMemberPayDto{
OrderId: fmt.Sprintf("%d", m.OrderId),
SystemMemberId: fmt.Sprintf("%d", m.SystemMemberId),
OrderNo: m.OrderNo,
AmountTotal: m.AmountTotal,
CouponAmountTotal: m.CouponAmountTotal,
PaymentAmountTotal: m.PaymentAmountTotal,
CreatedAt: m.CreatedAt,
}
}
// LoadSystemMember 加载会员数据
func (r *OrderMemberDto) LoadSystemMember(m *model.SystemMember) *OrderMemberDto {
if m != nil {
+4
View File
@@ -3,6 +3,7 @@ package dto
import (
"fmt"
"hepa-calc-api/api/model"
"time"
)
// QuestionDto 问题表
@@ -19,6 +20,7 @@ type QuestionDto struct {
PayCount int `json:"pay_count"` // 支付次数(查看报告的人次)
Price float64 `json:"price"` // 价格(原价)
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
DiscountEndTime *time.Time `json:"discount_end_time"` // 优惠截止时间
QuestionBrief string `json:"question_brief"` // 问题介绍
QuestionExplain string `json:"question_explain"` // 问题解释/科普
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
@@ -43,6 +45,7 @@ func GetQuestionDto(m *model.Question) *QuestionDto {
PayCount: m.PayCount,
Price: m.Price,
DiscountPrice: m.DiscountPrice,
DiscountEndTime: m.DiscountEndTime,
QuestionBrief: m.QuestionBrief,
QuestionExplain: m.QuestionExplain,
CreatedAt: m.CreatedAt,
@@ -70,6 +73,7 @@ func GetQuestionListDto(m []*model.Question) []*QuestionDto {
PayCount: v.PayCount,
Price: v.Price,
DiscountPrice: v.DiscountPrice,
DiscountEndTime: v.DiscountEndTime,
QuestionBrief: v.QuestionBrief,
QuestionExplain: v.QuestionExplain,
CreatedAt: v.CreatedAt,
+22 -21
View File
@@ -3,17 +3,18 @@ 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"` // 优惠价格
FirstTimePrice float64 `json:"first_time_price"` // 首次购买价格
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 *time.Time `json:"discount_end_time"` // 优惠截止时间
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
}
// GetSystemMemberListDto 列表
@@ -24,13 +25,13 @@ func GetSystemMemberListDto(m []*model.SystemMember) []*SystemMemberDto {
if len(m) > 0 {
for i, v := range m {
response := &SystemMemberDto{
SystemMemberId: fmt.Sprintf("%d", v.SystemMemberId),
MemberDays: v.MemberDays,
Price: v.Price,
DiscountPrice: v.DiscountPrice,
FirstTimePrice: v.FirstTimePrice,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
SystemMemberId: fmt.Sprintf("%d", v.SystemMemberId),
MemberDays: v.MemberDays,
Price: v.Price,
DiscountPrice: v.DiscountPrice,
DiscountEndTime: v.DiscountEndTime,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
@@ -44,12 +45,12 @@ func GetSystemMemberListDto(m []*model.SystemMember) []*SystemMemberDto {
// GetSystemMemberDto 详情
func GetSystemMemberDto(m *model.SystemMember) *SystemMemberDto {
return &SystemMemberDto{
SystemMemberId: fmt.Sprintf("%d", m.SystemMemberId),
MemberDays: m.MemberDays,
Price: m.Price,
DiscountPrice: m.DiscountPrice,
FirstTimePrice: m.FirstTimePrice,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
SystemMemberId: fmt.Sprintf("%d", m.SystemMemberId),
MemberDays: m.MemberDays,
Price: m.Price,
DiscountPrice: m.DiscountPrice,
DiscountEndTime: m.DiscountEndTime,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}