fix:合并
This commit is contained in:
@@ -2,13 +2,7 @@ package configs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"strconv"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -27,49 +21,49 @@ type WebSetTimeInfoData struct {
|
||||
}
|
||||
|
||||
func GetOrderTimeConfig(ctx context.Context, db *gorm.DB) (res WebSetTimeInfo, err error) {
|
||||
resData, err := gmodel.NewFsWebSetModel(db).FindValueByKey(ctx, string(constants.WEBSET_TIME_INFO))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
res.ProductDay = int64(constants.ORDER_PRODUCT_DAY)
|
||||
res.FactoryDeliverDay = int64(constants.ORDER_FACTORY_DELIVER_DAY)
|
||||
res.DeliverUpsDay = int64(constants.ORDER_DELIVER_UPS_DAY)
|
||||
res.UpsTransDay = int64(constants.ORDER_UPS_TRANS_DAY)
|
||||
return res, nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
} else {
|
||||
var timeInfo WebSetTimeInfoData
|
||||
err = json.Unmarshal([]byte(*resData.Value), &timeInfo)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
productDay, err := strconv.Atoi(timeInfo.ProductDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
factoryDeliverDay, err := strconv.Atoi(timeInfo.FactoryDeliverDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
deliverUpsDay, err := strconv.Atoi(timeInfo.DeliverUpsDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
upsTransDay, err := strconv.Atoi(timeInfo.UpsTransDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
res.ProductDay = int64(productDay)
|
||||
res.FactoryDeliverDay = int64(factoryDeliverDay)
|
||||
res.DeliverUpsDay = int64(deliverUpsDay)
|
||||
res.UpsTransDay = int64(upsTransDay)
|
||||
}
|
||||
// resData, err := gmodel.NewFsWebSetModel(db).FindValueByKey(ctx, string(constants.WEBSET_TIME_INFO))
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// res.ProductDay = int64(constants.ORDER_PRODUCT_DAY)
|
||||
// res.FactoryDeliverDay = int64(constants.ORDER_FACTORY_DELIVER_DAY)
|
||||
// res.DeliverUpsDay = int64(constants.ORDER_DELIVER_UPS_DAY)
|
||||
// res.UpsTransDay = int64(constants.ORDER_UPS_TRANS_DAY)
|
||||
// return res, nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return res, err
|
||||
// } else {
|
||||
// var timeInfo WebSetTimeInfoData
|
||||
// err = json.Unmarshal([]byte(*resData.Value), &timeInfo)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return res, err
|
||||
// }
|
||||
// productDay, err := strconv.Atoi(timeInfo.ProductDay)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return res, err
|
||||
// }
|
||||
// factoryDeliverDay, err := strconv.Atoi(timeInfo.FactoryDeliverDay)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return res, err
|
||||
// }
|
||||
// deliverUpsDay, err := strconv.Atoi(timeInfo.DeliverUpsDay)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return res, err
|
||||
// }
|
||||
// upsTransDay, err := strconv.Atoi(timeInfo.UpsTransDay)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return res, err
|
||||
// }
|
||||
// res.ProductDay = int64(productDay)
|
||||
// res.FactoryDeliverDay = int64(factoryDeliverDay)
|
||||
// res.DeliverUpsDay = int64(deliverUpsDay)
|
||||
// res.UpsTransDay = int64(upsTransDay)
|
||||
// }
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user