Browse Source

删除订单相关文件

master v0.1.0
guzeng 3 years ago
parent
commit
eab886b9c0
4 changed files with 0 additions and 316 deletions
  1. +0
    -41
      order_sign.go
  2. +0
    -69
      order_sn.go
  3. +0
    -30
      order_sn_test.go
  4. +0
    -176
      order_status.go

+ 0
- 41
order_sign.go View File

@ -1,41 +0,0 @@
package orderattr
import (
"crypto/md5"
"encoding/hex"
"strings"
)
/**
* 通知订单状态时签名
* 签名方式md5(order_sn-status--time---appid)
* 2020/08/21
*gz
*/
func Sign(order_sn, status, time, appid string) string {
return Md5Password(StringJoin(order_sn, "--", status, "--", time, "--", appid))
}
//密码加密
func Md5Password(password string) string {
h := md5.New()
h.Write([]byte(password)) // 需要加密的字符串
cipher2Str := h.Sum(nil)
sMd5 := hex.EncodeToString(cipher2Str) // 输出加密结果
return sMd5
}
/*
* 连接多个字符串
* 2019/05/05
*/
func StringJoin(s ...string) string {
var build strings.Builder
if len(s) > 0 {
for _, v := range s {
build.WriteString(v)
}
}
return build.String()
}

+ 0
- 69
order_sn.go View File

@ -1,69 +0,0 @@
package orderattr
import (
"math/rand"
"strconv"
"strings"
"time"
)
/**
* 订单号规则
* id后4位随机4位+当前时间10
* 2020/08/10
*/
func NewOrderSn(user_id string) string {
var prefix string
if user_id != "" {
if len(user_id) > 4 {
prefix = user_id[len(user_id)-4:] //截取后4位
} else {
prefix = user_id
}
} else {
//随机4位
str := "123456789"
bytes := []byte(str)
result := []byte{}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < 4; i++ {
result = append(result, bytes[r.Intn(len(bytes))])
}
prefix = string(result)
}
//拼接
var build strings.Builder
build.WriteString(prefix)
build.WriteString(strconv.FormatInt(time.Now().Unix(), 10)) //当前时间
return build.String()
}
/**
* 核销码规则
* 随机2位+当前时间6
* 2020/08/10
*/
func VerifyNumber() string {
var prefix string
//随机4位
str := "123456789"
bytes := []byte(str)
result := []byte{}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < 1; i++ {
result = append(result, bytes[r.Intn(len(bytes))])
}
prefix = string(result)
//拼接
var build strings.Builder
build.WriteString(prefix)
build.WriteString(strconv.FormatInt(time.Now().UnixNano(), 10)[10:17]) //当前时间
return build.String()
}

+ 0
- 30
order_sn_test.go View File

@ -1,30 +0,0 @@
package orderattr
import (
"testing"
"time"
)
func Test_NewNumber(t *testing.T) {
t.Log(time.Now().UnixNano())
var set map[string]int
set = make(map[string]int)
var i, reply int = 0, 0
var num string
for i < 100000 {
i++
num = VerifyNumber()
if _, ok := set[num]; ok {
reply++
} else {
set[num] = i
}
}
t.Log("reply:", reply)
// t.Log(set)
}

+ 0
- 176
order_status.go View File

@ -1,176 +0,0 @@
package site
/**
'0': 待支付 下单尚未支付 created
'1':已支付 付款成功此状态可退款 payed
'5'已验证 虚拟订单验证核销码 using
'6'已完成 与供应商结算后订单结束配送订单配送完成 finished
'7'已取消 订单取消 canceled
'8'自动取消 到期未支付自动取消此状态可由管理员手动延期取消 autocanceled
'9'申请退款 用户自助申请退订单此状态可退款
'13'已退款 订单完成退款 refunded
'15'自动完成 使用时间过期自动完成 finished
cancel,received,payed,created,finished,using
## 发货
is_delivery 是否发货 '1': 已发货
delivery 发货时间
## 收货
is_received 是否收货 '1': 已收货
received 收货时间
*/
var statusList map[string]string = map[string]string{
"0": "created",
"1": "payed",
"5": "using",
"6": "finished",
"7": "canceled",
"8": "autocanceled",
"9": "askForRefund",
"13": "refunded",
"15": "autofinished",
}
var statusExtendList map[string]string = map[string]string{
"6": "received", //已收货归入已完成,
}
/*串货订单,供应商系统订单状态*/
var channelOrderStatusList map[string]string = map[string]string{
"1": "nosend",
"2": "created",
"3": "payed",
"4": "askForRefund",
"5": "refunded",
"6": "canceled",
"7": "finished",
"8": "payFailed", //支付失败
"9": "breakoff", //断开
"10": "fullRefund", //全额退款
"14": "autocanceled",
"15": "autofinished",
"16": "delivered",
}
func GetOrderStatusKey(status string) (key string) {
for k, val := range statusList {
if val == status {
key = k
break
}
}
if key == "" { //再找扩展的状态
for k, val := range statusExtendList {
if val == status {
key = k
break
}
}
}
return
}
func GetOrderStatusText(key string) (text string) {
for k, val := range statusList {
if k == key {
text = val
break
}
}
if text == "" { //再找扩展的状态
for k, val := range statusExtendList {
if k == key {
text = val
break
}
}
}
return
}
/**
* 返回订单状态描述
* 2021/01/28
*/
func GetOrderStatusDescByFlag(flag string) (text string) {
status := GetStatusText(flag)
return GetStatusDesc(status)
}
/**
* 返回订单状态描述
* 2020/10/22
*/
func GetOrderStatusDesc(key string) (text string) {
var statusDesc map[string]string = map[string]string{
"created": "已创建",
"payed": "已支付",
"askForRefund": "请求退款",
"using": "使用中",
"finished": "已完成",
"canceled": "已取消",
"autocanceled": "自动取消",
"refunded": "已退款",
"autofinished": "自动完成",
"received": "已收货",
}
for k, val := range statusDesc {
if k == key {
text = val
break
}
}
return
}
func GetChannelOrderStatusKey(status string) (key string) {
for k, val := range channelOrderStatusList {
if val == status {
key = k
break
}
}
return
}
func GetChannelOrderStatusText(key string) (text string) {
for k, val := range channelOrderStatusList {
if k == key {
text = val
break
}
}
return
}
/**
* 返回订单状态描述
* 2020/10/22
*/
func GetChannelOrderStatusDesc(key string) (text string) {
var statusDesc map[string]string = map[string]string{
"nosend": "未发送",
"created": "已创建",
"payed": "已支付",
"askForRefund": "请求退款",
"refunded": "已退款",
"canceled": "已取消",
"finished": "已完成",
"payFailed": "支付失败",
"breakoff": "断开",
"fullRefund": "全额退款",
"autocanceled": "自动取消",
"autofinished": "自动取消",
"delivered": "已发货",
}
for k, val := range statusDesc {
if k == key {
text = val
break
}
}
return
}

Loading…
Cancel
Save