fix
This commit is contained in:
parent
3a2fb3bc5d
commit
9050b4ab0e
|
@ -10,7 +10,7 @@ import (
|
||||||
"fusenapi/server/inventory/internal/types"
|
"fusenapi/server/inventory/internal/types"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/snow_id_generator"
|
"fusenapi/utils/id_generator"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -58,11 +58,7 @@ func (l *TakeLogic) Take(req *types.TakeReq, userinfo *auth.UserInfo) (resp *bas
|
||||||
//提货单总单
|
//提货单总单
|
||||||
addressInfoBytes, _ := json.Marshal(addressInfo)
|
addressInfoBytes, _ := json.Marshal(addressInfo)
|
||||||
addressInfoJson := string(addressInfoBytes)
|
addressInfoJson := string(addressInfoBytes)
|
||||||
trackNum, err := snow_id_generator.GenSnowId()
|
trackNum := id_generator.GenPickUpTrackNum()
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to gen trackNum")
|
|
||||||
}
|
|
||||||
status := int64(constants.STATUS_ORDERD)
|
status := int64(constants.STATUS_ORDERD)
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
pickUpData := gmodel.FsCloudPickUp{
|
pickUpData := gmodel.FsCloudPickUp{
|
||||||
|
@ -73,7 +69,6 @@ func (l *TakeLogic) Take(req *types.TakeReq, userinfo *auth.UserInfo) (resp *bas
|
||||||
Status: &status,
|
Status: &status,
|
||||||
Ctime: &now,
|
Ctime: &now,
|
||||||
}
|
}
|
||||||
//开启事务
|
|
||||||
//箱数验证
|
//箱数验证
|
||||||
boxes := int64(0)
|
boxes := int64(0)
|
||||||
//需要更新的库存信息
|
//需要更新的库存信息
|
||||||
|
@ -121,6 +116,9 @@ func (l *TakeLogic) Take(req *types.TakeReq, userinfo *auth.UserInfo) (resp *bas
|
||||||
Ctime: &now,
|
Ctime: &now,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if boxes < 3 {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "Take out more than three boxes")
|
||||||
|
}
|
||||||
//事务处理数据
|
//事务处理数据
|
||||||
err = l.svcCtx.AllModels.FsCloudPickUp.SavePickUpWithTransaction(l.ctx, &pickUpData, stockUpdateList, pickUpDetailAddList)
|
err = l.svcCtx.AllModels.FsCloudPickUp.SavePickUpWithTransaction(l.ctx, &pickUpData, stockUpdateList, pickUpDetailAddList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
13
utils/id_generator/pickup_track_num.go
Normal file
13
utils/id_generator/pickup_track_num.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package id_generator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GenPickUpTrackNum() string {
|
||||||
|
a := fmt.Sprintf("%s%.8d", time.Now().Format("20060102150405.000"), rand.Intn(1000000))
|
||||||
|
return strings.ReplaceAll(a, ".", "")
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package snow_id_generator
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/bwmarrin/snowflake"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 雪花算法生成id
|
|
||||||
func GenSnowId() (string, error) {
|
|
||||||
node, err := snowflake.NewNode(1)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s%s", time.Now().Format("20060102"), node.Generate().Base58()), nil
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user