tools

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const GET_IP_URL string = `http://whois.pconline.com.cn/ipJson.jsp?json=true&ip=`

Variables

This section is empty.

Functions

func Add

func Add(f1, f2 float64) float64

Add 精确加法

func AliSendSMS

func AliSendSMS(sms SmsInfo, phoneNumber, code string) error

阿里云发送短信

func Bccomp

func Bccomp(a, b float64) int64

func BoolToInt

func BoolToInt(b bool) int64

func ClientIP

func ClientIP(r *http.Request) string

获取客户端ip

func ConcatenatedStringBuilder

func ConcatenatedStringBuilder(str ...string) string

ConcatenatedStringBuilder 高效字符串拼接 strings.Builder 是一个变长的字节缓存区,其内部使用slice来存储字节(buf []byte)

func CreateOrderNo

func CreateOrderNo() string

func Date2Timestamp

func Date2Timestamp(datetime string) int64

纯日期字符串转时间戳(秒)

func DateTime2Timestamp

func DateTime2Timestamp(datetime string) int64

日期时间字符串转时间戳(秒)

func Decimal

func Decimal(value float64) float64

Decimal float64 保留 两位小数

func Div

func Div(f1, f2 float64) float64

Div 精确除法

func Float

func Float(d decimal.Decimal) float64

decimal=>float64

func Float2Float

func Float2Float(num float64, format string) float64

Float2Float float转float64并保留4位精度

func Float64DivInt64

func Float64DivInt64(f1 float64, i2 int64) float64

func Float64MulInt64

func Float64MulInt64(f1 float64, i1 int64) float64

func Float64ToString

func Float64ToString(f float64) string

func FormatSecond

func FormatSecond(seconds int64) (day, hour, minute, second int64)

秒转换为时分秒

func GbkToUtf8

func GbkToUtf8(str []byte) (b []byte, err error)

transform GBK bytes to UTF-8 bytes

func Get

func Get(url string) string

发送GET请求 url: 请求地址 response: 请求返回的内容

func GetActiveStatus

func GetActiveStatus(value int64) map[string]interface{}

GetActiveStatus 获取 活动状态(1生效 0未生效)

func GetAloneGradeEquity

func GetAloneGradeEquity(aloneGradeEquity string) map[string]string

func GetApplyStatus

func GetApplyStatus(value int64) map[string]interface{}

获取 分销商提现申请状态 (10待审核 20审核通过 30驳回 40已打款)

func GetAskCommentStatus

func GetAskCommentStatus(value int64) map[string]interface{}

GetAskCommentStatus 提问评论状态(0=待审核 1=审核通过 2=审核不通过)

func GetAskStatus

func GetAskStatus(value int64) map[string]interface{}

GetAskStatus 提问状态(0=待审核 1=审核通过 2=审核不通过)

func GetBalanceLogScene

func GetBalanceLogScene(value int64) map[string]interface{}

GetBalanceLogScene 余额变动场景(10用户充值 20用户消费 30管理员操作 40订单退款)

func GetBetweenStr

func GetBetweenStr(str, start, end string) string

func GetCityByIp

func GetCityByIp(ipAddr string) string

返回:IP地址所属的城市

func GetColorAttr

func GetColorAttr(value int64) map[string]interface{}

获取优惠券颜色

func GetColorText

func GetColorText(value int64) string

func GetCouponState

func GetCouponState(TotalNum, ReceiveNum, ExpireType, EndTime, isReceive int64) map[string]interface{}

func GetCouponTypeAttr

func GetCouponTypeAttr(value int64) map[string]interface{}

func GetCouponTypeText

func GetCouponTypeText(value int64) string

获取直播状态

func GetDateTime

func GetDateTime(date string) (int64, int64)

通过时间戳获取00:00:00和23.59.59时间戳 例data : 2020-11-11

func GetDeliveryStatus

func GetDeliveryStatus(value int64) map[string]interface{}

获取 DeliveryStatus 发货状态(10未发货 20已发货)

func GetDeliveryStatusText

func GetDeliveryStatusText(value int64) string

func GetDeliveryType

func GetDeliveryType(value int64) map[string]interface{}

获取 deliveryType 配送方式(10快递配送 20上门自提 30无需物流)

func GetIsCheckAttr

func GetIsCheckAttr(value int64) map[string]interface{}

获取is_check中文

func GetJoinStatusAttr

func GetJoinStatusAttr(status, endTime, joinEndTime int64) int64

func GetLiveStatusText

func GetLiveStatusText(value int64) string

func GetLiveStatusTextAttr

func GetLiveStatusTextAttr(value int64) map[string]interface{}

获取优惠券类型

func GetMapKeys

func GetMapKeys(m map[string]string) []string

获取map所有key的方式

func GetMethodAttr

func GetMethodAttr(value int64) map[string]interface{}

func GetMethodText

func GetMethodText(value int64) string

func GetOrderRefundIsAgree

func GetOrderRefundIsAgree(value int64) map[string]interface{}

商家审核状态(0待审核 10已同意 20已拒绝)

func GetOrderRefundPlateStatus

func GetOrderRefundPlateStatus(value int64) map[string]interface{}

10申请平台介入20同意30拒绝

func GetOrderRefundStatus

func GetOrderRefundStatus(value int64) map[string]interface{}

售后单状态(0进行中 10已拒绝 20已完成 30已取消)

func GetOrderRefundType

func GetOrderRefundType(value int64) map[string]interface{}

售后类型(10退货退款 20换货 30退款)

func GetOrderSource

func GetOrderSource(value int64) string

获取 订单来源(10普通 20积分 30拼团 40砍价 50秒杀 60礼包购)

func GetOrderStatus

func GetOrderStatus(value int64) map[string]interface{}

获取 订单状态10=>进行中,20=>已取消,30=>已完成

func GetOrderStatusText

func GetOrderStatusText(value int64) string

func GetOrderType

func GetOrderType(value int64) map[string]interface{}

获取 订单类型(10商城订单)

func GetPayStatus

func GetPayStatus(value int64) map[string]interface{}

获取 付款状态(10未付款 20已付款)

func GetPayStatusText

func GetPayStatusText(value int64) string

func GetPayType

func GetPayType(value int64) map[string]interface{}

获取 支付方式(10余额支付 20微信支付)

func GetPayTypeText

func GetPayTypeText(payType int64) string

func GetProductStatus

func GetProductStatus(value int64) map[string]interface{}

获取product_status

func GetProductStatusText

func GetProductStatusText(value int64) string

func GetRandomCapitalString

func GetRandomCapitalString(l int) string

func GetRandomNumber

func GetRandomNumber() string

生成 6位随机数字验证码

func GetRandomString

func GetRandomString(l int) string

随机生成指定位数的大写字母和数字的组合

func GetReceiptStatus

func GetReceiptStatus(value int64) map[string]interface{}

获取 收货状态(10未收货 20已收货)

func GetReceiptStatusText

func GetReceiptStatusText(value int64) string

func GetSecKillProductStatusTextAttr

func GetSecKillProductStatusTextAttr(status int64) string

func GetStatusTextAttr

func GetStatusTextAttr(status, startTime, endTime int64) string

func GetStoreStatus

func GetStoreStatus(status int64) map[string]interface{}

获取门店状态

func GetTimeAttr

func GetTimeAttr(time int64) map[string]interface{}

func GetTodayDate

func GetTodayDate() string

获取当天日期 return:2021-01-01

func GetTodayDateTime

func GetTodayDateTime() (int64, int64)

func GetUpdatePriceAttr

func GetUpdatePriceAttr(value float64) string

func GetYesterdayDate

func GetYesterdayDate() string

获取昨天日期 return:2021-01-01

func HideMobileMid

func HideMobileMid(phone string) string

隐藏手机号码中间4位

func HttpBuildQuery

func HttpBuildQuery(params map[string]string) (paramStr string)

func IdsToString

func IdsToString(ids []int64) string

*

 *将查询出来的数组转成字符串格式
	example:[1,2,3] => "1,2,3"

func Int64DivFloat64

func Int64DivFloat64(i2 int64, f1 float64) float64

func Int64DivInt64

func Int64DivInt64(i1, i2 int64) float64

func Int64MulFloat64

func Int64MulFloat64(i1 int64, f1 float64) float64

func Int64MulInt64

func Int64MulInt64(i1 int64, i2 int64) float64

func Int64SToString

func Int64SToString(s []int64) string

int64切片转string

func Int64SubFloat

func Int64SubFloat(f1 int64, f2 float64) float64

func Int64SubInt64

func Int64SubInt64(f1, f2 int64) int64

func Int64ToString

func Int64ToString(i int64) string

func IntPart

func IntPart(f float64) int64

IntPart 返回小数的整数部分

func IsContain

func IsContain(items []string, item string) bool

判断元素是否在数组中

func IsContainInt64

func IsContainInt64(items []int64, item int64) bool

判断元素是否在数组中

func ItoStringSli

func ItoStringSli(intS []int) string

int切片转string

func JsonTostring

func JsonTostring(v interface{}) string

JsonTostring

func KeyInMap

func KeyInMap(myMap map[string]string, key string) bool

判断key是否在map中

func Krand

func Krand(size int, kind int) string

随机字符串

func Mul

func Mul(f1, f2 float64) float64

Mul 精确乘法

func Post

func Post(url string, data string, contentType string) (string, error)

发送POST请求 url: 请求地址 data: POST请求提交的数据 contentType: 请求体格式,如:application/json,"application/x-www-form-urlencoded" content: 请求放回的内容

func RandNum

func RandNum(length int, max int) []string

* len: 长度 max: 个数 随机生成长度为len的max个纯数字随机数

func RemoveDuplicate

func RemoveDuplicate(list *[]int64) []int64

去除数组中相同元素

func RemoveLastRune

func RemoveLastRune(s string, i int) string

删除 s 最后 i长度的字符

func SearchParam

func SearchParam(s string) (str []string, value []interface{})

SearchParam 解析查询参数

func ServerIP

func ServerIP() (ip string, err error)

获取服务端ip

func SliceRemoveDuplicates

func SliceRemoveDuplicates(slice []string) []string
  • 去除数组中相同元素

这种发放适用于string,int,float等切片,会对切片中的元素进行排序

func StrDate

func StrDate() string

获取字符串日期

func StrDateAndTime

func StrDateAndTime() string

func String2Bool

func String2Bool(str string) bool

String2Bool 字符串转bool

func String2Float64

func String2Float64(str string) float64

String2Float64 string 转 float64

func String2Int

func String2Int(str string) int

String2Int string 转 int

func String2Int64

func String2Int64(str string) int64

String2Int64 string 转 int64

func StringIdsToString

func StringIdsToString(ids []string) string

去除id为0的元素

func StringToFloat64

func StringToFloat64(s string) float64

func StringToInt64

func StringToInt64(s string) int64

func StringToInterface

func StringToInterface(s string, v interface{}) error

string to v

func Sub

func Sub(f1, f2 float64) float64

Sub 精确减法

func Substr

func Substr(str string, start, length int) string

func TimesToNum

func TimesToNum(timestamp int64) string

func Timestamp2Date

func Timestamp2Date(timestamp int64) string

时间戳(秒)转时间字符串

func Timestamp2min

func Timestamp2min(timestamp int64) string

func TimestampToDataWithDay

func TimestampToDataWithDay(timestamp int64) string

func TraverseMapInStringOrder

func TraverseMapInStringOrder(params map[string]string, handler MapEntryHandler)

按字母顺序遍历map

func Utf8ToGbk

func Utf8ToGbk(str []byte) (b []byte, err error)

transform UTF-8 bytes to GBK bytes

Types

type IpInfo

type IpInfo struct {
	Ip       string `json:"ip"`       // ip
	Pro      string `json:"pro"`      // 省会
	ProCode  string `json:"proCode"`  // 邮政编码
	City     string `json:"city"`     // 城市
	CityCode string `json:"cityCode"` // 城市邮政编码
	Addr     string `json:"addr"`     // 运营商
}

func IPInfo

func IPInfo(ipAddr string) (ip IpInfo)

返回:IP地址的信息(结构体)

type MapEntryHandler

type MapEntryHandler func(string, string)

type Set

type Set struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

* 构造set类型

func New

func New() *Set

func (*Set) Add

func (s *Set) Add(item string)

func (*Set) Clear

func (s *Set) Clear()

func (*Set) Has

func (s *Set) Has(item string) bool

func (*Set) IsEmpty

func (s *Set) IsEmpty() bool

func (*Set) Len

func (s *Set) Len() int

func (*Set) List

func (s *Set) List() []string

func (*Set) Remove

func (s *Set) Remove(item string)

type SmsInfo

type SmsInfo struct {
	AccessKeyId        string `json:"AccessKeyId"`
	AccessKeySecret    string `json:"AccessKeySecret"`
	SignName           string `json:"sign"`
	TemplateCode       string `json:"login_template"`
	TemplateParam      string `json:"apply_template"`
	SupplierRejectCode string `json:"supplier_reject_code"`
	SupplierPassCode   string `json:"supplier_pass_code"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL