fix:合并
This commit is contained in:
@@ -99,6 +99,13 @@ var (
|
||||
|
||||
CodeLogoCombineErr = &StatusResponse{5115, "logo combine fail"} // 合图失败
|
||||
CodeLogoCombineNoFoundErr = &StatusResponse{5116, "template record not found"} // 模版不存在
|
||||
|
||||
CodeErrOrder = &StatusResponse{5300, "ocreate order failed"} // 订单错误
|
||||
CodeErrOrderCreatShoppingCartEmpty = &StatusResponse{5301, "ocreate order failed, shopping cart is empty"} // 订单创建失败,购物车为空
|
||||
CodeErrOrderCreatShoppingCartNotMatched = &StatusResponse{5302, "ocreate order failed, shopping cart not matched"} // 订单创建失败,购物车不相符
|
||||
CodeErrOrderCreatProductAbsent = &StatusResponse{5303, "ocreate order failed, product is absent"} // 订单创建失败,商品不存在
|
||||
CodeErrOrderCreatProductPriceAbsent = &StatusResponse{5304, "ocreate order failed, price of product is absent"} // 订单创建失败,商品价格不存在
|
||||
CodeErrOrderCreatProductAccessoryAbsent = &StatusResponse{5305, "ocreate order failed, accessory of product is absent"} // 订单创建失败,商品配件不存在
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1 +1,25 @@
|
||||
package order
|
||||
|
||||
import (
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetAmountCurrency(req *gmodel.AmountCurrency) (*float64, error) {
|
||||
if req.CurrentCurrency == req.OriginalCurrency {
|
||||
req.CurrentAmount = req.OriginalAmount
|
||||
} else {
|
||||
f1, err1 := strconv.ParseFloat(string(req.OriginalAmount), 64)
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
}
|
||||
f2, err2 := strconv.ParseFloat(string(req.OriginalAmount), 64)
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
result := f1 * f2
|
||||
req.CurrentAmount = constants.AmountUnit(strconv.FormatFloat(result, 'f', -1, 64))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user