Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ef417273
authored
Mar 20, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
浮点数计算
parent
34399331
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
pkg/common/function.go
service/service_ly_common.go
pkg/common/function.go
View file @
ef417273
...
...
@@ -9,10 +9,6 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/pkg/config"
"go_sku_server/pkg/vars"
"math"
...
...
@@ -24,6 +20,12 @@ import (
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv"
"github.com/shopspring/decimal"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
)
/*
...
...
@@ -601,3 +603,9 @@ func MyRound(x float64, wei int) float64 {
}
////////////类型转换/////////////////////
//浮点数乘法
func
MulFloat
(
x
float64
,
y
float64
)
float64
{
result
,
_
:=
decimal
.
NewFromFloat
(
x
)
.
Mul
(
decimal
.
NewFromFloat
(
y
))
.
Float64
()
return
result
}
service/service_ly_common.go
View file @
ef417273
...
...
@@ -420,7 +420,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
!
hasCoefficient
{
coefficient
=
defaultCoefficient
}
fmt
.
Println
(
"供应商系数 : "
,
coefficient
)
//下面是计算价格
...
...
@@ -445,9 +444,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
//美金成本价
priceCostUs
:=
common
.
MyRound
(
price
.
PriceUs
*
usDiscountRatio
,
4
)
priceCostUs
:=
common
.
MulFloat
(
price
.
PriceUs
,
usDiscountRatio
)
fmt
.
Println
(
priceCostUs
)
priceCostUs
=
common
.
MyRound
(
priceCostUs
,
4
)
//美金售价
priceUs
:=
priceCostUs
*
priceRatio
.
RatioUsd
priceUs
:=
common
.
MulFloat
(
priceCostUs
,
priceRatio
.
RatioUsd
)
// priceUs := priceCostUs * priceRatio.RatioUsd
fmt
.
Println
(
priceUs
)
//人民币成本价
priceCostCn
:=
common
.
MyRound
(
price
.
PriceUs
*
coefficient
.
Ratio
*
cnDiscountRatio
*
tax
,
4
)
//人民币售价
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment