fix
This commit is contained in:
parent
5db1f3f09d
commit
584cb5d531
|
@ -129,8 +129,8 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
}
|
||||
calculateResultList = append(calculateResultList, types.CalculateResultItem{
|
||||
CartId: cart.Id,
|
||||
ItemPrice: fmt.Sprintf("%.3f", format.CentitoDollar(itemPrice)),
|
||||
TotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(totalPrice)),
|
||||
ItemPrice: format.CentitoDollar(itemPrice, 3),
|
||||
TotalPrice: format.CentitoDollar(totalPrice, 2),
|
||||
})
|
||||
updData := &gmodel.FsShoppingCart{
|
||||
PurchaseQuantity: &reqPurchaseQuantity,
|
||||
|
@ -152,7 +152,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, err.Error())
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.CalculateCartPriceRsp{
|
||||
SubTotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(subTotalPrice)),
|
||||
SubTotalPrice: format.CentitoDollar(subTotalPrice, 2),
|
||||
CalculateResultList: calculateResultList,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -173,8 +173,8 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
|||
FittingId: *cart.FittingId,
|
||||
FittingName: fittingName,
|
||||
},
|
||||
ItemPrice: fmt.Sprintf("%.3f", format.CentitoDollar(itemPrice)),
|
||||
TotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(totalPrice)),
|
||||
ItemPrice: format.CentitoDollar(itemPrice, 3),
|
||||
TotalPrice: format.CentitoDollar(totalPrice, 2),
|
||||
DiyInformation: types.DiyInformation{
|
||||
Phone: snapShot.UserDiyInformation.Phone,
|
||||
Address: snapShot.UserDiyInformation.Address,
|
||||
|
|
|
@ -2,19 +2,15 @@ package format
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 厘转美元
|
||||
func CentitoDollar(price int64, remainFloatPoint ...uint) float64 {
|
||||
s := "%.3f"
|
||||
func CentitoDollar(price int64, remainFloatPoint ...uint) string {
|
||||
s := "%0.3f"
|
||||
if len(remainFloatPoint) > 0 {
|
||||
s = fmt.Sprintf("%%.%df", remainFloatPoint[0])
|
||||
s = fmt.Sprintf("%%0.%df", remainFloatPoint[0])
|
||||
}
|
||||
fmt.Println(s)
|
||||
str := fmt.Sprintf(s, float64(price)/float64(1000))
|
||||
dollar, _ := strconv.ParseFloat(str, 64)
|
||||
return dollar
|
||||
return fmt.Sprintf(s, float64(price)/float64(1000))
|
||||
}
|
||||
|
||||
// 厘转美元
|
||||
|
|
Loading…
Reference in New Issue
Block a user