Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
@@ -57,7 +57,7 @@ func hasInvalidPatterns(key string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var checkModuleRe = regexp.MustCompile("[^\\.a-zA-Z_-]")
|
||||
var checkModuleRe = regexp.MustCompile("[^\\.a-zA-Z_\\-0-9]")
|
||||
|
||||
// CheckModuleQuery 检查模块的json查询的格式
|
||||
func CheckModuleQuery(moduleQuery string) bool {
|
||||
|
||||
@@ -2,23 +2,29 @@ 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))
|
||||
}
|
||||
|
||||
// 厘转美元(向下截断,舍弃掉厘)用于计算总价
|
||||
func CentitoDollarWithNoHalfAdjust(price int64, remainFloatPoint ...uint) string {
|
||||
s := "%0.2f"
|
||||
if len(remainFloatPoint) > 0 {
|
||||
s = fmt.Sprintf("%%0.%df", remainFloatPoint[0])
|
||||
}
|
||||
t := price / 10
|
||||
return fmt.Sprintf(s, float64(t)/float64(100))
|
||||
}
|
||||
|
||||
// 厘转美元
|
||||
func CentitoDollarStr(price float64) string {
|
||||
s := "%.2f"
|
||||
s := "%0.2f"
|
||||
return fmt.Sprintf(s, price/float64(1000))
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ func MetadataModulePATCH(tx *gorm.DB, module string, tableStructPointer any, upd
|
||||
if stype.Kind() == reflect.Pointer {
|
||||
stype = stype.Elem()
|
||||
}
|
||||
tname := tx.NamingStrategy.TableName(stype.Name())
|
||||
|
||||
updatesql := `UPDATE %s
|
||||
SET metadata = CASE
|
||||
@@ -80,7 +81,7 @@ func MetadataModulePATCH(tx *gorm.DB, module string, tableStructPointer any, upd
|
||||
args = append(args, metadata, metadata)
|
||||
args = append(args, values...)
|
||||
|
||||
updatesql = fmt.Sprintf(updatesql, tx.NamingStrategy.TableName(stype.Name()), module, WhereKeysCond)
|
||||
updatesql = fmt.Sprintf(updatesql, tname, module, WhereKeysCond)
|
||||
// logx.Error(updatesql)
|
||||
err = tx.Exec(updatesql, args...).Error
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user