Merge branch 'feature/mhw-v1.01' of gitee.com:fusenpack/fusenapi into feature/mhw-v1.01
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 美分转美元
|
||||
func CentoDollar(price int64) float64 {
|
||||
str := fmt.Sprintf("%.2f", float64(price)/float64(100))
|
||||
// 厘转美元
|
||||
func CentitoDollar(price int64) float64 {
|
||||
str := fmt.Sprintf("%.3f", float64(price)/float64(1000))
|
||||
dollar, _ := strconv.ParseFloat(str, 64)
|
||||
return dollar
|
||||
}
|
||||
|
||||
@@ -21,14 +21,16 @@ type ModelInfo struct {
|
||||
}
|
||||
type FittingInfo struct {
|
||||
FittingJson string `json:"fitting_json"` //配件设计json数据
|
||||
FittingName string `json:"fitting_name"` //配件名称
|
||||
}
|
||||
type TemplateInfo struct {
|
||||
TemplateJson string `json:"template_json"` //模板设计json数据
|
||||
TemplateTag string `json:"template_tag"` //模板标签
|
||||
}
|
||||
type SizeInfo struct {
|
||||
Inch string `json:"inch"`
|
||||
Cm string `json:"cm"`
|
||||
Inch string `json:"inch"`
|
||||
Cm string `json:"cm"`
|
||||
Capacity string `json:"capacity"`
|
||||
}
|
||||
type UserDiyInformation struct {
|
||||
Phone string `json:"phone"` //电话
|
||||
|
||||
@@ -14,21 +14,28 @@ type VerifyShoppingCartSnapshotDataChangeReq struct {
|
||||
MapModel map[int64]gmodel.FsProductModel3d //模型跟配件都在
|
||||
MapTemplate map[int64]gmodel.FsProductTemplateV2
|
||||
MapCartChange map[int64]string
|
||||
MapSnapshot map[int64]CartSnapshot
|
||||
MapProduct map[int64]struct{}
|
||||
}
|
||||
|
||||
func VerifyShoppingCartSnapshotDataChange(req VerifyShoppingCartSnapshotDataChangeReq) error {
|
||||
for _, cartInfo := range req.Carts {
|
||||
descrptionBuilder := strings.Builder{}
|
||||
//产品下架/删除
|
||||
if _, ok := req.MapProduct[*cartInfo.ProductId]; !ok {
|
||||
descrptionBuilder.WriteString("<p>the product is off shelf or deleted </p>")
|
||||
}
|
||||
var snapShotParseInfo CartSnapshot
|
||||
if err := json.Unmarshal([]byte(*cartInfo.Snapshot), &snapShotParseInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
req.MapSnapshot[cartInfo.Id] = snapShotParseInfo
|
||||
//快照中模板设计json数据哈希值
|
||||
snapshotTemplateJsonHash := hash.JsonHashKey(snapShotParseInfo.TemplateInfo.TemplateJson)
|
||||
//快照中模型设计json数据哈希值
|
||||
snapshotModelJsonHash := hash.JsonHashKey(snapShotParseInfo.ModelInfo.ModelJson)
|
||||
//快照中配件设计json数据哈希值
|
||||
snapshotFittingJsonHash := hash.JsonHashKey(snapShotParseInfo.FittingInfo.FittingJson)
|
||||
descrptionBuilder := strings.Builder{}
|
||||
//有模板验证模板相关
|
||||
if *cartInfo.TemplateId > 0 {
|
||||
if curTemplateInfo, ok := req.MapTemplate[*cartInfo.TemplateId]; !ok {
|
||||
|
||||
@@ -3,20 +3,20 @@ package step_price
|
||||
// 返回美元
|
||||
func GetStepPrice(minBuyNum int, stepNum []int, stepPrice []int) float64 {
|
||||
if minBuyNum > stepNum[len(stepNum)-1] {
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
|
||||
}
|
||||
for k, v := range stepNum {
|
||||
if minBuyNum <= v {
|
||||
if k <= (len(stepPrice) - 1) {
|
||||
return float64(stepPrice[k]) / float64(100)
|
||||
return float64(stepPrice[k]) / float64(1000)
|
||||
}
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
|
||||
}
|
||||
}
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
|
||||
}
|
||||
|
||||
// 返回美分
|
||||
// 返回厘
|
||||
func GetCentStepPrice(minBuyNum int, stepNum []int, stepPrice []int) int64 {
|
||||
if minBuyNum > stepNum[len(stepNum)-1] {
|
||||
return int64(stepPrice[len(stepPrice)-1])
|
||||
|
||||
Reference in New Issue
Block a user