fix
This commit is contained in:
parent
2830ea8724
commit
bde9e98f62
|
@ -22,7 +22,7 @@ func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (r
|
|||
func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (result *FsAddress, err error) {
|
||||
|
||||
err = a.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
// now := time.Now().Unix()
|
||||
// now := time.Now().UTC().Unix()
|
||||
result = &FsAddress{
|
||||
UserId: address.UserId,
|
||||
Name: address.Name,
|
||||
|
|
|
@ -39,7 +39,7 @@ func (p *FsCloudPickUpModel) GetCloudPickUpByIDAndUserID(ctx context.Context, us
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctime := time.Now().Unix()
|
||||
ctime := time.Now().UTC().Unix()
|
||||
cs.Ctime = &ctime
|
||||
if constants.ConcactService(*cs.Type) == constants.TYPE_DEFAULT {
|
||||
*cs.RelationId = 0
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
func (m *FsGuestModel) GenerateGuestID(ctx context.Context, AccessSecret uint64) (authKey string, err error) {
|
||||
|
||||
err = m.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
var record = &FsGuest{}
|
||||
tx.Create(record)
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ func (o *FsOrderModel) FindOneAndCreateServiceContact(ctx context.Context, userI
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctime := time.Now().Unix()
|
||||
ctime := time.Now().UTC().Unix()
|
||||
cs.Ctime = &ctime
|
||||
if constants.ConcactService(*cs.Type) == constants.TYPE_DEFAULT {
|
||||
*cs.RelationId = 0
|
||||
|
|
|
@ -87,7 +87,7 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
|
|||
if err != nil {
|
||||
// 没有找到在数据库就创建注册
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
createAt := time.Now().Unix()
|
||||
createAt := time.Now().UTC().Unix()
|
||||
user.Email = &token.Email
|
||||
user.CreatedAt = &createAt
|
||||
user.GoogleId = &token.Id
|
||||
|
@ -129,7 +129,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
if err != nil {
|
||||
// 没有找到在数据库就创建注册
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
createAt := time.Now().Unix()
|
||||
createAt := time.Now().UTC().Unix()
|
||||
user.Email = &token.Email
|
||||
user.CreatedAt = &createAt
|
||||
user.PasswordHash = &token.Password
|
||||
|
|
|
@ -112,7 +112,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us
|
|||
|
||||
l.isRegistered = true
|
||||
// 如果密码匹配,则生成 JWT Token。
|
||||
jwtToken, err := auth.GenerateJwtTokenUint64(auth.StringToHash(*user.PasswordHash), l.svcCtx.Config.Auth.AccessExpire, time.Now().Unix(), user.Id, 0)
|
||||
jwtToken, err := auth.GenerateJwtTokenUint64(auth.StringToHash(*user.PasswordHash), l.svcCtx.Config.Auth.AccessExpire, time.Now().UTC().Unix(), user.Id, 0)
|
||||
|
||||
// 如果生成 JWT Token 失败,则抛出错误并返回未认证的状态码。
|
||||
if err != nil {
|
||||
|
|
|
@ -3,6 +3,7 @@ package logic
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"net/http"
|
||||
|
@ -67,8 +68,8 @@ func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin, userinfo *auth.U
|
|||
}
|
||||
|
||||
// 如果密码匹配,则生成 JWT Token。
|
||||
nowSec := time.Now().Unix()
|
||||
us, err := l.svcCtx.SharedState.GetUserState(user.Id)
|
||||
nowSec := time.Now().UTC().Unix()
|
||||
us, err := shared.GetUserState(user.Id, l.svcCtx.MysqlConn)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeSharedStateErr)
|
||||
|
|
|
@ -46,7 +46,7 @@ func (l *BackendUserLoginLogic) BackendUserLogin(req *types.RequestUserLogin) (r
|
|||
}
|
||||
|
||||
// 如果密码匹配,则生成 JWT Token。
|
||||
nowSec := time.Now().Unix()
|
||||
nowSec := time.Now().UTC().Unix()
|
||||
jwtToken, err = auth.GenerateBackendJwtToken(&l.svcCtx.Config.Auth.AccessSecret, l.svcCtx.Config.Auth.AccessExpire, nowSec, user.Id, 0)
|
||||
|
||||
// 如果生成 JWT Token 失败,则抛出错误并返回未认证的状态码。
|
||||
|
|
|
@ -5,9 +5,10 @@ import (
|
|||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"fusenapi/server/canteen/internal/svc"
|
||||
"fusenapi/server/canteen/internal/types"
|
||||
|
||||
|
@ -57,7 +58,7 @@ func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCant
|
|||
for _, v := range productSizeList {
|
||||
mapProductSize[v.Id] = v
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
//开启事务
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
canteenProductModel = gmodel.NewFsCanteenProductModel(tx)
|
||||
|
|
|
@ -107,7 +107,7 @@ func (l *UserAgainOrderLogic) UserAgainOrder(req *types.UserAgainOrderReq, useri
|
|||
}
|
||||
cartInfo, err := cartModel.FindOneCartByParams(l.ctx, cartReq)
|
||||
if err == nil && (err != nil && errors.Is(err, gorm.ErrRecordNotFound)) {
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
nowTime := time.Now()
|
||||
data := gmodel.FsCart{
|
||||
UserId: &userinfo.UserId,
|
||||
|
|
|
@ -94,7 +94,7 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
|||
|
||||
var (
|
||||
IsRefund int64 = 0
|
||||
CreatedAt = time.Now().Unix()
|
||||
CreatedAt = time.Now().UTC().Unix()
|
||||
)
|
||||
|
||||
refund := &gmodel.FsRefundReason{
|
||||
|
|
|
@ -61,7 +61,7 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us
|
|||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "the order status not cancle")
|
||||
}
|
||||
|
||||
var cancelTime int64 = time.Now().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
||||
var cancelTime int64 = time.Now().UTC().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
||||
// 第一次支付成功后48小时后不能进行取消操作
|
||||
if *orderInfo.IsPayCompleted == 1 && cancelTime > 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "The current order cannot be cancelled")
|
||||
|
@ -73,7 +73,7 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us
|
|||
orderInfo.RefundReasonId = &req.RefundReasonId
|
||||
orderInfo.RefundReason = &req.RefundReason
|
||||
|
||||
var nowTime = time.Now().Unix()
|
||||
var nowTime = time.Now().UTC().Unix()
|
||||
var payList []handlers.PayInfo
|
||||
// 事务处理
|
||||
ctx := l.ctx
|
||||
|
|
|
@ -158,7 +158,7 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||
|
||||
//如果是部分支付状态,那么取消订单倒计时2天
|
||||
if *item.Status == int64(constants.STATUS_NEW_PART_PAY) {
|
||||
surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().Unix()
|
||||
surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().UTC().Unix()
|
||||
if surplusAt < 0 {
|
||||
surplusAt = 0
|
||||
}
|
||||
|
|
|
@ -9,11 +9,12 @@ import (
|
|||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/id_generator"
|
||||
"fusenapi/utils/step_price"
|
||||
"gorm.io/gorm"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/inventory/internal/svc"
|
||||
|
@ -106,7 +107,7 @@ func (l *SupplementLogic) Supplement(req *types.SupplementReq, userinfo *auth.Us
|
|||
amount := step_price.GetCentStepPrice(int(minByNum), stepNum, stepPrice) + optionalPrice
|
||||
totalAmount := amount * req.Num
|
||||
newOrderSn := id_generator.GenSnNum()
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
deliveryMethod := int64(constants.DELIVERY_METHOD_CLOUD)
|
||||
isSup := int64(1)
|
||||
//生成雪花id
|
||||
|
|
|
@ -11,10 +11,12 @@ import (
|
|||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/id_generator"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"fusenapi/server/inventory/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
|
@ -60,7 +62,7 @@ func (l *TakeLogic) Take(req *types.TakeReq, userinfo *auth.UserInfo) (resp *bas
|
|||
addressInfoJson := string(addressInfoBytes)
|
||||
trackNum := id_generator.GenSnNum()
|
||||
status := int64(constants.STATUS_ORDERD)
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
pickUpData := gmodel.FsCloudPickUp{
|
||||
UserId: &userinfo.UserId,
|
||||
TrackNum: &trackNum,
|
||||
|
|
|
@ -62,7 +62,7 @@ func (l *SaveMapLibraryLogic) SaveMapLibrary(req *types.Request, userinfo *auth.
|
|||
}
|
||||
sort := int64(0)
|
||||
status := int64(1)
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
createList := make([]gmodel.FsMapLibrary, 0, len(postData))
|
||||
updateList := make([]gmodel.FsMapLibrary, 0, len(postData))
|
||||
//开启事务
|
||||
|
|
|
@ -84,7 +84,7 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte
|
|||
}
|
||||
|
||||
// 判断订单状态以及该支付金额
|
||||
var nowAt int64 = time.Now().Unix()
|
||||
var nowAt int64 = time.Now().UTC().Unix()
|
||||
var payAmount int64
|
||||
if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
payAmount = *orderInfo.TotalAmount / 2
|
||||
|
|
|
@ -66,7 +66,7 @@ func (l *StripeWebhookLogic) StripeWebhook(req *types.StripeWebhookReq, userinfo
|
|||
|
||||
// 新增支付回调事件日志
|
||||
var payMethod = int64(constants.PAYMETHOD_STRIPE)
|
||||
var nowTime = time.Now().Unix()
|
||||
var nowTime = time.Now().UTC().Unix()
|
||||
var eventData = string(event.Data.Raw)
|
||||
var fsPayEvent = &gmodel.FsPayEvent{
|
||||
PayMethod: &payMethod,
|
||||
|
@ -279,7 +279,7 @@ func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe.
|
|||
}
|
||||
}
|
||||
|
||||
var nowTime int64 = time.Now().Unix()
|
||||
var nowTime int64 = time.Now().UTC().Unix()
|
||||
|
||||
// 支付成功
|
||||
if paymentIntent.Status == "succeeded" {
|
||||
|
|
|
@ -7,10 +7,11 @@ import (
|
|||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/product-model/internal/svc"
|
||||
|
@ -56,7 +57,7 @@ func (l *UpdateProductModelLogic) UpdateProductModel(req *types.UpdateProductMod
|
|||
tx := l.svcCtx.MysqlConn.Begin()
|
||||
lightModel := gmodel.NewFsProductModel3dLightModel(tx)
|
||||
productModel3dModel := gmodel.NewFsProductModel3dModel(tx)
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
if req.LightData.Id > 0 { //更新
|
||||
modelLightSaveData.Id = req.LightData.Id
|
||||
err = lightModel.Update(l.ctx, req.LightData.Id, &modelLightSaveData)
|
||||
|
|
|
@ -35,7 +35,7 @@ func (l *AddBaseMapLogic) AddBaseMap(req *types.AddBaseMapReq, userInfo *auth.Ba
|
|||
if req.Name == "" || req.Url == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param is empty")
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
err := l.svcCtx.AllModels.FsProductTemplateBasemap.Create(l.ctx, &gmodel.FsProductTemplateBasemap{
|
||||
Name: &req.Name,
|
||||
Url: &req.Url,
|
||||
|
|
|
@ -134,7 +134,7 @@ func (l *DesignGatherLogic) DesignGather(req *types.DesignGatherReq, userinfo *a
|
|||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to generate design sn")
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
err = l.svcCtx.AllModels.FsProductDesignGather.Create(l.ctx, &gmodel.FsProductDesignGather{
|
||||
Sn: &designSn,
|
||||
UserId: &userinfo.UserId,
|
||||
|
|
|
@ -101,7 +101,7 @@ func (l *CartAddLogic) CartAdd(req *types.CartAddReq, userinfo *auth.UserInfo) (
|
|||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get cart info")
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
now := time.Now().UTC().Unix()
|
||||
nowTime := time.Now().UTC()
|
||||
data := gmodel.FsCart{
|
||||
UserId: &userinfo.UserId,
|
||||
|
|
|
@ -85,7 +85,7 @@ func (l *CreateOrderLogic) CreateOrder(req *types.CreateOrderReq, userinfo *auth
|
|||
mapModel3d[v.Id] = k
|
||||
}
|
||||
var (
|
||||
now = time.Now().Unix()
|
||||
now = time.Now().UTC().Unix()
|
||||
total int64 //总价
|
||||
)
|
||||
orderSn := id_generator.GenSnNum()
|
||||
|
|
|
@ -184,7 +184,7 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
|||
resultStr = resLogoStandard.Res
|
||||
|
||||
var module = "logo"
|
||||
var nowTime = time.Now().Unix()
|
||||
var nowTime = time.Now().UTC().Unix()
|
||||
// 新增记录
|
||||
userMaterialModel := gmodel.NewFsUserMaterialModel(l.svcCtx.MysqlConn)
|
||||
_, err = userMaterialModel.CreateOrUpdate(l.ctx, &gmodel.FsUserMaterial{
|
||||
|
|
|
@ -141,7 +141,7 @@ func BenchmarkJWT(b *testing.B) {
|
|||
|
||||
for i := 0; i < b.N; i++ {
|
||||
claims := &jwt.StandardClaims{
|
||||
ExpiresAt: time.Now().Unix() + 1020213021,
|
||||
ExpiresAt: time.Now().UTC().Unix() + 1020213021,
|
||||
Issuer: "test",
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ package basic
|
|||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fusenapi/utils/auth"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRequestParse(t *testing.T) {
|
||||
|
@ -17,7 +17,9 @@ func TestHash(t *testing.T) {
|
|||
a := "fs12345678"
|
||||
h := sha256.New()
|
||||
h.Write([]byte(a))
|
||||
s := base64.RawURLEncoding.EncodeToString(h.Sum(nil))
|
||||
s := "5JlPincPavgw0X/Fmj15xLId5vOEtdarc6hR1XlBx80="
|
||||
|
||||
log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 421231233, time.Now().UTC().Unix(), 39, 0))
|
||||
key := auth.StringToHash(s)
|
||||
log.Println(key)
|
||||
// log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 400000000, time.Now().UTC().Unix(), 39, 0))
|
||||
|
|
Loading…
Reference in New Issue
Block a user