v1.1.0 新增通知、暂时性2折
This commit is contained in:
@@ -8,12 +8,14 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"math"
|
||||
"qnc-server/app/user/cmd/api/internal/svc"
|
||||
"qnc-server/app/user/cmd/api/internal/types"
|
||||
"qnc-server/app/user/model"
|
||||
"qnc-server/common/ctxdata"
|
||||
"qnc-server/common/xerr"
|
||||
"qnc-server/pkg/lzkit/crypto"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PaymentLogic struct {
|
||||
@@ -70,10 +72,29 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成订单, 获取用户信息失败: %+v", err)
|
||||
}
|
||||
|
||||
currentTime := time.Now()
|
||||
|
||||
var mhour int
|
||||
if user.Inside == 1 {
|
||||
amount = 0.01
|
||||
mhour = 0
|
||||
} else {
|
||||
amount = product.SellPrice
|
||||
mhour = 12
|
||||
}
|
||||
// 设置时间范围:2025年1月1日中午12点到2025年1月2日中午12点
|
||||
startTime := time.Date(2025, 1, 1, mhour, 0, 0, 0, time.Local)
|
||||
endTime := time.Date(2025, 1, 2, 12, 0, 0, 0, time.Local)
|
||||
|
||||
if currentTime.After(startTime) && currentTime.Before(endTime) {
|
||||
// 打两折
|
||||
amount = product.SellPrice * 0.2
|
||||
amount = math.Round(amount*100) / 100
|
||||
} else {
|
||||
if user.Inside == 1 {
|
||||
amount = 0.01
|
||||
} else {
|
||||
amount = product.SellPrice
|
||||
}
|
||||
}
|
||||
var createOrderErr error
|
||||
if req.PayMethod == "wechatpay" {
|
||||
|
||||
Reference in New Issue
Block a user