fix:购物车下单

This commit is contained in:
momo
2023-09-21 10:30:36 +08:00
parent 137919a4d7
commit 4f61702e14
9 changed files with 171 additions and 19 deletions

View File

@@ -79,9 +79,32 @@ func GetAmountInfo(req GetAmountInfoReq) gmodel.AmountInfo {
}
}
func GenerateOrderNumber(deliveryMethod int, userID int) string {
type GetAmountCurrencyUSDReq struct {
ExchangeRate int64 `json:"exchange_rate"` // 换算汇率
CurrentAmount int64 `json:"current_amount"` // 当前金额
OriginalAmount int64 `json:"original_amount"` // 原始金额
CurrentCurrency string `json:"current_currency"` // 当前货币
OriginalCurrency string `json:"original_currency"` // 原始货币
}
type GetAmountCurrencyUSDRes struct {
ExchangeRate string `json:"exchange_rate"` // 换算汇率
CurrentAmount string `json:"current_amount"` // 当前金额
OriginalAmount string `json:"original_amount"` // 原始金额
CurrentCurrency string `json:"current_currency"` // 当前货币
OriginalCurrency string `json:"original_currency"` // 原始货币
}
// 处理金额(美元)
func GetAmountCurrencyUSD(req *GetAmountCurrencyUSDReq) (res GetAmountCurrencyUSDRes) {
return GetAmountCurrencyUSDRes{
ExchangeRate: fmt.Sprintf("%.2f", float64(req.ExchangeRate)/1000),
}
}
func GenerateOrderNumber() string {
t := time.Now()
orderNumber := fmt.Sprintf("%d%02d%02d%d", t.Year(), t.Month(), t.Day(), t.Nanosecond())
orderNumber := fmt.Sprintf("%d%02d%02d%08d", t.Year(), t.Month(), t.Day(), t.UnixNano()%100000000)
fmt.Println(orderNumber)
return orderNumber
}